From a4d66f8272c08c722a0a3fa6843ccf61e05d2928 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 8 Oct 2023 17:48:05 +0200 Subject: fix(engine): stop destroying vertex buffer before vertex array --- engine/src/renderer/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'engine/src/renderer') diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs index a339ea8..13091fd 100644 --- a/engine/src/renderer/mod.rs +++ b/engine/src/renderer/mod.rs @@ -55,6 +55,9 @@ pub struct Renderable { shader_program: crate::shader::Program, vertex_arr: VertexArray, + + /// Vertex buffer has to live as long as the vertex array + _vertex_buffer: VertexBuffers<1>, } impl Renderable @@ -74,14 +77,10 @@ impl Renderable vertex_attrib_ptr(0); enable_vertex_attrib_array(0); - unsafe { - gl::BindBuffer(gl::ARRAY_BUFFER, 0); - gl::BindVertexArray(0); - } - Self { shader_program, vertex_arr, + _vertex_buffer: vertex_buffer, } } } -- cgit v1.2.3-18-g5258