Jump to content
  • Advertisement

Archived

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

Fredric

OpenGL "Clearing the Screen"?? (OpenGL)

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

In the following short program, // my second OpenGL program! #include 'windows.h' #include 'gl/gl.h' #include 'gl/glaux.h' // called by the AUX library to draw a shape void CALLBACK RenderScene() { // set color to blue glClearColor(0.0f, 0.0f, 1.0f, 1.0f); // clear the window glClear(GL_COLOR_BUFFER_BIT); // set the current drawing color to green glColor3f(0.0f, 1.0f, 0.0f); // fill the rectangle with the current drawing color glRectf(100.0f, 150.0f, 150.0f, 100.0f); glFlush(); } void main() { // setup the window auxInitDisplayMode(AUX_SINGLE / AUX_RGBA); // single buffed; rgba mode auxInitPosition(300,250,100,100); // coordinates, size auxInitWindow("My Second OpenGL Program!"); // Set function to call when window needs updating auxMainLoop(RenderScene); } when it has the auxClear(AUX_COLOR_BUFFER_BIT), it says in my book that this 'clears' the window. By clearing the window, what did the author mean? It obviously doesn't delete everything that exists in the window, or else the background and Rectangle would be gone... can someone further explain this to a newbie OpenGL programmer like me? edit: It didn't display my includes Programming::~Fredric(const Annoy_Ance) Edited by - Fredric on 3/16/00 11:31:05 PM

Share this post


Link to post
Share on other sites
Advertisement
ummm, am I missing something, or are you calling clear BEFORE drawing the rectangle.... that''s why it doesn''t disappear, each time the main loop executes, you are clearing the scene, then drawing the rectangle again..

---
Matt Benic

"Ummm, you mean this aint bubba's-house-of-hillbilly?"

Share this post


Link to post
Share on other sites
Yoi got it, but why, when I call glClear(GL_COLOR_BUFFER_BIT), the author says that it clears the window. In my language, clearing the window means erasing everything inside it... but, that can''t be true or else the background would be black, and there wouldn''t be a funky rectangle still inside.

Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites
grr well it does this:

1. Clear the window to a nice dark shade of black
2. Draw a rectangle.

Is that clear?
Does that make sense?

it REDRAWS the rectangle after EVERY clear, you will never get to see the completely black screen


~ Mad Keith ~
**SoftwareMode**

Share this post


Link to post
Share on other sites
it's not gonna clear it to black if that's what you think it should be doing.
since you call 'glClearColor(0.0f, 0.0f, 1.0f, 1.0f);' you're setting the clear color to bright blue with the alpha component at full also (which doesn't even matter in this prog).
glClearColor() sets the color used by glClear when it clears the screen.

-well when you specify GL_COLOR_BUFFER_BIT in glClear() but i assume you knew that-

Edited by - shmaLbus on 3/17/00 10:22:22 AM

Share this post


Link to post
Share on other sites
Ohhhh... I get it now! So everytime the glClear(COLOR_BUFFER_BIT) is executed, it sets the color that it''s clearing with to the glClearColor... I get it now! Thanks a lot! Sweet.. I got it, thankyou very much!!

Programming::~Fredric(const Annoy_Ance)

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!