PDA

View Full Version : Trouble Getting Two Windows to display correctly



faulerwulf
11-21-2013, 06:46 PM
Title pretty much sums it up. The first window works perfectly fine and loads the spinning Sierpinski gasket. However, the second window appears (the border of it) but nothing inside of it.

The code for display2

void display2()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(15.0,0.0,0.0,1.0);
glCallList(COMP1);

glTranslatef(1.0, 0.0, 0.0);

glScalef(0.5, 1.0,0.5);
glCallList(CYLINDER);
glFlush();
}

And the code for the main

void main(int argc, char **argv)
{
n=2;//atoi(argv[1]); /* or enter number of subdivision steps here */
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(500, 500);
glClearColor (1.0, 1.0, 1.0, 1.0);
glEnable(GL_DEPTH_TEST);


glutCreateWindow("3D Gasket Single Buffer");
glutReshapeFunc(myReshape);
glutIdleFunc(spinIt);

computeSierpinski();

glutDisplayFunc(display);

glMatrixMode(GL_MODELVIEW);
glRotatef(150.0,1.0,1.0,1.0);

glClearColor (1.0, 1.0, 1.0, 1.0);
glutCreateWindow("3D Gasket Double Buffer");
glutPositionWindow(510,23);
glutIdleFunc(spinIt);
glutReshapeFunc(myReshape);

init();
compositionCal();
glutDisplayFunc(display2);

glutMainLoop();
}

Any suggestions? If you need more of the code, just ask. Thanks for your help!

carsten neumann
11-24-2013, 01:27 PM
You use double buffering but don't call glutSwapBuffers() at the end of display2().