Browse Source

OpenGL ES 2.x doesn't require glEnable/glDisable on GL_TEXTURE_* targets anymore, apparently.

rdb 16 years ago
parent
commit
442ef013c4

+ 21 - 13
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -7094,18 +7094,20 @@ update_standard_texture_bindings() {
     _glActiveTexture(GL_TEXTURE0 + i);
     _glActiveTexture(GL_TEXTURE0 + i);
 
 
     // First, turn off the previous texture mode.
     // First, turn off the previous texture mode.
+#ifndef OPENGLES_2
 #ifndef OPENGLES
 #ifndef OPENGLES
     GLP(Disable)(GL_TEXTURE_1D);
     GLP(Disable)(GL_TEXTURE_1D);
-#endif
+#endif  // OPENGLES
     GLP(Disable)(GL_TEXTURE_2D);
     GLP(Disable)(GL_TEXTURE_2D);
     if (_supports_3d_texture) {
     if (_supports_3d_texture) {
 #ifndef OPENGLES_1
 #ifndef OPENGLES_1
       GLP(Disable)(GL_TEXTURE_3D);
       GLP(Disable)(GL_TEXTURE_3D);
-#endif
+#endif  // OPENGLES_1
     }
     }
     if (_supports_cube_map) {
     if (_supports_cube_map) {
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
     }
     }
+#endif // OPENGLES_2
     
     
     TextureContext *tc = texture->prepare_now(_prepared_objects, this);
     TextureContext *tc = texture->prepare_now(_prepared_objects, this);
     if (tc == (TextureContext *)NULL) {
     if (tc == (TextureContext *)NULL) {
@@ -7113,6 +7115,7 @@ update_standard_texture_bindings() {
       break;
       break;
     }
     }
     
     
+#ifndef OPENGLES_2
     // Then, turn on the current texture mode.
     // Then, turn on the current texture mode.
     GLenum target = get_texture_target(texture->get_texture_type());
     GLenum target = get_texture_target(texture->get_texture_type());
     if (target == GL_NONE) {
     if (target == GL_NONE) {
@@ -7120,9 +7123,12 @@ update_standard_texture_bindings() {
       break;
       break;
     }
     }
     GLP(Enable)(target);
     GLP(Enable)(target);
+#endif
     
     
     if (!update_texture(tc, false)) {
     if (!update_texture(tc, false)) {
+#ifndef OPENGLES_2
       GLP(Disable)(target);
       GLP(Disable)(target);
+#endif
       break;
       break;
     }
     }
     
     
@@ -7248,6 +7254,7 @@ update_standard_texture_bindings() {
     }
     }
   }
   }
   
   
+#ifndef OPENGLES_2
   // Disable the texture stages that are no longer used.
   // Disable the texture stages that are no longer used.
   for (i = num_stages; i < _num_active_texture_stages; i++) {
   for (i = num_stages; i < _num_active_texture_stages; i++) {
     _glActiveTexture(GL_TEXTURE0 + i);
     _glActiveTexture(GL_TEXTURE0 + i);
@@ -7258,14 +7265,13 @@ update_standard_texture_bindings() {
     if (_supports_3d_texture) {
     if (_supports_3d_texture) {
 #ifndef OPENGLES_1
 #ifndef OPENGLES_1
       GLP(Disable)(GL_TEXTURE_3D);
       GLP(Disable)(GL_TEXTURE_3D);
-#endif
+#endif  // OPENGLES_1
     }
     }
-#ifndef OPENGLES_2
     if (_supports_cube_map) {
     if (_supports_cube_map) {
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
     }
     }
-#endif
   }
   }
+#endif  // OPENGLES_2
   
   
   // Save the count of texture stages for next time.
   // Save the count of texture stages for next time.
   _num_active_texture_stages = num_stages;
   _num_active_texture_stages = num_stages;
@@ -7315,24 +7321,24 @@ update_show_usage_texture_bindings(int show_stage_index) {
     tc->enqueue_lru(&_prepared_objects->_graphics_memory_lru);
     tc->enqueue_lru(&_prepared_objects->_graphics_memory_lru);
   }
   }
 
 
+#ifndef OPENGLES_2
   // Disable all texture stages.
   // Disable all texture stages.
   for (i = 0; i < _num_active_texture_stages; i++) {
   for (i = 0; i < _num_active_texture_stages; i++) {
     _glActiveTexture(GL_TEXTURE0 + i);
     _glActiveTexture(GL_TEXTURE0 + i);
 #ifndef OPENGLES
 #ifndef OPENGLES
     GLP(Disable)(GL_TEXTURE_1D);
     GLP(Disable)(GL_TEXTURE_1D);
-#endif
+#endif  // OPENGLES
     GLP(Disable)(GL_TEXTURE_2D);
     GLP(Disable)(GL_TEXTURE_2D);
     if (_supports_3d_texture) {
     if (_supports_3d_texture) {
 #ifndef OPENGLES_1
 #ifndef OPENGLES_1
       GLP(Disable)(GL_TEXTURE_3D);
       GLP(Disable)(GL_TEXTURE_3D);
-#endif
+#endif  // OPENGLES_1
     }
     }
-#ifndef OPENGLES_2
     if (_supports_cube_map) {
     if (_supports_cube_map) {
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
     }
     }
-#endif
   }
   }
+#endif
   
   
   // Save the count of texture stages for next time.
   // Save the count of texture stages for next time.
   _num_active_texture_stages = num_stages;
   _num_active_texture_stages = num_stages;
@@ -7351,7 +7357,9 @@ update_show_usage_texture_bindings(int show_stage_index) {
 
 
     // Choose the corresponding usage texture and apply it.
     // Choose the corresponding usage texture and apply it.
     _glActiveTexture(GL_TEXTURE0 + i);
     _glActiveTexture(GL_TEXTURE0 + i);
+#ifndef OPENGLES_2
     GLP(Enable)(GL_TEXTURE_2D);
     GLP(Enable)(GL_TEXTURE_2D);
+#endif
 
 
     UsageTextureKey key(texture->get_x_size(), texture->get_y_size());
     UsageTextureKey key(texture->get_x_size(), texture->get_y_size());
     UsageTextures::iterator ui = _usage_textures.find(key);
     UsageTextures::iterator ui = _usage_textures.find(key);
@@ -7453,28 +7461,28 @@ upload_usage_texture(int width, int height) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void CLP(GraphicsStateGuardian)::
 void CLP(GraphicsStateGuardian)::
 disable_standard_texture_bindings() {
 disable_standard_texture_bindings() {
+#ifndef OPENGLES_2
   // Disable the texture stages that are no longer used.
   // Disable the texture stages that are no longer used.
   for (int i = 0; i < _num_active_texture_stages; i++) {
   for (int i = 0; i < _num_active_texture_stages; i++) {
     _glActiveTexture(GL_TEXTURE0 + i);
     _glActiveTexture(GL_TEXTURE0 + i);
 #ifndef OPENGLES
 #ifndef OPENGLES
     GLP(Disable)(GL_TEXTURE_1D);
     GLP(Disable)(GL_TEXTURE_1D);
-#endif
+#endif  // OPENGLES
     GLP(Disable)(GL_TEXTURE_2D);
     GLP(Disable)(GL_TEXTURE_2D);
     if (_supports_3d_texture) {
     if (_supports_3d_texture) {
 #ifndef OPENGLES_1
 #ifndef OPENGLES_1
       GLP(Disable)(GL_TEXTURE_3D);
       GLP(Disable)(GL_TEXTURE_3D);
-#endif
+#endif  // OPENGLES_1
     }
     }
-#ifndef OPENGLES_2
     if (_supports_cube_map) {
     if (_supports_cube_map) {
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
     }
     }
-#endif
   }
   }
   
   
   _num_active_texture_stages = 0;
   _num_active_texture_stages = 0;
   
   
   report_my_gl_errors();
   report_my_gl_errors();
+#endif  // OPENGLES_2
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 8 - 2
panda/src/glstuff/glShaderContext_src.cxx

@@ -546,6 +546,7 @@ disable_shader_texture_bindings(GSG *gsg) {
     return;
     return;
   }
   }
 
 
+#ifndef OPENGLES_2
   for (int i=0; i<(int)_shader->_tex_spec.size(); i++) {
   for (int i=0; i<(int)_shader->_tex_spec.size(); i++) {
     if (_shader->get_language() == Shader::SL_GLSL) {
     if (_shader->get_language() == Shader::SL_GLSL) {
       if (_shader->_tex_spec[i]._name == 0) {
       if (_shader->_tex_spec[i]._name == 0) {
@@ -565,19 +566,20 @@ disable_shader_texture_bindings(GSG *gsg) {
     }
     }
 #ifndef OPENGLES
 #ifndef OPENGLES
     GLP(Disable)(GL_TEXTURE_1D);
     GLP(Disable)(GL_TEXTURE_1D);
-#endif
+#endif  // OPENGLES
     GLP(Disable)(GL_TEXTURE_2D);
     GLP(Disable)(GL_TEXTURE_2D);
 #ifndef OPENGLES_1
 #ifndef OPENGLES_1
     if (gsg->_supports_3d_texture) {
     if (gsg->_supports_3d_texture) {
       GLP(Disable)(GL_TEXTURE_3D);
       GLP(Disable)(GL_TEXTURE_3D);
     }
     }
-#endif
+#endif  // OPENGLES_1
     if (gsg->_supports_cube_map) {
     if (gsg->_supports_cube_map) {
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
     }
     }
     // This is probably faster - but maybe not as safe?
     // This is probably faster - but maybe not as safe?
     // cgGLDisableTextureParameter(p);
     // cgGLDisableTextureParameter(p);
   }
   }
+#endif  // OPENGLES_2
   _stage_offset = 0;
   _stage_offset = 0;
 
 
 #ifdef HAVE_CG
 #ifdef HAVE_CG
@@ -670,7 +672,9 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg) {
       // Unsupported texture mode.
       // Unsupported texture mode.
       continue;
       continue;
     }
     }
+#ifndef OPENGLES_2
     GLP(Enable)(target);
     GLP(Enable)(target);
+#endif
     gsg->apply_texture(tc);
     gsg->apply_texture(tc);
 
 
     if (_shader->get_language() == Shader::SL_GLSL) {
     if (_shader->get_language() == Shader::SL_GLSL) {
@@ -679,7 +683,9 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg) {
     }
     }
 
 
     if (!gsg->update_texture(tc, false)) {
     if (!gsg->update_texture(tc, false)) {
+#ifndef OPENGLES_2
       GLP(Disable)(target);
       GLP(Disable)(target);
+#endif
       continue;
       continue;
     }
     }
   }
   }