hi,
does anybody know the problem?
i always get one frame with the sphere, then a blank screen.
the code:
GLint displayList;
void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(screenWidth, screenHeight);
glutInitWindowPosition(100,100);
glutCreateWindow(“OpenGL”);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
displayList = glGenLists(1);
glColor4f(0.2f, 0.2f, 0.2f, 0.75f);
glNewList(displayList, GL_COMPILE);
glutSolidSphere(1,10,10);
glEndList();
glutPassiveMotionFunc(mouseMotion);
glutIgnoreKeyRepeat(false);
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(pressSpecialKey);
glutSpecialUpFunc(releaseSpecialKey);
glutDisplayFunc(renderScene);
glutIdleFunc(renderScene);
glutReshapeFunc(changeSize);
glutMainLoop();
}
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glCallList(displayList);
gluLookAt(0, 1, 10,
0, 0, 0,
0.0f, 1.0f, 0.0f);
glutSwapBuffers();
}
void changeSize(int scrWidth, int scrHeight)
{
screenWidth = scrWidth;
screenHeight = scrHeight;
if(scrHeight == 0)
scrHeight = 1;
ratio = 1.0f * scrWidth / scrHeight;
glViewport(0, 0, scrWidth, scrHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, ratio, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}