Is glEnable kept when switching FBO?
Asked Answered
S

1

5

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?

Sansbury answered 20/7, 2013 at 9:52 Comment(0)
I
10

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.

Ineradicable answered 20/7, 2013 at 10:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.