Hi Robert, hi J-S

I'll remind the conclusions of our discussion in case someone new to the topic is interested:

(1) We agreed that we may now remove the code forcing attachment of color/depth buffers to FBO when user had not attached such buffer. To relax FBO requirements its neeccessary to refactor DrawBuffer/ReadBuffer management. Specifically, we need to allow for explicit setting of GL_NONE for DrawBuffer & ReadBuffer. Current implementation does use GL_NONE flag but interprets it more like "INHERIT BUFFER SETTING FROM PARENT" value. In practice glDrawBuffer( GL_NONE ) and glReadBuffer( GL_NONE ) is not called by OSG.

(2) We also agreed that it would be nice if we could add setDrawBuffer/setReadBuffer methods to State and change buffers in 'lazy update' manner.

I promised I would try to come up with solution and post a submission implementing above proposals. I considered couple options and decided that best approach to implementing (1) would be adding DRAW_BUFFER / READ_BUFFER to CullSettings::VariablesMask flags. As we are going to allow for GL_NONE buffers in their verbatim meaning, we need to specifcally define methods to allow cameras inherit or override buffer settings from their parents. I think it will be appropriate to handle this in similar way Camera::_clearColor is handled. CullSettings::CLEAR_COLOR mask defines whether ClearColor is inherited or overriden. CullSettings::DRAW_BUFFER and CullSettings::READ_BUFFER could be introduced and interpreted in the same way with Camera::_drawBuffer, Camera::_readBuffer variables.

Do you approve such a plan of extending CullSettings masks for use with DrawBuffer and ReadBuffer ?

I also have a decision problem with feature (2): I wanted to add following osg::State methods and variables

State::_drawBuffer
void State::setDrawBuffer( GLuint )
GLuint State::getDrawBuffer( void )

State::_readBuffer
void State::setReadBuffer( GLuint )
GLuint State::getReadBuffer( void )

Difficulty here is related to proper setting of default values of State::_readBuffer and State::_drawBuffer. OpenGL spec says that defaults depend on context. They are set to GL_BACK for double buffered contexts and set to GL_FRONT for single buffered contexts. When State is created its not yet known with which context it would be used.

I came up with 2 possible solutions:

(A) Changing State::_drawBuffer/_readBuffer defaults after associating State with GraphicsContext. This is usually done in GraphicsWindow(or its subclass)::init virtual method. This method would have to call state->setDrawBuffer/setReadBuffer to initialize defaults properly.
Drawbacks:
- many classes deriving from GraphicsWindow - many changes need to be done.
- not sure what defaults should be applied for SharedContexts and external contexts for windows created by the users. - I am hesitant to modify all GraphicsWindow subclasses::init because I am mainly Windows progrmammer. I'am afraid I may break something in Linux or MacOS.

(B) Read buffer defaults ( glGet(GL_DRAW_BUFFER) ) set in GL Context when State sees context for the first time. Good place for this would be State::initializeExtensionProcs method.
Drawbacks:
- initializeExtensionProcs is mainly used for setting OpenGL context / State capability variables like number of texture stages etc. Setting DrawBuffer/ReadBuffer defaults would be (dangerous?) precedence of StateAttributes/StateModes like initialization.

Which option do You prefer here ?

Cheers,
Wojtek Lewandowski
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to