use std::ffi::c_void;
use std::ptr;
#[repr(u32)]
#[derive(Clone, Copy, Debug)]
pub enum DataType {
Byte = 0x1400, UnsignedByte = 0x1401, Short = 0x1402, UnsignedShort = 0x1403, Int = 0x1404, UnsignedInt = 0x1405, HalfFloat = 0x140B, Float = 0x1406, Double = 0x140A, Int2_10_10_10Rev = 0x8D9F, UnsignedInt2_10_10_10Rev = 0x8368, }
pub struct VertexAttribPointer {
index: u32,
}
impl VertexAttribPointer {
pub fn new(
index: u32,
size: i32,
data_type: DataType,
normalized: bool,
stride: i32,
) -> VertexAttribPointer {
let normalized = if normalized { gl::TRUE } else { gl::FALSE };
unsafe {
gl::VertexAttribPointer(
index,
size,
data_type as u32,
normalized,
stride,
ptr::null(),
)
};
VertexAttribPointer { index }
}
pub fn enable(&self) {
unsafe { gl::EnableVertexAttribArray(self.index) };
}
pub fn disable(&self) {
unsafe { gl::DisableVertexAttribArray(self.index) };
}
}