Added support for releasing GLObjects, and renamed DisplayListVisitor the
GLObjectVisitor to better fit its function, and added support for releasing objects as well as compiling them.
This commit is contained in:
@@ -199,7 +199,7 @@ void Drawable::dirtyBound()
|
||||
}
|
||||
}
|
||||
|
||||
void Drawable::compile(State& state) const
|
||||
void Drawable::compileGLObjects(State& state) const
|
||||
{
|
||||
if (!_useDisplayList) return;
|
||||
|
||||
@@ -216,12 +216,6 @@ void Drawable::compile(State& state) const
|
||||
glDeleteLists( globj, 1 );
|
||||
}
|
||||
|
||||
|
||||
if (_stateset.valid())
|
||||
{
|
||||
_stateset->compile(state);
|
||||
}
|
||||
|
||||
globj = glGenLists( 1 );
|
||||
glNewList( globj, GL_COMPILE );
|
||||
|
||||
@@ -234,6 +228,32 @@ void Drawable::compile(State& state) const
|
||||
|
||||
}
|
||||
|
||||
void Drawable::releaseGLObjects(State* state) const
|
||||
{
|
||||
if (!_useDisplayList) return;
|
||||
|
||||
if (state)
|
||||
{
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
unsigned int contextID = state->getContextID();
|
||||
|
||||
// get the globj for the current contextID.
|
||||
GLuint& globj = _globjList[contextID];
|
||||
|
||||
// call the globj if already set otherwise comple and execute.
|
||||
if( globj != 0 )
|
||||
{
|
||||
glDeleteLists( globj, 1 );
|
||||
globj = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const_cast<Drawable*>(this)->dirtyDisplayList();
|
||||
}
|
||||
}
|
||||
|
||||
void Drawable::setSupportsDisplayList(bool flag)
|
||||
{
|
||||
// if value unchanged simply return.
|
||||
|
||||
@@ -177,6 +177,11 @@ void FragmentProgram::apply(State& state) const
|
||||
}
|
||||
}
|
||||
|
||||
void FragmentProgram::releaseGLObjects(State* state) const
|
||||
{
|
||||
const_cast<FragmentProgram*>(this)->dirtyFragmentProgramObject();
|
||||
}
|
||||
|
||||
|
||||
typedef buffered_value< ref_ptr<FragmentProgram::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
@@ -190,6 +190,6 @@ void Geode::compileDrawables(State& state)
|
||||
itr!=_drawables.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->compile(state);
|
||||
(*itr)->compileGLObjects(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -752,13 +752,13 @@ const StateSet::RefAttributePair* StateSet::getTextureAttributePair(unsigned int
|
||||
}
|
||||
|
||||
|
||||
void StateSet::compile(State& state) const
|
||||
void StateSet::compileGLObjects(State& state) const
|
||||
{
|
||||
for(AttributeList::const_iterator itr = _attributeList.begin();
|
||||
itr!=_attributeList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.first->compile(state);
|
||||
itr->second.first->compileGLObjects(state);
|
||||
}
|
||||
|
||||
for(TextureAttributeList::const_iterator taitr=_textureAttributeList.begin();
|
||||
@@ -769,7 +769,29 @@ void StateSet::compile(State& state) const
|
||||
itr!=taitr->end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.first->compile(state);
|
||||
itr->second.first->compileGLObjects(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StateSet::releaseGLObjects(State* state) const
|
||||
{
|
||||
for(AttributeList::const_iterator itr = _attributeList.begin();
|
||||
itr!=_attributeList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.first->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
for(TextureAttributeList::const_iterator taitr=_textureAttributeList.begin();
|
||||
taitr!=_textureAttributeList.end();
|
||||
++taitr)
|
||||
{
|
||||
for(AttributeList::const_iterator itr = taitr->begin();
|
||||
itr!=taitr->end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.first->releaseGLObjects(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1046,11 +1046,15 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image*
|
||||
#include <set>
|
||||
|
||||
|
||||
void Texture::compile(State& state) const
|
||||
void Texture::compileGLObjects(State& state) const
|
||||
{
|
||||
apply(state);
|
||||
}
|
||||
|
||||
void Texture::releaseGLObjects(State* state) const
|
||||
{
|
||||
const_cast<Texture*>(this)->dirtyTextureObject();
|
||||
}
|
||||
|
||||
typedef buffered_value< ref_ptr<Texture::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
@@ -177,6 +177,11 @@ void VertexProgram::apply(State& state) const
|
||||
}
|
||||
}
|
||||
|
||||
void VertexProgram::releaseGLObjects(State* state) const
|
||||
{
|
||||
const_cast<VertexProgram*>(this)->dirtyVertexProgramObject();
|
||||
}
|
||||
|
||||
|
||||
typedef buffered_value< ref_ptr<VertexProgram::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
Reference in New Issue
Block a user