summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/src/renderer/opengl.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/engine/src/renderer/opengl.rs b/engine/src/renderer/opengl.rs
index dc8e561..261148b 100644
--- a/engine/src/renderer/opengl.rs
+++ b/engine/src/renderer/opengl.rs
@@ -131,7 +131,8 @@ struct GraphicsContext
{
gl_context: ContextWithFns,
surfaces: HashMap<SurfaceId, GlutinSurface<GlutinWindowSurface>>,
- uniform_buffer_objs: HashMap<u32, opengl_bindings::buffer::Buffer<u8>>,
+ shader_uniform_buffer_objs:
+ HashMap<RendererObjectId, HashMap<u32, opengl_bindings::buffer::Buffer<u8>>>,
objects: HashMap<RendererObjectRawValue, GraphicsContextObject>,
next_object_key: RendererObjectRawValue,
}
@@ -639,7 +640,7 @@ fn init_window_graphics(
GraphicsContext {
gl_context,
surfaces: HashMap::from([(surface_id, surface)]),
- uniform_buffer_objs: HashMap::new(),
+ shader_uniform_buffer_objs: HashMap::new(),
objects: HashMap::new(),
next_object_key: RendererObjectRawValue::default(),
},
@@ -681,7 +682,7 @@ fn handle_commands(
let GraphicsContext {
ref gl_context,
ref surfaces,
- ref mut uniform_buffer_objs,
+ ref mut shader_uniform_buffer_objs,
objects: ref mut graphics_ctx_objects,
next_object_key: ref mut next_graphics_ctx_object_key,
} = *graphics_ctx;
@@ -812,10 +813,12 @@ fn handle_commands(
continue;
};
- if activated_gl_shader_program.is_none() {
+ let Some((activated_gl_shader_program_obj_id, _)) =
+ &activated_gl_shader_program
+ else {
tracing::error!("No shader program is activated");
continue;
- }
+ };
if let ShaderBindingValue::Texture(texture_asset) = &binding_value {
let Some(texture_obj) = renderer_object_store.get_texture_obj(
@@ -848,6 +851,10 @@ fn handle_commands(
let binding_index = binding_location.binding_index;
+ let uniform_buffer_objs = shader_uniform_buffer_objs
+ .entry(*activated_gl_shader_program_obj_id)
+ .or_default();
+
let uniform_buffer =
uniform_buffer_objs.entry(binding_index).or_insert_with(|| {
let uniform_buf =