opengl: question about glutMainLoop()
Posted
by lego69
on Stack Overflow
See other posts from Stack Overflow
or by lego69
Published on 2010-05-24T16:08:25Z
Indexed on
2010/05/24
16:11 UTC
Read the original article
Hit count: 196
can somebody explain how does glutMainLoop
work?
and second question, why glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
defined
after glutDisplayFunc(RenderScene);
cause firstly we call glClear(GL_COLOR_BUFFER_BIT);
and only then define glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(800, 00);
glutInitWindowPosition(300,50);
glutCreateWindow("GLRect");
glutDisplayFunc(RenderScene);
glutReshapeFunc(ChangeSize);
glClearColor(0.0f, 0.0f, 1.0f, 1.0f); <--
glutMainLoop();
return 0;
}
void RenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);
// Set current drawing color to red
// R G B
glColor3f(1.0f, 0.0f, 1.0f);
// Draw a filled rectangle with current color
glRectf(0.0f, 0.0f, 50.0f, -50.0f);
// Flush drawing commands
glFlush();
}
© Stack Overflow or respective owner