diff options
Diffstat (limited to 'engine/src/renderer')
-rw-r--r-- | engine/src/renderer/mod.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs index 8ca85e2..068b8f0 100644 --- a/engine/src/renderer/mod.rs +++ b/engine/src/renderer/mod.rs @@ -1,8 +1,10 @@ use std::ffi::{c_void, CString}; use std::process::abort; +use cstr::cstr; use glfw::WindowSize; +use crate::object::Object; #[cfg(feature = "debug")] use crate::opengl::debug::{MessageSeverity, MessageSource, MessageType}; use crate::opengl::shader::Program as ShaderProgram; @@ -92,14 +94,18 @@ fn opengl_debug_message_cb( }; } -pub fn render<'renderable>(renderables: impl IntoIterator<Item = &'renderable Renderable>) +pub fn render<'obj>(objects: impl IntoIterator<Item = &'obj Object>) { clear_buffers(BufferClearMask::COLOR); - for renderable in renderables { - renderable.shader_program.activate(); + for obj in objects { + obj.renderable().shader_program.activate(); - renderable.vertex_arr.bind(|vert_arr_curr_bound| { + obj.renderable() + .shader_program + .set_uniform_matrix_4fv(cstr!("transform"), &obj.transform().as_matrix()); + + obj.renderable().vertex_arr.bind(|vert_arr_curr_bound| { VertexArray::draw(&vert_arr_curr_bound, PrimitiveKind::Triangles, 0, 3); }); } |