Skip to content

Commit

Permalink
chore: rename drawingindexecies -> indextype
Browse files Browse the repository at this point in the history
  • Loading branch information
0x00002a committed Feb 1, 2024
1 parent d4d5c6f commit e74d426
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions citro3d/examples/cube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use citro3d::math::{
};
use citro3d::render::ClearFlags;
use citro3d::{attrib, buffer, render, shader};
use citro3d::{texenv, DrawingIndices};
use citro3d::{texenv, IndexType};
use ctru::prelude::*;
use ctru::services::gfx::{RawFrameBuffer, Screen, TopScreen3D};

Expand Down Expand Up @@ -170,7 +170,7 @@ fn main() {
instance.draw_elements(
buffer::Primitive::Triangles,
&buf_info,
DrawingIndices::U16(&indecies),
IndexType::U16(&indecies),
);
}

Expand Down
24 changes: 12 additions & 12 deletions citro3d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ impl Instance {
&mut self,
primitive: buffer::Primitive,
buf: &buffer::Info,
indices: impl Into<DrawingIndices<'a>>,
indices: impl Into<IndexType<'a>>,
) {
self.set_buffer_info(buf);
let indices: DrawingIndices<'a> = indices.into();
let indices: IndexType<'a> = indices.into();
let elements = match indices {
DrawingIndices::U16(v) => v.as_ptr() as *const _,
DrawingIndices::U8(v) => v.as_ptr() as *const _,
IndexType::U16(v) => v.as_ptr() as *const _,
IndexType::U8(v) => v.as_ptr() as *const _,
};
assert!(
is_linear_ptr(elements),
Expand All @@ -194,8 +194,8 @@ impl Instance {
indices.len() as i32,
// flag bit for short or byte
match indices {
DrawingIndices::U16(_) => citro3d_sys::C3D_UNSIGNED_SHORT,
DrawingIndices::U8(_) => citro3d_sys::C3D_UNSIGNED_BYTE,
IndexType::U16(_) => citro3d_sys::C3D_UNSIGNED_SHORT,
IndexType::U8(_) => citro3d_sys::C3D_UNSIGNED_BYTE,
} as i32,
elements,
);
Expand Down Expand Up @@ -277,26 +277,26 @@ impl Drop for Instance {
}
}

pub enum DrawingIndices<'a> {
pub enum IndexType<'a> {
U16(&'a [u16]),
U8(&'a [u8]),
}
impl DrawingIndices<'_> {
impl IndexType<'_> {
fn len(&self) -> usize {
match self {
DrawingIndices::U16(a) => a.len(),
DrawingIndices::U8(a) => a.len(),
IndexType::U16(a) => a.len(),
IndexType::U8(a) => a.len(),
}
}
}

impl<'a> From<&'a [u8]> for DrawingIndices<'a> {
impl<'a> From<&'a [u8]> for IndexType<'a> {
fn from(v: &'a [u8]) -> Self {
Self::U8(v)
}
}

impl<'a> From<&'a [u16]> for DrawingIndices<'a> {
impl<'a> From<&'a [u16]> for IndexType<'a> {
fn from(v: &'a [u16]) -> Self {
Self::U16(v)
}
Expand Down

0 comments on commit e74d426

Please sign in to comment.