From 1177a3225420f263366d685390d51f8aca4ffee8 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Wed, 11 May 2022 23:01:12 -0400 Subject: [PATCH] Completely remove ctru-sys dep and fix some lints --- citro3d-sys/Cargo.toml | 1 - citro3d-sys/bindgen.sh | 1 + citro3d-sys/src/bindings.rs | 6 +++--- citro3d-sys/src/lib.rs | 10 ++++------ citro3d-sys/src/texenv.rs | 8 ++++---- citro3d-sys/src/uniforms.rs | 1 - citro3d/examples/triangle.rs | 6 ++++-- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/citro3d-sys/Cargo.toml b/citro3d-sys/Cargo.toml index b0bd4ab..29379ee 100644 --- a/citro3d-sys/Cargo.toml +++ b/citro3d-sys/Cargo.toml @@ -6,4 +6,3 @@ edition = "2021" [dependencies] libc = "0.2.116" -ctru-sys = { git = "https://github.com/Meziu/ctru-rs.git" } diff --git a/citro3d-sys/bindgen.sh b/citro3d-sys/bindgen.sh index 2fb51c9..713f1a8 100755 --- a/citro3d-sys/bindgen.sh +++ b/citro3d-sys/bindgen.sh @@ -9,6 +9,7 @@ bindgen "$DEVKITPRO/libctru/include/citro3d.h" \ --no-layout-tests \ --ctypes-prefix "::libc" \ --no-prepend-enum-name \ + --fit-macro-constant-types \ --generate "functions,types,vars" \ --blocklist-type "u(8|16|32|64)" \ --opaque-type "GPU_.*" \ diff --git a/citro3d-sys/src/bindings.rs b/citro3d-sys/src/bindings.rs index 30364ca..294b741 100644 --- a/citro3d-sys/src/bindings.rs +++ b/citro3d-sys/src/bindings.rs @@ -82,9 +82,9 @@ where } pub const C3D_AspectRatioTop: f64 = 1.6666666666666667; pub const C3D_AspectRatioBot: f64 = 1.3333333333333333; -pub const C3D_MTXSTACK_SIZE: u32 = 8; -pub const C3D_FVUNIF_COUNT: u32 = 96; -pub const C3D_IVUNIF_COUNT: u32 = 4; +pub const C3D_MTXSTACK_SIZE: u8 = 8; +pub const C3D_FVUNIF_COUNT: u8 = 96; +pub const C3D_IVUNIF_COUNT: u8 = 4; pub const C3D_DEFAULT_CMDBUF_SIZE: u32 = 262144; pub type __int8_t = ::libc::c_schar; pub type __uint8_t = ::libc::c_uchar; diff --git a/citro3d-sys/src/lib.rs b/citro3d-sys/src/lib.rs index 6a5b301..8e17aae 100644 --- a/citro3d-sys/src/lib.rs +++ b/citro3d-sys/src/lib.rs @@ -1,17 +1,15 @@ #![no_std] #![allow(non_snake_case)] -#![feature(untagged_unions)] // used for [`C3D_Mtx`] +#![allow(warnings)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(clippy::all)] pub mod base; pub mod renderqueue; pub mod texenv; pub mod uniforms; -#[allow(warnings)] -#[allow(warnings)] -#[allow(non_upper_case_globals)] -#[allow(non_camel_case_types)] -#[allow(clippy::all)] mod bindings; pub use base::*; diff --git a/citro3d-sys/src/texenv.rs b/citro3d-sys/src/texenv.rs index 5679987..1919a19 100644 --- a/citro3d-sys/src/texenv.rs +++ b/citro3d-sys/src/texenv.rs @@ -26,14 +26,14 @@ where } pub unsafe fn C3D_TexEnvInit(env: *mut C3D_TexEnv) { - (*env).srcRgb = gpu_tevsources(ctru_sys::GPU_PREVIOUS, 0, 0) as u16; + (*env).srcRgb = gpu_tevsources(GPU_PREVIOUS, 0, 0) as u16; (*env).srcAlpha = (*env).srcRgb; (*env).__bindgen_anon_1.opAll = 0; - (*env).funcRgb = ctru_sys::GPU_REPLACE as u16; + (*env).funcRgb = GPU_REPLACE as u16; (*env).funcAlpha = (*env).funcRgb; (*env).color = 0xFFFFFFFF; - (*env).scaleRgb = ctru_sys::GPU_TEVSCALE_1 as u16; - (*env).scaleAlpha = ctru_sys::GPU_TEVSCALE_1 as u16; + (*env).scaleRgb = GPU_TEVSCALE_1 as u16; + (*env).scaleAlpha = GPU_TEVSCALE_1 as u16; } // TODO: maybe diff --git a/citro3d-sys/src/uniforms.rs b/citro3d-sys/src/uniforms.rs index 69c47ed..c2b0290 100644 --- a/citro3d-sys/src/uniforms.rs +++ b/citro3d-sys/src/uniforms.rs @@ -2,7 +2,6 @@ use super::*; -use ctru_sys::GPU_SHADER_TYPE; use libc::c_int; #[inline] diff --git a/citro3d/examples/triangle.rs b/citro3d/examples/triangle.rs index 230ab46..20d4c25 100644 --- a/citro3d/examples/triangle.rs +++ b/citro3d/examples/triangle.rs @@ -57,7 +57,7 @@ fn main() { break; } - const CLEAR_COLOR: u32 = 0x68B0D8FF; + const CLEAR_COLOR: u32 = 0x68_B0_D8_FF; unsafe { citro3d_sys::C3D_FrameBegin(citro3d_sys::C3D_FRAME_SYNCDRAW as u8); @@ -77,6 +77,8 @@ fn main() { citro3d_sys::C3D_Fini(); } } + +#[repr(C)] struct Vertex { x: f32, y: f32, @@ -156,7 +158,7 @@ fn scene_init() -> (shaderProgram_s, i8, C3D_Mtx, *mut libc::c_void, *mut DVLB_s let vbo_data = citro3d_sys::linearAlloc(vertices_len.try_into().expect("size does not fit in u32")); - vbo_data.copy_from(VERTICES.as_ptr() as _, vertices_len); + vbo_data.copy_from(VERTICES.as_ptr().cast(), vertices_len); // Configure buffers let buf_info = citro3d_sys::C3D_GetBufInfo();