From 4a3c49cdcbf09857a675179e63f27e5a6ffe9b22 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 19 Feb 2026 17:55:13 +0100 Subject: [PATCH] REVIEWED: `rlLoadTextureDepth()`, address inconsistencies with WebGL 2.0 for sized depth formats #5500 --- src/rlgl.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rlgl.h b/src/rlgl.h index d05bc42cb..3168b6a63 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -3432,6 +3432,13 @@ unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer) else glInternalFormat = GL_DEPTH_COMPONENT16; } #endif +#if defined(GRAPHICS_API_OPENGL_ES3) + // NOTE: This sized internal format should also work for WebGL 2.0 + // WARNING: Specification only allows GL_DEPTH_COMPONENT32F for GL_FLOAT type + // REF: https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml + if (RLGL.ExtSupported.maxDepthBits == 24) glInternalFormat = GL_DEPTH_COMPONENT24; + else glInternalFormat = GL_DEPTH_COMPONENT16; +#endif if (!useRenderBuffer && RLGL.ExtSupported.texDepth) {