Question

When I set stuff with glEnable, or specify func to the things I enable, and then switch frame buffer object, are my settings kept for each frame buffer object, or do I have to set them for each one? In practice, does this work?

glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT); 
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
for int i=0; i<N; i++{
     glBindFramebuffer(GL_FRAMEBUFFER, fbos[i]);
     rendering something to the fbos here
}

Or do I have to write

for int i=0; i<N; i++{
     glBindFramebuffer(GL_FRAMEBUFFER, fbos[i]);
     glEnable(GL_CULL_FACE);
     glCullFace(GL_FRONT); 
     glEnable(GL_DEPTH_TEST);
     glDepthMask(GL_TRUE);
     rendering something to the fbos here
}

EDIT: And what about glUseProgram? Is that kept?

Was it helpful?

Solution

No, GL_CULL_FACE and other rasterization state are not stored per framebuffer object. Indeed you need only to setup the state only once.

To check this fact, you can read the specification of the state in the chapter 23 (State tables) of the OpenGL specification. The table defines the state of each framebuffer object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top