diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 29: Add Shader::unload() method.

Message ID 20110721123632.17019.81377.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Alexandros Frantzis July 21, 2011, 12:36 p.m. UTC
------------------------------------------------------------
revno: 29
committer: Alexandros Frantzis <alf82@freemail.gr>
timestamp: Fri 2010-07-09 14:16:34 +0300
message:
  Add Shader::unload() method.
  Change Shader::remove() to remove a shader from use (but not unload it).
modified:
  shader.cpp
  shader.h


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'shader.cpp'
--- shader.cpp	2010-07-09 10:28:57 +0000
+++ shader.cpp	2010-07-09 11:16:34 +0000
@@ -27,7 +27,7 @@ 
 
 Shader::~Shader()
 {
-    remove();
+    unload();
 }
 
 void Shader::load(const char *pVertexShaderFileName, const char *pFragmentShaderFileName)
@@ -122,8 +122,19 @@ 
 
 void Shader::remove()
 {
+    glUseProgramObjectARB(0);
+}
+
+void Shader::unload()
+{
     glDetachObjectARB(mShaderProgram, mVertexShader);
     glDetachObjectARB(mShaderProgram, mFragmentShader);
-
+    
+    glDeleteObjectARB(mVertexShader);
+    glDeleteObjectARB(mFragmentShader);
     glDeleteObjectARB(mShaderProgram);
+
+    mVertexShader = 0;
+    mFragmentShader = 0;
+    mShaderProgram = 0;
 }

=== modified file 'shader.h'
--- shader.h	2010-07-09 10:28:57 +0000
+++ shader.h	2010-07-09 11:16:34 +0000
@@ -11,8 +11,10 @@ 
 public:
     ~Shader();
     void load(const char *pVertexShaderFileName, const char *pFragmentShaderFileName);
+    void unload();
+
+    void use();
     void remove();
-    void use();
     
     GLuint mVertexShader;
     GLuint mFragmentShader;