Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

galileo_g

how to keep drawing without clearing the screen?

This topic is 5158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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.





Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!