summaryrefslogtreecommitdiff
path: root/engine/src/opengl/vertex_array.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-08-16 22:10:00 +0200
committerHampusM <hampus@hampusmat.com>2024-08-16 22:10:00 +0200
commitc4686c2992417545e7a05a6a40ee9f1a8bbf3b96 (patch)
tree552951049d580283ab1beb5b512db44994b893ee /engine/src/opengl/vertex_array.rs
parent7d218b2525f90dfedcae02f3b3d0d2f7b9c99bd2 (diff)
perf(engine): create OpenGL objects as needed instead of each frame
Diffstat (limited to 'engine/src/opengl/vertex_array.rs')
-rw-r--r--engine/src/opengl/vertex_array.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/engine/src/opengl/vertex_array.rs b/engine/src/opengl/vertex_array.rs
index e1e1a15..da5d91e 100644
--- a/engine/src/opengl/vertex_array.rs
+++ b/engine/src/opengl/vertex_array.rs
@@ -125,6 +125,17 @@ impl VertexArray
{
unsafe { gl::BindVertexArray(self.array) }
}
+
+ /// Does a weak clone of this vertex array. The vertex array itself is NOT copied in
+ /// any way this function only copies the internal vertex array ID.
+ ///
+ /// # Safety
+ /// The returned `VertexArray` must not be dropped if another `VertexArray`
+ /// referencing the same vertex array ID is used later.
+ pub unsafe fn clone_unsafe(&self) -> Self
+ {
+ Self { array: self.array }
+ }
}
impl Drop for VertexArray