forked from AbleOS/ableos_userland
50 lines
985 B
Rust
50 lines
985 B
Rust
pub enum BufferUsage {
|
|
Vertex,
|
|
}
|
|
|
|
use alloc::vec::Vec;
|
|
|
|
use super::error::GPUError;
|
|
|
|
pub type VertexBuffer = Vec<u8>;
|
|
|
|
#[repr(C)]
|
|
pub struct XYZ {
|
|
x: f64,
|
|
y: f64,
|
|
z: f64,
|
|
}
|
|
|
|
#[repr(C)]
|
|
pub struct XYZW {
|
|
x: f64,
|
|
y: f64,
|
|
z: f64,
|
|
w: f64,
|
|
}
|
|
|
|
pub struct GraphicsEngine {
|
|
vertex_buffer_attributes_editable: bool,
|
|
vertex_buffer: VertexBuffer,
|
|
vertex_size: usize,
|
|
}
|
|
impl GraphicsEngine {
|
|
pub fn new() -> Self {
|
|
Self {
|
|
vertex_buffer_attributes_editable: true,
|
|
vertex_buffer: Vec::new(),
|
|
vertex_size: 0,
|
|
}
|
|
}
|
|
pub fn append_vertex(&mut self, mut vertex: Vec<u8>) -> Result<(), GPUError> {
|
|
if self.vertex_buffer_attributes_editable {
|
|
return Err(GPUError::EngineNotInitialized);
|
|
}
|
|
if !vertex.len() == self.vertex_size {
|
|
return Err(GPUError::ImproperVertexSize);
|
|
}
|
|
self.vertex_buffer.append(&mut vertex);
|
|
Ok(())
|
|
}
|
|
}
|