Skip to content

Commit 68ecc4e

Browse files
committed
sdl3
1 parent 73c1ab8 commit 68ecc4e

File tree

8 files changed

+32
-30
lines changed

8 files changed

+32
-30
lines changed

Cargo.lock

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

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ rust-version = "1.68.2"
99
[dependencies]
1010
libc = "*"
1111
sdl3 = { git = "https://github.com/revmischa/sdl3-rs.git" }
12-
# projectm = "1.0.5"
13-
projectm = { path = "../projectm-rs" }
12+
projectm = "1.0.5"
13+
# projectm = { path = "../projectm-rs" }
1414
#projectm = { git = "https://github.com/projectM-visualizer/projectm" }
1515
# gl = "0.14.0"
1616

src/app.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::{Arc, Mutex};
22

3-
use projectm_rs::core::{ProjectMHandle, Projectm};
4-
use sdl2::video::GLProfile;
3+
use projectm::core::{ProjectMHandle, Projectm};
4+
use sdl3::video::GLProfile;
55

66
pub mod audio;
77
pub mod config;
@@ -15,12 +15,12 @@ pub type ProjectMWrapped = Arc<Mutex<ProjectMHandle>>;
1515
/// Application state
1616
pub struct App {
1717
pm: ProjectMWrapped,
18-
playlist: projectm_rs::playlist::Playlist,
19-
sdl_context: sdl2::Sdl,
20-
window: sdl2::video::Window,
18+
playlist: projectm::playlist::Playlist,
19+
sdl_context: sdl3::Sdl,
20+
window: sdl3::video::Window,
2121
config: config::Config,
2222
audio: audio::Audio,
23-
_gl_context: sdl2::video::GLContext,
23+
_gl_context: sdl3::video::GLContext,
2424
}
2525

2626
pub fn default_config() -> config::Config {
@@ -30,7 +30,7 @@ pub fn default_config() -> config::Config {
3030
impl App {
3131
pub fn new(config: Option<crate::app::config::Config>) -> Self {
3232
// setup sdl
33-
let sdl_context = sdl2::init().unwrap();
33+
let sdl_context = sdl3::init().unwrap();
3434
let video_subsystem = sdl_context.video().unwrap();
3535

3636
// request GL version
@@ -64,7 +64,7 @@ impl App {
6464
let pm = Projectm::create();
6565

6666
// and a preset playlist
67-
let playlist = projectm_rs::playlist::Playlist::create(pm);
67+
let playlist = projectm::playlist::Playlist::create(pm);
6868

6969
// get/set window size
7070
let (width, height) = window.drawable_size(); // highDPI aware

src/app/audio.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use projectm_rs::core::ProjectMHandle;
2-
use sdl2::audio::{AudioCallback, AudioDevice, AudioSpecDesired};
1+
use projectm::core::ProjectMHandle;
2+
use sdl3::audio::{AudioCallback, AudioDevice, AudioSpecDesired};
33
use std::sync::Arc;
44
use std::sync::Mutex;
55

@@ -15,7 +15,7 @@ pub struct AudioCaptureDevice {
1515
}
1616

1717
pub struct Audio {
18-
audio_subsystem: sdl2::AudioSubsystem,
18+
audio_subsystem: sdl3::AudioSubsystem,
1919
device_index: AudioDeviceIndex,
2020
is_capturing: bool,
2121
frame_rate: Option<FrameRate>,
@@ -25,7 +25,7 @@ pub struct Audio {
2525

2626
/// Wrapper around the audio subsystem to capture audio and pass it to projectM.
2727
impl Audio {
28-
pub fn new(sdl_context: &sdl2::Sdl, projectm: ProjectMWrapped) -> Self {
28+
pub fn new(sdl_context: &sdl3::Sdl, projectm: ProjectMWrapped) -> Self {
2929
let audio_subsystem = sdl_context.audio().unwrap();
3030

3131
Self {
@@ -106,7 +106,7 @@ impl Audio {
106106
// how many samples to capture at a time
107107
// should be enough for 1 frame or less
108108
// should not be larger than max_samples / channels
109-
let max_samples: usize = projectm_rs::core::Projectm::pcm_get_max_samples()
109+
let max_samples: usize = projectm::core::Projectm::pcm_get_max_samples()
110110
.try_into()
111111
.unwrap();
112112
let samples_per_frame = (sample_rate / frame_rate) as usize;
@@ -183,6 +183,6 @@ impl AudioCallback for AudioCaptureCallback {
183183
// we need to pass it to projectm
184184
fn callback(&mut self, out: &mut [SampleFormat]) {
185185
let pm = *self.pm.lock().unwrap();
186-
projectm_rs::core::Projectm::pcm_add_float(pm, out.to_vec(), 2);
186+
projectm::core::Projectm::pcm_add_float(pm, out.to_vec(), 2);
187187
}
188188
}

src/app/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::app::App;
2-
use projectm_rs::core::Projectm;
2+
use projectm::core::Projectm;
33
use std::path::Path;
44

55
pub type FrameRate = u32;

src/app/main_loop.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use projectm_rs::core::Projectm;
2-
use sdl2::event::Event;
3-
use sdl2::keyboard::Keycode;
1+
use projectm::core::Projectm;
2+
use sdl3::event::Event;
3+
use sdl3::keyboard::Keycode;
44

55
use crate::app::App;
66

@@ -14,7 +14,7 @@ impl App {
1414

1515
// events
1616
let mut event_pump = self.sdl_context.event_pump().unwrap();
17-
let mut timer = self.sdl_context.timer().unwrap();
17+
let timer = self.sdl_context.timer().unwrap();
1818

1919
// renderLoop
2020
'running: loop {
@@ -82,10 +82,10 @@ impl App {
8282
Event::KeyUp {
8383
keycode: Some(Keycode::I),
8484
keymod:
85-
sdl2::keyboard::Mod::LCTRLMOD
86-
| sdl2::keyboard::Mod::RCTRLMOD
87-
| sdl2::keyboard::Mod::LGUIMOD
88-
| sdl2::keyboard::Mod::RGUIMOD,
85+
sdl3::keyboard::Mod::LCTRLMOD
86+
| sdl3::keyboard::Mod::RCTRLMOD
87+
| sdl3::keyboard::Mod::LGUIMOD
88+
| sdl3::keyboard::Mod::RGUIMOD,
8989
..
9090
} => {
9191
self.audio.open_next_device();

src/app/video.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ impl App {
55
let is_fullscreen = self.window.fullscreen_state();
66
self.window
77
.set_fullscreen(match is_fullscreen {
8-
sdl2::video::FullscreenType::True => sdl2::video::FullscreenType::Off,
9-
_ => sdl2::video::FullscreenType::True,
8+
sdl3::video::FullscreenType::True => sdl3::video::FullscreenType::Off,
9+
_ => sdl3::video::FullscreenType::True,
1010
})
1111
.unwrap();
1212
}

src/dummy_audio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use projectm_rs::core::{ProjectMHandle, Projectm};
1+
use projectm::core::{ProjectMHandle, Projectm};
22

33
#[allow(dead_code)]
44
pub fn generate_random_audio_data(projectm_handle: ProjectMHandle) {

0 commit comments

Comments
 (0)