Disable any enabled client-side arrays when binding a new shader. trunk
authorRyan C. Gordon <icculus@icculus.org>
Sun, 27 Apr 2008 05:16:36 -0400
branchtrunk
changeset 223 8df4e9545c87
parent 222 ed4421aa7e00
child 224 4acaf8199665
Disable any enabled client-side arrays when binding a new shader.
mojoshader_opengl.c
--- a/mojoshader_opengl.c	Sun Apr 27 05:10:35 2008 -0400
+++ b/mojoshader_opengl.c	Sun Apr 27 05:16:36 2008 -0400
@@ -347,14 +347,27 @@
 void MOJOSHADER_glBindProgram(MOJOSHADER_glProgram *program)
 {
     GLhandleARB handle = 0;
+
+    if (program == bound_program)
+        return;  // nothing to do.
+
+    // Disable any client-side arrays the current program could have used.
+    if (bound_program != NULL)
+    {
+        pglDisableClientState(GL_VERTEX_ARRAY);
+        for (i = 0; i < bound_program->attribute_count; i++)
+        {
+            const AttributeMap *map = &bound_program->attributes[i];
+            pglDisableVertexAttribArrayARB(map->location);
+        } // if
+    } // for
+
     if (program != NULL)
     {
         handle = program->handle;
         program->refcount++;
     } // if
 
-    // !!! FIXME: unbind client-side arrays.
-
     pglUseProgramObjectARB(handle);
     program_unref(bound_program);
     bound_program = program;