From c26fcee175fe0edc4abcf580cb82cb03310a3e5b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 27 Apr 2008 05:16:36 -0400 Subject: [PATCH] Disable any enabled client-side arrays when binding a new shader. --HG-- branch : trunk --- mojoshader_opengl.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mojoshader_opengl.c b/mojoshader_opengl.c index ce3df0af..0241ad0c 100644 --- a/mojoshader_opengl.c +++ b/mojoshader_opengl.c @@ -347,14 +347,27 @@ MOJOSHADER_glProgram *MOJOSHADER_glLinkProgram(MOJOSHADER_glShader *vshader, 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;