]> git.tdb.fi Git - libs/gl.git/blobdiff - source/program.cpp
Rework Bind and enable it to restore the old binding
[libs/gl.git] / source / program.cpp
index ef1f4c8a63fc0696f363bf21e10b60cb8fe4b80f..1f28e9565e19905e1770bce0de872621b25225f7 100644 (file)
@@ -113,8 +113,10 @@ void Program::bind() const
        if(!linked)
                throw InvalidState("Program is not linked");
 
+       if(!set_current(this))
+               return;
+
        glUseProgramObjectARB(id);
-       cur_prog = this;
 }
 
 int Program::get_uniform_location(const string &n) const
@@ -124,21 +126,12 @@ int Program::get_uniform_location(const string &n) const
 
 void Program::unbind()
 {
-       if(cur_prog)
-       {
-               glUseProgramObjectARB(0);
-               cur_prog = 0;
-       }
-}
+       if(!set_current(0))
+               return;
 
-void Program::maybe_bind()
-{
-       if(cur_prog!=this)
-               bind();
+       glUseProgramObjectARB(0);
 }
 
-const Program *Program::cur_prog = 0;
-
 
 Program::Loader::Loader(Program &p):
        DataFile::ObjectLoader<Program>(p)