summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dir-locals.el4
-rw-r--r--.gitmodules3
-rw-r--r--Cargo.lock70
-rw-r--r--Cargo.toml4
m---------deps/glfw-rs0
-rw-r--r--flake.nix60
-rw-r--r--src/context.rs11
-rw-r--r--src/framebuffer.rs2
-rw-r--r--src/lib.rs108
-rw-r--r--src/state.rs41
10 files changed, 146 insertions, 157 deletions
diff --git a/.dir-locals.el b/.dir-locals.el
index e3e9c3b..23a499f 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,2 +1,2 @@
-((rust-mode . ((eglot-workspace-configuration . (:rust-analyzer (:cargo (:target "wasm32-unknown-unknown")))))))
-;; ((rust-mode . ((eglot-workspace-configuration . (:rust-analyzer (:cargo (:target "x86_64-unknown-linux-gnu")))))))
+;; ((rust-mode . ((eglot-workspace-configuration . (:rust-analyzer (:cargo (:target "wasm32-unknown-unknown")))))))
+((rust-mode . ((eglot-workspace-configuration . (:rust-analyzer (:cargo (:target "x86_64-unknown-linux-gnu")))))))
diff --git a/.gitmodules b/.gitmodules
index d8e9eee..3ddd468 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "deps/gltf"]
path = deps/gltf
url = https://github.com/lcolonq/gltf
+[submodule "deps/glfw-rs"]
+ path = deps/glfw-rs
+ url = git@github.com:lcolonq/glfw-rs.git
diff --git a/Cargo.lock b/Cargo.lock
index 663c60a..487f341 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -274,7 +274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68"
dependencies = [
"block-sys",
- "objc2",
+ "objc2 0.4.1",
]
[[package]]
@@ -877,6 +877,17 @@ dependencies = [
]
[[package]]
+name = "glfw"
+version = "0.59.0"
+dependencies = [
+ "bitflags 1.3.2",
+ "objc2 0.5.2",
+ "raw-window-handle",
+ "serde",
+ "winapi",
+]
+
+[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1098,7 +1109,7 @@ checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319"
dependencies = [
"block2",
"dispatch",
- "objc2",
+ "objc2 0.4.1",
]
[[package]]
@@ -1476,9 +1487,9 @@ dependencies = [
[[package]]
name = "objc-sys"
-version = "0.3.2"
+version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459"
+checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310"
[[package]]
name = "objc2"
@@ -1487,7 +1498,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d"
dependencies = [
"objc-sys",
- "objc2-encode",
+ "objc2-encode 3.0.0",
+]
+
+[[package]]
+name = "objc2"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804"
+dependencies = [
+ "objc-sys",
+ "objc2-encode 4.1.0",
]
[[package]]
@@ -1497,6 +1518,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666"
[[package]]
+name = "objc2-encode"
+version = "4.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
+
+[[package]]
name = "object"
version = "0.36.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2020,29 +2047,6 @@ dependencies = [
]
[[package]]
-name = "sdl2"
-version = "0.37.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3b498da7d14d1ad6c839729bd4ad6fc11d90a57583605f3b4df2cd709a9cd380"
-dependencies = [
- "bitflags 1.3.2",
- "lazy_static",
- "libc",
- "sdl2-sys",
-]
-
-[[package]]
-name = "sdl2-sys"
-version = "0.37.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "951deab27af08ed9c6068b7b0d05a93c91f0a8eb16b6b816a5e73452a43521d3"
-dependencies = [
- "cfg-if",
- "libc",
- "version-compare",
-]
-
-[[package]]
name = "security-framework"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2409,6 +2413,7 @@ dependencies = [
"fontdue",
"getrandom",
"glam",
+ "glfw",
"glow",
"gltf",
"image 0.24.9",
@@ -2417,7 +2422,6 @@ dependencies = [
"log",
"rand",
"reqwest",
- "sdl2",
"serde",
"tobj",
"tokio",
@@ -2760,12 +2764,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
-name = "version-compare"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29"
-
-[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3324,7 +3322,7 @@ dependencies = [
"memmap2",
"ndk",
"ndk-sys",
- "objc2",
+ "objc2 0.4.1",
"once_cell",
"orbclient",
"percent-encoding",
diff --git a/Cargo.toml b/Cargo.toml
index a21500d..8f9450b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -47,6 +47,6 @@ web-sys = { version = "*", features = ["Document", "Window", "Element", "HtmlCan
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
env_logger = "*"
-sdl2 = "*"
+glfw = { path = "deps/glfw-rs", features = ["serde"] }
kira = "0.9.6"
-tokio = { version = "*", features = ["full"] } \ No newline at end of file
+tokio = { version = "*", features = ["full"] }
diff --git a/deps/glfw-rs b/deps/glfw-rs
new file mode 160000
+Subproject 8a0fb154f7ab6248276e6eafaf10ae157cdfda3
diff --git a/flake.nix b/flake.nix
index b188d0e..0599005 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,20 +1,12 @@
{
- description = "Build a cargo project";
-
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
-
- # The version of wasm-bindgen-cli needs to match the version in Cargo.lock
- # Update this to include the version you need
nixpkgs-for-wasm-bindgen.url = "github:NixOS/nixpkgs/4e6868b1aa3766ab1de169922bb3826143941973";
-
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
-
flake-utils.url = "github:numtide/flake-utils";
-
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
@@ -34,57 +26,38 @@
inherit (pkgs) lib;
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
- # Set the build targets supported by the toolchain,
- # wasm32-unknown-unknown is required for trunk
targets = [ "wasm32-unknown-unknown" ];
};
craneLib = ((crane.mkLib pkgs).overrideToolchain rustToolchain).overrideScope (_final: _prev: {
- # The version of wasm-bindgen-cli needs to match the version in Cargo.lock. You
- # can unpin this if your nixpkgs commit contains the appropriate wasm-bindgen-cli version
inherit (import nixpkgs-for-wasm-bindgen { inherit system; }) wasm-bindgen-cli;
});
- # When filtering sources, we want to allow assets other than .rs files
src = lib.cleanSourceWith {
- src = ./.; # The original, unfiltered source
+ src = ./.;
filter = path: type:
(lib.hasSuffix "\.html" path) ||
(lib.hasSuffix "\.scss" path) ||
- # Example of a folder for images, icons, etc
(lib.hasInfix "/assets/" path) ||
- # Default filter from crane (allow .rs files)
(craneLib.filterCargoSources path type)
;
};
- # Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;
strictDeps = true;
- # We must force the target, otherwise cargo will attempt to use your native target
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
-
buildInputs = [
- # Add additional build inputs here
] ++ lib.optionals pkgs.stdenv.isDarwin [
- # Additional darwin specific inputs can be set here
pkgs.libiconv
];
};
- # Build *just* the cargo dependencies, so we can reuse
- # all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
- # You cannot run cargo test on a wasm build
doCheck = false;
});
- # Build the actual crate itself, reusing the dependency
- # artifacts from above.
- # This derivation is a directory you can put on a webserver.
teleia = craneLib.buildTrunkPackage (commonArgs // {
inherit cargoArtifacts;
- # The version of wasm-bindgen-cli here must match the one from Cargo.lock.
wasm-bindgen-cli = pkgs.wasm-bindgen-cli.override {
version = "0.2.90";
hash = "sha256-X8+DVX7dmKh7BgXqP7Fp0smhup5OO8eWEhn26ODYbkQ=";
@@ -94,21 +67,11 @@
in
{
checks = {
- # Build the crate as part of `nix flake check` for convenience
inherit teleia;
-
- # Run clippy (and deny all warnings) on the crate source,
- # again, reusing the dependency artifacts from above.
- #
- # Note that this is done as a separate derivation so that
- # we can block the CI if there are issues here, but not
- # prevent downstream consumers from building our crate by itself.
teleia-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
-
- # Check formatting
teleia-fmt = craneLib.cargoFmt {
inherit src;
};
@@ -117,21 +80,24 @@
packages.default = teleia;
devShells.default = craneLib.devShell {
- # Inherit inputs from checks.
checks = self.checks.${system};
-
- # Additional dev-shell environment variables can be set directly
- # MY_CUSTOM_DEVELOPMENT_VAR = "something else";
-
- # Extra inputs can be added here; cargo and rustc are provided by default.
packages = [
pkgs.trunk
pkgs.rust-analyzer
- pkgs.pkg-config
- pkgs.openssl.dev
- pkgs.SDL2
pkgs.glxinfo
pkgs.alsa-lib
+ pkgs.cmake
+ pkgs.pkg-config
+ pkgs.openssl.dev
+ pkgs.glfw
+ pkgs.xorg.libX11
+ pkgs.xorg.libXcursor
+ pkgs.xorg.libXi
+ pkgs.xorg.libXrandr
+ pkgs.xorg.libXinerama
+ pkgs.libxkbcommon
+ pkgs.xorg.libxcb
+ pkgs.libglvnd
];
};
});
diff --git a/src/context.rs b/src/context.rs
index ca3ebe3..05d6990 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -14,10 +14,11 @@ extern {
pub struct Context {
pub render_width: f32,
pub render_height: f32,
- pub window: sdl2::video::Window,
+ pub glfw: std::cell::RefCell<glfw::Glfw>,
+ pub window: std::cell::RefCell<glfw::PWindow>,
pub gl: glow::Context,
pub emptyvao: glow::VertexArray,
- pub timer: sdl2::TimerSubsystem,
+ pub start_instant: std::time::Instant,
}
@@ -46,16 +47,16 @@ impl Context {
}
#[cfg(not(target_arch = "wasm32"))]
- pub fn new(sdl: sdl2::Sdl, window: sdl2::video::Window, gl: glow::Context, render_width: f32, render_height: f32) -> Self {
+ pub fn new(glfw: std::cell::RefCell<glfw::Glfw>, window: std::cell::RefCell<glfw::PWindow>, gl: glow::Context, render_width: f32, render_height: f32) -> Self {
let emptyvao = unsafe {
gl.create_vertex_array().expect("failed to initialize vao")
};
let ret = Self {
render_width, render_height,
- window,
+ glfw, window,
gl,
emptyvao,
- timer: sdl.timer().expect("failed to initialize timer subsystem"),
+ start_instant: std::time::Instant::now(),
};
ret.init();
ret
diff --git a/src/framebuffer.rs b/src/framebuffer.rs
index f97a967..b3ce859 100644
--- a/src/framebuffer.rs
+++ b/src/framebuffer.rs
@@ -15,7 +15,7 @@ impl Framebuffer {
let (windoww, windowh): (f32, f32) = ctx.window.inner_size().into();
#[cfg(not(target_arch = "wasm32"))]
let (windoww, windowh) = {
- let (w, h) = ctx.window.size();
+ let (w, h) = ctx.window.borrow().get_size();
(w as f32, h as f32)
};
let ratio = ctx.compute_upscale(windoww as _, windowh as _) as f32;
diff --git a/src/lib.rs b/src/lib.rs
index 78202b0..383a28d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -23,6 +23,9 @@ use winit::platform::web::WindowExtWebSys;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::JsCast;
+#[cfg(not(target_arch = "wasm32"))]
+use glfw::Context;
+
static mut CTX: Option<*const context::Context> = None;
static mut ST: Option<*mut state::State> = None;
static mut G: Option<*mut std::ffi::c_void> = None;
@@ -40,7 +43,7 @@ where
}
#[cfg(not(target_arch = "wasm32"))]
-pub async fn run<'a, F, G, Fut>(title: &str, w: u32, h: u32, gnew: F)
+pub async fn run<'a, F, G, Fut>(title: &str, w: u32, h: u32, overlay: bool, gnew: F)
where
Fut: std::future::Future<Output = G>,
G: state::Game + 'static,
@@ -52,28 +55,46 @@ where
log::info!("hello computer, starting up...");
- let (sdl, window, gl, mut event_loop, _gl_context) = {
- let sdl = sdl2::init().expect("failed to initialize SDL2");
- let video = sdl.video().expect("failed to initialize SDL2 video");
+ let (rglfw, rwindow, gl, events) = {
+ use glfw::fail_on_errors;
+ let mut glfw = glfw::init(glfw::fail_on_errors!()).expect("failed to initialize GLFW");
// let gl_attr = video.gl_attr();
// gl_attr.set_context_profile(sdl2::video::GLProfile::Core);
// gl_attr.set_context_version(3, 0);
- let window = video
- .window(title, w as _, h as _)
- .opengl()
- // .fullscreen_desktop()
- .resizable()
- .build()
- .unwrap();
- let gl_context = window.gl_create_context().unwrap();
+ let (mut window, events) = glfw.with_primary_monitor(|glfw, primary| {
+ if overlay {
+ let mon = primary.expect("failed to get monitor");
+ let mode = mon.get_video_mode().expect("failed to get video mode");
+ glfw.window_hint(glfw::WindowHint::RedBits(Some(mode.red_bits)));
+ glfw.window_hint(glfw::WindowHint::GreenBits(Some(mode.green_bits)));
+ glfw.window_hint(glfw::WindowHint::BlueBits(Some(mode.blue_bits)));
+ glfw.window_hint(glfw::WindowHint::RefreshRate(Some(mode.refresh_rate)));
+ glfw.window_hint(glfw::WindowHint::Resizable(false));
+ glfw.window_hint(glfw::WindowHint::Decorated(false));
+ glfw.window_hint(glfw::WindowHint::Floating(true));
+ glfw.window_hint(glfw::WindowHint::TransparentFramebuffer(true));
+ unsafe {
+ // glfw.window_hint(glfw::WindowHint::MousePassthrough(true));
+ glfw::ffi::glfwWindowHint(0x0002000D, 1); // mouse passthrough
+ }
+ glfw.create_window(mode.width, mode.height, title, glfw::WindowMode::FullScreen(mon))
+ .expect("failed to create window")
+ } else {
+ glfw.create_window(w as _, h as _, title, glfw::WindowMode::Windowed)
+ .expect("failed to create window")
+ }
+ });
+ window.make_current();
+ window.set_key_polling(true);
let gl = unsafe {
- glow::Context::from_loader_function(|s| video.gl_get_proc_address(s) as *const _)
+ glow::Context::from_loader_function(|s| window.get_proc_address(s) as *const _)
};
- let event_loop = sdl.event_pump().unwrap();
- (sdl, window, gl, event_loop, gl_context)
+ (glfw, window, gl, events)
};
+ let glfw = std::cell::RefCell::new(rglfw);
+ let window = std::cell::RefCell::new(rwindow);
- let ctx = Box::leak(Box::new(context::Context::new(sdl, window, gl, w as f32, h as f32)));
+ let ctx = Box::leak(Box::new(context::Context::new(glfw, window, gl, w as f32, h as f32)));
let game = Box::leak(Box::new(gnew(ctx).await));
let st = Box::leak(Box::new(state::State::new(&ctx)));
@@ -84,33 +105,34 @@ where
}
'running: loop {
- for event in event_loop.poll_iter() {
+ if ctx.window.borrow().should_close() {
+ log::info!("bye!");
+ break 'running;
+ }
+ ctx.glfw.borrow_mut().poll_events();
+ for (_, event) in glfw::flush_messages(&events) {
match event {
- sdl2::event::Event::Quit {..} => {
- log::info!("bye!");
- break 'running;
- },
- sdl2::event::Event::Window { win_event: sdl2::event::WindowEvent::Resized(_, _), .. } => {
- st.handle_resize(&ctx);
- },
- sdl2::event::Event::Window { win_event: sdl2::event::WindowEvent::FocusLost, .. } => {
- st.keys = state::Keys::new();
- },
- sdl2::event::Event::MouseMotion { x, y, .. } => {
- st.mouse_moved(&ctx, x as f32, y as f32, game);
- },
- sdl2::event::Event::MouseButtonDown {..} => {
- st.mouse_pressed(&ctx, game)
- },
- sdl2::event::Event::MouseButtonUp {..} => {
- st.mouse_released(&ctx)
- },
- sdl2::event::Event::KeyDown { keycode: Some(key), repeat: false, .. } => {
- st.key_pressed(&ctx, state::Keycode::new(key))
- },
- sdl2::event::Event::KeyUp { keycode: Some(key), repeat: false, .. } => {
- st.key_released(&ctx, state::Keycode::new(key))
- },
+ // sdl2::event::Event::Window { win_event: sdl2::event::WindowEvent::Resized(_, _), .. } => {
+ // st.handle_resize(&ctx);
+ // },
+ // sdl2::event::Event::Window { win_event: sdl2::event::WindowEvent::FocusLost, .. } => {
+ // st.keys = state::Keys::new();
+ // },
+ // sdl2::event::Event::MouseMotion { x, y, .. } => {
+ // st.mouse_moved(&ctx, x as f32, y as f32, game);
+ // },
+ // sdl2::event::Event::MouseButtonDown {..} => {
+ // st.mouse_pressed(&ctx, game)
+ // },
+ // sdl2::event::Event::MouseButtonUp {..} => {
+ // st.mouse_released(&ctx)
+ // },
+ // sdl2::event::Event::KeyDown { keycode: Some(key), repeat: false, .. } => {
+ // st.key_pressed(&ctx, state::Keycode::new(key))
+ // },
+ // sdl2::event::Event::KeyUp { keycode: Some(key), repeat: false, .. } => {
+ // st.key_released(&ctx, state::Keycode::new(key))
+ // },
_ => {},
}
}
@@ -131,7 +153,7 @@ where
}
st.run_update(&ctx, game);
st.run_render(&ctx, game);
- ctx.window.gl_swap_window();
+ ctx.window.borrow_mut().swap_buffers();
}
// event_loop.set_control_flow(winit::event_loop::ControlFlow::Poll);
diff --git a/src/state.rs b/src/state.rs
index 03ebf5e..2ac6d4b 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -102,17 +102,17 @@ pub type Keycode = winit::keyboard::KeyCode;
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Keycode {
- pub kc: sdl2::keyboard::Keycode
+ pub kc: glfw::Key
}
#[cfg(not(target_arch = "wasm32"))]
impl Keycode {
- pub fn new(kc: sdl2::keyboard::Keycode) -> Self { Self { kc } }
+ pub fn new(kc: glfw::Key) -> Self { Self { kc } }
}
#[cfg(not(target_arch = "wasm32"))]
impl Serialize for Keycode {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: serde::Serializer {
- (self.kc.into_i32()).serialize(serializer)
+ (self.kc as i32).serialize(serializer)
}
}
#[cfg(not(target_arch = "wasm32"))]
@@ -120,10 +120,8 @@ impl<'de> Deserialize<'de> for Keycode {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: serde::Deserializer<'de> {
i32::deserialize(deserializer)
- .and_then(|x| {
- sdl2::keyboard::Keycode::from_i32(x)
- .map(|kc| Keycode { kc })
- .ok_or(serde::de::Error::custom("invalid entity flags"))
+ .map(|x| unsafe {
+ std::mem::transmute(x)
})
}
}
@@ -161,7 +159,8 @@ pub fn now(ctx: &context::Context) -> Timestamp {
#[cfg(not(target_arch = "wasm32"))]
pub fn now(ctx: &context::Context) -> Timestamp {
- let ms = ctx.timer.ticks64();
+ let elapsed = ctx.start_instant.elapsed();
+ let ms = elapsed.as_millis();
(ms as f64) / 1000.0
}
@@ -184,16 +183,16 @@ pub fn default_keybindings() -> BiHashMap<Keycode, Key> {
#[cfg(not(target_arch = "wasm32"))]
pub fn default_keybindings() -> BiHashMap<Keycode, Key> {
BiHashMap::from_iter(vec![
- (Keycode::new(sdl2::keyboard::Keycode::W), Key::Up),
- (Keycode::new(sdl2::keyboard::Keycode::S), Key::Down),
- (Keycode::new(sdl2::keyboard::Keycode::A), Key::Left),
- (Keycode::new(sdl2::keyboard::Keycode::D), Key::Right),
- (Keycode::new(sdl2::keyboard::Keycode::NUM_1), Key::A),
- (Keycode::new(sdl2::keyboard::Keycode::NUM_2), Key::B),
- (Keycode::new(sdl2::keyboard::Keycode::Q), Key::L),
- (Keycode::new(sdl2::keyboard::Keycode::E), Key::R),
- (Keycode::new(sdl2::keyboard::Keycode::TAB), Key::Start),
- (Keycode::new(sdl2::keyboard::Keycode::SPACE), Key::Select),
+ (Keycode::new(glfw::Key::W), Key::Up),
+ (Keycode::new(glfw::Key::S), Key::Down),
+ (Keycode::new(glfw::Key::A), Key::Left),
+ (Keycode::new(glfw::Key::D), Key::Right),
+ (Keycode::new(glfw::Key::Num1), Key::A),
+ (Keycode::new(glfw::Key::Num2), Key::B),
+ (Keycode::new(glfw::Key::Q), Key::L),
+ (Keycode::new(glfw::Key::E), Key::R),
+ (Keycode::new(glfw::Key::Tab), Key::Start),
+ (Keycode::new(glfw::Key::Space), Key::Select),
])
}
@@ -420,7 +419,7 @@ impl State {
#[cfg(target_arch = "wasm32")]
let rebind = key == winit::keyboard::KeyCode::F12;
#[cfg(not(target_arch = "wasm32"))]
- let rebind = key.kc == sdl2::keyboard::Keycode::F12;
+ let rebind = key.kc == glfw::Key::F12;
if rebind {
self.keybindings = default_keybindings();
self.rebinding = None;
@@ -505,13 +504,13 @@ impl State {
pub fn run_render<G>(&mut self, ctx: &context::Context, game: &mut G) where G: Game {
self.render_framebuffer.bind(&ctx);
- ctx.clear_color(glam::Vec4::new(0.1, 0.1, 0.1, 1.0));
+ ctx.clear_color(glam::Vec4::new(0.1, 0.1, 0.1, 0.0));
ctx.clear();
game.render(ctx, self);
self.screen.bind(&ctx);
- ctx.clear_color(glam::Vec4::new(0.0, 0.0, 0.0, 1.0));
+ ctx.clear_color(glam::Vec4::new(0.0, 0.0, 0.0, 0.0));
ctx.clear();
self.shader_upscale.bind(&ctx);
self.render_framebuffer.bind_texture(&ctx);