PDA

View Full Version : Why does SetupRC( ) come before RenderScene?



Y-T
06-27-2000, 09:22 AM
Why does SetupRC( ) come before RenderScene?
Shouldn't SetupRC( ) come before since it sets the glClearColor? How does glClear(GL_COLOR_BUFFER_BIT); know what color to clear with if it goes before SetupRC( )?

#include <windows.h>
#include <gl/glut.h>

// Called to draw scene
void RenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);


// Flush drawing commands
glFlush();
}

// Setup the rendering state
void SetupRC(void)
{
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
}


// Main program entry point
void main(void)
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);

SetupRC();

glutMainLoop();
}
I'd appreciate any response to this message.
Thanx,
Y-T

tom
06-27-2000, 10:42 AM
Well, you set the display function (RenderScene) using glutDisplayFunc()

But this will not call RenderScene, it only tells GLUT to call RenderScene when the window should be redrawn.

Then you call SetupRC(), which sets the clear color.

Finally you call glutMainLoop(). NOW GLUT creates the window, and RenderScene will be called.

Y-T
06-27-2000, 06:31 PM
Alright now i understand! Thanx alot for replying =)!!!

Y-T