Moved VBO switching code into inline methods into osg::State to speed performance
This commit is contained in:
@@ -457,8 +457,6 @@ void VertexBufferObject::compileBufferImplementation(State& state) const
|
||||
|
||||
// Unmap the texture image buffer
|
||||
if (vboMemory) extensions->glUnmapBuffer(_target);
|
||||
|
||||
extensions->glBindBuffer(_target, 0);
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<<std::endl;
|
||||
// osg::notify(osg::NOTICE)<<"pbo "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl;
|
||||
@@ -466,24 +464,24 @@ void VertexBufferObject::compileBufferImplementation(State& state) const
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ElementsBufferObject
|
||||
// ElementBufferObject
|
||||
//
|
||||
ElementsBufferObject::ElementsBufferObject()
|
||||
ElementBufferObject::ElementBufferObject()
|
||||
{
|
||||
_target = GL_ELEMENT_ARRAY_BUFFER_ARB;
|
||||
_usage = GL_STATIC_DRAW_ARB;
|
||||
}
|
||||
|
||||
ElementsBufferObject::ElementsBufferObject(const ElementsBufferObject& vbo,const CopyOp& copyop):
|
||||
ElementBufferObject::ElementBufferObject(const ElementBufferObject& vbo,const CopyOp& copyop):
|
||||
BufferObject(vbo,copyop)
|
||||
{
|
||||
}
|
||||
|
||||
ElementsBufferObject::~ElementsBufferObject()
|
||||
ElementBufferObject::~ElementBufferObject()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int ElementsBufferObject::addDrawElements(osg::DrawElements* drawElements)
|
||||
unsigned int ElementBufferObject::addDrawElements(osg::DrawElements* drawElements)
|
||||
{
|
||||
unsigned int i = _bufferEntryDrawElementsPairs.size();
|
||||
_bufferEntryDrawElementsPairs.resize(i+1);
|
||||
@@ -494,7 +492,7 @@ unsigned int ElementsBufferObject::addDrawElements(osg::DrawElements* drawElemen
|
||||
return i;
|
||||
}
|
||||
|
||||
void ElementsBufferObject::setDrawElements(unsigned int i, DrawElements* drawElements)
|
||||
void ElementBufferObject::setDrawElements(unsigned int i, DrawElements* drawElements)
|
||||
{
|
||||
if (i+1>=_bufferEntryDrawElementsPairs.size()) _bufferEntryDrawElementsPairs.resize(i+1);
|
||||
|
||||
@@ -503,7 +501,7 @@ void ElementsBufferObject::setDrawElements(unsigned int i, DrawElements* drawEle
|
||||
_bufferEntryDrawElementsPairs[i].first.dataSize = 0;
|
||||
}
|
||||
|
||||
bool ElementsBufferObject::needsCompile(unsigned int contextID) const
|
||||
bool ElementBufferObject::needsCompile(unsigned int contextID) const
|
||||
{
|
||||
if (isDirty(contextID)) return true;
|
||||
|
||||
@@ -538,13 +536,13 @@ bool ElementsBufferObject::needsCompile(unsigned int contextID) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void ElementsBufferObject::compileBufferImplementation(State& state) const
|
||||
void ElementBufferObject::compileBufferImplementation(State& state) const
|
||||
{
|
||||
unsigned int contextID = state.getContextID();
|
||||
|
||||
_compiledList[contextID] = 1;
|
||||
|
||||
osg::notify(osg::NOTICE)<<"ElementsBufferObject::compile"<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ElementBufferObject::compile"<<std::endl;
|
||||
|
||||
Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
@@ -637,8 +635,6 @@ void ElementsBufferObject::compileBufferImplementation(State& state) const
|
||||
// Unmap the texture image buffer
|
||||
if (eboMemory) extensions->glUnmapBuffer(_target);
|
||||
|
||||
extensions->glBindBuffer(_target, 0);
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<<std::endl;
|
||||
// osg::notify(osg::NOTICE)<<"pbo "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl;
|
||||
}
|
||||
@@ -741,8 +737,6 @@ void PixelBufferObject::compileBufferImplementation(State& state) const
|
||||
// Unmap the texture image buffer
|
||||
extensions->glUnmapBuffer(_target);
|
||||
|
||||
extensions->glBindBuffer(_target, 0);
|
||||
|
||||
_bufferEntryImagePair.first.modifiedCount[contextID] = image->getModifiedCount();
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<<std::endl;
|
||||
|
||||
@@ -824,7 +824,7 @@ bool Geometry::addPrimitiveSet(PrimitiveSet* primitiveset)
|
||||
{
|
||||
if (primitiveset)
|
||||
{
|
||||
if (_useVertexBufferObjects) addElementsBufferObjectIfRequired(primitiveset);
|
||||
if (_useVertexBufferObjects) addElementBufferObjectIfRequired(primitiveset);
|
||||
|
||||
_primitives.push_back(primitiveset);
|
||||
dirtyDisplayList();
|
||||
@@ -839,7 +839,7 @@ bool Geometry::setPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset)
|
||||
{
|
||||
if (i<_primitives.size() && primitiveset)
|
||||
{
|
||||
if (_useVertexBufferObjects) addElementsBufferObjectIfRequired(primitiveset);
|
||||
if (_useVertexBufferObjects) addElementBufferObjectIfRequired(primitiveset);
|
||||
|
||||
_primitives[i] = primitiveset;
|
||||
dirtyDisplayList();
|
||||
@@ -855,7 +855,7 @@ bool Geometry::insertPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset)
|
||||
|
||||
if (primitiveset)
|
||||
{
|
||||
if (_useVertexBufferObjects) addElementsBufferObjectIfRequired(primitiveset);
|
||||
if (_useVertexBufferObjects) addElementBufferObjectIfRequired(primitiveset);
|
||||
|
||||
if (i<_primitives.size())
|
||||
{
|
||||
@@ -1079,14 +1079,14 @@ void Geometry::addVertexBufferObjectIfRequired(osg::Array* array)
|
||||
}
|
||||
}
|
||||
|
||||
void Geometry::addElementsBufferObjectIfRequired(osg::PrimitiveSet* primitiveSet)
|
||||
void Geometry::addElementBufferObjectIfRequired(osg::PrimitiveSet* primitiveSet)
|
||||
{
|
||||
if (_useVertexBufferObjects)
|
||||
{
|
||||
osg::DrawElements* drawElements = primitiveSet->getDrawElements();
|
||||
if (drawElements && !drawElements->getElementsBufferObject())
|
||||
if (drawElements && !drawElements->getElementBufferObject())
|
||||
{
|
||||
drawElements->setElementsBufferObject(getOrCreateElementsBufferObject());
|
||||
drawElements->setElementBufferObject(getOrCreateElementBufferObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1112,12 +1112,12 @@ osg::VertexBufferObject* Geometry::getOrCreateVertexBufferObject()
|
||||
return vbo;
|
||||
}
|
||||
|
||||
osg::ElementsBufferObject* Geometry::getOrCreateElementsBufferObject()
|
||||
osg::ElementBufferObject* Geometry::getOrCreateElementBufferObject()
|
||||
{
|
||||
DrawElementsList drawElementsList;
|
||||
getDrawElementsList(drawElementsList);
|
||||
|
||||
osg::ElementsBufferObject* ebo = 0;
|
||||
osg::ElementBufferObject* ebo = 0;
|
||||
|
||||
DrawElementsList::iterator deitr;
|
||||
for(deitr = drawElementsList.begin();
|
||||
@@ -1125,10 +1125,10 @@ osg::ElementsBufferObject* Geometry::getOrCreateElementsBufferObject()
|
||||
++deitr)
|
||||
{
|
||||
osg::DrawElements* elements = *deitr;
|
||||
if (!elements->getElementsBufferObject()) ebo = elements->getElementsBufferObject();
|
||||
if (!elements->getElementBufferObject()) ebo = elements->getElementBufferObject();
|
||||
}
|
||||
|
||||
if (!ebo) ebo = new osg::ElementsBufferObject;
|
||||
if (!ebo) ebo = new osg::ElementBufferObject;
|
||||
|
||||
return ebo;
|
||||
}
|
||||
@@ -1150,7 +1150,7 @@ void Geometry::setUseVertexBufferObjects(bool flag)
|
||||
getDrawElementsList(drawElementsList);
|
||||
|
||||
typedef std::vector<osg::VertexBufferObject*> VertexBufferObjectList;
|
||||
typedef std::vector<osg::ElementsBufferObject*> ElementsBufferObjectList;
|
||||
typedef std::vector<osg::ElementBufferObject*> ElementBufferObjectList;
|
||||
|
||||
if (_useVertexBufferObjects)
|
||||
{
|
||||
@@ -1183,9 +1183,9 @@ void Geometry::setUseVertexBufferObjects(bool flag)
|
||||
|
||||
if (!drawElementsList.empty())
|
||||
{
|
||||
ElementsBufferObjectList eboList;
|
||||
ElementBufferObjectList eboList;
|
||||
|
||||
osg::ElementsBufferObject* ebo = 0;
|
||||
osg::ElementBufferObject* ebo = 0;
|
||||
|
||||
DrawElementsList::iterator deitr;
|
||||
for(deitr = drawElementsList.begin();
|
||||
@@ -1193,17 +1193,17 @@ void Geometry::setUseVertexBufferObjects(bool flag)
|
||||
++deitr)
|
||||
{
|
||||
osg::DrawElements* elements = *deitr;
|
||||
if (!elements->getElementsBufferObject()) ebo = elements->getElementsBufferObject();
|
||||
if (!elements->getElementBufferObject()) ebo = elements->getElementBufferObject();
|
||||
}
|
||||
|
||||
if (!ebo) ebo = new osg::ElementsBufferObject;
|
||||
if (!ebo) ebo = new osg::ElementBufferObject;
|
||||
|
||||
for(deitr = drawElementsList.begin();
|
||||
deitr != drawElementsList.end();
|
||||
++deitr)
|
||||
{
|
||||
osg::DrawElements* elements = *deitr;
|
||||
if (!elements->getElementsBufferObject()) elements->setElementsBufferObject(ebo);
|
||||
if (!elements->getElementBufferObject()) elements->setElementBufferObject(ebo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1222,7 +1222,7 @@ void Geometry::setUseVertexBufferObjects(bool flag)
|
||||
++deitr)
|
||||
{
|
||||
osg::DrawElements* elements = *deitr;
|
||||
if (!elements->getElementsBufferObject()) elements->setElementsBufferObject(0);
|
||||
if (!elements->getElementBufferObject()) elements->setElementBufferObject(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1416,6 +1416,59 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
||||
//
|
||||
#if 1
|
||||
|
||||
|
||||
#if 1
|
||||
|
||||
|
||||
state.setNormalPointer(_normalData.binding==BIND_PER_VERTEX ? _normalData.array.get() : 0);
|
||||
state.setColorPointer(_colorData.binding==BIND_PER_VERTEX ? _colorData.array.get() : 0);
|
||||
state.setSecondaryColorPointer(_secondaryColorData.binding==BIND_PER_VERTEX ? _secondaryColorData.array.get() : 0);
|
||||
state.setFogCoordPointer(_fogCoordData.binding==BIND_PER_VERTEX ? _fogCoordData.array.get() : 0);
|
||||
|
||||
unsigned int unit;
|
||||
for(unit=0;unit<_texCoordList.size();++unit)
|
||||
{
|
||||
state.setTexCoordPointer(unit, _texCoordList[unit].array.get());
|
||||
}
|
||||
state.disableTexCoordPointersAboveAndIncluding(unit);
|
||||
|
||||
if( handleVertexAttributes )
|
||||
{
|
||||
unsigned int index;
|
||||
for( index = 0; index < _vertexAttribList.size(); ++index )
|
||||
{
|
||||
const Array* array = _vertexAttribList[index].array.get();
|
||||
const AttributeBinding ab = _vertexAttribList[index].binding;
|
||||
state.setVertexAttribPointer(index, (ab==BIND_PER_VERTEX ? array : 0), _vertexAttribList[index].normalize);
|
||||
|
||||
if(array && ab!=BIND_PER_VERTEX)
|
||||
{
|
||||
const IndexArray* indexArray = _vertexAttribList[index].indices.get();
|
||||
|
||||
if( indexArray && indexArray->getNumElements() > 0 )
|
||||
{
|
||||
drawVertexAttribMap[ab].push_back(
|
||||
new DrawVertexAttrib(extensions,index,_vertexAttribList[index].normalize,array,indexArray) );
|
||||
}
|
||||
else
|
||||
{
|
||||
drawVertexAttribMap[ab].push_back(
|
||||
new DrawVertexAttrib(extensions,index,_vertexAttribList[index].normalize,array,0) );
|
||||
}
|
||||
}
|
||||
}
|
||||
state.disableVertexAttribPointersAboveAndIncluding( index );
|
||||
|
||||
}
|
||||
else if (vertexVertexAttributesSupported)
|
||||
{
|
||||
state.disableVertexAttribPointersAboveAndIncluding( 0 );
|
||||
}
|
||||
|
||||
state.setVertexPointer(_vertexData.array.get());
|
||||
|
||||
#else
|
||||
|
||||
// first compile the VBO's
|
||||
const VertexBufferObject* prev_vbo = 0;
|
||||
const VertexBufferObject* new_vbo = 0;
|
||||
@@ -1519,8 +1572,8 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
||||
|
||||
SETARRAYPOINTER(_vertexData, state.setVertexPointer, state.disableVertexPointer)
|
||||
|
||||
const osg::ElementsBufferObject* prev_ebo = 0;
|
||||
const osg::ElementsBufferObject* new_ebo = 0;
|
||||
const osg::ElementBufferObject* prev_ebo = 0;
|
||||
const osg::ElementBufferObject* new_ebo = 0;
|
||||
for(PrimitiveSetList::const_iterator itr=_primitives.begin();
|
||||
itr!=_primitives.end();
|
||||
++itr)
|
||||
@@ -1528,7 +1581,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
||||
const DrawElements* de = (*itr)->getDrawElements();
|
||||
if (de)
|
||||
{
|
||||
new_ebo = de->getElementsBufferObject();
|
||||
new_ebo = de->getElementBufferObject();
|
||||
if (new_ebo && new_ebo!=prev_ebo)
|
||||
{
|
||||
new_ebo->compileBuffer(contextID, state);
|
||||
@@ -1537,6 +1590,8 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
GLuint& buffer = _vboList[state.getContextID()];
|
||||
@@ -1861,7 +1916,9 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
||||
|
||||
if (usingVertexBufferObjects)
|
||||
{
|
||||
extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
|
||||
// extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
|
||||
state.unbindVertexBufferObject();
|
||||
state.unbindElementBufferObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -155,16 +155,28 @@ void DrawElementsUByte::draw(State& state, bool useVertexBufferObjects) const
|
||||
if (useVertexBufferObjects)
|
||||
{
|
||||
#if 1
|
||||
#if 1
|
||||
const ElementBufferObject* ebo = getElementBufferObject();
|
||||
state.bindElementBufferObject(ebo);
|
||||
if (ebo)
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, ebo->getOffset(getElementBufferObjectIndex()));
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, &front());
|
||||
}
|
||||
#else
|
||||
unsigned int contextID = state.getContextID();
|
||||
const BufferObject::Extensions* extensions = BufferObject::getExtensions(contextID, true);
|
||||
|
||||
const ElementsBufferObject* ebo = getElementsBufferObject();
|
||||
const ElementBufferObject* ebo = getElementBufferObject();
|
||||
if (ebo)
|
||||
{
|
||||
//ebo->compileBuffer(state);
|
||||
ebo->bindBuffer(contextID);
|
||||
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, ebo->getOffset(getElementsBufferObjectIndex()));
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, ebo->getOffset(getElementBufferObjectIndex()));
|
||||
|
||||
extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
}
|
||||
@@ -172,6 +184,7 @@ void DrawElementsUByte::draw(State& state, bool useVertexBufferObjects) const
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_INT, &front());
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
unsigned int contextID = state.getContextID();
|
||||
const BufferObject::Extensions* extensions = BufferObject::getExtensions(contextID, true);
|
||||
@@ -268,16 +281,28 @@ void DrawElementsUShort::draw(State& state, bool useVertexBufferObjects) const
|
||||
if (useVertexBufferObjects)
|
||||
{
|
||||
#if 1
|
||||
#if 1
|
||||
const ElementBufferObject* ebo = getElementBufferObject();
|
||||
state.bindElementBufferObject(ebo);
|
||||
if (ebo)
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_SHORT, ebo->getOffset(getElementBufferObjectIndex()));
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_SHORT, &front());
|
||||
}
|
||||
#else
|
||||
unsigned int contextID = state.getContextID();
|
||||
const BufferObject::Extensions* extensions = BufferObject::getExtensions(contextID, true);
|
||||
|
||||
const ElementsBufferObject* ebo = getElementsBufferObject();
|
||||
const ElementBufferObject* ebo = getElementBufferObject();
|
||||
if (ebo)
|
||||
{
|
||||
//ebo->compileBuffer(state);
|
||||
ebo->bindBuffer(contextID);
|
||||
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_SHORT, ebo->getOffset(getElementsBufferObjectIndex()));
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_SHORT, ebo->getOffset(getElementBufferObjectIndex()));
|
||||
|
||||
extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
}
|
||||
@@ -285,6 +310,7 @@ void DrawElementsUShort::draw(State& state, bool useVertexBufferObjects) const
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_INT, &front());
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
unsigned int contextID = state.getContextID();
|
||||
const BufferObject::Extensions* extensions = BufferObject::getExtensions(contextID, true);
|
||||
@@ -382,16 +408,28 @@ void DrawElementsUInt::draw(State& state, bool useVertexBufferObjects) const
|
||||
if (useVertexBufferObjects)
|
||||
{
|
||||
#if 1
|
||||
#if 1
|
||||
const ElementBufferObject* ebo = getElementBufferObject();
|
||||
state.bindElementBufferObject(ebo);
|
||||
if (ebo)
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_INT, ebo->getOffset(getElementBufferObjectIndex()));
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_INT, &front());
|
||||
}
|
||||
#else
|
||||
unsigned int contextID = state.getContextID();
|
||||
const BufferObject::Extensions* extensions = BufferObject::getExtensions(contextID, true);
|
||||
|
||||
const ElementsBufferObject* ebo = getElementsBufferObject();
|
||||
const ElementBufferObject* ebo = getElementBufferObject();
|
||||
if (ebo)
|
||||
{
|
||||
//ebo->compileBuffer(state);
|
||||
ebo->bindBuffer(contextID);
|
||||
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_INT, ebo->getOffset(getElementsBufferObjectIndex()));
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_INT, ebo->getOffset(getElementBufferObjectIndex()));
|
||||
|
||||
extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
}
|
||||
@@ -399,6 +437,7 @@ void DrawElementsUInt::draw(State& state, bool useVertexBufferObjects) const
|
||||
{
|
||||
glDrawElements(_mode, size(), GL_UNSIGNED_INT, &front());
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
unsigned int contextID = state.getContextID();
|
||||
const BufferObject::Extensions* extensions = BufferObject::getExtensions(contextID, true);
|
||||
|
||||
@@ -39,6 +39,10 @@ State::State()
|
||||
_currentActiveTextureUnit=0;
|
||||
_currentClientActiveTextureUnit=0;
|
||||
|
||||
_currentVBO = 0;
|
||||
_currentEBO = 0;
|
||||
_currentPBO = 0;
|
||||
|
||||
_isSecondaryColorSupportResolved = false;
|
||||
_isSecondaryColorSupported = false;
|
||||
|
||||
@@ -728,6 +732,7 @@ void State::initializeExtensionProcs()
|
||||
_glVertexAttribPointer = (VertexAttribPointerProc) osg::getGLExtensionFuncPtr("glVertexAttribPointer","glVertexAttribPointerARB");
|
||||
_glEnableVertexAttribArray = (EnableVertexAttribProc) osg::getGLExtensionFuncPtr("glEnableVertexAttribArray","glEnableVertexAttribArrayARB");
|
||||
_glDisableVertexAttribArray = (DisableVertexAttribProc) osg::getGLExtensionFuncPtr("glDisableVertexAttribArray","glDisableVertexAttribArrayARB");
|
||||
_glBindBuffer = (BindBufferProc) osg::getGLExtensionFuncPtr("glBindBuffer","glBindBufferARB");
|
||||
|
||||
_extensionProcsInitialized = true;
|
||||
}
|
||||
@@ -736,8 +741,6 @@ bool State::setClientActiveTextureUnit( unsigned int unit )
|
||||
{
|
||||
if (unit!=_currentClientActiveTextureUnit)
|
||||
{
|
||||
if (!_extensionProcsInitialized) initializeExtensionProcs();
|
||||
|
||||
if (_glClientActiveTexture)
|
||||
{
|
||||
_glClientActiveTexture(GL_TEXTURE0+unit);
|
||||
@@ -758,8 +761,6 @@ bool State::setActiveTextureUnit( unsigned int unit )
|
||||
{
|
||||
if (unit!=_currentActiveTextureUnit)
|
||||
{
|
||||
if (!_extensionProcsInitialized) initializeExtensionProcs();
|
||||
|
||||
if (_glActiveTexture)
|
||||
{
|
||||
_glActiveTexture(GL_TEXTURE0+unit);
|
||||
@@ -775,8 +776,6 @@ bool State::setActiveTextureUnit( unsigned int unit )
|
||||
|
||||
void State::setFogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
|
||||
{
|
||||
if (!_extensionProcsInitialized) initializeExtensionProcs();
|
||||
|
||||
if (_glFogCoordPointer)
|
||||
{
|
||||
|
||||
@@ -798,8 +797,6 @@ void State::setFogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
|
||||
void State::setSecondaryColorPointer( GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
if (!_extensionProcsInitialized) initializeExtensionProcs();
|
||||
|
||||
if (_glSecondaryColorPointer)
|
||||
{
|
||||
if (!_secondaryColorArray._enabled || _secondaryColorArray._dirty)
|
||||
@@ -822,8 +819,6 @@ void State::setVertexAttribPointer( unsigned int index,
|
||||
GLint size, GLenum type, GLboolean normalized,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
if (!_extensionProcsInitialized) initializeExtensionProcs();
|
||||
|
||||
if (_glVertexAttribPointer)
|
||||
{
|
||||
if ( index >= _vertexAttribArrayList.size()) _vertexAttribArrayList.resize(index+1);
|
||||
@@ -848,8 +843,6 @@ void State::setVertexAttribPointer( unsigned int index,
|
||||
* note, only updates values that change.*/
|
||||
void State::disableVertexAttribPointer( unsigned int index )
|
||||
{
|
||||
if (!_extensionProcsInitialized) initializeExtensionProcs();
|
||||
|
||||
if (_glDisableVertexAttribArray)
|
||||
{
|
||||
if ( index >= _vertexAttribArrayList.size()) _vertexAttribArrayList.resize(index+1);
|
||||
@@ -866,8 +859,6 @@ void State::disableVertexAttribPointer( unsigned int index )
|
||||
|
||||
void State::disableVertexAttribPointersAboveAndIncluding( unsigned int index )
|
||||
{
|
||||
if (!_extensionProcsInitialized) initializeExtensionProcs();
|
||||
|
||||
if (_glDisableVertexAttribArray)
|
||||
{
|
||||
while (index<_vertexAttribArrayList.size())
|
||||
|
||||
@@ -845,9 +845,10 @@ void SceneView::draw()
|
||||
{
|
||||
if (_camera->getNodeMask()==0) return;
|
||||
|
||||
if (!_initCalled) init();
|
||||
|
||||
osg::State* state = _renderInfo.getState();
|
||||
state->initializeExtensionProcs();
|
||||
|
||||
if (!_initCalled) init();
|
||||
|
||||
// note, to support multi-pipe systems the deletion of OpenGL display list
|
||||
// and texture objects is deferred until the OpenGL context is the correct
|
||||
|
||||
@@ -224,6 +224,8 @@ struct CompositeViewerCompileOperation : public osg::Operation
|
||||
// OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
|
||||
// osg::notify(osg::NOTICE)<<"Compile "<<context<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
||||
|
||||
context->getState()->initializeExtensionProcs();
|
||||
|
||||
osgUtil::GLObjectsVisitor compileVisitor;
|
||||
compileVisitor.setState(context->getState());
|
||||
|
||||
|
||||
@@ -940,6 +940,8 @@ struct ViewerCompileOperation : public osg::Operation
|
||||
// osg::notify(osg::NOTICE)<<"Compile "<<context<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
||||
|
||||
// context->makeCurrent();
|
||||
|
||||
context->getState()->initializeExtensionProcs();
|
||||
|
||||
osgUtil::GLObjectsVisitor compileVisitor;
|
||||
compileVisitor.setState(context->getState());
|
||||
|
||||
Reference in New Issue
Block a user