Skip to content

Commit

Permalink
Fixed|libgui|GLProgram: Rebuilding a program
Browse files Browse the repository at this point in the history
The state of the GLProgram was not properly updated when its was
rebuilt. The existing uniform bindings are retained, but they need
to be updated.
  • Loading branch information
skyjake committed Nov 15, 2013
1 parent 61e50ac commit afe8914
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions doomsday/libgui/src/glprogram.cpp
Expand Up @@ -73,18 +73,23 @@ DENG2_OBSERVES(GLUniform, Deletion)
}
}

void release()
void releaseButRetainBindings()
{
self.setState(NotReady);
detachAllShaders();
unbindAll();
if(name)
{
glDeleteProgram(name);
name = 0;
}
}

void release()
{
unbindAll();
releaseButRetainBindings();
}

void attach(GLShader const *shader)
{
DENG2_ASSERT(shader->isReady());
Expand Down Expand Up @@ -187,7 +192,7 @@ DENG2_OBSERVES(GLUniform, Deletion)

void markAllBoundUniformsChanged()
{
foreach(GLUniform const *u, changed)
foreach(GLUniform const *u, bound)
{
changed.insert(u);
}
Expand Down Expand Up @@ -265,7 +270,7 @@ GLProgram &GLProgram::build(GLShader const *vertexShader, GLShader const *fragme
DENG2_ASSERT(fragmentShader->isReady());
DENG2_ASSERT(fragmentShader->type() == GLShader::Fragment);

d->detachAllShaders();
d->releaseButRetainBindings();
d->attach(vertexShader);
d->attach(fragmentShader);
d->bindVertexAttribs();
Expand Down

0 comments on commit afe8914

Please sign in to comment.