mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-24 21:08:19 -06:00
"fix" compile errs
This commit is contained in:
parent
bcaf011b88
commit
4307a50a76
146
Cargo.lock
generated
146
Cargo.lock
generated
|
@ -244,32 +244,13 @@ version = "0.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "block-sys"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7"
|
|
||||||
dependencies = [
|
|
||||||
"objc-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "block2"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68"
|
|
||||||
dependencies = [
|
|
||||||
"block-sys",
|
|
||||||
"objc2 0.4.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block2"
|
name = "block2"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "43ff7d91d3c1d568065b06c899777d1e48dcf76103a672a0adbc238a7f247f1e"
|
checksum = "43ff7d91d3c1d568065b06c899777d1e48dcf76103a672a0adbc238a7f247f1e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"objc2 0.5.1",
|
"objc2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1027,8 +1008,8 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hui"
|
name = "hui"
|
||||||
version = "0.1.0-alpha.4"
|
version = "0.1.0-alpha.5"
|
||||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"derive_setters",
|
"derive_setters",
|
||||||
|
@ -1041,13 +1022,14 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"rect_packer",
|
"rect_packer",
|
||||||
|
"rustc-hash",
|
||||||
"tinyset",
|
"tinyset",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hui-derive"
|
name = "hui-derive"
|
||||||
version = "0.1.0-alpha.4"
|
version = "0.1.0-alpha.5"
|
||||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.60",
|
"syn 2.0.60",
|
||||||
|
@ -1055,13 +1037,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hui-winit"
|
name = "hui-winit"
|
||||||
version = "0.1.0-alpha.4"
|
version = "0.1.0-alpha.5"
|
||||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glam",
|
"glam",
|
||||||
"hui",
|
"hui",
|
||||||
"log",
|
"log",
|
||||||
"winit 0.29.15",
|
"winit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1093,17 +1075,6 @@ dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "icrate"
|
|
||||||
version = "0.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319"
|
|
||||||
dependencies = [
|
|
||||||
"block2 0.3.0",
|
|
||||||
"dispatch",
|
|
||||||
"objc2 0.4.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ident_case"
|
name = "ident_case"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -1281,7 +1252,7 @@ dependencies = [
|
||||||
"uflow",
|
"uflow",
|
||||||
"wgpu",
|
"wgpu",
|
||||||
"winapi",
|
"winapi",
|
||||||
"winit 0.30.0",
|
"winit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1649,16 +1620,6 @@ version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da284c198fb9b7b0603f8635185e85fbd5b64ee154b1ed406d489077de2d6d60"
|
checksum = "da284c198fb9b7b0603f8635185e85fbd5b64ee154b1ed406d489077de2d6d60"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "objc2"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d"
|
|
||||||
dependencies = [
|
|
||||||
"objc-sys",
|
|
||||||
"objc2-encode 3.0.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2"
|
name = "objc2"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
|
@ -1666,7 +1627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4b25e1034d0e636cd84707ccdaa9f81243d399196b8a773946dcffec0401659"
|
checksum = "b4b25e1034d0e636cd84707ccdaa9f81243d399196b8a773946dcffec0401659"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"objc-sys",
|
"objc-sys",
|
||||||
"objc2-encode 4.0.1",
|
"objc2-encode",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1675,8 +1636,8 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fb79768a710a9a1798848179edb186d1af7e8a8679f369e4b8d201dd2a034047"
|
checksum = "fb79768a710a9a1798848179edb186d1af7e8a8679f369e4b8d201dd2a034047"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2 0.5.0",
|
"block2",
|
||||||
"objc2 0.5.1",
|
"objc2",
|
||||||
"objc2-core-data",
|
"objc2-core-data",
|
||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
@ -1687,17 +1648,11 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6e092bc42eaf30a08844e6a076938c60751225ec81431ab89f5d1ccd9f958d6c"
|
checksum = "6e092bc42eaf30a08844e6a076938c60751225ec81431ab89f5d1ccd9f958d6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2 0.5.0",
|
"block2",
|
||||||
"objc2 0.5.1",
|
"objc2",
|
||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "objc2-encode"
|
|
||||||
version = "3.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2-encode"
|
name = "objc2-encode"
|
||||||
version = "4.0.1"
|
version = "4.0.1"
|
||||||
|
@ -1710,9 +1665,9 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cfaefe14254871ea16c7d88968c0ff14ba554712a20d76421eec52f0a7fb8904"
|
checksum = "cfaefe14254871ea16c7d88968c0ff14ba554712a20d76421eec52f0a7fb8904"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2 0.5.0",
|
"block2",
|
||||||
"dispatch",
|
"dispatch",
|
||||||
"objc2 0.5.1",
|
"objc2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2000,15 +1955,6 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8ffb4dfda4b01cc420847665dc480760d596ce186f2772a66ed32fe9acb1c45"
|
checksum = "d8ffb4dfda4b01cc420847665dc480760d596ce186f2772a66ed32fe9acb1c45"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_syscall"
|
|
||||||
version = "0.3.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
@ -2815,16 +2761,6 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "web-time"
|
|
||||||
version = "0.2.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-time"
|
name = "web-time"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -3009,15 +2945,6 @@ dependencies = [
|
||||||
"windows-targets 0.42.2",
|
"windows-targets 0.42.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-sys"
|
|
||||||
version = "0.48.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
|
||||||
dependencies = [
|
|
||||||
"windows-targets 0.48.5",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
|
@ -3205,41 +3132,6 @@ version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winit"
|
|
||||||
version = "0.29.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0d59ad965a635657faf09c8f062badd885748428933dad8e8bdd64064d92e5ca"
|
|
||||||
dependencies = [
|
|
||||||
"android-activity 0.5.2",
|
|
||||||
"atomic-waker",
|
|
||||||
"bitflags 2.5.0",
|
|
||||||
"calloop",
|
|
||||||
"cfg_aliases 0.1.1",
|
|
||||||
"core-foundation",
|
|
||||||
"core-graphics",
|
|
||||||
"cursor-icon",
|
|
||||||
"icrate",
|
|
||||||
"js-sys",
|
|
||||||
"libc",
|
|
||||||
"log",
|
|
||||||
"ndk 0.8.0",
|
|
||||||
"ndk-sys 0.5.0+25.2.9519653",
|
|
||||||
"objc2 0.4.1",
|
|
||||||
"once_cell",
|
|
||||||
"orbclient",
|
|
||||||
"redox_syscall 0.3.5",
|
|
||||||
"rustix",
|
|
||||||
"smol_str",
|
|
||||||
"unicode-segmentation",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"wasm-bindgen-futures",
|
|
||||||
"web-sys",
|
|
||||||
"web-time 0.2.4",
|
|
||||||
"windows-sys 0.48.0",
|
|
||||||
"xkbcommon-dl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winit"
|
name = "winit"
|
||||||
version = "0.30.0"
|
version = "0.30.0"
|
||||||
|
@ -3262,7 +3154,7 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"ndk 0.9.0",
|
"ndk 0.9.0",
|
||||||
"objc2 0.5.1",
|
"objc2",
|
||||||
"objc2-app-kit",
|
"objc2-app-kit",
|
||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
"orbclient",
|
"orbclient",
|
||||||
|
@ -3283,7 +3175,7 @@ dependencies = [
|
||||||
"wayland-protocols",
|
"wayland-protocols",
|
||||||
"wayland-protocols-plasma",
|
"wayland-protocols-plasma",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"web-time 1.1.0",
|
"web-time",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
"x11-dl",
|
"x11-dl",
|
||||||
"x11rb",
|
"x11rb",
|
||||||
|
|
|
@ -21,10 +21,13 @@ opt-level = 1
|
||||||
[profile.dev.package.uflow]
|
[profile.dev.package.uflow]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
[profile.dev.package.glium]
|
[profile.dev.package.wgpu]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
[profile.dev.package.bracket-noise]
|
[profile.dev.package.wgpu-core]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
|
[profile.dev.package.wgpu-hal]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
[profile.dev.package.fastnoise-lite]
|
[profile.dev.package.fastnoise-lite]
|
||||||
|
|
|
@ -1,64 +1,64 @@
|
||||||
//! Custom env_logger options and styling
|
//! Custom env_logger options and styling
|
||||||
|
|
||||||
/// Custom env_logger options and styling
|
/// Custom env_logger options and styling
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
use log::Level;
|
use log::Level;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use env_logger::{fmt::Color, Builder, Env};
|
use env_logger::{fmt::Color, Builder, Env};
|
||||||
|
|
||||||
let env = Env::default()
|
let env = Env::default()
|
||||||
.filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn");
|
.filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn,wgpu=warn,wgpu_core=warn,wgpu_hal=warn,hui=info,hui-winit=info,hui-glium=info,hui-wgpu=info");
|
||||||
Builder::from_env(env)
|
Builder::from_env(env)
|
||||||
.format(|buf, record| {
|
.format(|buf, record| {
|
||||||
let mut level_style = buf.style();
|
let mut level_style = buf.style();
|
||||||
level_style.set_color(match record.level() {
|
level_style.set_color(match record.level() {
|
||||||
Level::Error => Color::Red,
|
Level::Error => Color::Red,
|
||||||
Level::Warn => Color::Yellow,
|
Level::Warn => Color::Yellow,
|
||||||
Level::Debug | Level::Trace => Color::Cyan,
|
Level::Debug | Level::Trace => Color::Cyan,
|
||||||
_ => Color::Blue
|
_ => Color::Blue
|
||||||
}).set_bold(true);
|
}).set_bold(true);
|
||||||
|
|
||||||
let mut bold_style = buf.style();
|
let mut bold_style = buf.style();
|
||||||
bold_style.set_bold(true);
|
bold_style.set_bold(true);
|
||||||
|
|
||||||
let mut location_style = buf.style();
|
let mut location_style = buf.style();
|
||||||
location_style.set_bold(true);
|
location_style.set_bold(true);
|
||||||
location_style.set_dimmed(true);
|
location_style.set_dimmed(true);
|
||||||
|
|
||||||
let mut location_line_style = buf.style();
|
let mut location_line_style = buf.style();
|
||||||
location_line_style.set_dimmed(true);
|
location_line_style.set_dimmed(true);
|
||||||
|
|
||||||
let text = format!("{}", record.args());
|
let text = format!("{}", record.args());
|
||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
buf,
|
buf,
|
||||||
"{} {:<50}\t{}{}{}{}",
|
"{} {:<50}\t{}{}{}{}",
|
||||||
level_style.value(match record.level() {
|
level_style.value(match record.level() {
|
||||||
Level::Error => "[e]",
|
Level::Error => "[e]",
|
||||||
Level::Warn => "[w]",
|
Level::Warn => "[w]",
|
||||||
Level::Info => "[i]",
|
Level::Info => "[i]",
|
||||||
Level::Debug => "[d]",
|
Level::Debug => "[d]",
|
||||||
Level::Trace => "[t]",
|
Level::Trace => "[t]",
|
||||||
}),
|
}),
|
||||||
text,
|
text,
|
||||||
bold_style.value((text.len() > 50).then_some("\n ╰─ ").unwrap_or_default()),
|
bold_style.value((text.len() > 50).then_some("\n ╰─ ").unwrap_or_default()),
|
||||||
location_style.value(record.target()),
|
location_style.value(record.target()),
|
||||||
location_line_style.value(" :"),
|
location_line_style.value(" :"),
|
||||||
location_line_style.value(record.line().unwrap_or(0))
|
location_line_style.value(record.line().unwrap_or(0))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.init();
|
.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Custom env_logger options and styling
|
/// Custom env_logger options and styling
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use android_logger::Config;
|
use android_logger::Config;
|
||||||
android_logger::init_once(
|
android_logger::init_once(
|
||||||
Config::default().with_max_level(LevelFilter::Trace),
|
Config::default().with_max_level(LevelFilter::Trace),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ crate-type = ["lib", "cdylib"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kubi-shared = { path = "../kubi-shared" }
|
kubi-shared = { path = "../kubi-shared" }
|
||||||
kubi-logging = { path = "../kubi-logging" }
|
kubi-logging = { path = "../kubi-logging" }
|
||||||
hui = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
hui = { git = "https://github.com/griffi-gh/hui", rev = "3a50d2d0dde" }
|
||||||
hui-winit = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
hui-winit = { git = "https://github.com/griffi-gh/hui", rev = "3a50d2d0dde", features = ["winit_30"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
wgpu = { version = "0.20", features = ["webgl"] }
|
wgpu = { version = "0.20", features = ["webgl"] }
|
||||||
pollster = "0.3"
|
pollster = "0.3"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use shipyard::{AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
use shipyard::{AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||||
use crate::{events::InputDeviceEvent, rendering::{Renderer, WindowSize}};
|
use crate::{events::InputDeviceEvent, rendering::Renderer};
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::PhysicalPosition, event::{DeviceEvent, ElementState, RawKeyEvent}, keyboard::{KeyCode, PhysicalKey}, window::CursorGrabMode
|
dpi::PhysicalPosition, event::{DeviceEvent, ElementState, RawKeyEvent}, keyboard::{KeyCode, PhysicalKey}, window::CursorGrabMode
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@ pub fn update_cursor_lock_state(
|
||||||
}
|
}
|
||||||
if lock.is_inserted_or_modified() {
|
if lock.is_inserted_or_modified() {
|
||||||
//TODO MIGRATION
|
//TODO MIGRATION
|
||||||
let window = &display.window;
|
let window = display.window();
|
||||||
window.set_cursor_grab(match lock.0 {
|
window.set_cursor_grab(match lock.0 {
|
||||||
true => CursorGrabMode::Confined,
|
true => CursorGrabMode::Confined,
|
||||||
false => CursorGrabMode::None,
|
false => CursorGrabMode::None,
|
||||||
|
@ -42,7 +42,6 @@ pub fn debug_toggle_lock(
|
||||||
mut lock: UniqueViewMut<CursorLock>,
|
mut lock: UniqueViewMut<CursorLock>,
|
||||||
device_events: View<InputDeviceEvent>,
|
device_events: View<InputDeviceEvent>,
|
||||||
ren: NonSendSync<UniqueView<Renderer>>,
|
ren: NonSendSync<UniqueView<Renderer>>,
|
||||||
size: UniqueView<WindowSize>,
|
|
||||||
) {
|
) {
|
||||||
for evt in device_events.iter() {
|
for evt in device_events.iter() {
|
||||||
if let DeviceEvent::Key(RawKeyEvent {
|
if let DeviceEvent::Key(RawKeyEvent {
|
||||||
|
@ -51,8 +50,8 @@ pub fn debug_toggle_lock(
|
||||||
}) = evt.event {
|
}) = evt.event {
|
||||||
lock.0 = !lock.0;
|
lock.0 = !lock.0;
|
||||||
if !lock.0 {
|
if !lock.0 {
|
||||||
let center = PhysicalPosition::new(size.0.x as f64 / 2., size.0.y as f64 / 2.);
|
let center = PhysicalPosition::new(ren.size().width as f64 / 2., ren.size().height as f64 / 2.);
|
||||||
let _ = ren.window.set_cursor_position(center);
|
let _ = ren.window().set_cursor_position(center);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ pub fn initial_resize_event(
|
||||||
) {
|
) {
|
||||||
let (w, h) = {
|
let (w, h) = {
|
||||||
let renderer = storages.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
let renderer = storages.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||||
renderer.display.get_framebuffer_dimensions()
|
(renderer.size().width, renderer.size().height)
|
||||||
};
|
};
|
||||||
storages.add_entity((
|
storages.add_entity((
|
||||||
EventComponent,
|
EventComponent,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use hui::UiInstance;
|
use hui::UiInstance;
|
||||||
//use hui_glium::GliumUiRenderer;
|
//use hui_glium::GliumUiRenderer;
|
||||||
use shipyard::{AllStoragesView, Unique, UniqueView, NonSendSync, UniqueViewMut};
|
use shipyard::{AllStoragesView, Unique, UniqueView, NonSendSync, UniqueViewMut};
|
||||||
use crate::rendering::{RenderTarget, Renderer, WindowSize};
|
use crate::rendering::{Renderer, WindowSize};
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
pub struct UiState {
|
pub struct UiState {
|
||||||
|
@ -34,13 +34,13 @@ pub fn kubi_ui_end(
|
||||||
//renderer.update(hui);
|
//renderer.update(hui);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kubi_ui_draw(
|
// pub fn kubi_ui_draw(
|
||||||
ui: NonSendSync<UniqueView<UiState>>,
|
// ui: NonSendSync<UniqueView<UiState>>,
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
size: UniqueView<WindowSize>
|
// size: UniqueView<WindowSize>
|
||||||
) {
|
// ) {
|
||||||
//ui.renderer.draw(&mut target.0, size.0.as_vec2());
|
// ui.renderer.draw(&mut target.0, size.0.as_vec2());
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn hui_process_winit_events(
|
pub fn hui_process_winit_events(
|
||||||
event: &winit::event::Event<()>,
|
event: &winit::event::Event<()>,
|
||||||
|
|
|
@ -75,18 +75,12 @@ use events::{
|
||||||
};
|
};
|
||||||
use input::{init_input, process_inputs};
|
use input::{init_input, process_inputs};
|
||||||
use player_controller::{debug_switch_ctl_type, update_player_controllers};
|
use player_controller::{debug_switch_ctl_type, update_player_controllers};
|
||||||
|
// use rendering::{
|
||||||
|
// clear_background, entities::render_entities, init_window_size, primitives::init_primitives, resize_renderer, selection_box::render_selection_box, sumberge::render_submerged_view, update_window_size, world::{draw_current_chunk_border, draw_world, draw_world_trans, init_trans_chunk_queue}, BackgroundColor, RenderTarget, Renderer
|
||||||
|
// };
|
||||||
use rendering::{
|
use rendering::{
|
||||||
Renderer,
|
init_window_size, resize_renderer, update_window_size,
|
||||||
RenderTarget,
|
BackgroundColor, Renderer
|
||||||
BackgroundColor,
|
|
||||||
clear_background,
|
|
||||||
init_window_size,
|
|
||||||
update_window_size,
|
|
||||||
primitives::init_primitives,
|
|
||||||
world::{init_trans_chunk_queue, draw_world, draw_world_trans, draw_current_chunk_border},
|
|
||||||
selection_box::render_selection_box,
|
|
||||||
entities::render_entities,
|
|
||||||
sumberge::render_submerged_view,
|
|
||||||
};
|
};
|
||||||
use block_placement::update_block_placement;
|
use block_placement::update_block_placement;
|
||||||
use delta_time::{DeltaTime, init_delta_time};
|
use delta_time::{DeltaTime, init_delta_time};
|
||||||
|
@ -95,7 +89,7 @@ use control_flow::{exit_on_esc, insert_control_flow_unique, RequestExit};
|
||||||
use state::{is_ingame, is_ingame_or_loading, is_loading, init_state, update_state, is_connecting};
|
use state::{is_ingame, is_ingame_or_loading, is_loading, init_state, update_state, is_connecting};
|
||||||
use networking::{update_networking, update_networking_late, is_multiplayer, disconnect_on_exit, is_singleplayer};
|
use networking::{update_networking, update_networking_late, is_multiplayer, disconnect_on_exit, is_singleplayer};
|
||||||
use init::initialize_from_args;
|
use init::initialize_from_args;
|
||||||
use hui_integration::{kubi_ui_begin, kubi_ui_draw, kubi_ui_end, kubi_ui_init};
|
use hui_integration::{kubi_ui_begin, /*kubi_ui_draw,*/ kubi_ui_end, kubi_ui_init};
|
||||||
use loading_screen::update_loading_screen;
|
use loading_screen::update_loading_screen;
|
||||||
use connecting_screen::update_connecting_screen;
|
use connecting_screen::update_connecting_screen;
|
||||||
use fixed_timestamp::init_fixed_timestamp_storage;
|
use fixed_timestamp::init_fixed_timestamp_storage;
|
||||||
|
@ -121,7 +115,7 @@ fn startup() -> Workload {
|
||||||
init_window_size,
|
init_window_size,
|
||||||
kubi_ui_init,
|
kubi_ui_init,
|
||||||
load_prefabs,
|
load_prefabs,
|
||||||
init_primitives,
|
//init_primitives,
|
||||||
insert_lock_state,
|
insert_lock_state,
|
||||||
init_state,
|
init_state,
|
||||||
initialize_from_args,
|
initialize_from_args,
|
||||||
|
@ -132,7 +126,7 @@ fn startup() -> Workload {
|
||||||
init_client_physics,
|
init_client_physics,
|
||||||
init_chat_manager,
|
init_chat_manager,
|
||||||
init_crosshair_image,
|
init_crosshair_image,
|
||||||
init_trans_chunk_queue,
|
//init_trans_chunk_queue,
|
||||||
).into_sequential_workload()
|
).into_sequential_workload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +134,7 @@ fn update() -> Workload {
|
||||||
(
|
(
|
||||||
debug_toggle_lock,
|
debug_toggle_lock,
|
||||||
update_window_size,
|
update_window_size,
|
||||||
|
resize_renderer,
|
||||||
update_cursor_lock_state,
|
update_cursor_lock_state,
|
||||||
process_inputs,
|
process_inputs,
|
||||||
kubi_ui_begin,
|
kubi_ui_begin,
|
||||||
|
@ -181,20 +176,20 @@ fn update() -> Workload {
|
||||||
).into_sequential_workload()
|
).into_sequential_workload()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render() -> Workload {
|
// fn render() -> Workload {
|
||||||
(
|
// (
|
||||||
clear_background,
|
// clear_background,
|
||||||
(
|
// (
|
||||||
draw_world,
|
// draw_world,
|
||||||
draw_current_chunk_border,
|
// draw_current_chunk_border,
|
||||||
render_selection_box,
|
// render_selection_box,
|
||||||
render_entities,
|
// render_entities,
|
||||||
draw_world_trans,
|
// draw_world_trans,
|
||||||
render_submerged_view,
|
// render_submerged_view,
|
||||||
).into_sequential_workload().run_if(is_ingame),
|
// ).into_sequential_workload().run_if(is_ingame),
|
||||||
kubi_ui_draw,
|
// kubi_ui_draw,
|
||||||
).into_sequential_workload()
|
// ).into_sequential_workload()
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn after_frame_end() -> Workload {
|
fn after_frame_end() -> Workload {
|
||||||
(
|
(
|
||||||
|
@ -244,7 +239,7 @@ pub fn kubi_main(
|
||||||
world.add_workload(pre_startup);
|
world.add_workload(pre_startup);
|
||||||
world.add_workload(startup);
|
world.add_workload(startup);
|
||||||
world.add_workload(update);
|
world.add_workload(update);
|
||||||
world.add_workload(render);
|
//world.add_workload(render);
|
||||||
world.add_workload(after_frame_end);
|
world.add_workload(after_frame_end);
|
||||||
|
|
||||||
//Save _visualizer.json
|
//Save _visualizer.json
|
||||||
|
@ -326,18 +321,18 @@ pub fn kubi_main(
|
||||||
world.run_workload(update).unwrap();
|
world.run_workload(update).unwrap();
|
||||||
|
|
||||||
//Start rendering (maybe use custom views for this?)
|
//Start rendering (maybe use custom views for this?)
|
||||||
let target = {
|
// let target = {
|
||||||
let renderer = world.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
// let renderer = world.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||||
renderer.display.draw()
|
// renderer.display.draw()
|
||||||
};
|
// };
|
||||||
world.add_unique_non_send_sync(RenderTarget(target));
|
// world.add_unique_non_send_sync(RenderTarget(target));
|
||||||
|
|
||||||
//Run render workflow
|
//Run render workflow
|
||||||
world.run_workload(render).unwrap();
|
//world.run_workload(render).unwrap();
|
||||||
|
|
||||||
//Finish rendering
|
//Finish rendering
|
||||||
let target = world.remove_unique::<RenderTarget>().unwrap();
|
// let target = world.remove_unique::<RenderTarget>().unwrap();
|
||||||
target.0.finish().unwrap();
|
// target.0.finish().unwrap();
|
||||||
|
|
||||||
//After frame end
|
//After frame end
|
||||||
world.run_workload(after_frame_end).unwrap();
|
world.run_workload(after_frame_end).unwrap();
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
use std::{io::{BufReader, Read}, path::Path};
|
use std::{io::{BufReader, Read}, path::Path};
|
||||||
use hui::text::FontHandle;
|
use hui::text::FontHandle;
|
||||||
use shipyard::{AllStoragesView, NonSendSync, Unique, UniqueView, UniqueViewMut};
|
use shipyard::{AllStoragesView, NonSendSync, Unique, UniqueView, UniqueViewMut};
|
||||||
use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program};
|
|
||||||
use kubi_shared::block::BlockTexture;
|
use kubi_shared::block::BlockTexture;
|
||||||
use crate::{filesystem::AssetManager, hui_integration::UiState, rendering::Renderer};
|
use crate::{filesystem::AssetManager, hui_integration::UiState, rendering::Renderer};
|
||||||
|
|
||||||
mod texture;
|
mod texture;
|
||||||
mod shaders;
|
mod shaders;
|
||||||
|
|
||||||
use texture::load_texture2darray_prefab;
|
//use texture::load_texture2darray_prefab;
|
||||||
use shaders::include_shader_prefab;
|
|
||||||
|
|
||||||
pub trait AssetPaths {
|
pub trait AssetPaths {
|
||||||
fn file_name(self) -> &'static str;
|
fn file_name(self) -> &'static str;
|
||||||
|
@ -41,7 +39,7 @@ impl AssetPaths for BlockTexture {
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct BlockTexturesPrefab(pub SrgbTexture2dArray);
|
pub struct BlockTexturesPrefab(pub wgpu::Texture);
|
||||||
|
|
||||||
// #[derive(Unique)]
|
// #[derive(Unique)]
|
||||||
// #[repr(transparent)]
|
// #[repr(transparent)]
|
||||||
|
@ -65,15 +63,15 @@ pub fn load_prefabs(
|
||||||
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
||||||
assman: UniqueView<AssetManager>
|
assman: UniqueView<AssetManager>
|
||||||
) {
|
) {
|
||||||
log::info!("Loading textures...");
|
// log::info!("Loading textures...");
|
||||||
storages.add_unique_non_send_sync(BlockTexturesPrefab(
|
// storages.add_unique_non_send_sync(BlockTexturesPrefab(
|
||||||
load_texture2darray_prefab::<BlockTexture, _>(
|
// load_texture2darray_prefab::<BlockTexture, _>(
|
||||||
&assman,
|
// &assman,
|
||||||
"blocks".into(),
|
// "blocks".into(),
|
||||||
&renderer.display,
|
// &renderer.display,
|
||||||
MipmapsOption::AutoGeneratedMipmaps
|
// MipmapsOption::AutoGeneratedMipmaps
|
||||||
)
|
// )
|
||||||
));
|
// ));
|
||||||
|
|
||||||
log::info!("Loading the UI stuff...");
|
log::info!("Loading the UI stuff...");
|
||||||
{
|
{
|
||||||
|
@ -85,33 +83,33 @@ pub fn load_prefabs(
|
||||||
storages.add_unique(UiFontPrefab(font_handle));
|
storages.add_unique(UiFontPrefab(font_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("Compiling shaders...");
|
//log::info!("Compiling shaders...");
|
||||||
storages.add_unique_non_send_sync(ChunkShaderPrefab(
|
// storages.add_unique_non_send_sync(ChunkShaderPrefab(
|
||||||
include_shader_prefab!(
|
// include_shader_prefab!(
|
||||||
"world",
|
// "world",
|
||||||
"../shaders/world.vert",
|
// "../shaders/world.vert",
|
||||||
"../shaders/world.frag",
|
// "../shaders/world.frag",
|
||||||
&renderer.display
|
// &renderer.display
|
||||||
)
|
// )
|
||||||
));
|
// ));
|
||||||
storages.add_unique_non_send_sync(ColoredShaderPrefab(
|
// storages.add_unique_non_send_sync(ColoredShaderPrefab(
|
||||||
include_shader_prefab!(
|
// include_shader_prefab!(
|
||||||
"colored",
|
// "colored",
|
||||||
"../shaders/colored.vert",
|
// "../shaders/colored.vert",
|
||||||
"../shaders/colored.frag",
|
// "../shaders/colored.frag",
|
||||||
&renderer.display
|
// &renderer.display
|
||||||
)
|
// )
|
||||||
));
|
// ));
|
||||||
storages.add_unique_non_send_sync(Colored2ShaderPrefab(
|
// storages.add_unique_non_send_sync(Colored2ShaderPrefab(
|
||||||
include_shader_prefab!(
|
// include_shader_prefab!(
|
||||||
"colored",
|
// "colored",
|
||||||
"../shaders/colored2.vert",
|
// "../shaders/colored2.vert",
|
||||||
"../shaders/colored2.frag",
|
// "../shaders/colored2.frag",
|
||||||
&renderer.display
|
// &renderer.display
|
||||||
)
|
// )
|
||||||
));
|
// ));
|
||||||
|
|
||||||
log::info!("releasing shader compiler");
|
//log::info!("releasing shader compiler");
|
||||||
|
|
||||||
//renderer.display.release_shader_compiler();
|
//renderer.display.release_shader_compiler();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +1,45 @@
|
||||||
use strum::IntoEnumIterator;
|
// use strum::IntoEnumIterator;
|
||||||
use rayon::prelude::*;
|
// use rayon::prelude::*;
|
||||||
use std::{path::PathBuf, io::BufReader};
|
// use std::{path::PathBuf, io::BufReader};
|
||||||
use glium::{texture::{SrgbTexture2dArray, RawImage2d, MipmapsOption}, backend::Facade};
|
// use crate::filesystem::AssetManager;
|
||||||
use crate::filesystem::AssetManager;
|
// use super::AssetPaths;
|
||||||
use super::AssetPaths;
|
|
||||||
|
// pub fn load_texture2darray_prefab<
|
||||||
pub fn load_texture2darray_prefab<
|
// T: AssetPaths + IntoEnumIterator,
|
||||||
T: AssetPaths + IntoEnumIterator,
|
// E: Facade
|
||||||
E: Facade
|
// >(
|
||||||
>(
|
// assman: &AssetManager,
|
||||||
assman: &AssetManager,
|
// directory: PathBuf,
|
||||||
directory: PathBuf,
|
// facade: &E,
|
||||||
facade: &E,
|
// mipmaps: MipmapsOption,
|
||||||
mipmaps: MipmapsOption,
|
// ) -> SrgbTexture2dArray {
|
||||||
) -> SrgbTexture2dArray {
|
// log::info!("started loading {}", directory.as_os_str().to_str().unwrap());
|
||||||
log::info!("started loading {}", directory.as_os_str().to_str().unwrap());
|
// //Load raw images
|
||||||
//Load raw images
|
// let tex_files: Vec<&'static str> = T::iter().map(|x| x.file_name()).collect();
|
||||||
let tex_files: Vec<&'static str> = T::iter().map(|x| x.file_name()).collect();
|
// let raw_images: Vec<RawImage2d<u8>> = tex_files.par_iter().map(|&file_name| {
|
||||||
let raw_images: Vec<RawImage2d<u8>> = tex_files.par_iter().map(|&file_name| {
|
// log::info!("loading texture {}", file_name);
|
||||||
log::info!("loading texture {}", file_name);
|
// //Get path to the image and open the file
|
||||||
//Get path to the image and open the file
|
// let reader = {
|
||||||
let reader = {
|
// let path = directory.join(file_name);
|
||||||
let path = directory.join(file_name);
|
// BufReader::new(assman.open_asset(&path).expect("Failed to open texture file"))
|
||||||
BufReader::new(assman.open_asset(&path).expect("Failed to open texture file"))
|
// };
|
||||||
};
|
// //Parse image data
|
||||||
//Parse image data
|
// let (image_data, dimensions) = {
|
||||||
let (image_data, dimensions) = {
|
// let image = image::load(
|
||||||
let image = image::load(
|
// reader,
|
||||||
reader,
|
// image::ImageFormat::Png
|
||||||
image::ImageFormat::Png
|
// ).unwrap().to_rgba8();
|
||||||
).unwrap().to_rgba8();
|
// let dimensions = image.dimensions();
|
||||||
let dimensions = image.dimensions();
|
// (image.into_raw(), dimensions)
|
||||||
(image.into_raw(), dimensions)
|
// };
|
||||||
};
|
// //Create a glium RawImage
|
||||||
//Create a glium RawImage
|
// RawImage2d::from_raw_rgba_reversed(
|
||||||
RawImage2d::from_raw_rgba_reversed(
|
// &image_data,
|
||||||
&image_data,
|
// dimensions
|
||||||
dimensions
|
// )
|
||||||
)
|
// }).collect();
|
||||||
}).collect();
|
// log::info!("done loading texture files, uploading to the gpu");
|
||||||
log::info!("done loading texture files, uploading to the gpu");
|
// //Upload images to the GPU
|
||||||
//Upload images to the GPU
|
// SrgbTexture2dArray::with_mipmaps(facade, raw_images, mipmaps)
|
||||||
SrgbTexture2dArray::with_mipmaps(facade, raw_images, mipmaps)
|
// .expect("Failed to upload texture array to GPU")
|
||||||
.expect("Failed to upload texture array to GPU")
|
// }
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use pollster::FutureExt;
|
use pollster::FutureExt;
|
||||||
use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, AllStoragesView};
|
use raw_window_handle::HasRawWindowHandle;
|
||||||
|
use shipyard::{AllStoragesView, AllStoragesViewMut, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||||
|
use wgpu::SurfaceTargetUnsafe;
|
||||||
use winit::{
|
use winit::{
|
||||||
event_loop::ActiveEventLoop,
|
event_loop::ActiveEventLoop,
|
||||||
window::{WindowAttributes, Fullscreen, Window},
|
window::{WindowAttributes, Fullscreen, Window},
|
||||||
|
@ -14,6 +16,11 @@ pub mod selection_box;
|
||||||
pub mod entities;
|
pub mod entities;
|
||||||
pub mod sumberge;
|
pub mod sumberge;
|
||||||
|
|
||||||
|
pub struct BufferPair {
|
||||||
|
pub index: wgpu::Buffer,
|
||||||
|
pub vertex: wgpu::Buffer,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct BackgroundColor(pub Vec3);
|
pub struct BackgroundColor(pub Vec3);
|
||||||
|
@ -26,14 +33,16 @@ pub struct WindowSize(pub UVec2);
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
pub struct Renderer {
|
pub struct Renderer {
|
||||||
pub window: Window,
|
instance: wgpu::Instance,
|
||||||
pub instance: wgpu::Instance,
|
surface: wgpu::Surface<'static>,
|
||||||
pub surface: wgpu::Surface<'static>,
|
device: wgpu::Device,
|
||||||
pub device: wgpu::Device,
|
queue: wgpu::Queue,
|
||||||
pub queue: wgpu::Queue,
|
surface_config: wgpu::SurfaceConfiguration,
|
||||||
pub surface_config: wgpu::SurfaceConfiguration,
|
size: PhysicalSize<u32>,
|
||||||
pub size: PhysicalSize<u32>,
|
|
||||||
// pub depth_texture: wgpu::Texture,
|
// pub depth_texture: wgpu::Texture,
|
||||||
|
|
||||||
|
//must be last due to drop order
|
||||||
|
window: Window,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Renderer {
|
impl Renderer {
|
||||||
|
@ -95,7 +104,11 @@ impl Renderer {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
let surface = instance.create_surface(window).unwrap();
|
// Create a surface with `create_surface_unsafe` to get a surface with 'static lifetime
|
||||||
|
// It should never outlive the window it's created from
|
||||||
|
let surface = unsafe {
|
||||||
|
instance.create_surface_unsafe(SurfaceTargetUnsafe::from_window(&window).unwrap()).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
let adapter = instance.request_adapter(
|
let adapter = instance.request_adapter(
|
||||||
&wgpu::RequestAdapterOptions {
|
&wgpu::RequestAdapterOptions {
|
||||||
|
@ -139,13 +152,89 @@ impl Renderer {
|
||||||
pub fn reconfigure(&self) {
|
pub fn reconfigure(&self) {
|
||||||
self.surface.configure(&self.device, &self.surface_config);
|
self.surface.configure(&self.device, &self.surface_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//getters:
|
||||||
|
pub fn size(&self) -> PhysicalSize<u32> {
|
||||||
|
self.size
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn window(&self) -> &Window {
|
||||||
|
&self.window
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn surface(&self) -> &wgpu::Surface<'static> {
|
||||||
|
&self.surface
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn device(&self) -> &wgpu::Device {
|
||||||
|
&self.device
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn queue(&self) -> &wgpu::Queue {
|
||||||
|
&self.queue
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn surface_config(&self) -> &wgpu::SurfaceConfiguration {
|
||||||
|
&self.surface_config
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_background(
|
pub fn render_master(storages: AllStoragesViewMut) {
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
let renderer = storages.borrow::<UniqueView<Renderer>>().unwrap();
|
||||||
color: UniqueView<BackgroundColor>,
|
|
||||||
|
let mut encoder = renderer.device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
||||||
|
label: Some("main_encoder"),
|
||||||
|
});
|
||||||
|
let surface_texture = renderer.surface().get_current_texture().unwrap();
|
||||||
|
let surface_view = surface_texture.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
|
||||||
|
{
|
||||||
|
let bg_color = storages.borrow::<UniqueView<BackgroundColor>>().unwrap();
|
||||||
|
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
|
label: Some("main0_pass"),
|
||||||
|
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||||
|
view: &surface_view,
|
||||||
|
resolve_target: None,
|
||||||
|
ops: wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(wgpu::Color {
|
||||||
|
r: bg_color.0.x as f64,
|
||||||
|
g: bg_color.0.y as f64,
|
||||||
|
b: bg_color.0.z as f64,
|
||||||
|
a: 1.0,
|
||||||
|
}),
|
||||||
|
store: wgpu::StoreOp::Store,
|
||||||
|
},
|
||||||
|
})],
|
||||||
|
depth_stencil_attachment: None,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
|
||||||
|
// render_pass.set_pipeline(&renderer.pipeline);
|
||||||
|
// render_pass.set_bind_group(0, &renderer.bind_group, &[]);
|
||||||
|
// render_pass.set_vertex_buffer(0, renderer.vertex_buffer.slice(..));
|
||||||
|
// render_pass.set_index_buffer(renderer.index_buffer.slice(..));
|
||||||
|
// render_pass.draw_indexed(0..renderer.num_indices, 0, 0..1);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.queue().submit(Some(encoder.finish()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// pub fn clear_background(
|
||||||
|
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
|
// color: UniqueView<BackgroundColor>,
|
||||||
|
// ) {
|
||||||
|
// target.0.clear_color_srgb_and_depth((color.0.x, color.0.y, color.0.z, 1.), 1.);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//Resize the renderer
|
||||||
|
|
||||||
|
pub fn resize_renderer(
|
||||||
|
mut renderer: UniqueViewMut<Renderer>,
|
||||||
|
resize: View<WindowResizedEvent>,
|
||||||
) {
|
) {
|
||||||
target.0.clear_color_srgb_and_depth((color.0.x, color.0.y, color.0.z, 1.), 1.);
|
if let Some(size) = resize.iter().last() {
|
||||||
|
renderer.resize(PhysicalSize::new(size.0.x, size.0.y));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//not sure if this belongs here
|
//not sure if this belongs here
|
||||||
|
|
|
@ -1,58 +1,58 @@
|
||||||
use shipyard::{NonSendSync, UniqueViewMut, UniqueView, View, IntoIter, IntoWithId};
|
// use shipyard::{NonSendSync, UniqueViewMut, UniqueView, View, IntoIter, IntoWithId};
|
||||||
use glium::{DepthTest, Depth, PolygonMode, BackfaceCullingMode, DrawParameters, Surface, uniform};
|
// use glium::{DepthTest, Depth, PolygonMode, BackfaceCullingMode, DrawParameters, Surface, uniform};
|
||||||
use kubi_shared::{entity::Entity, transform::Transform};
|
// use kubi_shared::{entity::Entity, transform::Transform};
|
||||||
use crate::{
|
// use crate::{
|
||||||
prefabs::ColoredShaderPrefab,
|
// prefabs::ColoredShaderPrefab,
|
||||||
camera::Camera,
|
// camera::Camera,
|
||||||
settings::GameSettings
|
// settings::GameSettings
|
||||||
};
|
// };
|
||||||
use super::{
|
// use super::{
|
||||||
RenderTarget,
|
// RenderTarget,
|
||||||
primitives::cube::CenteredCubePrimitive
|
// primitives::cube::CenteredCubePrimitive
|
||||||
};
|
// };
|
||||||
|
|
||||||
// TODO: entity models
|
// // TODO: entity models
|
||||||
pub fn render_entities(
|
// pub fn render_entities(
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
buffers: NonSendSync<UniqueView<CenteredCubePrimitive>>,
|
// buffers: NonSendSync<UniqueView<CenteredCubePrimitive>>,
|
||||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||||
camera: View<Camera>,
|
// camera: View<Camera>,
|
||||||
settings: UniqueView<GameSettings>,
|
// settings: UniqueView<GameSettings>,
|
||||||
entities: View<Entity>,
|
// entities: View<Entity>,
|
||||||
transform: View<Transform>,
|
// transform: View<Transform>,
|
||||||
) {
|
// ) {
|
||||||
let (camera_id, camera) = camera.iter().with_id().next().expect("No cameras in the scene");
|
// let (camera_id, camera) = camera.iter().with_id().next().expect("No cameras in the scene");
|
||||||
|
|
||||||
let draw_parameters = DrawParameters {
|
// let draw_parameters = DrawParameters {
|
||||||
depth: Depth {
|
// depth: Depth {
|
||||||
test: DepthTest::IfLess,
|
// test: DepthTest::IfLess,
|
||||||
write: true,
|
// write: true,
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
},
|
// },
|
||||||
multisampling: settings.msaa.is_some(),
|
// multisampling: settings.msaa.is_some(),
|
||||||
polygon_mode: PolygonMode::Fill,
|
// polygon_mode: PolygonMode::Fill,
|
||||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
};
|
// };
|
||||||
let view = camera.view_matrix.to_cols_array_2d();
|
// let view = camera.view_matrix.to_cols_array_2d();
|
||||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||||
|
|
||||||
for (entity_id, (_, trans)) in (&entities, &transform).iter().with_id() {
|
// for (entity_id, (_, trans)) in (&entities, &transform).iter().with_id() {
|
||||||
//skip rendering camera holder (as the entity would block the view)
|
// //skip rendering camera holder (as the entity would block the view)
|
||||||
if entity_id == camera_id { continue }
|
// if entity_id == camera_id { continue }
|
||||||
|
|
||||||
//render entity
|
// //render entity
|
||||||
target.0.draw(
|
// target.0.draw(
|
||||||
&buffers.0,
|
// &buffers.0,
|
||||||
&buffers.1,
|
// &buffers.1,
|
||||||
&program.0,
|
// &program.0,
|
||||||
&uniform! {
|
// &uniform! {
|
||||||
color: [1.0, 1.0, 1.0, 1.0_f32],
|
// color: [1.0, 1.0, 1.0, 1.0_f32],
|
||||||
model: trans.0.to_cols_array_2d(),
|
// model: trans.0.to_cols_array_2d(),
|
||||||
view: view,
|
// view: view,
|
||||||
perspective: perspective,
|
// perspective: perspective,
|
||||||
},
|
// },
|
||||||
&draw_parameters
|
// &draw_parameters
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
use shipyard::{Workload, IntoWorkload};
|
// use shipyard::{Workload, IntoWorkload};
|
||||||
use glium::implement_vertex;
|
// use glium::implement_vertex;
|
||||||
|
|
||||||
pub mod cube;
|
// pub mod cube;
|
||||||
pub mod rect;
|
// pub mod rect;
|
||||||
pub mod stri;
|
// pub mod stri;
|
||||||
|
|
||||||
use cube::init_cube_primitive;
|
// use cube::init_cube_primitive;
|
||||||
use rect::init_rect_primitive;
|
// use rect::init_rect_primitive;
|
||||||
use stri::init_stri_primitive;
|
// use stri::init_stri_primitive;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default)]
|
// #[derive(Clone, Copy, Default)]
|
||||||
pub struct PositionOnlyVertex {
|
// pub struct PositionOnlyVertex {
|
||||||
pub position: [f32; 3],
|
// pub position: [f32; 3],
|
||||||
}
|
// }
|
||||||
implement_vertex!(PositionOnlyVertex, position);
|
// implement_vertex!(PositionOnlyVertex, position);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default)]
|
// #[derive(Clone, Copy, Default)]
|
||||||
pub struct PositionOnlyVertex2d {
|
// pub struct PositionOnlyVertex2d {
|
||||||
pub position: [f32; 2],
|
// pub position: [f32; 2],
|
||||||
}
|
// }
|
||||||
implement_vertex!(PositionOnlyVertex2d, position);
|
// implement_vertex!(PositionOnlyVertex2d, position);
|
||||||
|
|
||||||
pub fn init_primitives() -> Workload {
|
// pub fn init_primitives() -> Workload {
|
||||||
(
|
// (
|
||||||
init_cube_primitive,
|
// init_cube_primitive,
|
||||||
init_rect_primitive,
|
// init_rect_primitive,
|
||||||
init_stri_primitive,
|
// init_stri_primitive,
|
||||||
).into_workload()
|
// ).into_workload()
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,85 +1,85 @@
|
||||||
use shipyard::{AllStoragesView, NonSendSync, UniqueView, Unique};
|
// use shipyard::{AllStoragesView, NonSendSync, UniqueView, Unique};
|
||||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||||
use crate::rendering::Renderer;
|
// use crate::rendering::Renderer;
|
||||||
use super::PositionOnlyVertex;
|
// use super::PositionOnlyVertex;
|
||||||
|
|
||||||
#[derive(Unique)]
|
// #[derive(Unique)]
|
||||||
pub struct CubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
// pub struct CubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||||
|
|
||||||
#[derive(Unique)]
|
// #[derive(Unique)]
|
||||||
pub struct CenteredCubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
// pub struct CenteredCubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||||
|
|
||||||
const CENTERED_CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
// const CENTERED_CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||||
// front
|
// // front
|
||||||
PositionOnlyVertex { position: [-0.5, -0.5, 0.5] },
|
// PositionOnlyVertex { position: [-0.5, -0.5, 0.5] },
|
||||||
PositionOnlyVertex { position: [ 0.5, -0.5, 0.5] },
|
// PositionOnlyVertex { position: [ 0.5, -0.5, 0.5] },
|
||||||
PositionOnlyVertex { position: [ 0.5, 0.5, 0.5] },
|
// PositionOnlyVertex { position: [ 0.5, 0.5, 0.5] },
|
||||||
PositionOnlyVertex { position: [-0.5, 0.5, 0.5] },
|
// PositionOnlyVertex { position: [-0.5, 0.5, 0.5] },
|
||||||
// back
|
// // back
|
||||||
PositionOnlyVertex { position: [-0.5, -0.5, -0.5] },
|
// PositionOnlyVertex { position: [-0.5, -0.5, -0.5] },
|
||||||
PositionOnlyVertex { position: [ 0.5, -0.5, -0.5] },
|
// PositionOnlyVertex { position: [ 0.5, -0.5, -0.5] },
|
||||||
PositionOnlyVertex { position: [ 0.5, 0.5, -0.5] },
|
// PositionOnlyVertex { position: [ 0.5, 0.5, -0.5] },
|
||||||
PositionOnlyVertex { position: [-0.5, 0.5, -0.5] },
|
// PositionOnlyVertex { position: [-0.5, 0.5, -0.5] },
|
||||||
];
|
// ];
|
||||||
const CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
// const CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||||
// front
|
// // front
|
||||||
PositionOnlyVertex { position: [0.0, 0.0, 1.0] },
|
// PositionOnlyVertex { position: [0.0, 0.0, 1.0] },
|
||||||
PositionOnlyVertex { position: [1.0, 0.0, 1.0] },
|
// PositionOnlyVertex { position: [1.0, 0.0, 1.0] },
|
||||||
PositionOnlyVertex { position: [1.0, 1.0, 1.0] },
|
// PositionOnlyVertex { position: [1.0, 1.0, 1.0] },
|
||||||
PositionOnlyVertex { position: [0.0, 1.0, 1.0] },
|
// PositionOnlyVertex { position: [0.0, 1.0, 1.0] },
|
||||||
// back
|
// // back
|
||||||
PositionOnlyVertex { position: [0.0, 0.0, 0.0] },
|
// PositionOnlyVertex { position: [0.0, 0.0, 0.0] },
|
||||||
PositionOnlyVertex { position: [1.0, 0.0, 0.0] },
|
// PositionOnlyVertex { position: [1.0, 0.0, 0.0] },
|
||||||
PositionOnlyVertex { position: [1.0, 1.0, 0.0] },
|
// PositionOnlyVertex { position: [1.0, 1.0, 0.0] },
|
||||||
PositionOnlyVertex { position: [0.0, 1.0, 0.0] },
|
// PositionOnlyVertex { position: [0.0, 1.0, 0.0] },
|
||||||
];
|
// ];
|
||||||
const CUBE_INDICES: &[u16] = &[
|
// const CUBE_INDICES: &[u16] = &[
|
||||||
// front
|
// // front
|
||||||
0, 1, 2,
|
// 0, 1, 2,
|
||||||
2, 3, 0,
|
// 2, 3, 0,
|
||||||
// right
|
// // right
|
||||||
1, 5, 6,
|
// 1, 5, 6,
|
||||||
6, 2, 1,
|
// 6, 2, 1,
|
||||||
// back
|
// // back
|
||||||
7, 6, 5,
|
// 7, 6, 5,
|
||||||
5, 4, 7,
|
// 5, 4, 7,
|
||||||
// left
|
// // left
|
||||||
4, 0, 3,
|
// 4, 0, 3,
|
||||||
3, 7, 4,
|
// 3, 7, 4,
|
||||||
// bottom
|
// // bottom
|
||||||
4, 5, 1,
|
// 4, 5, 1,
|
||||||
1, 0, 4,
|
// 1, 0, 4,
|
||||||
// top
|
// // top
|
||||||
3, 2, 6,
|
// 3, 2, 6,
|
||||||
6, 7, 3
|
// 6, 7, 3
|
||||||
];
|
// ];
|
||||||
|
|
||||||
pub(super) fn init_cube_primitive(
|
// pub(super) fn init_cube_primitive(
|
||||||
storages: AllStoragesView,
|
// storages: AllStoragesView,
|
||||||
display: NonSendSync<UniqueView<Renderer>>
|
// display: NonSendSync<UniqueView<Renderer>>
|
||||||
) {
|
// ) {
|
||||||
{
|
// {
|
||||||
let vert = VertexBuffer::immutable(
|
// let vert = VertexBuffer::immutable(
|
||||||
&display.display,
|
// &display.display,
|
||||||
CUBE_VERTICES
|
// CUBE_VERTICES
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
let index = IndexBuffer::immutable(
|
// let index = IndexBuffer::immutable(
|
||||||
&display.display,
|
// &display.display,
|
||||||
PrimitiveType::TrianglesList,
|
// PrimitiveType::TrianglesList,
|
||||||
CUBE_INDICES
|
// CUBE_INDICES
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
storages.add_unique_non_send_sync(CubePrimitive(vert, index));
|
// storages.add_unique_non_send_sync(CubePrimitive(vert, index));
|
||||||
}
|
// }
|
||||||
{
|
// {
|
||||||
let vert = VertexBuffer::immutable(
|
// let vert = VertexBuffer::immutable(
|
||||||
&display.display,
|
// &display.display,
|
||||||
CENTERED_CUBE_VERTICES
|
// CENTERED_CUBE_VERTICES
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
let index = IndexBuffer::immutable(
|
// let index = IndexBuffer::immutable(
|
||||||
&display.display,
|
// &display.display,
|
||||||
PrimitiveType::TrianglesList,
|
// PrimitiveType::TrianglesList,
|
||||||
CUBE_INDICES
|
// CUBE_INDICES
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
storages.add_unique_non_send_sync(CenteredCubePrimitive(vert, index));
|
// storages.add_unique_non_send_sync(CenteredCubePrimitive(vert, index));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
// use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||||
use crate::rendering::Renderer;
|
// use crate::rendering::Renderer;
|
||||||
use super::PositionOnlyVertex2d;
|
// use super::PositionOnlyVertex2d;
|
||||||
|
|
||||||
#[derive(Unique)]
|
// #[derive(Unique)]
|
||||||
pub struct RectPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
// pub struct RectPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||||
|
|
||||||
const RECT_VERTEX: &[PositionOnlyVertex2d] = &[
|
// const RECT_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||||
PositionOnlyVertex2d { position: [0., 0.] },
|
// PositionOnlyVertex2d { position: [0., 0.] },
|
||||||
PositionOnlyVertex2d { position: [1., 0.] },
|
// PositionOnlyVertex2d { position: [1., 0.] },
|
||||||
PositionOnlyVertex2d { position: [0., 1.] },
|
// PositionOnlyVertex2d { position: [0., 1.] },
|
||||||
PositionOnlyVertex2d { position: [1., 1.] },
|
// PositionOnlyVertex2d { position: [1., 1.] },
|
||||||
];
|
// ];
|
||||||
const RECT_INDEX: &[u16] = &[0, 1, 2, 1, 3, 2];
|
// const RECT_INDEX: &[u16] = &[0, 1, 2, 1, 3, 2];
|
||||||
|
|
||||||
pub(super) fn init_rect_primitive(
|
// pub(super) fn init_rect_primitive(
|
||||||
storages: AllStoragesView,
|
// storages: AllStoragesView,
|
||||||
display: NonSendSync<UniqueView<Renderer>>
|
// display: NonSendSync<UniqueView<Renderer>>
|
||||||
) {
|
// ) {
|
||||||
let vert = VertexBuffer::immutable(
|
// let vert = VertexBuffer::immutable(
|
||||||
&display.display,
|
// &display.display,
|
||||||
RECT_VERTEX
|
// RECT_VERTEX
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
let index = IndexBuffer::immutable(
|
// let index = IndexBuffer::immutable(
|
||||||
&display.display,
|
// &display.display,
|
||||||
PrimitiveType::TrianglesList,
|
// PrimitiveType::TrianglesList,
|
||||||
RECT_INDEX
|
// RECT_INDEX
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
storages.add_unique_non_send_sync(RectPrimitive(vert, index));
|
// storages.add_unique_non_send_sync(RectPrimitive(vert, index));
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
// use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||||
use crate::rendering::Renderer;
|
// use crate::rendering::Renderer;
|
||||||
use super::PositionOnlyVertex2d;
|
// use super::PositionOnlyVertex2d;
|
||||||
|
|
||||||
#[derive(Unique)]
|
// #[derive(Unique)]
|
||||||
pub struct STriPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
// pub struct STriPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||||
|
|
||||||
const STRI_VERTEX: &[PositionOnlyVertex2d] = &[
|
// const STRI_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||||
PositionOnlyVertex2d { position: [-1., -1.] },
|
// PositionOnlyVertex2d { position: [-1., -1.] },
|
||||||
PositionOnlyVertex2d { position: [ 3., -1.] },
|
// PositionOnlyVertex2d { position: [ 3., -1.] },
|
||||||
PositionOnlyVertex2d { position: [-1., 3.] },
|
// PositionOnlyVertex2d { position: [-1., 3.] },
|
||||||
];
|
// ];
|
||||||
const STRI_INDEX: &[u16] = &[0, 1, 2];
|
// const STRI_INDEX: &[u16] = &[0, 1, 2];
|
||||||
|
|
||||||
pub(super) fn init_stri_primitive(
|
// pub(super) fn init_stri_primitive(
|
||||||
storages: AllStoragesView,
|
// storages: AllStoragesView,
|
||||||
display: NonSendSync<UniqueView<Renderer>>
|
// display: NonSendSync<UniqueView<Renderer>>
|
||||||
) {
|
// ) {
|
||||||
let vert = VertexBuffer::immutable(
|
// let vert = VertexBuffer::immutable(
|
||||||
&display.display,
|
// &display.display,
|
||||||
STRI_VERTEX
|
// STRI_VERTEX
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
let index = IndexBuffer::immutable(
|
// let index = IndexBuffer::immutable(
|
||||||
&display.display,
|
// &display.display,
|
||||||
PrimitiveType::TrianglesList,
|
// PrimitiveType::TrianglesList,
|
||||||
STRI_INDEX
|
// STRI_INDEX
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
storages.add_unique_non_send_sync(STriPrimitive(vert, index));
|
// storages.add_unique_non_send_sync(STriPrimitive(vert, index));
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
use glam::{Mat4, Vec3, Quat};
|
// use glam::{Mat4, Vec3, Quat};
|
||||||
use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut, UniqueView};
|
// use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut, UniqueView};
|
||||||
use glium::{
|
// use glium::{
|
||||||
Surface,
|
// Surface,
|
||||||
DrawParameters,
|
// DrawParameters,
|
||||||
BackfaceCullingMode,
|
// BackfaceCullingMode,
|
||||||
Blend, Depth, DepthTest,
|
// Blend, Depth, DepthTest,
|
||||||
uniform,
|
// uniform,
|
||||||
};
|
// };
|
||||||
use crate::{
|
// use crate::{
|
||||||
world::raycast::LookingAtBlock,
|
// world::raycast::LookingAtBlock,
|
||||||
camera::Camera,
|
// camera::Camera,
|
||||||
prefabs::ColoredShaderPrefab
|
// prefabs::ColoredShaderPrefab
|
||||||
};
|
// };
|
||||||
use super::{
|
// use super::{
|
||||||
RenderTarget,
|
// RenderTarget,
|
||||||
primitives::cube::CubePrimitive,
|
// primitives::cube::CubePrimitive,
|
||||||
};
|
// };
|
||||||
|
|
||||||
const SMOL: f32 = 0.0025;
|
// const SMOL: f32 = 0.0025;
|
||||||
|
|
||||||
pub fn render_selection_box(
|
// pub fn render_selection_box(
|
||||||
lookat: View<LookingAtBlock>,
|
// lookat: View<LookingAtBlock>,
|
||||||
camera: View<Camera>,
|
// camera: View<Camera>,
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||||
buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
// buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||||
) {
|
// ) {
|
||||||
let camera = camera.iter().next().unwrap();
|
// let camera = camera.iter().next().unwrap();
|
||||||
let Some(lookat) = lookat.iter().next() else { return };
|
// let Some(lookat) = lookat.iter().next() else { return };
|
||||||
let Some(lookat) = lookat.0 else { return };
|
// let Some(lookat) = lookat.0 else { return };
|
||||||
|
|
||||||
//Darken block
|
// //Darken block
|
||||||
target.0.draw(
|
// target.0.draw(
|
||||||
&buffers.0,
|
// &buffers.0,
|
||||||
&buffers.1,
|
// &buffers.1,
|
||||||
&program.0,
|
// &program.0,
|
||||||
&uniform! {
|
// &uniform! {
|
||||||
color: [0., 0., 0., 0.5_f32],
|
// color: [0., 0., 0., 0.5_f32],
|
||||||
model: Mat4::from_scale_rotation_translation(
|
// model: Mat4::from_scale_rotation_translation(
|
||||||
Vec3::splat(1. + SMOL * 2.),
|
// Vec3::splat(1. + SMOL * 2.),
|
||||||
Quat::default(),
|
// Quat::default(),
|
||||||
lookat.block_position.as_vec3() - Vec3::splat(SMOL)
|
// lookat.block_position.as_vec3() - Vec3::splat(SMOL)
|
||||||
).to_cols_array_2d(),
|
// ).to_cols_array_2d(),
|
||||||
perspective: camera.perspective_matrix.to_cols_array_2d(),
|
// perspective: camera.perspective_matrix.to_cols_array_2d(),
|
||||||
view: camera.view_matrix.to_cols_array_2d(),
|
// view: camera.view_matrix.to_cols_array_2d(),
|
||||||
},
|
// },
|
||||||
&DrawParameters {
|
// &DrawParameters {
|
||||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||||
blend: Blend::alpha_blending(),
|
// blend: Blend::alpha_blending(),
|
||||||
depth: Depth {
|
// depth: Depth {
|
||||||
//this may be unreliable... unless scale is applied! hacky...
|
// //this may be unreliable... unless scale is applied! hacky...
|
||||||
test: DepthTest::IfLessOrEqual,
|
// test: DepthTest::IfLessOrEqual,
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
},
|
// },
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
}
|
// }
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
use glium::{uniform, Blend, DrawParameters, Surface};
|
// use glium::{uniform, Blend, DrawParameters, Surface};
|
||||||
use kubi_shared::transform::Transform;
|
// use kubi_shared::transform::Transform;
|
||||||
use shipyard::{IntoIter, NonSendSync, UniqueView, UniqueViewMut, View};
|
// use shipyard::{IntoIter, NonSendSync, UniqueView, UniqueViewMut, View};
|
||||||
use crate::{
|
// use crate::{
|
||||||
player::MainPlayer,
|
// player::MainPlayer,
|
||||||
prefabs::Colored2ShaderPrefab,
|
// prefabs::Colored2ShaderPrefab,
|
||||||
rendering::primitives::stri::STriPrimitive,
|
// rendering::primitives::stri::STriPrimitive,
|
||||||
world::ChunkStorage,
|
// world::ChunkStorage,
|
||||||
};
|
// };
|
||||||
use super::RenderTarget;
|
// use super::RenderTarget;
|
||||||
|
|
||||||
pub fn render_submerged_view(
|
// pub fn render_submerged_view(
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
primitive: NonSendSync<UniqueView<STriPrimitive>>,
|
// primitive: NonSendSync<UniqueView<STriPrimitive>>,
|
||||||
program: NonSendSync<UniqueView<Colored2ShaderPrefab>>,
|
// program: NonSendSync<UniqueView<Colored2ShaderPrefab>>,
|
||||||
plr: View<MainPlayer>,
|
// plr: View<MainPlayer>,
|
||||||
trans: View<Transform>,
|
// trans: View<Transform>,
|
||||||
world: UniqueView<ChunkStorage>,
|
// world: UniqueView<ChunkStorage>,
|
||||||
) {
|
// ) {
|
||||||
let (_, plr_trans) = (&plr, &trans).iter().next().expect("Main player MIA");
|
// let (_, plr_trans) = (&plr, &trans).iter().next().expect("Main player MIA");
|
||||||
let plr_pos = plr_trans.0.to_scale_rotation_translation().2;
|
// let plr_pos = plr_trans.0.to_scale_rotation_translation().2;
|
||||||
let block_at_pos = world.get_block(plr_pos.floor().as_ivec3());
|
// let block_at_pos = world.get_block(plr_pos.floor().as_ivec3());
|
||||||
let Some(block_at_pos) = block_at_pos else { return };
|
// let Some(block_at_pos) = block_at_pos else { return };
|
||||||
let Some(color) = block_at_pos.descriptor().submerge else { return };
|
// let Some(color) = block_at_pos.descriptor().submerge else { return };
|
||||||
|
|
||||||
let draw_parameters = DrawParameters {
|
// let draw_parameters = DrawParameters {
|
||||||
blend: Blend::alpha_blending(),
|
// blend: Blend::alpha_blending(),
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
};
|
// };
|
||||||
target.0.draw(
|
// target.0.draw(
|
||||||
&primitive.0,
|
// &primitive.0,
|
||||||
&primitive.1,
|
// &primitive.1,
|
||||||
&program.0,
|
// &program.0,
|
||||||
&uniform! {
|
// &uniform! {
|
||||||
color: color.to_array(),
|
// color: color.to_array(),
|
||||||
},
|
// },
|
||||||
&draw_parameters,
|
// &draw_parameters,
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
use glam::{ivec3, IVec3, Mat4, Quat, Vec3};
|
// use glam::{ivec3, IVec3, Mat4, Quat, Vec3};
|
||||||
use shipyard::{track, AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
// use shipyard::{track, AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||||
use glium::{
|
// use glium::{
|
||||||
draw_parameters::{
|
// draw_parameters::{
|
||||||
BackfaceCullingMode, Depth, DepthTest, PolygonMode
|
// BackfaceCullingMode, Depth, DepthTest, PolygonMode
|
||||||
}, implement_vertex, uniform, uniforms::{
|
// }, implement_vertex, uniform, uniforms::{
|
||||||
MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerBehavior, SamplerWrapFunction
|
// MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerBehavior, SamplerWrapFunction
|
||||||
}, Blend, DrawParameters, Smooth, Surface
|
// }, Blend, DrawParameters, Smooth, Surface
|
||||||
};
|
// };
|
||||||
use crate::{
|
// use crate::{
|
||||||
camera::Camera,
|
// camera::Camera,
|
||||||
player::MainPlayer,
|
// player::MainPlayer,
|
||||||
transform::Transform,
|
// transform::Transform,
|
||||||
prefabs::{
|
// prefabs::{
|
||||||
ChunkShaderPrefab,
|
// ChunkShaderPrefab,
|
||||||
BlockTexturesPrefab,
|
// BlockTexturesPrefab,
|
||||||
ColoredShaderPrefab,
|
// ColoredShaderPrefab,
|
||||||
},
|
// },
|
||||||
world::{
|
// world::{
|
||||||
ChunkStorage,
|
// ChunkStorage,
|
||||||
ChunkMeshStorage,
|
// ChunkMeshStorage,
|
||||||
chunk::CHUNK_SIZE,
|
// chunk::CHUNK_SIZE,
|
||||||
}, settings::GameSettings,
|
// }, settings::GameSettings,
|
||||||
};
|
// };
|
||||||
use super::{RenderTarget, primitives::cube::CubePrimitive};
|
// use super::{RenderTarget, primitives::cube::CubePrimitive};
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -32,217 +32,216 @@ pub struct ChunkVertex {
|
||||||
pub uv: [f32; 2],
|
pub uv: [f32; 2],
|
||||||
pub tex_index: u8,
|
pub tex_index: u8,
|
||||||
}
|
}
|
||||||
implement_vertex!(ChunkVertex, position, normal, uv, tex_index);
|
|
||||||
|
|
||||||
#[derive(Unique)]
|
// #[derive(Unique)]
|
||||||
pub struct TransChunkQueue(pub Vec<IVec3>);
|
// pub struct TransChunkQueue(pub Vec<IVec3>);
|
||||||
|
|
||||||
pub fn init_trans_chunk_queue(storages: AllStoragesView) {
|
// pub fn init_trans_chunk_queue(storages: AllStoragesView) {
|
||||||
storages.add_unique(TransChunkQueue(Vec::with_capacity(512)));
|
// storages.add_unique(TransChunkQueue(Vec::with_capacity(512)));
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn draw_params(settings: &GameSettings) -> DrawParameters {
|
// fn draw_params(settings: &GameSettings) -> DrawParameters {
|
||||||
DrawParameters {
|
// DrawParameters {
|
||||||
depth: Depth {
|
// depth: Depth {
|
||||||
test: DepthTest::IfLess,
|
// test: DepthTest::IfLess,
|
||||||
write: true,
|
// write: true,
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
},
|
// },
|
||||||
multisampling: settings.msaa.is_some(),
|
// multisampling: settings.msaa.is_some(),
|
||||||
polygon_mode: PolygonMode::Fill, //Change to Line for wireframe
|
// polygon_mode: PolygonMode::Fill, //Change to Line for wireframe
|
||||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn texture_sampler<'a, T>(texture: &'a T, settings: &GameSettings) -> Sampler<'a, T> {
|
// fn texture_sampler<'a, T>(texture: &'a T, settings: &GameSettings) -> Sampler<'a, T> {
|
||||||
Sampler(texture, SamplerBehavior {
|
// Sampler(texture, SamplerBehavior {
|
||||||
minify_filter: MinifySamplerFilter::LinearMipmapLinear,
|
// minify_filter: MinifySamplerFilter::LinearMipmapLinear,
|
||||||
magnify_filter: MagnifySamplerFilter::Nearest,
|
// magnify_filter: MagnifySamplerFilter::Nearest,
|
||||||
max_anisotropy: settings.max_anisotropy.unwrap_or_default(),
|
// max_anisotropy: settings.max_anisotropy.unwrap_or_default(),
|
||||||
wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp),
|
// wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp),
|
||||||
depth_texture_comparison: None,
|
// depth_texture_comparison: None,
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn draw_world(
|
// pub fn draw_world(
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
chunks: UniqueView<ChunkStorage>,
|
// chunks: UniqueView<ChunkStorage>,
|
||||||
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
// meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||||
program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
// program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||||
texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
// texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||||
transform: View<Transform>,
|
// transform: View<Transform>,
|
||||||
camera: View<Camera>,
|
// camera: View<Camera>,
|
||||||
settings: UniqueView<GameSettings>,
|
// settings: UniqueView<GameSettings>,
|
||||||
mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
// mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||||
) {
|
// ) {
|
||||||
// let (camera, transform) = (&camera, &transform).iter().next().expect("No cameras in the scene");
|
// // let (camera, transform) = (&camera, &transform).iter().next().expect("No cameras in the scene");
|
||||||
// let camera_position = transform.0.to_scale_rotation_translation().2;
|
// // let camera_position = transform.0.to_scale_rotation_translation().2;
|
||||||
|
|
||||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||||
let view = camera.view_matrix.to_cols_array_2d();
|
// let view = camera.view_matrix.to_cols_array_2d();
|
||||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||||
|
|
||||||
let draw_parameters = draw_params(&settings);
|
// let draw_parameters = draw_params(&settings);
|
||||||
let texture_sampler = texture_sampler(&texture.0, &settings);
|
// let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||||
|
|
||||||
for (&position, chunk) in &chunks.chunks {
|
// for (&position, chunk) in &chunks.chunks {
|
||||||
if let Some(key) = chunk.mesh_index {
|
// if let Some(key) = chunk.mesh_index {
|
||||||
let mesh = meshes.get(key).expect("Mesh index pointing to nothing");
|
// let mesh = meshes.get(key).expect("Mesh index pointing to nothing");
|
||||||
let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
// let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||||
|
|
||||||
//Skip mesh if its empty
|
// //Skip mesh if its empty
|
||||||
if mesh.index_buffer.len() == 0 && mesh.trans_index_buffer.len() == 0 {
|
// if mesh.index_buffer.len() == 0 && mesh.trans_index_buffer.len() == 0 {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Frustum culling
|
// //Frustum culling
|
||||||
{
|
// {
|
||||||
let minp = world_position;
|
// let minp = world_position;
|
||||||
let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32);
|
// let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32);
|
||||||
if !camera.frustum.is_box_visible(minp, maxp) {
|
// if !camera.frustum.is_box_visible(minp, maxp) {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Draw chunk mesh
|
// //Draw chunk mesh
|
||||||
if mesh.index_buffer.len() > 0 {
|
// if mesh.index_buffer.len() > 0 {
|
||||||
target.0.draw(
|
// target.0.draw(
|
||||||
&mesh.vertex_buffer,
|
// &mesh.vertex_buffer,
|
||||||
&mesh.index_buffer,
|
// &mesh.index_buffer,
|
||||||
&program.0,
|
// &program.0,
|
||||||
&uniform! {
|
// &uniform! {
|
||||||
position_offset: world_position.to_array(),
|
// position_offset: world_position.to_array(),
|
||||||
view: view,
|
// view: view,
|
||||||
perspective: perspective,
|
// perspective: perspective,
|
||||||
tex: texture_sampler,
|
// tex: texture_sampler,
|
||||||
discard_alpha: true,
|
// discard_alpha: true,
|
||||||
},
|
// },
|
||||||
&draw_parameters
|
// &draw_parameters
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if mesh.trans_index_buffer.len() > 0 {
|
// if mesh.trans_index_buffer.len() > 0 {
|
||||||
trans_queue.0.push(position);
|
// trans_queue.0.push(position);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// const HALF_CHUNK_SIZE: IVec3 = IVec3::splat((CHUNK_SIZE >> 1) as i32);
|
// // const HALF_CHUNK_SIZE: IVec3 = IVec3::splat((CHUNK_SIZE >> 1) as i32);
|
||||||
// trans_queue.0.sort_by_cached_key(|&pos| -(
|
// // trans_queue.0.sort_by_cached_key(|&pos| -(
|
||||||
// (pos + HALF_CHUNK_SIZE).distance_squared(camera_position.as_ivec3())
|
// // (pos + HALF_CHUNK_SIZE).distance_squared(camera_position.as_ivec3())
|
||||||
// ));
|
// // ));
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn draw_world_trans(
|
// pub fn draw_world_trans(
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
chunks: UniqueView<ChunkStorage>,
|
// chunks: UniqueView<ChunkStorage>,
|
||||||
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
// meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||||
program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
// program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||||
texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
// texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||||
camera: View<Camera>,
|
// camera: View<Camera>,
|
||||||
settings: UniqueView<GameSettings>,
|
// settings: UniqueView<GameSettings>,
|
||||||
mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
// mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||||
) {
|
// ) {
|
||||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||||
let view = camera.view_matrix.to_cols_array_2d();
|
// let view = camera.view_matrix.to_cols_array_2d();
|
||||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||||
|
|
||||||
let mut draw_parameters = draw_params(&settings);
|
// let mut draw_parameters = draw_params(&settings);
|
||||||
draw_parameters.blend = Blend::alpha_blending();
|
// draw_parameters.blend = Blend::alpha_blending();
|
||||||
draw_parameters.backface_culling = BackfaceCullingMode::CullingDisabled;
|
// draw_parameters.backface_culling = BackfaceCullingMode::CullingDisabled;
|
||||||
draw_parameters.smooth = Some(Smooth::Fastest);
|
// draw_parameters.smooth = Some(Smooth::Fastest);
|
||||||
|
|
||||||
let texture_sampler = texture_sampler(&texture.0, &settings);
|
// let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||||
|
|
||||||
for position in trans_queue.0.drain(..).rev() {
|
// for position in trans_queue.0.drain(..).rev() {
|
||||||
let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
// let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||||
let mesh_idx = chunks.chunks[&position].mesh_index.expect("No mesh index");
|
// let mesh_idx = chunks.chunks[&position].mesh_index.expect("No mesh index");
|
||||||
let mesh = meshes.get(mesh_idx).expect("Mesh index pointing to nothing");
|
// let mesh = meshes.get(mesh_idx).expect("Mesh index pointing to nothing");
|
||||||
target.0.draw(
|
// target.0.draw(
|
||||||
&mesh.trans_vertex_buffer,
|
// &mesh.trans_vertex_buffer,
|
||||||
&mesh.trans_index_buffer,
|
// &mesh.trans_index_buffer,
|
||||||
&program.0,
|
// &program.0,
|
||||||
&uniform! {
|
// &uniform! {
|
||||||
position_offset: world_position.to_array(),
|
// position_offset: world_position.to_array(),
|
||||||
view: view,
|
// view: view,
|
||||||
perspective: perspective,
|
// perspective: perspective,
|
||||||
tex: texture_sampler,
|
// tex: texture_sampler,
|
||||||
discard_alpha: false,
|
// discard_alpha: false,
|
||||||
},
|
// },
|
||||||
&draw_parameters
|
// &draw_parameters
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn draw_current_chunk_border(
|
// pub fn draw_current_chunk_border(
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
player: View<MainPlayer>,
|
// player: View<MainPlayer>,
|
||||||
transforms: View<Transform, track::All>,
|
// transforms: View<Transform, track::All>,
|
||||||
buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
// buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||||
camera: View<Camera>,
|
// camera: View<Camera>,
|
||||||
settings: UniqueView<GameSettings>,
|
// settings: UniqueView<GameSettings>,
|
||||||
) {
|
// ) {
|
||||||
if cfg!(target_os = "android") {
|
// if cfg!(target_os = "android") {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if !settings.debug_draw_current_chunk_border {
|
// if !settings.debug_draw_current_chunk_border {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||||
let view = camera.view_matrix.to_cols_array_2d();
|
// let view = camera.view_matrix.to_cols_array_2d();
|
||||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||||
let (_, &player_transform) = (&player, &transforms).iter().next().expect("No player");
|
// let (_, &player_transform) = (&player, &transforms).iter().next().expect("No player");
|
||||||
let (_, _, player_position) = player_transform.0.to_scale_rotation_translation();
|
// let (_, _, player_position) = player_transform.0.to_scale_rotation_translation();
|
||||||
let player_in_chunk = ivec3(
|
// let player_in_chunk = ivec3(
|
||||||
(player_position.x as i32).div_euclid(CHUNK_SIZE as i32),
|
// (player_position.x as i32).div_euclid(CHUNK_SIZE as i32),
|
||||||
(player_position.y as i32).div_euclid(CHUNK_SIZE as i32),
|
// (player_position.y as i32).div_euclid(CHUNK_SIZE as i32),
|
||||||
(player_position.z as i32).div_euclid(CHUNK_SIZE as i32),
|
// (player_position.z as i32).div_euclid(CHUNK_SIZE as i32),
|
||||||
);
|
// );
|
||||||
let world_position = player_in_chunk.as_vec3() * CHUNK_SIZE as f32;
|
// let world_position = player_in_chunk.as_vec3() * CHUNK_SIZE as f32;
|
||||||
target.0.draw(
|
// target.0.draw(
|
||||||
&buffers.0,
|
// &buffers.0,
|
||||||
&buffers.1,
|
// &buffers.1,
|
||||||
&program.0,
|
// &program.0,
|
||||||
&uniform! {
|
// &uniform! {
|
||||||
model: Mat4::from_scale_rotation_translation(
|
// model: Mat4::from_scale_rotation_translation(
|
||||||
Vec3::splat(CHUNK_SIZE as f32),
|
// Vec3::splat(CHUNK_SIZE as f32),
|
||||||
Quat::default(),
|
// Quat::default(),
|
||||||
world_position
|
// world_position
|
||||||
).to_cols_array_2d(),
|
// ).to_cols_array_2d(),
|
||||||
color: [0.25f32; 4],
|
// color: [0.25f32; 4],
|
||||||
view: view,
|
// view: view,
|
||||||
perspective: perspective,
|
// perspective: perspective,
|
||||||
},
|
// },
|
||||||
&DrawParameters {
|
// &DrawParameters {
|
||||||
depth: Depth {
|
// depth: Depth {
|
||||||
test: DepthTest::IfLess,
|
// test: DepthTest::IfLess,
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
},
|
// },
|
||||||
blend: Blend::alpha_blending(),
|
// blend: Blend::alpha_blending(),
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
}
|
// }
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
target.0.draw(
|
// target.0.draw(
|
||||||
&buffers.0,
|
// &buffers.0,
|
||||||
&buffers.1,
|
// &buffers.1,
|
||||||
&program.0,
|
// &program.0,
|
||||||
&uniform! {
|
// &uniform! {
|
||||||
model: Mat4::from_scale_rotation_translation(
|
// model: Mat4::from_scale_rotation_translation(
|
||||||
Vec3::splat(CHUNK_SIZE as f32),
|
// Vec3::splat(CHUNK_SIZE as f32),
|
||||||
Quat::default(),
|
// Quat::default(),
|
||||||
world_position
|
// world_position
|
||||||
).to_cols_array_2d(),
|
// ).to_cols_array_2d(),
|
||||||
color: [0.0f32; 4],
|
// color: [0.0f32; 4],
|
||||||
view: view,
|
// view: view,
|
||||||
perspective: perspective,
|
// perspective: perspective,
|
||||||
},
|
// },
|
||||||
&DrawParameters {
|
// &DrawParameters {
|
||||||
polygon_mode: PolygonMode::Point,
|
// polygon_mode: PolygonMode::Point,
|
||||||
line_width: Some(2.),
|
// line_width: Some(2.),
|
||||||
point_size: Some(5.),
|
// point_size: Some(5.),
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
}
|
// }
|
||||||
).unwrap();
|
// ).unwrap();
|
||||||
}
|
// }
|
||||||
|
|
|
@ -7,7 +7,7 @@ use hui::{
|
||||||
UiElementExt,
|
UiElementExt,
|
||||||
},
|
},
|
||||||
layout::{Alignment, Direction},
|
layout::{Alignment, Direction},
|
||||||
frame_rect, size,
|
rect_frame, size,
|
||||||
};
|
};
|
||||||
use shipyard::{UniqueView, UniqueViewMut, Workload, NonSendSync, IntoWorkload};
|
use shipyard::{UniqueView, UniqueViewMut, Workload, NonSendSync, IntoWorkload};
|
||||||
use winit::keyboard::KeyCode;
|
use winit::keyboard::KeyCode;
|
||||||
|
@ -28,7 +28,7 @@ pub fn loading_screen_base(bg_alpha: f32, xui: impl FnOnce(&mut ElementList)) ->
|
||||||
.with_children(|ui| {
|
.with_children(|ui| {
|
||||||
Container::default()
|
Container::default()
|
||||||
.with_size(size!(400, auto))
|
.with_size(size!(400, auto))
|
||||||
.with_background(frame_rect! {
|
.with_background(rect_frame! {
|
||||||
color: (0.2, 0.2, 0.2),
|
color: (0.2, 0.2, 0.2),
|
||||||
corner_radius: 8.
|
corner_radius: 8.
|
||||||
})
|
})
|
||||||
|
@ -63,11 +63,11 @@ fn render_loading_ui(
|
||||||
ProgressBar::default()
|
ProgressBar::default()
|
||||||
.with_value(value)
|
.with_value(value)
|
||||||
.with_size(size!(100%, 15))
|
.with_size(size!(100%, 15))
|
||||||
.with_background(frame_rect! {
|
.with_background(rect_frame! {
|
||||||
color: (0.1, 0.1, 0.1),
|
color: (0.1, 0.1, 0.1),
|
||||||
corner_radius: 2.
|
corner_radius: 2.
|
||||||
})
|
})
|
||||||
.with_foreground(frame_rect! {
|
.with_foreground(rect_frame! {
|
||||||
color: (0.4, 0.4, 1.0),
|
color: (0.4, 0.4, 1.0),
|
||||||
corner_radius: 2.
|
corner_radius: 2.
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,7 @@ use hui::{
|
||||||
element::{br::Break, container::Container, slider::Slider, text::Text, UiElementExt},
|
element::{br::Break, container::Container, slider::Slider, text::Text, UiElementExt},
|
||||||
layout::{Alignment, Direction},
|
layout::{Alignment, Direction},
|
||||||
signal::Signal,
|
signal::Signal,
|
||||||
frame_rect, size,
|
rect_frame, size,
|
||||||
};
|
};
|
||||||
use shipyard::{NonSendSync, UniqueView, UniqueViewMut};
|
use shipyard::{NonSendSync, UniqueView, UniqueViewMut};
|
||||||
use winit::keyboard::KeyCode;
|
use winit::keyboard::KeyCode;
|
||||||
|
@ -34,7 +34,7 @@ pub fn render_settings_ui(
|
||||||
.with_align(Alignment::Center)
|
.with_align(Alignment::Center)
|
||||||
.with_children(|ui| {
|
.with_children(|ui| {
|
||||||
Container::default()
|
Container::default()
|
||||||
.with_background(frame_rect! {
|
.with_background(rect_frame! {
|
||||||
color: (0.2, 0.2, 0.2),
|
color: (0.2, 0.2, 0.2),
|
||||||
corner_radius: 8.
|
corner_radius: 8.
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use glam::IVec3;
|
use glam::IVec3;
|
||||||
use atomic::Atomic;
|
use atomic::Atomic;
|
||||||
use glium::{VertexBuffer, IndexBuffer};
|
|
||||||
use kubi_shared::worldgen::AbortState;
|
use kubi_shared::worldgen::AbortState;
|
||||||
use crate::rendering::world::ChunkVertex;
|
use crate::rendering::{world::ChunkVertex, BufferPair};
|
||||||
|
|
||||||
pub use kubi_shared::chunk::{CHUNK_SIZE, BlockData};
|
pub use kubi_shared::chunk::{CHUNK_SIZE, BlockData};
|
||||||
|
|
||||||
|
@ -18,10 +17,8 @@ impl ChunkData {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ChunkMesh {
|
pub struct ChunkMesh {
|
||||||
pub vertex_buffer: VertexBuffer<ChunkVertex>,
|
pub main: BufferPair,
|
||||||
pub index_buffer: IndexBuffer<u32>,
|
pub trans: BufferPair,
|
||||||
pub trans_vertex_buffer: VertexBuffer<ChunkVertex>,
|
|
||||||
pub trans_index_buffer: IndexBuffer<u32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use atomic::{Atomic, Ordering};
|
use atomic::{Atomic, Ordering};
|
||||||
use glam::{IVec3, ivec3};
|
use glam::{IVec3, ivec3};
|
||||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
|
||||||
use kubi_shared::{networking::{channels::Channel, messages::ClientToServerMessage}, worldgen::AbortState};
|
use kubi_shared::{networking::{channels::Channel, messages::ClientToServerMessage}, worldgen::AbortState};
|
||||||
use shipyard::{View, UniqueView, UniqueViewMut, IntoIter, Workload, IntoWorkload, NonSendSync, track};
|
use shipyard::{View, UniqueView, UniqueViewMut, IntoIter, Workload, IntoWorkload, NonSendSync, track};
|
||||||
use uflow::SendMode;
|
use uflow::SendMode;
|
||||||
|
@ -327,21 +326,23 @@ fn process_completed_tasks(
|
||||||
|
|
||||||
//apply the mesh
|
//apply the mesh
|
||||||
//TODO: Skip if mesh is empty? (i.e. set to None)
|
//TODO: Skip if mesh is empty? (i.e. set to None)
|
||||||
let mesh = ChunkMesh {
|
unimplemented!();
|
||||||
vertex_buffer: VertexBuffer::immutable(&renderer.display, &vertices).unwrap(),
|
|
||||||
index_buffer: IndexBuffer::immutable(&renderer.display, PrimitiveType::TrianglesList, &indices).unwrap(),
|
|
||||||
trans_vertex_buffer: VertexBuffer::immutable(&renderer.display, &trans_vertices).unwrap(),
|
|
||||||
trans_index_buffer: IndexBuffer::immutable(&renderer.display, PrimitiveType::TrianglesList, &trans_indices).unwrap(),
|
|
||||||
};
|
|
||||||
if let Some(index) = chunk.mesh_index {
|
|
||||||
meshes.update(index, mesh).expect("Mesh update failed");
|
|
||||||
} else {
|
|
||||||
let mesh_index = meshes.insert(mesh);
|
|
||||||
chunk.mesh_index = Some(mesh_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
//update chunk state
|
// let mesh = ChunkMesh {
|
||||||
chunk.current_state = CurrentChunkState::Rendered;
|
// vertex_buffer: VertexBuffer::immutable(&renderer.display, &vertices).unwrap(),
|
||||||
|
// index_buffer: IndexBuffer::immutable(&renderer.display, PrimitiveType::TrianglesList, &indices).unwrap(),
|
||||||
|
// trans_vertex_buffer: VertexBuffer::immutable(&renderer.display, &trans_vertices).unwrap(),
|
||||||
|
// trans_index_buffer: IndexBuffer::immutable(&renderer.display, PrimitiveType::TrianglesList, &trans_indices).unwrap(),
|
||||||
|
// };
|
||||||
|
// if let Some(index) = chunk.mesh_index {
|
||||||
|
// meshes.update(index, mesh).expect("Mesh update failed");
|
||||||
|
// } else {
|
||||||
|
// let mesh_index = meshes.insert(mesh);
|
||||||
|
// chunk.mesh_index = Some(mesh_index);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //update chunk state
|
||||||
|
// chunk.current_state = CurrentChunkState::Rendered;
|
||||||
|
|
||||||
//increase ops counter
|
//increase ops counter
|
||||||
ops += 1;
|
ops += 1;
|
||||||
|
|
Loading…
Reference in a new issue