ferum
2006.06.22, 09:56 PM
Ok, I know we have had these sort of discusions before but I'm talking really basic. Right now I have been making really simple openGL demos (ie press a button and the cube rotates) using GLUT. so my basic structure is:
--#include statements--
display()
{
glClear(), glLoadIdentity(), glPushMatrix() etc. display stuff
}
reshape (int width, int height)
{
glViewport(), glMatrixMode(), etc.
}
idle ()
{
glutPostRedisplay();
}
int main (int argc, char** argv)
{
glutInit(), glutInitDisplayMode(), glutInitWindowSize(), glutCreateWindow()calls
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glutMainLoop();
return EXIT_SUCCESS;
}
Also any variable I need to keep track of the location things and such I have been making global variables since the program is constantly exiting the display() function and re-entering it.
I hear people talking about a main loop. Where do I put such a loop?
How does this glutMainLoop() thing work?
I'm really sorry if this is hard to understand. I'm having a hard time articulating right now, I'll probably go back later and edit it.
--#include statements--
display()
{
glClear(), glLoadIdentity(), glPushMatrix() etc. display stuff
}
reshape (int width, int height)
{
glViewport(), glMatrixMode(), etc.
}
idle ()
{
glutPostRedisplay();
}
int main (int argc, char** argv)
{
glutInit(), glutInitDisplayMode(), glutInitWindowSize(), glutCreateWindow()calls
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glutMainLoop();
return EXIT_SUCCESS;
}
Also any variable I need to keep track of the location things and such I have been making global variables since the program is constantly exiting the display() function and re-entering it.
I hear people talking about a main loop. Where do I put such a loop?
How does this glutMainLoop() thing work?
I'm really sorry if this is hard to understand. I'm having a hard time articulating right now, I'll probably go back later and edit it.