shaders resizing and version bump!

This commit is contained in:
Alex Janka 2023-10-03 15:57:57 +11:00
parent eaa47213f7
commit 09e0d83e97
4 changed files with 13 additions and 13 deletions

2
Cargo.lock generated
View file

@ -1220,7 +1220,7 @@ dependencies = [
[[package]]
name = "gb-emu"
version = "0.3.3"
version = "0.4.0"
dependencies = [
"ash",
"ash-window",

View file

@ -1,6 +1,6 @@
[package]
name = "gb-emu"
version = "0.3.3"
version = "0.4.0"
edition = "2021"
[features]

View file

@ -44,7 +44,7 @@ pub struct WindowInfo {
struct WindowData {
renderer: Mutex<RendererBackend>,
window: Window,
real_factor: RwLock<u32>,
rendered_size: RwLock<(u32, u32)>,
}
pub struct WindowManager {
@ -111,13 +111,13 @@ impl WindowManager {
if let Some(w) = self.windows.get(&window_id) {
if let Ok(mut renderer) = w.renderer.lock() {
let inner_size = w.window.inner_size();
if let Ok(real_factor) = w.real_factor.read() {
if let Ok(rendered_size) = w.rendered_size.read() {
renderer.render(
ResolutionData {
real_width: inner_size.width,
real_height: inner_size.height,
scaled_width: inner_size.width / *real_factor,
scaled_height: inner_size.height / *real_factor,
scaled_width: rendered_size.0,
scaled_height: rendered_size.1,
},
&self.window_data_manager,
);
@ -153,7 +153,7 @@ impl WindowRenderer {
) -> (Self, WindowInfo) {
let window = WindowBuilder::new()
.with_title("Gameboy")
.with_resizable(false)
.with_resizable(shader_path.is_some())
.build(event_loop)
.unwrap();
@ -177,7 +177,7 @@ impl WindowRenderer {
let data = Arc::new(WindowData {
renderer,
window,
real_factor: RwLock::new(real_factor),
rendered_size: RwLock::new((1, 1)),
});
let info = WindowInfo {
@ -211,8 +211,8 @@ impl Renderer<[u8; 4]> for WindowRenderer {
let real_width = (width as u32) * real_factor;
let real_height = (height as u32) * real_factor;
if let Ok(mut f) = self.data.real_factor.write() {
*f = real_factor;
if let Ok(mut f) = self.data.rendered_size.write() {
*f = (width as u32, height as u32);
}
self.data

View file

@ -122,9 +122,9 @@ pub(super) fn rgb_from_bytes(bytes: u16) -> Colour {
let g = (bytes & (0b11111 << 5)) >> 5;
let r = bytes & 0b11111;
// direct colour emulation:
// let blue = (raw_blue << 3) | (raw_blue >> 2);
// let green = (raw_green << 3) | (raw_green >> 2);
// let red = (raw_red << 3) | (raw_red >> 2);
// let blue = (b << 3) | (b >> 2);
// let green = (g << 3) | (g >> 2);
// let red = (r << 3) | (r >> 2);
// colour emulation from
// https://web.archive.org/web/20200322151952/https://byuu.net/video/color-emulation