diff options
Diffstat (limited to 'opengl-bindings/src/buffer.rs')
| -rw-r--r-- | opengl-bindings/src/buffer.rs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/opengl-bindings/src/buffer.rs b/opengl-bindings/src/buffer.rs index 2567aba..4d0fcba 100644 --- a/opengl-bindings/src/buffer.rs +++ b/opengl-bindings/src/buffer.rs @@ -1,3 +1,5 @@ +use std::any::type_name; +use std::fmt::Debug; use std::marker::PhantomData; use std::mem::size_of_val; use std::ptr::null; @@ -6,7 +8,7 @@ use safer_ffi::layout::ReprC; use crate::MaybeCurrentContextWithFns; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Buffer<Item: ReprC> { buf: crate::sys::types::GLuint, @@ -15,6 +17,7 @@ pub struct Buffer<Item: ReprC> impl<Item: ReprC> Buffer<Item> { + #[tracing::instrument(skip(current_context))] #[must_use] pub fn new(current_context: &MaybeCurrentContextWithFns) -> Self { @@ -31,6 +34,7 @@ impl<Item: ReprC> Buffer<Item> /// /// # Errors /// Returns `Err` if the size (in bytes) is too large. + #[tracing::instrument(skip(current_context))] pub fn init( &self, current_context: &MaybeCurrentContextWithFns, @@ -60,6 +64,7 @@ impl<Item: ReprC> Buffer<Item> /// /// # Errors /// Returns `Err` if the total size (in bytes) is too large. + #[tracing::instrument(skip(current_context, items))] pub fn store( &self, current_context: &MaybeCurrentContextWithFns, @@ -91,12 +96,12 @@ impl<Item: ReprC> Buffer<Item> /// /// # Errors /// Returns `Err` if the total size (in bytes) is too large. + #[tracing::instrument(skip(current_context, items))] pub fn store_at_byte_offset( &self, current_context: &MaybeCurrentContextWithFns, byte_offset: usize, items: &[Item], - // usage: Usage, ) -> Result<(), Error> { let total_size = size_of_val(items); @@ -121,7 +126,6 @@ impl<Item: ReprC> Buffer<Item> byte_offset, total_size, items.as_ptr().cast(), - // usage.into_gl(), ); } @@ -133,6 +137,7 @@ impl<Item: ReprC> Buffer<Item> /// /// # Errors /// Returns `Err` if the total size (in bytes) is too large. + #[tracing::instrument(skip(current_context, values, map_func))] pub fn store_mapped<Value>( &self, current_context: &MaybeCurrentContextWithFns, @@ -187,6 +192,7 @@ impl<Item: ReprC> Buffer<Item> Ok(()) } + #[tracing::instrument(skip(current_context))] pub fn delete(&self, current_context: &MaybeCurrentContextWithFns) { unsafe { @@ -194,6 +200,7 @@ impl<Item: ReprC> Buffer<Item> } } + #[tracing::instrument(skip(current_context))] pub fn bind_to_indexed_target( &self, current_context: &MaybeCurrentContextWithFns, @@ -216,6 +223,19 @@ impl<Item: ReprC> Buffer<Item> } } +impl<Item: ReprC> Debug for Buffer<Item> +{ + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result + { + let name = format!("Buffer<{}>", type_name::<Item>()); + + formatter + .debug_struct(&name) + .field("buf", &self.buf) + .finish() + } +} + /// Buffer usage. #[derive(Debug, Clone, Copy)] pub enum Usage |
