diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c45c2f..cc0e552 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,12 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Install Northfear SDL fork + run: | + chown -R 1000:1000 northfear-sdl2 + cd northfear-sdl2 + sudo --preserve-env=VITASDK -u \#1000 vita-makepkg + vdpm sdl2-2.30.2-1-arm.tar.xz - name: Build run: | cargo vita build vpk --release --package vita-std-tests --tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02e9a8b..c780bad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,12 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Install Northfear SDL fork + run: | + chown -R 1000:1000 northfear-sdl2 + cd northfear-sdl2 + sudo --preserve-env=VITASDK -u \#1000 vita-makepkg + vdpm sdl2-2.30.2-1-arm.tar.xz - name: Build run: | cargo vita build vpk --release --package vita-std-tests --tests diff --git a/Cargo.lock b/Cargo.lock index a6e9238..77067ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,6 +248,26 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "gl" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81457bb802910ad5b535eb48541c51830a761804aa5b7087adbc9d049aa57aca" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gl_generator" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + [[package]] name = "h2" version = "0.3.21" @@ -399,6 +419,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "khronos_api" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037ab472c33f67b5fbd3e9163a2645319e5356fcd355efa6d4eb7fff4bbcb554" + [[package]] name = "lazy_static" version = "1.4.0" @@ -1132,6 +1158,15 @@ dependencies = [ "sdl2", ] +[[package]] +name = "vita-example-sdl-gles" +version = "0.1.0" +dependencies = [ + "gl", + "rand", + "sdl2", +] + [[package]] name = "vita-example-vitasdk" version = "0.1.0" @@ -1360,3 +1395,12 @@ dependencies = [ "cfg-if", "windows-sys", ] + +[[package]] +name = "xml-rs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2" +dependencies = [ + "bitflags 1.3.2", +] diff --git a/crates/3-sdl/src/main.rs b/crates/3-sdl/src/main.rs index 5ab4b82..79ad6b0 100644 --- a/crates/3-sdl/src/main.rs +++ b/crates/3-sdl/src/main.rs @@ -202,7 +202,7 @@ fn dummy_texture<'a>( } pub fn main() -> Result<(), String> { - let sdl_context = sdl2::init()?; + let sdl_context: sdl2::Sdl = sdl2::init()?; let video_subsystem = sdl_context.video()?; // Init controller diff --git a/crates/4-vitasdk/src/debug/font.rs b/crates/4-vitasdk/src/debug/font.rs index 6ccba7b..eaea6db 100644 --- a/crates/4-vitasdk/src/debug/font.rs +++ b/crates/4-vitasdk/src/debug/font.rs @@ -3,7 +3,6 @@ pub struct DebugFont { pub width: usize, pub height: usize, pub first: u8, - pub last: u8, pub size_w: usize, pub size_h: usize, } @@ -13,7 +12,6 @@ pub const DEBUG_FONT: DebugFont = DebugFont { width: 8, height: 8, first: 0, - last: 255, size_w: 8, size_h: 8, }; diff --git a/crates/5-vitasdk-gles/Cargo.toml b/crates/5-vitasdk-gles/Cargo.toml new file mode 100644 index 0000000..3e791e5 --- /dev/null +++ b/crates/5-vitasdk-gles/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "vita-example-sdl-gles" +version = "0.1.0" +edition = "2021" + +license = "MIT OR Apache-2.0" +repository = "https://github.com/vita-rust/examples" +homepage = "https://github.com/vita-rust/examples/crates/4-vitasdk" + +description = "VITASDK example" + +[dependencies] +rand = "0.8.5" +gl = "0.10.0" +sdl2 = { version = "0.35.2", features = ["use-pkgconfig"] } + +[package.metadata.vita] +title_id = "RUSTTEST5" +title_name = "SDL+GL test" diff --git a/crates/5-vitasdk-gles/src/main.rs b/crates/5-vitasdk-gles/src/main.rs new file mode 100644 index 0000000..9ac44c8 --- /dev/null +++ b/crates/5-vitasdk-gles/src/main.rs @@ -0,0 +1,43 @@ +#[link(name = "SDL2", kind = "static")] +#[link(name = "vitaGL", kind = "static")] +#[link(name = "vitashark", kind = "static")] +#[link(name = "SceShaccCg_stub", kind = "static")] +#[link(name = "mathneon", kind = "static")] +#[link(name = "SceShaccCgExt", kind = "static")] +#[link(name = "taihen_stub", kind = "static")] +#[link(name = "SceKernelDmacMgr_stub", kind = "static")] +#[link(name = "SceIme_stub", kind = "static")] +extern "C" {} + +fn main() { + let sdl = sdl2::init().unwrap(); + let video_subsystem = sdl.video().unwrap(); + let window = video_subsystem + .window("Game", 900, 700) + .opengl() + .build() + .unwrap(); + + let _gl_context = window.gl_create_context().unwrap(); + let _gl = gl::load_with(|s| video_subsystem.gl_get_proc_address(s) as *const std::os::raw::c_void); + + unsafe { + gl::ClearColor(0.3, 0.3, 0.5, 1.0); + } + + let mut event_pump = sdl.event_pump().unwrap(); + 'main: loop { + for event in event_pump.poll_iter() { + match event { + sdl2::event::Event::Quit {..} => break 'main, + _ => {}, + } + } + + unsafe { + gl::Clear(gl::COLOR_BUFFER_BIT); + } + + window.gl_swap_window(); + } +} diff --git a/northfear-sdl2/VITABUILD b/northfear-sdl2/VITABUILD new file mode 100644 index 0000000..8a099c1 --- /dev/null +++ b/northfear-sdl2/VITABUILD @@ -0,0 +1,28 @@ +pkgname=sdl2 +pkgver=2.30.2 +pkgrel=1 +gitrev=0867aceb28a493b489f54a3407a3b820b092206a +url='https://www.libsdl.org' +source=( + "https://github.com/Northfear/SDL/archive/${gitrev}.tar.gz" + ) +sha256sums=( + SKIP +) + +prepare() { + cd "SDL-${gitrev}" +} + +build() { + cd "SDL-${gitrev}" + mkdir build && cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=$VITASDK/share/vita.toolchain.cmake -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_BUILD_TYPE=Release -DSDL_TEST=OFF -DVIDEO_VITA_VGL=ON + make -j$(nproc) +} + +package () { + cd "SDL-${gitrev}" + cd build + make DESTDIR=$pkgdir install +}