how to keep drawing without clearing the screen?

Started by
6 comments, last by galileo_g 19 years, 10 months ago
Hi I am just wondering how do i draw something (like a line) and keep drawing on the next DrawGLScene(GLvoid) loop without clearing the screen? I tried taking out : glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); after the 1st run but it just gave a whole heap of crap on the screen. Please help!
Advertisement
Draw something over the entire screen before you draw the line, like a big giant square.
Which is far slower than just clearing the screen (and doesn''t even clear the Z buffer)
Why don''t you want to clear it anyway?
The reason I don''t want to clear it is because I want to draw a graph of continous input against time(like an oscilloscope) I only want to clear it after a few loops when the line hits the edge of the screen.

I''m using Nehe''s lesson as basecode btw.





Why not just make an array of points? Isn''t that good enough?
You can just use vectors for that job, or arrays if it''s a predetermined number of points (which I believe it is) and you''re not to lazy. Then just use GL_LINE_LOOP and there you go; an oscillo-graph.
Killers don't end up in jailThey end up on a high-score!
I guess you''re using double buffering? So if you just clear once, only one of the buffers will have been cleared, the other one containing whatever random data happened to be there.
The simple solution would simply be to not use double buffering, but, in my opinion, you might as well clear and redraw the graph every frame.
quote:The reason I don''t want to clear it is because I want to draw a graph of continous input against time(like an oscilloscope) I only want to clear it after a few loops when the line hits the edge of the screen.


How many ''dots'' do you want? I''ll assume 100 across the screen for this post.

Make an array of vertices to hold them. Every frame add your new dot to the array and draw all the lines from dot to dot for that frame. Then clear the screen. When you get to the 100h one, just push back all the other ones by 1 and then fill the 100th out with the new one.

When you get to the point where you want to clear, just erase every vertex in the array.
quote:Original post by Raduprv
Which is far slower than just clearing the screen (and doesn''t even clear the Z buffer)
Why don''t you want to clear it anyway?


Normally you really don''t want to clear the color buffer. I don''t think any of the current games clear the color buffer each frame. I''m quite sure engines of those game''s assume, that user is filling each pixel of the screen every frame, so clearing isn''t needed.

This topic is closed to new replies.

Advertisement