c++opengl3ddisplaylist

OpenGL Display list blocks glEnable(GL_COLOR_MATERIAL)


I have the following code:

glDisable(GL_COLOR_MATERIAL);
cout<<(int)glIsEnabled(GL_COLOR_MATERIAL)<<endl;
glEnable(GL_COLOR_MATERIAL);
cout<<(int)glIsEnabled(GL_COLOR_MATERIAL)<<endl;

modelDL[t] = glGenLists(1);
glNewList(modelDL[t],GL_COMPILE);           

glDisable(GL_COLOR_MATERIAL);
cout<<(int)glIsEnabled(GL_COLOR_MATERIAL)<<endl;
glEnable(GL_COLOR_MATERIAL);
cout<<(int)glIsEnabled(GL_COLOR_MATERIAL)<<endl;

It appears to be that the 2 lines on the middle of the display list blocks glDisable and glEnable. The output of this code is:

0
1
1
1

and it should be

0
1
0
1

If the delete the 2 lines of the display list, the output is fine. how can I use glEnable and glDisable with display list?


Solution

  • Use GL_COMPILE_AND_EXECUTE if you want to see the side-effects of your display list as it's being built.