@@ -987,7 +987,8 @@ typedef struct rlglData {
987
987
bool vao ; // VAO support (OpenGL ES2 could not support VAO extension) (GL_ARB_vertex_array_object)
988
988
bool instancing ; // Instancing supported (GL_ANGLE_instanced_arrays, GL_EXT_draw_instanced + GL_EXT_instanced_arrays)
989
989
bool texNPOT ; // NPOT textures full support (GL_ARB_texture_non_power_of_two, GL_OES_texture_npot)
990
- bool texDepth ; // Depth textures supported (GL_ARB_depth_texture, GL_WEBGL_depth_texture, GL_OES_depth_texture)
990
+ bool texDepth ; // Depth textures supported (GL_ARB_depth_texture, GL_OES_depth_texture)
991
+ bool texDepthWebGL ; // Depth textures supported WebGL specific (GL_WEBGL_depth_texture)
991
992
bool texFloat32 ; // float textures support (32 bit per channel) (GL_OES_texture_float)
992
993
bool texCompDXT ; // DDS texture compression support (GL_EXT_texture_compression_s3tc, GL_WEBGL_compressed_texture_s3tc, GL_WEBKIT_WEBGL_compressed_texture_s3tc)
993
994
bool texCompETC1 ; // ETC1 texture compression support (GL_OES_compressed_ETC1_RGB8_texture, GL_WEBGL_compressed_texture_etc1)
@@ -2218,11 +2219,12 @@ void rlLoadExtensions(void *loader)
2218
2219
if (strcmp (extList [i ], (const char * )"GL_OES_texture_float" ) == 0 ) RLGL .ExtSupported .texFloat32 = true;
2219
2220
2220
2221
// Check depth texture support
2221
- if ((strcmp (extList [i ], (const char * )"GL_OES_depth_texture" ) == 0 ) ||
2222
- (strcmp (extList [i ], (const char * )"GL_WEBGL_depth_texture" ) == 0 )) RLGL .ExtSupported .texDepth = true;
2222
+ if (strcmp (extList [i ], (const char * )"GL_OES_depth_texture" ) == 0 ) RLGL .ExtSupported .texDepth = true;
2223
+ if (strcmp (extList [i ], (const char * )"GL_WEBGL_depth_texture" ) == 0 ) RLGL .ExtSupported .texDepthWebGL = true; // WebGL requires unsized internal format
2224
+ if (RLGL .ExtSupported .texDepthWebGL ) RLGL .ExtSupported .texDepth = true;
2223
2225
2224
- if (strcmp (extList [i ], (const char * )"GL_OES_depth24" ) == 0 ) RLGL .ExtSupported .maxDepthBits = 24 ;
2225
- if (strcmp (extList [i ], (const char * )"GL_OES_depth32" ) == 0 ) RLGL .ExtSupported .maxDepthBits = 32 ;
2226
+ if (strcmp (extList [i ], (const char * )"GL_OES_depth24" ) == 0 ) RLGL .ExtSupported .maxDepthBits = 24 ; // Not available on WebGL
2227
+ if (strcmp (extList [i ], (const char * )"GL_OES_depth32" ) == 0 ) RLGL .ExtSupported .maxDepthBits = 32 ; // Not available on WebGL
2226
2228
2227
2229
// Check texture compression support: DXT
2228
2230
if ((strcmp (extList [i ], (const char * )"GL_EXT_texture_compression_s3tc" ) == 0 ) ||
@@ -2975,23 +2977,28 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
2975
2977
}
2976
2978
2977
2979
// Load depth texture/renderbuffer (to be attached to fbo)
2978
- // WARNING: OpenGL ES 2.0 requires GL_OES_depth_texture/ WEBGL_depth_texture extensions
2980
+ // WARNING: OpenGL ES 2.0 requires GL_OES_depth_texture and WebGL requires WEBGL_depth_texture extensions
2979
2981
unsigned int rlLoadTextureDepth (int width , int height , bool useRenderBuffer )
2980
2982
{
2981
2983
unsigned int id = 0 ;
2982
2984
2983
2985
#if defined(GRAPHICS_API_OPENGL_33 ) || defined(GRAPHICS_API_OPENGL_ES2 )
2984
2986
// In case depth textures not supported, we force renderbuffer usage
2985
2987
if (!RLGL .ExtSupported .texDepth ) useRenderBuffer = true;
2986
-
2988
+
2987
2989
// NOTE: We let the implementation to choose the best bit-depth
2988
2990
// Possible formats: GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT32 and GL_DEPTH_COMPONENT32F
2989
2991
unsigned int glInternalFormat = GL_DEPTH_COMPONENT ;
2990
2992
2991
2993
#if defined(GRAPHICS_API_OPENGL_ES2 )
2992
- if (RLGL .ExtSupported .maxDepthBits == 32 ) glInternalFormat = GL_DEPTH_COMPONENT32_OES ;
2993
- else if (RLGL .ExtSupported .maxDepthBits == 24 ) glInternalFormat = GL_DEPTH_COMPONENT24_OES ;
2994
- else glInternalFormat = GL_DEPTH_COMPONENT16 ;
2994
+ // WARNING: WebGL platform requires unsized internal format definition (GL_DEPTH_COMPONENT)
2995
+ // while other platforms using OpenGL ES 2.0 require/support sized internal formats depending on the GPU capabilities
2996
+ if (!RLGL .ExtSupported .texDepthWebGL )
2997
+ {
2998
+ if (RLGL .ExtSupported .maxDepthBits == 32 ) glInternalFormat = GL_DEPTH_COMPONENT32_OES ;
2999
+ else if (RLGL .ExtSupported .maxDepthBits == 24 ) glInternalFormat = GL_DEPTH_COMPONENT24_OES ;
3000
+ else glInternalFormat = GL_DEPTH_COMPONENT16 ;
3001
+ }
2995
3002
#endif
2996
3003
2997
3004
if (!useRenderBuffer && RLGL .ExtSupported .texDepth )
0 commit comments