Jump to content
  • Advertisement

Archived

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

pizza box

Clearing the Screen

This topic is 6063 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

I''m programming a tetris-style game using Window''s GDI. Every time I draw a rectangle it stays on the screen when I draw the next one, so I would leave a trail of rectangles whenever I moved the block. To solve this, I drew a big black rectangle the size of the screen to clear it before drawing the next frame, but I was wondering if there was a faster way to clear the screen, or perhaps a function that I could use? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Have you tried just drawing a black box over the tetris box? So you can use the same code that you used to draw the box but with black instead of your color.

Share this post


Link to post
Share on other sites
Thats what Ive been doing, but the box I draw is the entire screen so it clears out everything. The problem is that I can see the blocks flickering, so it is kind of slow. I was wondering if there are any built-in functions to solve this.

Share this post


Link to post
Share on other sites
You dont have to draw a black box over the entire screen. Just a black one on same place and same size but black... Or double buffer. (drawing everything on a invisible area then copy it all to the screen.

/Mario

Mvh Mario..

Edited by - Dharma on December 13, 2001 8:21:03 PM

Share this post


Link to post
Share on other sites
What API are you in? Doing double buffering by putting a black square over the screen is not double buffering. OpenGL uses this:
  
// Swap the buffers (double-buffering)

SwapBuffers(window->hDC);

Share this post


Link to post
Share on other sites
If you will stick to using GDI... Below you have a link describing this.

http://www.winprog.org/tutorial/references.html

Mvh Mario..

Share this post


Link to post
Share on other sites
Thanks for the link. I wasn''t double buffering before, I had a late post. Hopefully things will run a little smoother now. Thanks

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!