Added State::glDrawBuffer/glReadBuffer() method to implement lazy state updating for glDrawBuffer and glReadBuffer

This commit is contained in:
Robert Osfield
2018-03-06 09:49:02 +00:00
parent ee3235e7e0
commit 64341cfb72
2 changed files with 36 additions and 0 deletions

View File

@@ -51,6 +51,9 @@ State::State():
_shaderComposer = new ShaderComposer;
_currentShaderCompositionProgram = 0L;
_drawBuffer = GL_NONE;
_readBuffer = GL_NONE;
_identity = new osg::RefMatrix(); // default RefMatrix constructs to identity.
_initialViewMatrix = _identity;
_projection = _identity;
@@ -434,6 +437,28 @@ void State::reset()
}
void State::glDrawBuffer(GLenum buffer)
{
if (_drawBuffer!=buffer)
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
glDrawBuffer(buffer);
#endif
_drawBuffer=buffer;
}
}
void State::glReadBuffer(GLenum buffer)
{
if (_readBuffer!=buffer)
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
glReadBuffer(buffer);
#endif
_readBuffer=buffer;
}
}
void State::setInitialViewMatrix(const osg::RefMatrix* matrix)
{
if (matrix) _initialViewMatrix = matrix;