diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 5c2c0b8831..df02a377d4 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -897,7 +897,7 @@ reset() { get_extension_func(GLPREFIX_QUOTED, "DeleteShader"); _glDetachShader = (PFNGLDETACHSHADERPROC) get_extension_func(GLPREFIX_QUOTED, "DetachShader"); - _glDisableVertexAttribArray (PFNGLDISABLEVERTEXATTRIBARRAYPROC) + _glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) get_extension_func(GLPREFIX_QUOTED, "DisableVertexAttribArray"); _glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) get_extension_func(GLPREFIX_QUOTED, "EnableVertexAttribArray"); diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 6b4d9283b6..ca707b049e 100755 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -308,7 +308,7 @@ CLP(ShaderContext):: // vertex program handles or Cg contexts). //////////////////////////////////////////////////////////////////// void CLP(ShaderContext):: -release_resources(const GSG *gsg) { +release_resources(GSG *gsg) { #ifdef HAVE_CG if (_cg_context) { cgDestroyContext(_cg_context); @@ -320,7 +320,7 @@ release_resources(const GSG *gsg) { } if (gsg) { gsg->report_my_gl_errors(); - } if (glGetError() != GL_NO_ERROR) { + } else if (glGetError() != GL_NO_ERROR) { GLCAT.error() << "GL error in ShaderContext destructor\n"; } #endif @@ -347,6 +347,8 @@ release_resources(const GSG *gsg) { gsg->_glDeleteProgram(_glsl_program); _glsl_program = 0; } + + gsg->report_my_gl_errors(); } //////////////////////////////////////////////////////////////////// @@ -507,7 +509,7 @@ disable_shader_vertex_arrays(GSG *gsg) { if (_shader->get_language() == Shader::SL_GLSL) { for (int i=0; i<(int)_shader->_var_spec.size(); i++) { - glDisableVertexAttribArray(i); + gsg->_glDisableVertexAttribArray(i); } } #ifdef HAVE_CG @@ -588,8 +590,8 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, #ifndef OPENGLES_2 glEnableClientState(GL_VERTEX_ARRAY); #endif - glEnableVertexAttribArray(i); - glVertexAttribPointer(i, num_values, gsg->get_numeric_type(numeric_type), + gsg->_glEnableVertexAttribArray(i); + gsg->_glVertexAttribPointer(i, num_values, gsg->get_numeric_type(numeric_type), GL_FALSE, stride, client_pointer + start); #ifndef OPENGLES_2 glDisableClientState(GL_VERTEX_ARRAY); @@ -606,6 +608,7 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, } #ifdef HAVE_CG else if (_shader->get_language() == Shader::SL_Cg) { + CGparameter p = _cg_parameter_map[_shader->_var_spec[i]._id._seqno]; cgGLDisableClientState(p); } #endif diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 9ed1ed74fb..0d309adf79 100755 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -72,14 +72,14 @@ private: int _stage_offset; // Avoid using this! It merely exists so the // destructor has access to the extension functions. - WCPT(GSG) _last_gsg; + WPT(GSG) _last_gsg; void glsl_report_shader_errors(GSG *gsg, unsigned int shader); void glsl_report_program_errors(GSG *gsg, unsigned int program); unsigned int glsl_compile_entry_point(GSG *gsg, Shader::ShaderType type); bool glsl_compile_shader(GSG *gsg); - void release_resources(const GSG *gsg); + void release_resources(GSG *gsg); public: static TypeHandle get_class_type() {