Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is glEnable kept when switching FBO?

Tags:

opengl

fbo

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?

like image 932
darius Avatar asked Jul 20 '13 09:07

darius


1 Answers

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.

like image 132
Luca Avatar answered Sep 17 '22 01:09

Luca