I am the beginner for OpenGL. I want to using the display list to switch two images on the screen with 60Hz with Vsync on.
I first generate two lists for each image.
glNewList(index, GL_COMPILE);
glDrawPixels(GLwidth, GLheight, GL_BGR_EXT, GL_UNSIGNED_BYTE, image2.data);
glEndList();
glNewList(index + 1, GL_COMPILE);
glDrawPixels(GLwidth, GLheight, GL_BGR_EXT, GL_UNSIGNED_BYTE, image.data);
glEndList();
lists[0] = 0; lists[1] = 2;
glListBase(index);
Then in the display function, I use following code
if (flag == 0)
{
glCallList(index);
flag = 1;
}
else
{
glCallList(index + 1);
flag = 0;
}
glutSwapBuffers();
glutPostRedisplay();
But after I run it, the screen dose not update. But sometimes, if I move the frame, it start to update. But it stops after several seconds. Dose anyone know what’s wrong with my code?