Browse Source

More work on OpenGL ES 2 support

rdb 16 years ago
parent
commit
e3fde823b0

+ 6 - 0
panda/src/egldisplay/eglGraphicsPipe.cxx

@@ -92,6 +92,12 @@ eglGraphicsPipe(const string &display) {
       << get_egl_error_string(eglGetError()) << "\n";
       << get_egl_error_string(eglGetError()) << "\n";
   }
   }
 
 
+  if (!eglBindAPI(EGL_OPENGL_ES_API)) {
+    egldisplay_cat.error()
+      << "Couldn't bind EGL to the OpenGL ES API: "
+      << get_egl_error_string(eglGetError()) << "\n";
+  }
+
   // Connect to an input method for supporting international text
   // Connect to an input method for supporting international text
   // entry.
   // entry.
   _im = XOpenIM(_display, NULL, NULL, NULL);
   _im = XOpenIM(_display, NULL, NULL, NULL);

+ 11 - 1
panda/src/egldisplay/eglGraphicsStateGuardian.cxx

@@ -156,7 +156,12 @@ choose_pixel_format(const FrameBufferProperties &properties,
   _fbprops.clear();
   _fbprops.clear();
 
 
   int attrib_list[] = {
   int attrib_list[] = {
-    EGL_RENDERABLE_TYPE, EGL_DONT_CARE,
+#ifdef OPENGLES_1
+    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
+#endif
+#ifdef OPENGLES_2
+    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+#endif
     EGL_SURFACE_TYPE, EGL_DONT_CARE,
     EGL_SURFACE_TYPE, EGL_DONT_CARE,
     EGL_NONE
     EGL_NONE
   };
   };
@@ -211,7 +216,12 @@ choose_pixel_format(const FrameBufferProperties &properties,
     egldisplay_cat.debug()
     egldisplay_cat.debug()
       << "Chosen config " << best_result << ": " << best_props << "\n";
       << "Chosen config " << best_result << ": " << best_props << "\n";
     _fbconfig = configs[best_result];
     _fbconfig = configs[best_result];
+#ifdef OPENGLES_2
+    EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
+    _context = eglCreateContext(_egl_display, _fbconfig, _share_context, context_attribs);
+#else
     _context = eglCreateContext(_egl_display, _fbconfig, _share_context, NULL);
     _context = eglCreateContext(_egl_display, _fbconfig, _share_context, NULL);
+#endif
     int err = eglGetError();
     int err = eglGetError();
     if (_context && err == EGL_SUCCESS) {
     if (_context && err == EGL_SUCCESS) {
       if (_visual) {
       if (_visual) {

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

@@ -693,6 +693,9 @@ reset() {
   _supports_tex_non_pow2 =
   _supports_tex_non_pow2 =
     has_extension("GL_ARB_texture_non_power_of_two");
     has_extension("GL_ARB_texture_non_power_of_two");
 
 
+#ifdef OPENGLES_2 // OpenGL ES 2.0 doesn't support multitexturing.
+  _supports_multitexture = false;
+#else
   if (is_at_least_gl_version(1, 3) || is_at_least_gles_version(1, 1)) {
   if (is_at_least_gl_version(1, 3) || is_at_least_gles_version(1, 1)) {
     _supports_multitexture = true;
     _supports_multitexture = true;
 
 
@@ -738,6 +741,8 @@ reset() {
       _supports_multitexture = false;
       _supports_multitexture = false;
     }
     }
   }
   }
+#endif
+
   if (!_supports_multitexture) {
   if (!_supports_multitexture) {
     _glActiveTexture = null_glActiveTexture;
     _glActiveTexture = null_glActiveTexture;
     _glClientActiveTexture = null_glActiveTexture;
     _glClientActiveTexture = null_glActiveTexture;
@@ -7036,6 +7041,7 @@ do_issue_texture() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void CLP(GraphicsStateGuardian)::
 void CLP(GraphicsStateGuardian)::
 update_standard_texture_bindings() {
 update_standard_texture_bindings() {
+#ifndef OPENGLES_2
 #ifndef NDEBUG
 #ifndef NDEBUG
   if (_show_texture_usage) {
   if (_show_texture_usage) {
     update_show_usage_texture_bindings(-1);
     update_show_usage_texture_bindings(-1);
@@ -7120,7 +7126,6 @@ update_standard_texture_bindings() {
       break;
       break;
     }
     }
     
     
-#ifndef OPENGLES_2
     if (stage->involves_color_scale() && _color_scale_enabled) {
     if (stage->involves_color_scale() && _color_scale_enabled) {
       Colorf color = stage->get_color();
       Colorf color = stage->get_color();
       color.set(color[0] * _current_color_scale[0],
       color.set(color[0] * _current_color_scale[0],
@@ -7231,7 +7236,6 @@ update_standard_texture_bindings() {
       GLint glmode = get_texture_apply_mode_type(stage->get_mode());
       GLint glmode = get_texture_apply_mode_type(stage->get_mode());
       GLP(TexEnvi)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, glmode);
       GLP(TexEnvi)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, glmode);
     }
     }
-#endif
 
 
     if (stage->get_saved_result()) {
     if (stage->get_saved_result()) {
       // This texture's result will be "saved" for a future stage's
       // This texture's result will be "saved" for a future stage's
@@ -7256,15 +7260,18 @@ update_standard_texture_bindings() {
       GLP(Disable)(GL_TEXTURE_3D);
       GLP(Disable)(GL_TEXTURE_3D);
 #endif
 #endif
     }
     }
+#ifndef OPENGLES_2
     if (_supports_cube_map) {
     if (_supports_cube_map) {
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
     }
     }
+#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;
   
   
   report_my_gl_errors();
   report_my_gl_errors();
+#endif
 }
 }
 
 
 
 
@@ -7320,9 +7327,11 @@ update_show_usage_texture_bindings(int show_stage_index) {
       GLP(Disable)(GL_TEXTURE_3D);
       GLP(Disable)(GL_TEXTURE_3D);
 #endif
 #endif
     }
     }
+#ifndef OPENGLES_2
     if (_supports_cube_map) {
     if (_supports_cube_map) {
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
       GLP(Disable)(GL_TEXTURE_CUBE_MAP);
     }
     }
+#endif
   }
   }
   
   
   // Save the count of texture stages for next time.
   // Save the count of texture stages for next time.
@@ -7456,9 +7465,11 @@ disable_standard_texture_bindings() {
       GLP(Disable)(GL_TEXTURE_3D);
       GLP(Disable)(GL_TEXTURE_3D);
 #endif
 #endif
     }
     }
+#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;