diff options
| author | HampusM <hampus@hampusmat.com> | 2026-03-21 15:22:51 +0100 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-03-21 15:22:51 +0100 |
| commit | 292217e0a7d5555b8c5534477869afcb5cd021e3 (patch) | |
| tree | 3960595daf49eb7ef6c78def8f9636ce579514e5 /opengl-bindings | |
| parent | f285f82072b491b1f3cc92db8e08485f26779d5a (diff) | |
fix(opengl-bindings): do not use type size as vertex attrib format size
Diffstat (limited to 'opengl-bindings')
| -rw-r--r-- | opengl-bindings/src/vertex_array.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/opengl-bindings/src/vertex_array.rs b/opengl-bindings/src/vertex_array.rs index d3af604..5d80c0c 100644 --- a/opengl-bindings/src/vertex_array.rs +++ b/opengl-bindings/src/vertex_array.rs @@ -146,23 +146,21 @@ impl VertexArray &self, current_context: &CurrentContextWithFns<'_>, attrib_index: u32, - data_type: DataType, - normalized: bool, - offset: u32, + attrib_format: AttributeFormat, ) { unsafe { current_context.fns().VertexArrayAttribFormat( self.array, attrib_index, - data_type.size(), - data_type as u32, - if normalized { + attrib_format.count.into(), + attrib_format.data_type.into_gl(), + if attrib_format.normalized { crate::sys::TRUE } else { crate::sys::FALSE }, - offset, + attrib_format.offset, ); } } @@ -216,22 +214,31 @@ impl PrimitiveKind } #[derive(Debug, Clone, Copy)] -#[repr(u32)] +#[non_exhaustive] pub enum DataType { - Float = crate::sys::FLOAT, + Float, } impl DataType { - fn size(self) -> crate::sys::types::GLint + fn into_gl(self) -> crate::sys::types::GLenum { match self { - Self::Float => const { cast_usize_to_c_int(size_of::<f32>()) }, + Self::Float => crate::sys::FLOAT, } } } +#[derive(Debug, Clone)] +pub struct AttributeFormat +{ + pub data_type: DataType, + pub count: u8, + pub normalized: bool, + pub offset: u32, +} + #[derive(Debug, thiserror::Error)] pub enum DrawError { |
