Skip to content

Commit a58e525

Browse files
committed
Added sdl+vitagl example
1 parent 7341fbe commit a58e525

File tree

8 files changed

+146
-3
lines changed

8 files changed

+146
-3
lines changed

.github/workflows/ci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ jobs:
1111
steps:
1212
- name: Checkout code
1313
uses: actions/checkout@v4
14+
- name: Install Northfear SDL fork
15+
run: |
16+
chown -R 1000:1000 northfear-sdl2
17+
cd northfear-sdl2
18+
sudo -u \#1000 vita-makepkg
19+
vdpm sdl2-2.30.2-1-arm.tar.xz
1420
- name: Build
1521
run: |
1622
cargo vita build vpk --release --package vita-std-tests --tests

.github/workflows/release.yml

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
20+
- name: Install Northfear SDL fork
21+
run: |
22+
cd northfear-sdl2
23+
sudo -u \#1000 vita-makepkg
24+
vdpm sdl2-2.30.2-1-arm.tar.xz
2025
- name: Build
2126
run: |
2227
cargo vita build vpk --release --package vita-std-tests --tests

Cargo.lock

+44
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/3-sdl/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn dummy_texture<'a>(
202202
}
203203

204204
pub fn main() -> Result<(), String> {
205-
let sdl_context = sdl2::init()?;
205+
let sdl_context: sdl2::Sdl = sdl2::init()?;
206206
let video_subsystem = sdl_context.video()?;
207207

208208
// Init controller

crates/4-vitasdk/src/debug/font.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pub struct DebugFont {
33
pub width: usize,
44
pub height: usize,
55
pub first: u8,
6-
pub last: u8,
76
pub size_w: usize,
87
pub size_h: usize,
98
}
@@ -13,7 +12,6 @@ pub const DEBUG_FONT: DebugFont = DebugFont {
1312
width: 8,
1413
height: 8,
1514
first: 0,
16-
last: 255,
1715
size_w: 8,
1816
size_h: 8,
1917
};

crates/5-vitasdk-gles/Cargo.toml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "vita-example-sdl-gles"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
license = "MIT OR Apache-2.0"
7+
repository = "https://github.com/vita-rust/examples"
8+
homepage = "https://github.com/vita-rust/examples/crates/4-vitasdk"
9+
10+
description = "VITASDK example"
11+
12+
[dependencies]
13+
rand = "0.8.5"
14+
gl = "0.10.0"
15+
sdl2 = { version = "0.35.2", features = ["use-pkgconfig"] }
16+
17+
[package.metadata.vita]
18+
title_id = "RUSTTEST5"
19+
title_name = "SDL+GL test"

crates/5-vitasdk-gles/src/main.rs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#[link(name = "SDL2", kind = "static")]
2+
#[link(name = "vitaGL", kind = "static")]
3+
#[link(name = "vitashark", kind = "static")]
4+
#[link(name = "SceShaccCg_stub", kind = "static")]
5+
#[link(name = "mathneon", kind = "static")]
6+
#[link(name = "SceShaccCgExt", kind = "static")]
7+
#[link(name = "taihen_stub", kind = "static")]
8+
#[link(name = "SceKernelDmacMgr_stub", kind = "static")]
9+
#[link(name = "SceIme_stub", kind = "static")]
10+
extern "C" {}
11+
12+
fn main() {
13+
let sdl = sdl2::init().unwrap();
14+
let video_subsystem = sdl.video().unwrap();
15+
let window = video_subsystem
16+
.window("Game", 900, 700)
17+
.opengl()
18+
.build()
19+
.unwrap();
20+
21+
let _gl_context = window.gl_create_context().unwrap();
22+
let _gl = gl::load_with(|s| video_subsystem.gl_get_proc_address(s) as *const std::os::raw::c_void);
23+
24+
unsafe {
25+
gl::ClearColor(0.3, 0.3, 0.5, 1.0);
26+
}
27+
28+
let mut event_pump = sdl.event_pump().unwrap();
29+
'main: loop {
30+
for event in event_pump.poll_iter() {
31+
match event {
32+
sdl2::event::Event::Quit {..} => break 'main,
33+
_ => {},
34+
}
35+
}
36+
37+
unsafe {
38+
gl::Clear(gl::COLOR_BUFFER_BIT);
39+
}
40+
41+
window.gl_swap_window();
42+
}
43+
}

northfear-sdl2/VITABUILD

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pkgname=sdl2
2+
pkgver=2.30.2
3+
pkgrel=1
4+
gitrev=0867aceb28a493b489f54a3407a3b820b092206a
5+
url='https://www.libsdl.org'
6+
source=(
7+
"https://github.com/Northfear/SDL/archive/${gitrev}.tar.gz"
8+
)
9+
sha256sums=(
10+
SKIP
11+
)
12+
13+
prepare() {
14+
cd "SDL-${gitrev}"
15+
}
16+
17+
build() {
18+
cd "SDL-${gitrev}"
19+
mkdir build && cd build
20+
cmake .. -DCMAKE_TOOLCHAIN_FILE=$VITASDK/share/vita.toolchain.cmake -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_BUILD_TYPE=Release -DSDL_TEST=OFF -DVIDEO_VITA_VGL=ON
21+
make -j$(nproc)
22+
}
23+
24+
package () {
25+
cd "SDL-${gitrev}"
26+
cd build
27+
make DESTDIR=$pkgdir install
28+
}

0 commit comments

Comments
 (0)