Browse Source

webgl: some fixes for WebGL 2 and current emscripten

rdb 8 years ago
parent
commit
8d68256b86

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

@@ -699,7 +699,10 @@ reset() {
 
 
 #elif defined(OPENGLES)
 #elif defined(OPENGLES)
   if (gl_support_primitive_restart_index && is_at_least_gles_version(3, 0)) {
   if (gl_support_primitive_restart_index && is_at_least_gles_version(3, 0)) {
+    // In WebGL 2, primitive restart is always enabled.
+#ifndef __EMSCRIPTEN__
     glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
     glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
+#endif
     _supported_geom_rendering |= Geom::GR_strip_cut_index;
     _supported_geom_rendering |= Geom::GR_strip_cut_index;
   }
   }
 
 
@@ -744,6 +747,8 @@ reset() {
 #ifndef OPENGLES_1
 #ifndef OPENGLES_1
   _glDrawRangeElements = null_glDrawRangeElements;
   _glDrawRangeElements = null_glDrawRangeElements;
 
 
+  // Temporarily disabled in WebGL due to Firefox bug
+#ifndef __EMSCRIPTEN__
 #ifdef OPENGLES
 #ifdef OPENGLES
   if (is_at_least_gles_version(3, 0)) {
   if (is_at_least_gles_version(3, 0)) {
     _glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)
     _glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)
@@ -764,6 +769,7 @@ reset() {
       << "glDrawRangeElements advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n";
       << "glDrawRangeElements advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n";
     _glDrawRangeElements = null_glDrawRangeElements;
     _glDrawRangeElements = null_glDrawRangeElements;
   }
   }
+#endif  // !__EMSCRIPTEN__
 #endif  // !OPENGLES_1
 #endif  // !OPENGLES_1
 
 
   _supports_3d_texture = false;
   _supports_3d_texture = false;
@@ -2887,7 +2893,7 @@ reset() {
   }
   }
 #endif  // !OPENGLES
 #endif  // !OPENGLES
 
 
-#ifndef OPENGLES_1
+#if !defined(OPENGLES_1) && !defined(__EMSCRIPTEN__)
   _supports_get_program_binary = false;
   _supports_get_program_binary = false;
   _program_binary_formats.clear();
   _program_binary_formats.clear();
 
 
@@ -3113,7 +3119,7 @@ reset() {
 
 
   report_my_gl_errors();
   report_my_gl_errors();
 
 
-#ifndef OPENGLES_1
+#if !defined(OPENGLES_1) && !defined(__EMSCRIPTEN__)
   if (GLCAT.is_debug()) {
   if (GLCAT.is_debug()) {
     if (_supports_get_program_binary) {
     if (_supports_get_program_binary) {
       GLCAT.debug()
       GLCAT.debug()

+ 3 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -703,8 +703,11 @@ protected:
   bool _supports_anisotropy;
   bool _supports_anisotropy;
   GLint _max_image_units;
   GLint _max_image_units;
   bool _supports_multi_bind;
   bool _supports_multi_bind;
+
+#if !defined(OPENGLES_1) && !defined(__EMSCRIPTEN__)
   bool _supports_get_program_binary;
   bool _supports_get_program_binary;
   pset<GLenum> _program_binary_formats;
   pset<GLenum> _program_binary_formats;
+#endif
 
 
 #ifdef OPENGLES
 #ifdef OPENGLES
   bool _supports_depth24;
   bool _supports_depth24;

+ 4 - 0
panda/src/glstuff/glShaderContext_src.cxx

@@ -3048,6 +3048,7 @@ glsl_compile_and_link() {
 
 
   // If we requested to retrieve the shader, we should indicate that before
   // If we requested to retrieve the shader, we should indicate that before
   // linking.
   // linking.
+#ifndef __EMSCRIPTEN__
   bool retrieve_binary = false;
   bool retrieve_binary = false;
   if (_glgsg->_supports_get_program_binary) {
   if (_glgsg->_supports_get_program_binary) {
     retrieve_binary = _shader->get_cache_compiled_shader();
     retrieve_binary = _shader->get_cache_compiled_shader();
@@ -3060,6 +3061,7 @@ glsl_compile_and_link() {
 
 
     _glgsg->_glProgramParameteri(_glsl_program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
     _glgsg->_glProgramParameteri(_glsl_program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
   }
   }
+#endif  // !__EMSCRIPTEN__
 
 
   if (GLCAT.is_debug()) {
   if (GLCAT.is_debug()) {
     GLCAT.debug()
     GLCAT.debug()
@@ -3080,6 +3082,7 @@ glsl_compile_and_link() {
   // Report any warnings.
   // Report any warnings.
   glsl_report_program_errors(_glsl_program, false);
   glsl_report_program_errors(_glsl_program, false);
 
 
+#ifndef __EMSCRIPTEN__
   if (retrieve_binary) {
   if (retrieve_binary) {
     GLint length = 0;
     GLint length = 0;
     _glgsg->_glGetProgramiv(_glsl_program, GL_PROGRAM_BINARY_LENGTH, &length);
     _glgsg->_glGetProgramiv(_glsl_program, GL_PROGRAM_BINARY_LENGTH, &length);
@@ -3110,6 +3113,7 @@ glsl_compile_and_link() {
     }
     }
 #endif  // NDEBUG
 #endif  // NDEBUG
   }
   }
+#endif  // !__EMSCRIPTEN__
 
 
   _glgsg->report_my_gl_errors();
   _glgsg->report_my_gl_errors();
   return true;
   return true;

+ 1 - 1
panda/src/webgldisplay/webGLGraphicsStateGuardian.h

@@ -18,7 +18,7 @@
 #include "webGLGraphicsPipe.h"
 #include "webGLGraphicsPipe.h"
 #include "gles2gsg.h"
 #include "gles2gsg.h"
 
 
-#include <html5.h>
+#include <emscripten/html5.h>
 
 
 /**
 /**
  * A specialization on GLES2GraphicsStateGuardian to add emscripten-specific
  * A specialization on GLES2GraphicsStateGuardian to add emscripten-specific

+ 1 - 1
panda/src/webgldisplay/webGLGraphicsWindow.h

@@ -19,7 +19,7 @@
 #include "webGLGraphicsPipe.h"
 #include "webGLGraphicsPipe.h"
 #include "graphicsWindow.h"
 #include "graphicsWindow.h"
 
 
-#include <html5.h>
+#include <emscripten/html5.h>
 
 
 /**
 /**
  * An interface to Emscripten's WebGL interface that represents an HTML5
  * An interface to Emscripten's WebGL interface that represents an HTML5