summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2024-09-23 10:50:36 -0700
committerclayjohn <claynjohn@gmail.com>2024-09-23 12:18:33 -0700
commit0305e437ffec0315c369723952a9a667a99a4fb9 (patch)
tree9492fdbdd2ad318be6f70ba46856673070398c21
parent694d3c2930bdfb43fd93e1e6641f66c4f19a5c77 (diff)
downloadredot-engine-0305e437ffec0315c369723952a9a667a99a4fb9.tar.gz
Clean up two recently introduced WebGL errors
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp4
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp8
-rw-r--r--drivers/gles3/storage/config.cpp2
-rw-r--r--drivers/gles3/storage/config.h1
4 files changed, 11 insertions, 4 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index df7aba265b..3c959f0143 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -2184,7 +2184,9 @@ void RasterizerCanvasGLES3::canvas_begin(RID p_to_render_target, bool p_to_backb
glBindFramebuffer(GL_FRAMEBUFFER, render_target->fbo);
glActiveTexture(GL_TEXTURE0 + config->max_texture_image_units - 4);
glBindTexture(GL_TEXTURE_2D, render_target->backbuffer);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, p_backbuffer_has_mipmaps ? render_target->mipmap_count - 1 : 0);
+ if (render_target->backbuffer != 0) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, p_backbuffer_has_mipmaps ? render_target->mipmap_count - 1 : 0);
+ }
}
if (render_target->is_transparent || p_to_backbuffer) {
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index 19ef3d416c..e79f1db08d 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -349,9 +349,6 @@ RasterizerGLES3::RasterizerGLES3() {
}
}
- // Disable OpenGL linear to sRGB conversion, because Godot will always do this conversion itself.
- glDisable(GL_FRAMEBUFFER_SRGB);
-
// OpenGL needs to be initialized before initializing the Rasterizers
config = memnew(GLES3::Config);
utilities = memnew(GLES3::Utilities);
@@ -368,6 +365,11 @@ RasterizerGLES3::RasterizerGLES3() {
fog = memnew(GLES3::Fog);
canvas = memnew(RasterizerCanvasGLES3());
scene = memnew(RasterizerSceneGLES3());
+
+ // Disable OpenGL linear to sRGB conversion, because Godot will always do this conversion itself.
+ if (config->srgb_framebuffer_supported) {
+ glDisable(GL_FRAMEBUFFER_SRGB);
+ }
}
RasterizerGLES3::~RasterizerGLES3() {
diff --git a/drivers/gles3/storage/config.cpp b/drivers/gles3/storage/config.cpp
index d6472c44c1..2b19bd581a 100644
--- a/drivers/gles3/storage/config.cpp
+++ b/drivers/gles3/storage/config.cpp
@@ -88,6 +88,7 @@ Config::Config() {
etc2_supported = false;
s3tc_supported = true;
rgtc_supported = true; //RGTC - core since OpenGL version 3.0
+ srgb_framebuffer_supported = true;
} else {
float_texture_supported = extensions.has("GL_EXT_color_buffer_float");
etc2_supported = true;
@@ -100,6 +101,7 @@ Config::Config() {
s3tc_supported = extensions.has("GL_EXT_texture_compression_dxt1") || extensions.has("GL_EXT_texture_compression_s3tc") || extensions.has("WEBGL_compressed_texture_s3tc");
#endif
rgtc_supported = extensions.has("GL_EXT_texture_compression_rgtc") || extensions.has("GL_ARB_texture_compression_rgtc") || extensions.has("EXT_texture_compression_rgtc");
+ srgb_framebuffer_supported = extensions.has("GL_EXT_sRGB_write_control");
}
glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &max_vertex_texture_image_units);
diff --git a/drivers/gles3/storage/config.h b/drivers/gles3/storage/config.h
index ff72fc5b58..112dfd0a5f 100644
--- a/drivers/gles3/storage/config.h
+++ b/drivers/gles3/storage/config.h
@@ -79,6 +79,7 @@ public:
bool astc_supported = false;
bool astc_hdr_supported = false;
bool astc_layered_supported = false;
+ bool srgb_framebuffer_supported = false;
bool force_vertex_shading = false;