OpenGL Display list blocks glEnable(GL_COLOR_MATERIAL)

235 views Asked by At

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?

2

There are 2 answers

0
genpfault On BEST ANSWER

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

0
Hanno Falk On

I think it is fine: The 2nd glDisable and glEnable is written into the list and will be executed later, when the list is displayed.

Putting it in the list, does not immediately change the state.