summaryrefslogtreecommitdiff
path: root/opengl-bindings/src
diff options
context:
space:
mode:
Diffstat (limited to 'opengl-bindings/src')
-rw-r--r--opengl-bindings/src/buffer.rs9
-rw-r--r--opengl-bindings/src/texture.rs12
-rw-r--r--opengl-bindings/src/vertex_array.rs11
3 files changed, 29 insertions, 3 deletions
diff --git a/opengl-bindings/src/buffer.rs b/opengl-bindings/src/buffer.rs
index c64ec8d..4c91649 100644
--- a/opengl-bindings/src/buffer.rs
+++ b/opengl-bindings/src/buffer.rs
@@ -105,7 +105,7 @@ impl<Item: ReprC> Buffer<Item>
let Ok(offset_casted) = crate::sys::types::GLintptr::try_from(offset) else {
unreachable!(); // Reason: The total size can be casted to a GLintptr
- // (done above) so offsets should be castable as well
+ // (done above) so offsets should be castable as well
};
unsafe {
@@ -121,6 +121,13 @@ impl<Item: ReprC> Buffer<Item>
Ok(())
}
+ pub fn delete(&self, current_context: &CurrentContextWithFns<'_>)
+ {
+ unsafe {
+ current_context.fns().DeleteBuffers(1, &raw const self.buf);
+ }
+ }
+
pub(crate) fn object(&self) -> crate::sys::types::GLuint
{
self.buf
diff --git a/opengl-bindings/src/texture.rs b/opengl-bindings/src/texture.rs
index 1859beb..2683772 100644
--- a/opengl-bindings/src/texture.rs
+++ b/opengl-bindings/src/texture.rs
@@ -1,5 +1,5 @@
-use crate::data_types::Dimens;
use crate::CurrentContextWithFns;
+use crate::data_types::Dimens;
#[derive(Debug)]
pub struct Texture
@@ -134,6 +134,16 @@ impl Texture
}
}
+ pub fn from_raw(raw: u32) -> Self
+ {
+ Self { texture: raw }
+ }
+
+ pub fn into_raw(self) -> u32
+ {
+ self.texture
+ }
+
fn alloc_image(
&self,
current_context: &CurrentContextWithFns<'_>,
diff --git a/opengl-bindings/src/vertex_array.rs b/opengl-bindings/src/vertex_array.rs
index 9942fe7..d3af604 100644
--- a/opengl-bindings/src/vertex_array.rs
+++ b/opengl-bindings/src/vertex_array.rs
@@ -3,8 +3,8 @@ use std::mem::size_of;
use safer_ffi::layout::ReprC;
-use crate::buffer::Buffer;
use crate::CurrentContextWithFns;
+use crate::buffer::Buffer;
#[derive(Debug)]
pub struct VertexArray
@@ -188,6 +188,15 @@ impl VertexArray
{
unsafe { current_context.fns().BindVertexArray(self.array) }
}
+
+ pub fn delete(&self, current_context: &CurrentContextWithFns<'_>)
+ {
+ unsafe {
+ current_context
+ .fns()
+ .DeleteVertexArrays(1, &raw const self.array);
+ }
+ }
}
#[derive(Debug)]