diff --git a/citro3d/examples/triangle.rs b/citro3d/examples/triangle.rs index 6309927..6a1e0cc 100644 --- a/citro3d/examples/triangle.rs +++ b/citro3d/examples/triangle.rs @@ -110,7 +110,7 @@ fn main() { ); } - target.draw_arrays(buffers::Primitive::Triangles, vbo_idx); + instance.draw_arrays(buffers::Primitive::Triangles, vbo_idx); }); }; diff --git a/citro3d/src/buffers.rs b/citro3d/src/buffers.rs index 9191d3f..9459c9f 100644 --- a/citro3d/src/buffers.rs +++ b/citro3d/src/buffers.rs @@ -83,6 +83,12 @@ impl BufInfo { }; if res < 0 { + // TODO: should we convert to a more specific error if this fails? + // It looks like the common cases are + // - too many buffers already added (max 12) + // - physical memory address in the wrong place (this can be seen by + // using default allocator instead of LinearAllocator) + // Err(crate::Error::System(res)) } else { Ok(Index { diff --git a/citro3d/src/lib.rs b/citro3d/src/lib.rs index 4e3bf09..2ce2ec5 100644 --- a/citro3d/src/lib.rs +++ b/citro3d/src/lib.rs @@ -73,6 +73,16 @@ impl Instance { citro3d_sys::C3D_FrameEnd(0); } } + + pub fn draw_arrays(&mut self, primitive: buffers::Primitive, index: buffers::Index) { + unsafe { + citro3d_sys::C3D_DrawArrays( + primitive as ctru_sys::GPU_Primitive_t, + index.as_raw(), + index.size(), + ); + } + } } impl Drop for Instance { diff --git a/citro3d/src/render.rs b/citro3d/src/render.rs index 08a232f..0a7a563 100644 --- a/citro3d/src/render.rs +++ b/citro3d/src/render.rs @@ -10,7 +10,7 @@ use ctru::gfx::Screen; use ctru::services::gspgpu::FramebufferFormat; use ctru_sys::{GPU_COLORBUF, GPU_DEPTHBUF}; -use crate::{buffers, Error, Result}; +use crate::{Error, Result}; mod transfer; @@ -91,16 +91,6 @@ impl<'screen> Target<'screen> { pub(crate) fn as_raw(&self) -> *mut C3D_RenderTarget { self.raw } - - pub fn draw_arrays(&mut self, primitive: buffers::Primitive, index: buffers::Index) { - unsafe { - citro3d_sys::C3D_DrawArrays( - primitive as ctru_sys::GPU_Primitive_t, - index.as_raw(), - index.size(), - ); - } - } } bitflags::bitflags! {