SDL2 only
parent
751d049784
commit
8932611a04
|
@ -19,27 +19,12 @@ version = "1.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
|
@ -337,7 +322,6 @@ version = "0.35.2"
|
|||
source = "git+https://github.com/Rust-SDL2/rust-sdl2#7b54256e87ae1d12bf674159b0b019fa297059d7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cmake",
|
||||
"libc",
|
||||
"version-compare",
|
||||
]
|
||||
|
|
|
@ -82,7 +82,6 @@ snapshot of where the engine state is right now.
|
|||
|
||||
I use and develop on Linux exclusively so although I once did a Windows build I don't maintain it.
|
||||
|
||||
- Bundled SDL2: `cargo build --features "sdl2-bundled"`
|
||||
- Distro SDL2: `cargo build`
|
||||
|
||||
The distro requires SDL2 + SDL2-mixer to be installed along with the related dev packages including `alsa-lib-devel` and `pulseaudio-libs-devel`.
|
||||
|
|
8
build.rs
8
build.rs
|
@ -1,11 +1,11 @@
|
|||
use std::{env, path::PathBuf};
|
||||
|
||||
fn main() {
|
||||
#[cfg(all(target_os = "macos", feature = "sdl2-bundled"))]
|
||||
println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path");
|
||||
// #[cfg(all(target_os = "macos", feature = "sdl2-bundled"))]
|
||||
// println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path");
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "sdl2-bundled"))]
|
||||
println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN");
|
||||
//#[cfg(all(target_os = "linux", feature = "sdl2-bundled"))]
|
||||
//println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN");
|
||||
|
||||
let target = env::var("TARGET").unwrap();
|
||||
if target.contains("pc-windows") {
|
||||
|
|
10
flatpak.yml
10
flatpak.yml
|
@ -29,7 +29,7 @@ modules:
|
|||
- type: archive
|
||||
url: https://github.com/FluidSynth/fluidsynth/archive/v2.2.7.tar.gz
|
||||
sha256: 460d86d8d687f567dc4780890b72538c7ff6b2082080ef2f9359d41670a309cf
|
||||
|
||||
|
||||
# - name: SDL2
|
||||
# buildsystem: autotools
|
||||
# cleanup:
|
||||
|
@ -58,7 +58,7 @@ modules:
|
|||
# - type: archive
|
||||
# url: https://gitlab.gnome.org/jadahl/libdecor/uploads/81adf91d27620e20bcc5f6b9b312d768/libdecor-0.1.0.tar.xz
|
||||
# sha256: fdefa11de4bd51cb14223a97e41fdd848f01f5c5ddca9b036a0c4e3e74d9f486
|
||||
|
||||
|
||||
# - name: SDL2_mixer
|
||||
# buildsystem: autotools
|
||||
# rm-configure: true
|
||||
|
@ -74,7 +74,7 @@ modules:
|
|||
# url: https://github.com/libsdl-org/SDL_mixer
|
||||
# tag: release-2.0.4
|
||||
# commit: da75a58c19de9fedea62724a5f7770cbbe39adf9
|
||||
|
||||
|
||||
- name: freepats
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
|
@ -87,7 +87,7 @@ modules:
|
|||
- type: archive
|
||||
url: https://freepats.zenvoid.org/freepats-20060219.tar.xz
|
||||
sha256: 500c61782ff4b22de6887c0a32e68dd98b511c4396ddf89e8cab482c7dcea89e
|
||||
|
||||
|
||||
- name: room4doom
|
||||
build-options:
|
||||
append-path: /usr/lib/sdk/rust-stable/bin
|
||||
|
@ -98,7 +98,7 @@ modules:
|
|||
RUST_BACKTRACE: "1"
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
- cargo --offline build --release --features "sdl2-bundled"
|
||||
- cargo --offline build --release
|
||||
- install -D -m 755 ./target/release/room4doom -t /app/bin/
|
||||
- install -D -m 755 ./target/release/libSDL2.so -t /app/lib/
|
||||
- ln -s /app/lib/libSDL2.so /app/lib/libSDL2.so.0
|
||||
|
|
|
@ -10,12 +10,6 @@ build = "../build.rs"
|
|||
name = "room4doom"
|
||||
path = "src/main.rs"
|
||||
|
||||
[features]
|
||||
default = ["sdl2-bundled"]
|
||||
sdl2-bundled = [
|
||||
"gamestate-traits/sdl2-bundled",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
gumdrop = "~0.8"
|
||||
input = { path = "../input" }
|
||||
|
|
|
@ -12,12 +12,12 @@ use gameplay::{
|
|||
use gamestate::{machination::Machinations, Game};
|
||||
use gamestate_traits::{
|
||||
sdl2::{
|
||||
self,
|
||||
keyboard::Scancode,
|
||||
pixels,
|
||||
rect::Rect,
|
||||
render::{Canvas, TextureCreator},
|
||||
video::{Window, WindowContext},
|
||||
{self},
|
||||
},
|
||||
GameState, MachinationTrait,
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ use crate::{cheats::Cheats, test_funcs::*, timestep::TimeStep, wipe::Wipe, CLIOp
|
|||
pub fn d_doom_loop(
|
||||
mut game: Game,
|
||||
mut input: Input,
|
||||
mut window: Window,
|
||||
window: Window,
|
||||
options: CLIOptions,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
// TODO: switch 320x200 | 640x400 on option
|
||||
|
@ -65,7 +65,7 @@ pub fn d_doom_loop(
|
|||
|
||||
// TODO: sort this block of stuff out
|
||||
let wsize = window.drawable_size();
|
||||
let ratio = wsize.1 as f32 * 1.333333;
|
||||
let ratio = wsize.1 as f32 * 1.333;
|
||||
let xp = (wsize.0 as f32 - ratio) / 2.0;
|
||||
|
||||
let crop_rect = Rect::new(xp as i32, 0, ratio as u32, wsize.1);
|
||||
|
@ -149,6 +149,7 @@ pub fn d_doom_loop(
|
|||
&mut render_buffer2,
|
||||
&tex_creator,
|
||||
&mut canvas,
|
||||
crop_rect,
|
||||
&mut timestep,
|
||||
);
|
||||
|
||||
|
@ -188,12 +189,12 @@ pub fn d_doom_loop(
|
|||
.unwrap()
|
||||
.as_texture(&tex_creator)
|
||||
.unwrap();
|
||||
canvas.copy(&surf, None, None).unwrap();
|
||||
canvas.copy(&surf, None, Some(crop_rect)).unwrap();
|
||||
canvas.present();
|
||||
|
||||
// FPS rate updates every second
|
||||
if let Some(_fps) = timestep.frame_rate() {
|
||||
//println!("{:?}", fps);
|
||||
println!("{:?}", _fps);
|
||||
|
||||
if options.palette_test {
|
||||
if pal_num == 13 {
|
||||
|
@ -289,6 +290,7 @@ fn d_display(
|
|||
draw_buf: &mut PixelBuf, // Draw to this buffer
|
||||
tex_creator: &TextureCreator<WindowContext>,
|
||||
canvas: &mut Canvas<Window>,
|
||||
crop_rect: Rect,
|
||||
timestep: &mut TimeStep,
|
||||
) {
|
||||
let automap_active = false;
|
||||
|
@ -376,7 +378,7 @@ fn d_display(
|
|||
.unwrap()
|
||||
.as_texture(&tex_creator)
|
||||
.unwrap();
|
||||
canvas.copy(&surf, None, None).unwrap();
|
||||
canvas.copy(&surf, None, Some(crop_rect)).unwrap();
|
||||
canvas.present();
|
||||
});
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
let mut user_config = UserConfig::load();
|
||||
|
||||
let sdl_ctx = sdl2::init()?;
|
||||
//let snd_ctx = sdl_ctx.audio().unwrap();
|
||||
//let snd_ctx = sdl_ctx.audio()?;
|
||||
let video_ctx = sdl_ctx.video()?;
|
||||
|
||||
let events = sdl_ctx.event_pump()?;
|
||||
|
|
|
@ -4,10 +4,6 @@ version = "0.2.0"
|
|||
authors = ["Luke Jones <luke@ljones.dev>"]
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["sdl2-bundled"]
|
||||
sdl2-bundled = ["sdl2/bundled"]
|
||||
|
||||
[dependencies]
|
||||
sdl2 = { git = "https://github.com/Rust-SDL2/rust-sdl2", features = ["mixer"] }
|
||||
gameplay = { path = "../gameplay" }
|
||||
|
|
Loading…
Reference in New Issue