From 3b87fc6423dc894b5ce90d37c3a1277b95b31998 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sun, 4 Jun 2023 19:38:46 +0200 Subject: [PATCH] mess around with srgb (wip) --- Cargo.lock | 77 +++++++++++++++++++++++++++++++++++++ kubi/Cargo.toml | 4 +- kubi/src/lib.rs | 25 ++++++++++++ kubi/src/prefabs/shaders.rs | 2 +- kubi/src/prefabs/texture.rs | 2 +- kubi/src/rendering.rs | 2 +- 6 files changed, 108 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8219cbe..faed465 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,6 +168,12 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + [[package]] name = "calloop" version = "0.10.5" @@ -187,6 +193,12 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "1.0.0" @@ -254,6 +266,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "core-foundation" version = "0.9.3" @@ -716,6 +738,12 @@ dependencies = [ "takeable-option", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "glutin" version = "0.29.1" @@ -931,6 +959,34 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +[[package]] +name = "java-locator" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72cb7c9d00a642469deceff95ca37d0da9ce72d7f8b863edbebdf0aac75093da" +dependencies = [ + "glob", + "lazy_static", +] + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "java-locator", + "jni-sys", + "libloading", + "log", + "thiserror", + "walkdir", + "windows-sys 0.45.0", +] + [[package]] name = "jni-sys" version = "0.3.0" @@ -963,11 +1019,13 @@ dependencies = [ "glium", "hashbrown 0.13.2", "image", + "jni", "kubi-logging", "kubi-shared", "log", "lz4_flex", "ndk", + "ndk-context", "ndk-glue", "nohash-hasher", "postcard", @@ -1696,6 +1754,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2066,6 +2133,16 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "walkdir" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/kubi/Cargo.toml b/kubi/Cargo.toml index 6528890..2779f18 100644 --- a/kubi/Cargo.toml +++ b/kubi/Cargo.toml @@ -32,9 +32,11 @@ tinyset = "0.4" [target.'cfg(target_os = "android")'.dependencies] ndk = "0.7" ndk-glue = "0.7" +ndk-context = "0.1" +jni = { version = "0.21", features = ["invocation"] } [target.'cfg(target_os = "windows")'.dependencies] -winapi = { version = "0.3" } +winapi = "0.3" [features] default = ["raw-evt"] diff --git a/kubi/src/lib.rs b/kubi/src/lib.rs index c43306c..595c688 100644 --- a/kubi/src/lib.rs +++ b/kubi/src/lib.rs @@ -1,5 +1,6 @@ #![allow(clippy::too_many_arguments)] // allowed because systems often need a lot of arguments +use anyhow::Result; use shipyard::{ World, Workload, IntoWorkload, UniqueView, UniqueViewMut, @@ -170,12 +171,36 @@ fn attach_console() { unsafe { AttachConsole(ATTACH_PARENT_PROCESS); } } +#[cfg(target_os = "android")] +fn do_android_init() -> Result<()> { + // let ctx = ndk_context::android_context(); + // let vm = unsafe { jni::JavaVM::from_raw(ctx.vm().cast()) }?; + // let env = vm.attach_current_thread()?; + // let window = env.call_method( + // ctx.context() as jni::sys::jobject, + // "getWindow", + // "(Ljava/lang/Object;)Ljava/lang/Object;", + // &[], + // )?; + // env.call_method( + // window as jni::sys::jobject, + // "setColorMode", + // "(Ljava/lang/Object;)Ljava/lang/Object;", + // &[], + // )?; + + Ok(()) +} + #[no_mangle] #[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))] pub fn kubi_main() { //Attach console on release builds on windows #[cfg(all(windows, not(debug_assertions)))] attach_console(); + //Android-specific jni/ndk stuff + #[cfg(target_os = "android")] do_android_init(); + //Print version println!("{:─^54}", format!("[ ▄▀ Kubi client v. {} ]", env!("CARGO_PKG_VERSION"))); diff --git a/kubi/src/prefabs/shaders.rs b/kubi/src/prefabs/shaders.rs index 7496a2f..a0a31fc 100644 --- a/kubi/src/prefabs/shaders.rs +++ b/kubi/src/prefabs/shaders.rs @@ -10,7 +10,7 @@ macro_rules! include_shader_prefab { tessellation_control_shader: None, tessellation_evaluation_shader: None, transform_feedback_varyings: None, - outputs_srgb: false, + outputs_srgb: true, uses_point_size: false, }).expect("Failed to compile gpu program") } diff --git a/kubi/src/prefabs/texture.rs b/kubi/src/prefabs/texture.rs index 845f1b6..5813a42 100644 --- a/kubi/src/prefabs/texture.rs +++ b/kubi/src/prefabs/texture.rs @@ -34,7 +34,7 @@ pub fn load_texture2darray_prefab< }; //Create a glium RawImage RawImage2d::from_raw_rgba_reversed( - &image_data, + &image_data, dimensions ) }).collect(); diff --git a/kubi/src/rendering.rs b/kubi/src/rendering.rs index 8b620c4..cc5af3a 100644 --- a/kubi/src/rendering.rs +++ b/kubi/src/rendering.rs @@ -83,7 +83,7 @@ impl Renderer { }); let cb = ContextBuilder::new() - .with_srgb(false) + .with_srgb(true) .with_depth_buffer(24) .with_multisampling(settings.msaa.unwrap_or_default()) .with_vsync(settings.vsync)