"Clearing the Screen"?? (OpenGL)

Started by
4 comments, last by Fredric 24 years, 1 month ago
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
3D Math- The type of mathematics that'll put hair on your chest!
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?"
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)
3D Math- The type of mathematics that'll put hair on your chest!
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**
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
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
-werdup-
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)
3D Math- The type of mathematics that'll put hair on your chest!

This topic is closed to new replies.

Advertisement