From 48e4ef517fa372a420724d1568639240bcecc2f4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 20:38:07 +0100 Subject: [PATCH] Windscreen water (OpenGL): the mask of the wipers read for the kernels [skip ci] The OpenGL renderer reads a texture when a draw binds it. The glasses never draw the mask of their wipers, only the kernels read it, so under OpenGL the mask stayed unread, the glass was never baked and had no map: no snow (the log said "glass 1 not baked yet" for good). The kernels now have a texture they read loaded from its file when nothing read it yet. Vulkan reads its textures without a draw, so it had this right. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD --- rendering/opengl46/opengl46water.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/rendering/opengl46/opengl46water.cpp b/rendering/opengl46/opengl46water.cpp index 4dbf77d18..457544257 100644 --- a/rendering/opengl46/opengl46water.cpp +++ b/rendering/opengl46/opengl46water.cpp @@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "rendering/opengl46/opengl46water.h" +#include "model/Texture.h" #include "rendering/renderer.h" #include "utilities/Logs.h" @@ -23,6 +24,16 @@ GLuint groups(std::size_t const Count) return static_cast((Count + gl::WATER_GROUP_SIZE - 1) / gl::WATER_GROUP_SIZE); } +// a texture a kernel reads, made ready: read from its file first when nothing read it yet. the opengl renderer reads a texture +// when a draw binds it, and the glasses never draw the mask of their wipers (only the kernels read it), so without this the mask +// stayed unread and the glass never got its map +bool kernel_texture(ITexture &Texture) +{ + if (auto *source{dynamic_cast(&Texture)}; (source != nullptr) && (source->data_state == resource_state::none) && (false == source->is_rendertarget)) + source->load(); + return Texture.create() && Texture.get_is_ready() && (Texture.get_id() != 0); +} + } // namespace namespace @@ -146,7 +157,7 @@ bool opengl46_windscreen_water::gpu_bake(std::size_t const Slot, texture_handle if ((!m_storage) || (Mask == null_handle)) return false; auto &texture{GfxRenderer->Texture(Mask)}; - if ((false == texture.create()) || (false == texture.get_is_ready()) || (texture.get_id() == 0)) + if (false == kernel_texture(texture)) return false; m_storage->bind_base(); m_block->update(Block); @@ -165,8 +176,7 @@ bool opengl46_windscreen_water::gpu_snow_layer(std::size_t const Slot, texture_h return false; auto &atlas{GfxRenderer->Texture(Atlas)}; auto &normal{GfxRenderer->Texture(Normal)}; - if ((false == atlas.create()) || (false == atlas.get_is_ready()) || (atlas.get_id() == 0) || (false == normal.create()) || (false == normal.get_is_ready()) || - (normal.get_id() == 0)) + if ((false == kernel_texture(atlas)) || (false == kernel_texture(normal))) return false; m_storage->bind_base(); m_block->update(Block);