Jelajahi Sumber

glgsg: Set maximum vertex attrib stride for WebGL

rdb 2 tahun lalu
induk
melakukan
6075307e66

+ 4 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.I

@@ -186,7 +186,10 @@ has_fixed_function_pipeline() const {
  */
 INLINE int CLP(GraphicsStateGuardian)::
 get_max_vertex_attrib_stride() const {
-#ifdef OPENGLES_1
+#ifdef __EMSCRIPTEN__
+  // WebGL has a static limit of 255 (yeah, that low).
+  return 255;
+#elif defined(OPENGLES_1)
   // Best guess.
   return 2048;
 #else

+ 1 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -3522,7 +3522,7 @@ reset() {
   }
 #endif
 
-#ifndef OPENGLES_1
+#if !defined(OPENGLES_1) && !defined(__EMSCRIPTEN__)
   _max_vertex_attrib_stride = -1;
 #ifdef OPENGLES
   if (is_at_least_gles_version(3, 1))

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

@@ -753,7 +753,11 @@ protected:
   bool _use_vertex_attrib_binding;
   CPT(GeomVertexFormat) _current_vertex_format;
   const GeomVertexColumn *_vertex_attrib_columns[32];
+#ifdef __EMSCRIPTEN__
+  static const int _max_vertex_attrib_stride = 255;
+#else
   int _max_vertex_attrib_stride = INT_MAX;
+#endif
 
   GLuint _current_sbuffer_index;
   pvector<GLuint> _current_sbuffer_base;