diff options
author | HampusM <hampus@hampusmat.com> | 2024-08-16 22:10:00 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-08-16 22:10:00 +0200 |
commit | c4686c2992417545e7a05a6a40ee9f1a8bbf3b96 (patch) | |
tree | 552951049d580283ab1beb5b512db44994b893ee /engine/src/opengl/buffer.rs | |
parent | 7d218b2525f90dfedcae02f3b3d0d2f7b9c99bd2 (diff) |
perf(engine): create OpenGL objects as needed instead of each frame
Diffstat (limited to 'engine/src/opengl/buffer.rs')
-rw-r--r-- | engine/src/opengl/buffer.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/engine/src/opengl/buffer.rs b/engine/src/opengl/buffer.rs index 68a75fb..2be7f12 100644 --- a/engine/src/opengl/buffer.rs +++ b/engine/src/opengl/buffer.rs @@ -39,6 +39,19 @@ impl<Item> Buffer<Item> { self.buf } + + /// Does a weak clone of this buffer. The buffer itself is NOT copied in any way this + /// function only copies the internal buffer ID. + /// + /// # Safety + /// The returned `Buffer` must not be dropped if another `Buffer` referencing the + /// same buffer ID is used later or if a [`VertexArray`] is used later. + /// + /// [`VertexArray`]: crate::opengl::vertex_array::VertexArray + pub unsafe fn clone_weak(&self) -> Self + { + Self { buf: self.buf, _pd: PhantomData } + } } impl<Item> Drop for Buffer<Item> |