From 292217e0a7d5555b8c5534477869afcb5cd021e3 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 21 Mar 2026 15:22:51 +0100 Subject: fix(opengl-bindings): do not use type size as vertex attrib format size --- opengl-bindings/src/vertex_array.rs | 29 ++++++++++++++++++----------- 1 file 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::()) }, + 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 { -- cgit v1.2.3-18-g5258