mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 14:58:44 -06:00
Compare commits
No commits in common. "906f4882a24423b5743bbaf1b25c8ca9cb9e836a" and "4ff284288ebc3d0b049ff5227f90ac3e5e7237a2" have entirely different histories.
906f4882a2
...
4ff284288e
299
Cargo.lock
generated
299
Cargo.lock
generated
|
@ -52,6 +52,27 @@ version = "0.2.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
|
||||
|
||||
[[package]]
|
||||
name = "android-activity"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289"
|
||||
dependencies = [
|
||||
"android-properties",
|
||||
"bitflags 2.5.0",
|
||||
"cc",
|
||||
"cesu8",
|
||||
"jni",
|
||||
"jni-sys",
|
||||
"libc",
|
||||
"log",
|
||||
"ndk 0.8.0",
|
||||
"ndk-context",
|
||||
"ndk-sys 0.5.0+25.2.9519653",
|
||||
"num_enum",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-activity"
|
||||
version = "0.6.0"
|
||||
|
@ -66,7 +87,7 @@ dependencies = [
|
|||
"jni-sys",
|
||||
"libc",
|
||||
"log",
|
||||
"ndk",
|
||||
"ndk 0.9.0",
|
||||
"ndk-context",
|
||||
"ndk-sys 0.6.0+11769913",
|
||||
"num_enum",
|
||||
|
@ -171,15 +192,15 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.3.0"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
||||
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.1"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
|
@ -223,13 +244,32 @@ version = "0.1.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "block2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43ff7d91d3c1d568065b06c899777d1e48dcf76103a672a0adbc238a7f247f1e"
|
||||
dependencies = [
|
||||
"objc2",
|
||||
"objc2 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -249,9 +289,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bytemuck_derive"
|
||||
version = "1.6.0"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60"
|
||||
checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -298,9 +338,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.96"
|
||||
version = "1.0.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd"
|
||||
checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
|
@ -403,9 +443,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "concurrent-queue"
|
||||
version = "2.5.0"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"
|
||||
checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
@ -680,9 +720,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.30"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae"
|
||||
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
|
@ -712,7 +752,7 @@ version = "0.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9099a2f86b8e674b75d03ff154b3fe4c5208ed249ced8d69cc313a9fa40bb488"
|
||||
dependencies = [
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown 0.14.3",
|
||||
"ttf-parser",
|
||||
]
|
||||
|
||||
|
@ -780,9 +820,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gilrs"
|
||||
version = "0.10.7"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b54e5e39844ab5cddaf3bbbdfdc2923a6cb34e36818b95618da4e3f26302c24c"
|
||||
checksum = "499067aa54af19f88732dc418f61f23d5912de1518665bb0eca034ca0d07574c"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"gilrs-core",
|
||||
|
@ -894,7 +934,7 @@ checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557"
|
|||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"gpu-descriptor-types",
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown 0.14.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -923,9 +963,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
|||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
version = "0.14.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"allocator-api2",
|
||||
|
@ -987,28 +1027,27 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
|||
|
||||
[[package]]
|
||||
name = "hui"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
version = "0.1.0-alpha.4"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||
dependencies = [
|
||||
"derive_more",
|
||||
"derive_setters",
|
||||
"document-features",
|
||||
"fontdue",
|
||||
"glam",
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown 0.14.3",
|
||||
"hui-derive",
|
||||
"image",
|
||||
"log",
|
||||
"nohash-hasher",
|
||||
"rect_packer",
|
||||
"rustc-hash",
|
||||
"tinyset",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hui-derive"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
version = "0.1.0-alpha.4"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.60",
|
||||
|
@ -1016,13 +1055,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "hui-winit"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
version = "0.1.0-alpha.4"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||
dependencies = [
|
||||
"glam",
|
||||
"hui",
|
||||
"log",
|
||||
"winit",
|
||||
"winit 0.29.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1054,6 +1093,17 @@ dependencies = [
|
|||
"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]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
|
@ -1090,7 +1140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown 0.14.3",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
@ -1202,14 +1252,13 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
|||
name = "kubi"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"android-activity",
|
||||
"android-activity 0.5.2",
|
||||
"anyhow",
|
||||
"atomic",
|
||||
"bytemuck",
|
||||
"flume",
|
||||
"gilrs",
|
||||
"glam",
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown 0.14.3",
|
||||
"hui",
|
||||
"hui-winit",
|
||||
"image",
|
||||
|
@ -1217,9 +1266,8 @@ dependencies = [
|
|||
"kubi-shared",
|
||||
"log",
|
||||
"lz4_flex",
|
||||
"ndk",
|
||||
"ndk 0.8.0",
|
||||
"nohash-hasher",
|
||||
"pollster",
|
||||
"postcard",
|
||||
"rand",
|
||||
"raw-window-handle",
|
||||
|
@ -1232,7 +1280,7 @@ dependencies = [
|
|||
"uflow",
|
||||
"wgpu",
|
||||
"winapi",
|
||||
"winit",
|
||||
"winit 0.30.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1251,7 +1299,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"flume",
|
||||
"glam",
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown 0.14.3",
|
||||
"kubi-logging",
|
||||
"kubi-shared",
|
||||
"log",
|
||||
|
@ -1276,7 +1324,7 @@ dependencies = [
|
|||
"bytemuck",
|
||||
"fastnoise-lite",
|
||||
"glam",
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown 0.14.3",
|
||||
"nohash-hasher",
|
||||
"num_enum",
|
||||
"nz",
|
||||
|
@ -1298,9 +1346,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.154"
|
||||
version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
|
@ -1363,9 +1411,9 @@ checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
|
|||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
|
@ -1471,6 +1519,21 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"jni-sys",
|
||||
"log",
|
||||
"ndk-sys 0.5.0+25.2.9519653",
|
||||
"num_enum",
|
||||
"raw-window-handle",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.9.0"
|
||||
|
@ -1536,9 +1599,9 @@ checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
|||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
@ -1566,9 +1629,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "nz"
|
||||
version = "0.3.5"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1e9655df3f51323812726b25a00d787562c5fa64177d286603429787b4386a9"
|
||||
checksum = "cb749eec2b3be2f169dd4facfec40a28cc40f2b02ad3c4d2c51ce578c3f635b0"
|
||||
|
||||
[[package]]
|
||||
name = "objc"
|
||||
|
@ -1585,6 +1648,16 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "objc2"
|
||||
version = "0.5.1"
|
||||
|
@ -1592,7 +1665,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "b4b25e1034d0e636cd84707ccdaa9f81243d399196b8a773946dcffec0401659"
|
||||
dependencies = [
|
||||
"objc-sys",
|
||||
"objc2-encode",
|
||||
"objc2-encode 4.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1601,8 +1674,8 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb79768a710a9a1798848179edb186d1af7e8a8679f369e4b8d201dd2a034047"
|
||||
dependencies = [
|
||||
"block2",
|
||||
"objc2",
|
||||
"block2 0.5.0",
|
||||
"objc2 0.5.1",
|
||||
"objc2-core-data",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
@ -1613,11 +1686,17 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e092bc42eaf30a08844e6a076938c60751225ec81431ab89f5d1ccd9f958d6c"
|
||||
dependencies = [
|
||||
"block2",
|
||||
"objc2",
|
||||
"block2 0.5.0",
|
||||
"objc2 0.5.1",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666"
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "4.0.1"
|
||||
|
@ -1630,9 +1709,9 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfaefe14254871ea16c7d88968c0ff14ba554712a20d76421eec52f0a7fb8904"
|
||||
dependencies = [
|
||||
"block2",
|
||||
"block2 0.5.0",
|
||||
"dispatch",
|
||||
"objc2",
|
||||
"objc2 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1764,12 +1843,6 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pollster"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
|
||||
|
||||
[[package]]
|
||||
name = "postcard"
|
||||
version = "1.0.8"
|
||||
|
@ -1920,6 +1993,15 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
|
@ -2066,18 +2148,18 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.200"
|
||||
version = "1.0.198"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f"
|
||||
checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.200"
|
||||
version = "1.0.198"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb"
|
||||
checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2106,9 +2188,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_with"
|
||||
version = "3.8.1"
|
||||
version = "3.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20"
|
||||
checksum = "2c85f8e96d1d6857f13768fcbd895fcb06225510022a2774ed8b5150581847b0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"chrono",
|
||||
|
@ -2124,9 +2206,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_with_macros"
|
||||
version = "3.8.1"
|
||||
version = "3.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2"
|
||||
checksum = "c8b3a576c4eb2924262d5951a3b737ccaf16c931e39a2810c36f9a7e25575557"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
|
@ -2139,7 +2221,7 @@ name = "shipyard"
|
|||
version = "0.6.0"
|
||||
source = "git+https://github.com/leudz/shipyard?rev=aacf3b1df5#aacf3b1df540c7d9d384830d7431ba618eee75c9"
|
||||
dependencies = [
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown 0.14.3",
|
||||
"lock_api",
|
||||
"rayon",
|
||||
"serde",
|
||||
|
@ -2449,7 +2531,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow 0.6.7",
|
||||
"winnow 0.6.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2726,6 +2808,16 @@ dependencies = [
|
|||
"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]]
|
||||
name = "web-time"
|
||||
version = "1.1.0"
|
||||
|
@ -2910,6 +3002,15 @@ dependencies = [
|
|||
"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]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
|
@ -3097,6 +3198,41 @@ version = "0.52.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "winit"
|
||||
version = "0.30.0"
|
||||
|
@ -3104,7 +3240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ea9e6d5d66cbf702e0dd820302144f51b69a95acdc495dd98ca280ff206562b1"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"android-activity",
|
||||
"android-activity 0.6.0",
|
||||
"atomic-waker",
|
||||
"bitflags 2.5.0",
|
||||
"bytemuck",
|
||||
|
@ -3118,8 +3254,8 @@ dependencies = [
|
|||
"js-sys",
|
||||
"libc",
|
||||
"memmap2",
|
||||
"ndk",
|
||||
"objc2",
|
||||
"ndk 0.9.0",
|
||||
"objc2 0.5.1",
|
||||
"objc2-app-kit",
|
||||
"objc2-foundation",
|
||||
"orbclient",
|
||||
|
@ -3140,7 +3276,7 @@ dependencies = [
|
|||
"wayland-protocols",
|
||||
"wayland-protocols-plasma",
|
||||
"web-sys",
|
||||
"web-time",
|
||||
"web-time 1.1.0",
|
||||
"windows-sys 0.52.0",
|
||||
"x11-dl",
|
||||
"x11rb",
|
||||
|
@ -3158,9 +3294,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.7"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578"
|
||||
checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
@ -3178,9 +3314,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "x11rb"
|
||||
version = "0.13.1"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12"
|
||||
checksum = "f8f25ead8c7e4cba123243a6367da5d3990e0d3affa708ea19dce96356bd9f1a"
|
||||
dependencies = [
|
||||
"as-raw-xcb-connection",
|
||||
"gethostname",
|
||||
|
@ -3193,9 +3329,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "x11rb-protocol"
|
||||
version = "0.13.1"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d"
|
||||
checksum = "e63e71c4b8bd9ffec2c963173a4dc4cbde9ee96961d4fcb4429db9929b606c34"
|
||||
|
||||
[[package]]
|
||||
name = "xcursor"
|
||||
|
@ -3247,3 +3383,8 @@ dependencies = [
|
|||
"quote",
|
||||
"syn 2.0.60",
|
||||
]
|
||||
|
||||
[[patch.unused]]
|
||||
name = "glium"
|
||||
version = "0.34.0"
|
||||
source = "git+https://github.com/glium/glium?rev=a352c667#a352c667c145e2dda1f5fe1fc2482cbe99de23be"
|
||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -21,13 +21,10 @@ opt-level = 1
|
|||
[profile.dev.package.uflow]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.wgpu]
|
||||
[profile.dev.package.glium]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.wgpu-core]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.wgpu-hal]
|
||||
[profile.dev.package.bracket-noise]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.fastnoise-lite]
|
||||
|
@ -40,3 +37,6 @@ opt-level = 3
|
|||
#enabling debug assertions here causes the game to abort
|
||||
[profile.dev.package.android-activity]
|
||||
debug-assertions = false
|
||||
|
||||
[patch.crates-io]
|
||||
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
|
||||
|
|
|
@ -1,64 +1,64 @@
|
|||
//! Custom env_logger options and styling
|
||||
|
||||
/// Custom env_logger options and styling
|
||||
#[inline]
|
||||
#[cfg(not(target_os = "android"))]
|
||||
pub fn init() {
|
||||
use log::Level;
|
||||
use std::io::Write;
|
||||
use env_logger::{fmt::Color, Builder, Env};
|
||||
|
||||
let env = Env::default()
|
||||
.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)
|
||||
.format(|buf, record| {
|
||||
let mut level_style = buf.style();
|
||||
level_style.set_color(match record.level() {
|
||||
Level::Error => Color::Red,
|
||||
Level::Warn => Color::Yellow,
|
||||
Level::Debug | Level::Trace => Color::Cyan,
|
||||
_ => Color::Blue
|
||||
}).set_bold(true);
|
||||
|
||||
let mut bold_style = buf.style();
|
||||
bold_style.set_bold(true);
|
||||
|
||||
let mut location_style = buf.style();
|
||||
location_style.set_bold(true);
|
||||
location_style.set_dimmed(true);
|
||||
|
||||
let mut location_line_style = buf.style();
|
||||
location_line_style.set_dimmed(true);
|
||||
|
||||
let text = format!("{}", record.args());
|
||||
|
||||
writeln!(
|
||||
buf,
|
||||
"{} {:<50}\t{}{}{}{}",
|
||||
level_style.value(match record.level() {
|
||||
Level::Error => "[e]",
|
||||
Level::Warn => "[w]",
|
||||
Level::Info => "[i]",
|
||||
Level::Debug => "[d]",
|
||||
Level::Trace => "[t]",
|
||||
}),
|
||||
text,
|
||||
bold_style.value((text.len() > 50).then_some("\n ╰─ ").unwrap_or_default()),
|
||||
location_style.value(record.target()),
|
||||
location_line_style.value(" :"),
|
||||
location_line_style.value(record.line().unwrap_or(0))
|
||||
)
|
||||
})
|
||||
.init();
|
||||
}
|
||||
|
||||
/// Custom env_logger options and styling
|
||||
#[inline]
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn init() {
|
||||
use log::LevelFilter;
|
||||
use android_logger::Config;
|
||||
android_logger::init_once(
|
||||
Config::default().with_max_level(LevelFilter::Trace),
|
||||
);
|
||||
}
|
||||
//! Custom env_logger options and styling
|
||||
|
||||
/// Custom env_logger options and styling
|
||||
#[inline]
|
||||
#[cfg(not(target_os = "android"))]
|
||||
pub fn init() {
|
||||
use log::Level;
|
||||
use std::io::Write;
|
||||
use env_logger::{fmt::Color, Builder, Env};
|
||||
|
||||
let env = Env::default()
|
||||
.filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn");
|
||||
Builder::from_env(env)
|
||||
.format(|buf, record| {
|
||||
let mut level_style = buf.style();
|
||||
level_style.set_color(match record.level() {
|
||||
Level::Error => Color::Red,
|
||||
Level::Warn => Color::Yellow,
|
||||
Level::Debug | Level::Trace => Color::Cyan,
|
||||
_ => Color::Blue
|
||||
}).set_bold(true);
|
||||
|
||||
let mut bold_style = buf.style();
|
||||
bold_style.set_bold(true);
|
||||
|
||||
let mut location_style = buf.style();
|
||||
location_style.set_bold(true);
|
||||
location_style.set_dimmed(true);
|
||||
|
||||
let mut location_line_style = buf.style();
|
||||
location_line_style.set_dimmed(true);
|
||||
|
||||
let text = format!("{}", record.args());
|
||||
|
||||
writeln!(
|
||||
buf,
|
||||
"{} {:<50}\t{}{}{}{}",
|
||||
level_style.value(match record.level() {
|
||||
Level::Error => "[e]",
|
||||
Level::Warn => "[w]",
|
||||
Level::Info => "[i]",
|
||||
Level::Debug => "[d]",
|
||||
Level::Trace => "[t]",
|
||||
}),
|
||||
text,
|
||||
bold_style.value((text.len() > 50).then_some("\n ╰─ ").unwrap_or_default()),
|
||||
location_style.value(record.target()),
|
||||
location_line_style.value(" :"),
|
||||
location_line_style.value(record.line().unwrap_or(0))
|
||||
)
|
||||
})
|
||||
.init();
|
||||
}
|
||||
|
||||
/// Custom env_logger options and styling
|
||||
#[inline]
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn init() {
|
||||
use log::LevelFilter;
|
||||
use android_logger::Config;
|
||||
android_logger::init_once(
|
||||
Config::default().with_max_level(LevelFilter::Trace),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ glam = { version = "0.27", features = ["debug-glam-assert", "fast-math"] }
|
|||
hashbrown = "0.14"
|
||||
nohash-hasher = "0.2"
|
||||
anyhow = "1.0"
|
||||
rayon = "1.10"
|
||||
rayon = "1.7"
|
||||
flume = "0.11"
|
||||
rand = "0.8"
|
||||
uflow = "0.7"
|
||||
|
|
|
@ -11,12 +11,10 @@ crate-type = ["lib", "cdylib"]
|
|||
[dependencies]
|
||||
kubi-shared = { path = "../kubi-shared" }
|
||||
kubi-logging = { path = "../kubi-logging" }
|
||||
hui = { git = "https://github.com/griffi-gh/hui", rev = "3a50d2d0dde" }
|
||||
hui-winit = { git = "https://github.com/griffi-gh/hui", rev = "3a50d2d0dde", features = ["winit_30"] }
|
||||
hui = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||
hui-winit = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||
log = "0.4"
|
||||
wgpu = { version = "0.20", features = ["webgl"] }
|
||||
pollster = "0.3"
|
||||
bytemuck = { version = "1.15", features = ["derive"] }
|
||||
winit = { version = "0.30", features = ["android-native-activity"] }
|
||||
raw-window-handle = "0.6"
|
||||
glam = { version = "0.27", features = ["debug-glam-assert", "fast-math"] }
|
||||
|
@ -24,7 +22,7 @@ image = { version = "0.25", default_features = false, features = ["png"] }
|
|||
strum = { version = "0.26", features = ["derive"] }
|
||||
hashbrown = "0.14"
|
||||
nohash-hasher = "0.2"
|
||||
rayon = "1.10"
|
||||
rayon = "1.7"
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "aacf3b1df5", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||
anyhow = "1.0"
|
||||
flume = "0.11"
|
||||
|
@ -38,10 +36,9 @@ serde_json = { version = "1.0", optional = true } #only used for `generate_visua
|
|||
rand = { version = "0.8", features = ["alloc", "small_rng"]}
|
||||
atomic = "0.6"
|
||||
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
android-activity = "0.6"
|
||||
ndk = "0.9"
|
||||
android-activity = "^0.5.2"
|
||||
ndk = "0.8"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version = "0.3", features = ["wincon"] }
|
||||
|
|
12
kubi/shaders/colored.frag
Normal file
12
kubi/shaders/colored.frag
Normal file
|
@ -0,0 +1,12 @@
|
|||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
|
||||
out vec4 out_color;
|
||||
uniform vec4 color;
|
||||
|
||||
void main() {
|
||||
// discard fully transparent pixels
|
||||
if (color.w <= 0.) discard;
|
||||
out_color = color;
|
||||
}
|
13
kubi/shaders/colored.vert
Normal file
13
kubi/shaders/colored.vert
Normal file
|
@ -0,0 +1,13 @@
|
|||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
|
||||
in vec3 position;
|
||||
uniform mat4 model;
|
||||
uniform mat4 perspective;
|
||||
uniform mat4 view;
|
||||
|
||||
void main() {
|
||||
mat4 modelview = view * model;
|
||||
gl_Position = perspective * modelview * vec4(position, 1.);
|
||||
}
|
10
kubi/shaders/colored2.frag
Normal file
10
kubi/shaders/colored2.frag
Normal file
|
@ -0,0 +1,10 @@
|
|||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
|
||||
out vec4 out_color;
|
||||
uniform vec4 color;
|
||||
|
||||
void main() {
|
||||
out_color = color;
|
||||
}
|
9
kubi/shaders/colored2.vert
Normal file
9
kubi/shaders/colored2.vert
Normal file
|
@ -0,0 +1,9 @@
|
|||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
|
||||
in vec2 position;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
}
|
26
kubi/shaders/world.frag
Normal file
26
kubi/shaders/world.frag
Normal file
|
@ -0,0 +1,26 @@
|
|||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
precision lowp sampler2DArray;
|
||||
|
||||
in vec3 v_normal;
|
||||
in vec2 v_uv;
|
||||
flat in uint v_tex_index;
|
||||
out vec4 color;
|
||||
uniform sampler2DArray tex;
|
||||
uniform bool discard_alpha;
|
||||
|
||||
void main() {
|
||||
// base color from texture
|
||||
color = texture(tex, vec3(v_uv, v_tex_index));
|
||||
|
||||
// discard fully transparent pixels
|
||||
if (discard_alpha ? (color.w < 0.5) : (color.w == 0.)) discard;
|
||||
|
||||
//basic "lighting"
|
||||
float light = abs(v_normal.x) + .8 * abs(v_normal.y) + .6 * abs(v_normal.z);
|
||||
color *= vec4(vec3(light), 1.);
|
||||
|
||||
//discard alpha
|
||||
if (discard_alpha) color.w = 1.;
|
||||
}
|
27
kubi/shaders/world.vert
Normal file
27
kubi/shaders/world.vert
Normal file
|
@ -0,0 +1,27 @@
|
|||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
|
||||
//TODO pack this data:
|
||||
// uint position_normal_uv
|
||||
// XXYYZZNU
|
||||
// wehere Normal and Uv are enums
|
||||
// maybe somehow pack in tex index too
|
||||
|
||||
in vec3 position;
|
||||
in vec3 normal;
|
||||
in vec2 uv;
|
||||
in uint tex_index;
|
||||
out vec2 v_uv;
|
||||
out vec3 v_normal;
|
||||
flat out uint v_tex_index;
|
||||
uniform vec3 position_offset;
|
||||
uniform mat4 perspective;
|
||||
uniform mat4 view;
|
||||
|
||||
void main() {
|
||||
v_normal = normal;
|
||||
v_tex_index = tex_index;
|
||||
v_uv = uv;
|
||||
gl_Position = perspective * view * vec4(position + position_offset, 1.);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
use shipyard::{AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||
use crate::{events::InputDeviceEvent, rendering::Renderer};
|
||||
use crate::{events::InputDeviceEvent, rendering::{Renderer, WindowSize}};
|
||||
use winit::{
|
||||
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() {
|
||||
//TODO MIGRATION
|
||||
let window = display.window();
|
||||
let window = &display.window;
|
||||
window.set_cursor_grab(match lock.0 {
|
||||
true => CursorGrabMode::Confined,
|
||||
false => CursorGrabMode::None,
|
||||
|
@ -42,6 +42,7 @@ pub fn debug_toggle_lock(
|
|||
mut lock: UniqueViewMut<CursorLock>,
|
||||
device_events: View<InputDeviceEvent>,
|
||||
ren: NonSendSync<UniqueView<Renderer>>,
|
||||
size: UniqueView<WindowSize>,
|
||||
) {
|
||||
for evt in device_events.iter() {
|
||||
if let DeviceEvent::Key(RawKeyEvent {
|
||||
|
@ -50,8 +51,8 @@ pub fn debug_toggle_lock(
|
|||
}) = evt.event {
|
||||
lock.0 = !lock.0;
|
||||
if !lock.0 {
|
||||
let center = PhysicalPosition::new(ren.size().width as f64 / 2., ren.size().height as f64 / 2.);
|
||||
let _ = ren.window().set_cursor_position(center);
|
||||
let center = PhysicalPosition::new(size.0.x as f64 / 2., size.0.y as f64 / 2.);
|
||||
let _ = ren.window.set_cursor_position(center);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ pub fn initial_resize_event(
|
|||
) {
|
||||
let (w, h) = {
|
||||
let renderer = storages.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
(renderer.size().width, renderer.size().height)
|
||||
renderer.display.get_framebuffer_dimensions()
|
||||
};
|
||||
storages.add_entity((
|
||||
EventComponent,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use hui::UiInstance;
|
||||
//use hui_glium::GliumUiRenderer;
|
||||
use shipyard::{AllStoragesView, Unique, UniqueView, NonSendSync, UniqueViewMut};
|
||||
use crate::rendering::{Renderer, WindowSize};
|
||||
use crate::rendering::{RenderTarget, Renderer, WindowSize};
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct UiState {
|
||||
|
@ -34,13 +34,13 @@ pub fn kubi_ui_end(
|
|||
//renderer.update(hui);
|
||||
}
|
||||
|
||||
// pub fn kubi_ui_draw(
|
||||
// ui: NonSendSync<UniqueView<UiState>>,
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// size: UniqueView<WindowSize>
|
||||
// ) {
|
||||
// ui.renderer.draw(&mut target.0, size.0.as_vec2());
|
||||
// }
|
||||
pub fn kubi_ui_draw(
|
||||
ui: NonSendSync<UniqueView<UiState>>,
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
size: UniqueView<WindowSize>
|
||||
) {
|
||||
//ui.renderer.draw(&mut target.0, size.0.as_vec2());
|
||||
}
|
||||
|
||||
pub fn hui_process_winit_events(
|
||||
event: &winit::event::Event<()>,
|
||||
|
|
|
@ -75,13 +75,18 @@ use events::{
|
|||
};
|
||||
use input::{init_input, process_inputs};
|
||||
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::{
|
||||
init_window_size, render_master, resize_renderer, update_window_size,
|
||||
world::{init_trans_chunk_queue, TransChunkQueue},
|
||||
BackgroundColor, Renderer,
|
||||
Renderer,
|
||||
RenderTarget,
|
||||
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 delta_time::{DeltaTime, init_delta_time};
|
||||
|
@ -90,7 +95,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 networking::{update_networking, update_networking_late, is_multiplayer, disconnect_on_exit, is_singleplayer};
|
||||
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 connecting_screen::update_connecting_screen;
|
||||
use fixed_timestamp::init_fixed_timestamp_storage;
|
||||
|
@ -116,7 +121,7 @@ fn startup() -> Workload {
|
|||
init_window_size,
|
||||
kubi_ui_init,
|
||||
load_prefabs,
|
||||
//init_primitives,
|
||||
init_primitives,
|
||||
insert_lock_state,
|
||||
init_state,
|
||||
initialize_from_args,
|
||||
|
@ -127,6 +132,7 @@ fn startup() -> Workload {
|
|||
init_client_physics,
|
||||
init_chat_manager,
|
||||
init_crosshair_image,
|
||||
init_trans_chunk_queue,
|
||||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
|
@ -134,12 +140,10 @@ fn update() -> Workload {
|
|||
(
|
||||
debug_toggle_lock,
|
||||
update_window_size,
|
||||
resize_renderer,
|
||||
update_cursor_lock_state,
|
||||
process_inputs,
|
||||
kubi_ui_begin,
|
||||
(
|
||||
init_trans_chunk_queue.run_if_missing_unique::<TransChunkQueue>(),
|
||||
init_game_world.run_if_missing_unique::<ChunkTaskManager>(),
|
||||
(
|
||||
spawn_player.run_if_storage_empty::<MainPlayer>(),
|
||||
|
@ -177,20 +181,20 @@ fn update() -> Workload {
|
|||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
// fn render() -> Workload {
|
||||
// (
|
||||
// clear_background,
|
||||
// (
|
||||
// draw_world,
|
||||
// draw_current_chunk_border,
|
||||
// render_selection_box,
|
||||
// render_entities,
|
||||
// draw_world_trans,
|
||||
// render_submerged_view,
|
||||
// ).into_sequential_workload().run_if(is_ingame),
|
||||
// kubi_ui_draw,
|
||||
// ).into_sequential_workload()
|
||||
// }
|
||||
fn render() -> Workload {
|
||||
(
|
||||
clear_background,
|
||||
(
|
||||
draw_world,
|
||||
draw_current_chunk_border,
|
||||
render_selection_box,
|
||||
render_entities,
|
||||
draw_world_trans,
|
||||
render_submerged_view,
|
||||
).into_sequential_workload().run_if(is_ingame),
|
||||
kubi_ui_draw,
|
||||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
fn after_frame_end() -> Workload {
|
||||
(
|
||||
|
@ -240,7 +244,7 @@ pub fn kubi_main(
|
|||
world.add_workload(pre_startup);
|
||||
world.add_workload(startup);
|
||||
world.add_workload(update);
|
||||
//world.add_workload(render);
|
||||
world.add_workload(render);
|
||||
world.add_workload(after_frame_end);
|
||||
|
||||
//Save _visualizer.json
|
||||
|
@ -321,21 +325,19 @@ pub fn kubi_main(
|
|||
//Run update workflows
|
||||
world.run_workload(update).unwrap();
|
||||
|
||||
world.run(render_master);
|
||||
|
||||
//Start rendering (maybe use custom views for this?)
|
||||
// let target = {
|
||||
// let renderer = world.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
// renderer.display.draw()
|
||||
// };
|
||||
// world.add_unique_non_send_sync(RenderTarget(target));
|
||||
let target = {
|
||||
let renderer = world.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
renderer.display.draw()
|
||||
};
|
||||
world.add_unique_non_send_sync(RenderTarget(target));
|
||||
|
||||
//Run render workflow
|
||||
//world.run_workload(render).unwrap();
|
||||
world.run_workload(render).unwrap();
|
||||
|
||||
//Finish rendering
|
||||
// let target = world.remove_unique::<RenderTarget>().unwrap();
|
||||
// target.0.finish().unwrap();
|
||||
let target = world.remove_unique::<RenderTarget>().unwrap();
|
||||
target.0.finish().unwrap();
|
||||
|
||||
//After frame end
|
||||
world.run_workload(after_frame_end).unwrap();
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
use std::{io::{BufReader, Read}, path::Path};
|
||||
use hui::text::FontHandle;
|
||||
use shipyard::{AllStoragesView, NonSendSync, Unique, UniqueView, UniqueViewMut};
|
||||
use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program};
|
||||
use kubi_shared::block::BlockTexture;
|
||||
use crate::{filesystem::AssetManager, hui_integration::UiState, rendering::Renderer};
|
||||
|
||||
mod texture;
|
||||
mod shaders;
|
||||
|
||||
//use texture::load_texture2darray_prefab;
|
||||
use texture::load_texture2darray_prefab;
|
||||
use shaders::include_shader_prefab;
|
||||
|
||||
pub trait AssetPaths {
|
||||
fn file_name(self) -> &'static str;
|
||||
|
@ -39,7 +41,7 @@ impl AssetPaths for BlockTexture {
|
|||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct BlockTexturesPrefab(pub wgpu::Texture);
|
||||
pub struct BlockTexturesPrefab(pub SrgbTexture2dArray);
|
||||
|
||||
// #[derive(Unique)]
|
||||
// #[repr(transparent)]
|
||||
|
@ -63,15 +65,15 @@ pub fn load_prefabs(
|
|||
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
||||
assman: UniqueView<AssetManager>
|
||||
) {
|
||||
// log::info!("Loading textures...");
|
||||
// storages.add_unique_non_send_sync(BlockTexturesPrefab(
|
||||
// load_texture2darray_prefab::<BlockTexture, _>(
|
||||
// &assman,
|
||||
// "blocks".into(),
|
||||
// &renderer.display,
|
||||
// MipmapsOption::AutoGeneratedMipmaps
|
||||
// )
|
||||
// ));
|
||||
log::info!("Loading textures...");
|
||||
storages.add_unique_non_send_sync(BlockTexturesPrefab(
|
||||
load_texture2darray_prefab::<BlockTexture, _>(
|
||||
&assman,
|
||||
"blocks".into(),
|
||||
&renderer.display,
|
||||
MipmapsOption::AutoGeneratedMipmaps
|
||||
)
|
||||
));
|
||||
|
||||
log::info!("Loading the UI stuff...");
|
||||
{
|
||||
|
@ -83,33 +85,33 @@ pub fn load_prefabs(
|
|||
storages.add_unique(UiFontPrefab(font_handle));
|
||||
}
|
||||
|
||||
//log::info!("Compiling shaders...");
|
||||
// storages.add_unique_non_send_sync(ChunkShaderPrefab(
|
||||
// include_shader_prefab!(
|
||||
// "world",
|
||||
// "../shaders/world.vert",
|
||||
// "../shaders/world.frag",
|
||||
// &renderer.display
|
||||
// )
|
||||
// ));
|
||||
// storages.add_unique_non_send_sync(ColoredShaderPrefab(
|
||||
// include_shader_prefab!(
|
||||
// "colored",
|
||||
// "../shaders/colored.vert",
|
||||
// "../shaders/colored.frag",
|
||||
// &renderer.display
|
||||
// )
|
||||
// ));
|
||||
// storages.add_unique_non_send_sync(Colored2ShaderPrefab(
|
||||
// include_shader_prefab!(
|
||||
// "colored",
|
||||
// "../shaders/colored2.vert",
|
||||
// "../shaders/colored2.frag",
|
||||
// &renderer.display
|
||||
// )
|
||||
// ));
|
||||
log::info!("Compiling shaders...");
|
||||
storages.add_unique_non_send_sync(ChunkShaderPrefab(
|
||||
include_shader_prefab!(
|
||||
"world",
|
||||
"../shaders/world.vert",
|
||||
"../shaders/world.frag",
|
||||
&renderer.display
|
||||
)
|
||||
));
|
||||
storages.add_unique_non_send_sync(ColoredShaderPrefab(
|
||||
include_shader_prefab!(
|
||||
"colored",
|
||||
"../shaders/colored.vert",
|
||||
"../shaders/colored.frag",
|
||||
&renderer.display
|
||||
)
|
||||
));
|
||||
storages.add_unique_non_send_sync(Colored2ShaderPrefab(
|
||||
include_shader_prefab!(
|
||||
"colored",
|
||||
"../shaders/colored2.vert",
|
||||
"../shaders/colored2.frag",
|
||||
&renderer.display
|
||||
)
|
||||
));
|
||||
|
||||
//log::info!("releasing shader compiler");
|
||||
log::info!("releasing shader compiler");
|
||||
|
||||
//renderer.display.release_shader_compiler();
|
||||
}
|
||||
|
|
|
@ -1,45 +1,46 @@
|
|||
// use strum::IntoEnumIterator;
|
||||
// use rayon::prelude::*;
|
||||
// use std::{path::PathBuf, io::BufReader};
|
||||
// use crate::filesystem::AssetManager;
|
||||
// use super::AssetPaths;
|
||||
|
||||
// pub fn load_texture2darray_prefab<
|
||||
// T: AssetPaths + IntoEnumIterator,
|
||||
// E: Facade
|
||||
// >(
|
||||
// assman: &AssetManager,
|
||||
// directory: PathBuf,
|
||||
// facade: &E,
|
||||
// mipmaps: MipmapsOption,
|
||||
// ) -> SrgbTexture2dArray {
|
||||
// log::info!("started loading {}", directory.as_os_str().to_str().unwrap());
|
||||
// //Load raw images
|
||||
// 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| {
|
||||
// log::info!("loading texture {}", file_name);
|
||||
// //Get path to the image and open the file
|
||||
// let reader = {
|
||||
// let path = directory.join(file_name);
|
||||
// BufReader::new(assman.open_asset(&path).expect("Failed to open texture file"))
|
||||
// };
|
||||
// //Parse image data
|
||||
// let (image_data, dimensions) = {
|
||||
// let image = image::load(
|
||||
// reader,
|
||||
// image::ImageFormat::Png
|
||||
// ).unwrap().to_rgba8();
|
||||
// let dimensions = image.dimensions();
|
||||
// (image.into_raw(), dimensions)
|
||||
// };
|
||||
// //Create a glium RawImage
|
||||
// RawImage2d::from_raw_rgba_reversed(
|
||||
// &image_data,
|
||||
// dimensions
|
||||
// )
|
||||
// }).collect();
|
||||
// log::info!("done loading texture files, uploading to the gpu");
|
||||
// //Upload images to the GPU
|
||||
// SrgbTexture2dArray::with_mipmaps(facade, raw_images, mipmaps)
|
||||
// .expect("Failed to upload texture array to GPU")
|
||||
// }
|
||||
use strum::IntoEnumIterator;
|
||||
use rayon::prelude::*;
|
||||
use std::{path::PathBuf, io::BufReader};
|
||||
use glium::{texture::{SrgbTexture2dArray, RawImage2d, MipmapsOption}, backend::Facade};
|
||||
use crate::filesystem::AssetManager;
|
||||
use super::AssetPaths;
|
||||
|
||||
pub fn load_texture2darray_prefab<
|
||||
T: AssetPaths + IntoEnumIterator,
|
||||
E: Facade
|
||||
>(
|
||||
assman: &AssetManager,
|
||||
directory: PathBuf,
|
||||
facade: &E,
|
||||
mipmaps: MipmapsOption,
|
||||
) -> SrgbTexture2dArray {
|
||||
log::info!("started loading {}", directory.as_os_str().to_str().unwrap());
|
||||
//Load raw images
|
||||
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| {
|
||||
log::info!("loading texture {}", file_name);
|
||||
//Get path to the image and open the file
|
||||
let reader = {
|
||||
let path = directory.join(file_name);
|
||||
BufReader::new(assman.open_asset(&path).expect("Failed to open texture file"))
|
||||
};
|
||||
//Parse image data
|
||||
let (image_data, dimensions) = {
|
||||
let image = image::load(
|
||||
reader,
|
||||
image::ImageFormat::Png
|
||||
).unwrap().to_rgba8();
|
||||
let dimensions = image.dimensions();
|
||||
(image.into_raw(), dimensions)
|
||||
};
|
||||
//Create a glium RawImage
|
||||
RawImage2d::from_raw_rgba_reversed(
|
||||
&image_data,
|
||||
dimensions
|
||||
)
|
||||
}).collect();
|
||||
log::info!("done loading texture files, uploading to the gpu");
|
||||
//Upload images to the GPU
|
||||
SrgbTexture2dArray::with_mipmaps(facade, raw_images, mipmaps)
|
||||
.expect("Failed to upload texture array to GPU")
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
use pollster::FutureExt;
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use shipyard::{AllStoragesView, AllStoragesViewMut, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||
use wgpu::SurfaceTargetUnsafe;
|
||||
use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, AllStoragesView};
|
||||
use winit::{
|
||||
event_loop::ActiveEventLoop,
|
||||
window::{WindowAttributes, Fullscreen, Window},
|
||||
dpi::PhysicalSize
|
||||
};
|
||||
use glam::{Vec3, UVec2};
|
||||
use crate::{events::WindowResizedEvent, settings::{FullscreenMode, GameSettings}, state::is_ingame};
|
||||
use crate::{events::WindowResizedEvent, settings::{GameSettings, FullscreenMode}};
|
||||
|
||||
pub mod primitives;
|
||||
pub mod world;
|
||||
|
@ -16,40 +13,24 @@ pub mod selection_box;
|
|||
pub mod entities;
|
||||
pub mod sumberge;
|
||||
|
||||
pub struct BufferPair {
|
||||
pub index: wgpu::Buffer,
|
||||
pub vertex: wgpu::Buffer,
|
||||
}
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct BackgroundColor(pub Vec3);
|
||||
|
||||
#[derive(Unique, Clone, Copy)]
|
||||
#[repr(transparent)]
|
||||
#[deprecated = "use Renderer.size instead"]
|
||||
#[allow(deprecated)]
|
||||
pub struct WindowSize(pub UVec2);
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct Renderer {
|
||||
instance: wgpu::Instance,
|
||||
surface: wgpu::Surface<'static>,
|
||||
device: wgpu::Device,
|
||||
queue: wgpu::Queue,
|
||||
surface_config: wgpu::SurfaceConfiguration,
|
||||
size: PhysicalSize<u32>,
|
||||
// pub depth_texture: wgpu::Texture,
|
||||
|
||||
//must be last due to drop order
|
||||
window: Window,
|
||||
pub window: Window,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn init(event_loop: &ActiveEventLoop, settings: &GameSettings) -> Self {
|
||||
log::info!("initializing display");
|
||||
|
||||
let window_attributes = Window::default_attributes()
|
||||
let wb = WindowAttributes::new()
|
||||
.with_title("kubi")
|
||||
.with_maximized(true)
|
||||
.with_min_inner_size(PhysicalSize::new(640, 480))
|
||||
|
@ -63,7 +44,6 @@ impl Renderer {
|
|||
let monitor = event_loop.primary_monitor().or_else(|| {
|
||||
event_loop.available_monitors().next()
|
||||
});
|
||||
|
||||
if let Some(monitor) = monitor {
|
||||
log::info!("monitor: {}", monitor.name().unwrap_or_else(|| "generic".into()));
|
||||
match fs_settings.mode {
|
||||
|
@ -95,151 +75,16 @@ impl Renderer {
|
|||
None
|
||||
}
|
||||
});
|
||||
let window = event_loop.create_window(window_attributes).unwrap();
|
||||
|
||||
let size = window.inner_size();
|
||||
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::Backends::BROWSER_WEBGPU | wgpu::Backends::VULKAN | wgpu::Backends::GL,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
// 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(
|
||||
&wgpu::RequestAdapterOptions {
|
||||
power_preference: wgpu::PowerPreference::HighPerformance,
|
||||
compatible_surface: Some(&surface),
|
||||
force_fallback_adapter: false,
|
||||
},
|
||||
).block_on().unwrap();
|
||||
|
||||
let (device, queue) = adapter.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
label: None,
|
||||
required_features: wgpu::Features::empty(),
|
||||
required_limits: wgpu::Limits::downlevel_defaults(),
|
||||
},
|
||||
None,
|
||||
).block_on().unwrap();
|
||||
|
||||
let surface_config = surface.get_default_config(&adapter, size.width, size.height).unwrap();
|
||||
surface.configure(&device, &surface_config);
|
||||
|
||||
Self { window, instance, surface, device, queue, surface_config, size }
|
||||
}
|
||||
|
||||
pub fn resize(&mut self, size: PhysicalSize<u32>) {
|
||||
if size.width == 0 || size.height == 0 {
|
||||
log::warn!("Ignoring resize event with zero width or height");
|
||||
return
|
||||
}
|
||||
if self.size == size {
|
||||
log::warn!("Ignoring resize event with same size");
|
||||
return
|
||||
}
|
||||
log::debug!("resizing surface to {:?}", size);
|
||||
self.size = size;
|
||||
self.surface_config.width = size.width;
|
||||
self.surface_config.height = size.height;
|
||||
self.surface.configure(&self.device, &self.surface_config);
|
||||
}
|
||||
|
||||
pub fn reconfigure(&self) {
|
||||
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
|
||||
Self { window }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_master(storages: AllStoragesViewMut) {
|
||||
let renderer = storages.borrow::<UniqueView<Renderer>>().unwrap();
|
||||
|
||||
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());
|
||||
|
||||
if storages.run(is_ingame) {
|
||||
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()
|
||||
});
|
||||
|
||||
let data = (&mut render_pass, &*renderer);
|
||||
|
||||
storages.run_with_data(world::draw_world, data);
|
||||
|
||||
// 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(std::iter::once(encoder.finish()));
|
||||
surface_texture.present();
|
||||
}
|
||||
|
||||
// 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>,
|
||||
pub fn clear_background(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
color: UniqueView<BackgroundColor>,
|
||||
) {
|
||||
if let Some(size) = resize.iter().last() {
|
||||
renderer.resize(PhysicalSize::new(size.0.x, size.0.y));
|
||||
}
|
||||
target.0.clear_color_srgb_and_depth((color.0.x, color.0.y, color.0.z, 1.), 1.);
|
||||
}
|
||||
|
||||
//not sure if this belongs here
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
// use shipyard::{NonSendSync, UniqueViewMut, UniqueView, View, IntoIter, IntoWithId};
|
||||
// use glium::{DepthTest, Depth, PolygonMode, BackfaceCullingMode, DrawParameters, Surface, uniform};
|
||||
// use kubi_shared::{entity::Entity, transform::Transform};
|
||||
// use crate::{
|
||||
// prefabs::ColoredShaderPrefab,
|
||||
// camera::Camera,
|
||||
// settings::GameSettings
|
||||
// };
|
||||
// use super::{
|
||||
// RenderTarget,
|
||||
// primitives::cube::CenteredCubePrimitive
|
||||
// };
|
||||
|
||||
// // TODO: entity models
|
||||
// pub fn render_entities(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// buffers: NonSendSync<UniqueView<CenteredCubePrimitive>>,
|
||||
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
// camera: View<Camera>,
|
||||
// settings: UniqueView<GameSettings>,
|
||||
// entities: View<Entity>,
|
||||
// transform: View<Transform>,
|
||||
// ) {
|
||||
// let (camera_id, camera) = camera.iter().with_id().next().expect("No cameras in the scene");
|
||||
|
||||
// let draw_parameters = DrawParameters {
|
||||
// depth: Depth {
|
||||
// test: DepthTest::IfLess,
|
||||
// write: true,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// multisampling: settings.msaa.is_some(),
|
||||
// polygon_mode: PolygonMode::Fill,
|
||||
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
// ..Default::default()
|
||||
// };
|
||||
// let view = camera.view_matrix.to_cols_array_2d();
|
||||
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
// for (entity_id, (_, trans)) in (&entities, &transform).iter().with_id() {
|
||||
// //skip rendering camera holder (as the entity would block the view)
|
||||
// if entity_id == camera_id { continue }
|
||||
|
||||
// //render entity
|
||||
// target.0.draw(
|
||||
// &buffers.0,
|
||||
// &buffers.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// color: [1.0, 1.0, 1.0, 1.0_f32],
|
||||
// model: trans.0.to_cols_array_2d(),
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// },
|
||||
// &draw_parameters
|
||||
// ).unwrap();
|
||||
// }
|
||||
// }
|
||||
use shipyard::{NonSendSync, UniqueViewMut, UniqueView, View, IntoIter, IntoWithId};
|
||||
use glium::{DepthTest, Depth, PolygonMode, BackfaceCullingMode, DrawParameters, Surface, uniform};
|
||||
use kubi_shared::{entity::Entity, transform::Transform};
|
||||
use crate::{
|
||||
prefabs::ColoredShaderPrefab,
|
||||
camera::Camera,
|
||||
settings::GameSettings
|
||||
};
|
||||
use super::{
|
||||
RenderTarget,
|
||||
primitives::cube::CenteredCubePrimitive
|
||||
};
|
||||
|
||||
// TODO: entity models
|
||||
pub fn render_entities(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
buffers: NonSendSync<UniqueView<CenteredCubePrimitive>>,
|
||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
camera: View<Camera>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
entities: View<Entity>,
|
||||
transform: View<Transform>,
|
||||
) {
|
||||
let (camera_id, camera) = camera.iter().with_id().next().expect("No cameras in the scene");
|
||||
|
||||
let draw_parameters = DrawParameters {
|
||||
depth: Depth {
|
||||
test: DepthTest::IfLess,
|
||||
write: true,
|
||||
..Default::default()
|
||||
},
|
||||
multisampling: settings.msaa.is_some(),
|
||||
polygon_mode: PolygonMode::Fill,
|
||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
..Default::default()
|
||||
};
|
||||
let view = camera.view_matrix.to_cols_array_2d();
|
||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
for (entity_id, (_, trans)) in (&entities, &transform).iter().with_id() {
|
||||
//skip rendering camera holder (as the entity would block the view)
|
||||
if entity_id == camera_id { continue }
|
||||
|
||||
//render entity
|
||||
target.0.draw(
|
||||
&buffers.0,
|
||||
&buffers.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
color: [1.0, 1.0, 1.0, 1.0_f32],
|
||||
model: trans.0.to_cols_array_2d(),
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
},
|
||||
&draw_parameters
|
||||
).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
// use shipyard::{Workload, IntoWorkload};
|
||||
// use glium::implement_vertex;
|
||||
use shipyard::{Workload, IntoWorkload};
|
||||
use glium::implement_vertex;
|
||||
|
||||
// pub mod cube;
|
||||
// pub mod rect;
|
||||
// pub mod stri;
|
||||
pub mod cube;
|
||||
pub mod rect;
|
||||
pub mod stri;
|
||||
|
||||
// use cube::init_cube_primitive;
|
||||
// use rect::init_rect_primitive;
|
||||
// use stri::init_stri_primitive;
|
||||
use cube::init_cube_primitive;
|
||||
use rect::init_rect_primitive;
|
||||
use stri::init_stri_primitive;
|
||||
|
||||
// #[derive(Clone, Copy, Default)]
|
||||
// pub struct PositionOnlyVertex {
|
||||
// pub position: [f32; 3],
|
||||
// }
|
||||
// implement_vertex!(PositionOnlyVertex, position);
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct PositionOnlyVertex {
|
||||
pub position: [f32; 3],
|
||||
}
|
||||
implement_vertex!(PositionOnlyVertex, position);
|
||||
|
||||
// #[derive(Clone, Copy, Default)]
|
||||
// pub struct PositionOnlyVertex2d {
|
||||
// pub position: [f32; 2],
|
||||
// }
|
||||
// implement_vertex!(PositionOnlyVertex2d, position);
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct PositionOnlyVertex2d {
|
||||
pub position: [f32; 2],
|
||||
}
|
||||
implement_vertex!(PositionOnlyVertex2d, position);
|
||||
|
||||
// pub fn init_primitives() -> Workload {
|
||||
// (
|
||||
// init_cube_primitive,
|
||||
// init_rect_primitive,
|
||||
// init_stri_primitive,
|
||||
// ).into_workload()
|
||||
// }
|
||||
pub fn init_primitives() -> Workload {
|
||||
(
|
||||
init_cube_primitive,
|
||||
init_rect_primitive,
|
||||
init_stri_primitive,
|
||||
).into_workload()
|
||||
}
|
||||
|
|
|
@ -1,85 +1,85 @@
|
|||
// use shipyard::{AllStoragesView, NonSendSync, UniqueView, Unique};
|
||||
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
// use crate::rendering::Renderer;
|
||||
// use super::PositionOnlyVertex;
|
||||
|
||||
// #[derive(Unique)]
|
||||
// pub struct CubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||
|
||||
// #[derive(Unique)]
|
||||
// pub struct CenteredCubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||
|
||||
// const CENTERED_CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||
// // 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] },
|
||||
// // 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] },
|
||||
// ];
|
||||
// const CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||
// // front
|
||||
// PositionOnlyVertex { position: [0.0, 0.0, 1.0] },
|
||||
// PositionOnlyVertex { position: [1.0, 0.0, 1.0] },
|
||||
// PositionOnlyVertex { position: [1.0, 1.0, 1.0] },
|
||||
// PositionOnlyVertex { position: [0.0, 1.0, 1.0] },
|
||||
// // back
|
||||
// PositionOnlyVertex { position: [0.0, 0.0, 0.0] },
|
||||
// PositionOnlyVertex { position: [1.0, 0.0, 0.0] },
|
||||
// PositionOnlyVertex { position: [1.0, 1.0, 0.0] },
|
||||
// PositionOnlyVertex { position: [0.0, 1.0, 0.0] },
|
||||
// ];
|
||||
// const CUBE_INDICES: &[u16] = &[
|
||||
// // front
|
||||
// 0, 1, 2,
|
||||
// 2, 3, 0,
|
||||
// // right
|
||||
// 1, 5, 6,
|
||||
// 6, 2, 1,
|
||||
// // back
|
||||
// 7, 6, 5,
|
||||
// 5, 4, 7,
|
||||
// // left
|
||||
// 4, 0, 3,
|
||||
// 3, 7, 4,
|
||||
// // bottom
|
||||
// 4, 5, 1,
|
||||
// 1, 0, 4,
|
||||
// // top
|
||||
// 3, 2, 6,
|
||||
// 6, 7, 3
|
||||
// ];
|
||||
|
||||
// pub(super) fn init_cube_primitive(
|
||||
// storages: AllStoragesView,
|
||||
// display: NonSendSync<UniqueView<Renderer>>
|
||||
// ) {
|
||||
// {
|
||||
// let vert = VertexBuffer::immutable(
|
||||
// &display.display,
|
||||
// CUBE_VERTICES
|
||||
// ).unwrap();
|
||||
// let index = IndexBuffer::immutable(
|
||||
// &display.display,
|
||||
// PrimitiveType::TrianglesList,
|
||||
// CUBE_INDICES
|
||||
// ).unwrap();
|
||||
// storages.add_unique_non_send_sync(CubePrimitive(vert, index));
|
||||
// }
|
||||
// {
|
||||
// let vert = VertexBuffer::immutable(
|
||||
// &display.display,
|
||||
// CENTERED_CUBE_VERTICES
|
||||
// ).unwrap();
|
||||
// let index = IndexBuffer::immutable(
|
||||
// &display.display,
|
||||
// PrimitiveType::TrianglesList,
|
||||
// CUBE_INDICES
|
||||
// ).unwrap();
|
||||
// storages.add_unique_non_send_sync(CenteredCubePrimitive(vert, index));
|
||||
// }
|
||||
// }
|
||||
use shipyard::{AllStoragesView, NonSendSync, UniqueView, Unique};
|
||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
use crate::rendering::Renderer;
|
||||
use super::PositionOnlyVertex;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct CubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct CenteredCubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||
|
||||
const CENTERED_CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||
// 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] },
|
||||
// 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] },
|
||||
];
|
||||
const CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||
// front
|
||||
PositionOnlyVertex { position: [0.0, 0.0, 1.0] },
|
||||
PositionOnlyVertex { position: [1.0, 0.0, 1.0] },
|
||||
PositionOnlyVertex { position: [1.0, 1.0, 1.0] },
|
||||
PositionOnlyVertex { position: [0.0, 1.0, 1.0] },
|
||||
// back
|
||||
PositionOnlyVertex { position: [0.0, 0.0, 0.0] },
|
||||
PositionOnlyVertex { position: [1.0, 0.0, 0.0] },
|
||||
PositionOnlyVertex { position: [1.0, 1.0, 0.0] },
|
||||
PositionOnlyVertex { position: [0.0, 1.0, 0.0] },
|
||||
];
|
||||
const CUBE_INDICES: &[u16] = &[
|
||||
// front
|
||||
0, 1, 2,
|
||||
2, 3, 0,
|
||||
// right
|
||||
1, 5, 6,
|
||||
6, 2, 1,
|
||||
// back
|
||||
7, 6, 5,
|
||||
5, 4, 7,
|
||||
// left
|
||||
4, 0, 3,
|
||||
3, 7, 4,
|
||||
// bottom
|
||||
4, 5, 1,
|
||||
1, 0, 4,
|
||||
// top
|
||||
3, 2, 6,
|
||||
6, 7, 3
|
||||
];
|
||||
|
||||
pub(super) fn init_cube_primitive(
|
||||
storages: AllStoragesView,
|
||||
display: NonSendSync<UniqueView<Renderer>>
|
||||
) {
|
||||
{
|
||||
let vert = VertexBuffer::immutable(
|
||||
&display.display,
|
||||
CUBE_VERTICES
|
||||
).unwrap();
|
||||
let index = IndexBuffer::immutable(
|
||||
&display.display,
|
||||
PrimitiveType::TrianglesList,
|
||||
CUBE_INDICES
|
||||
).unwrap();
|
||||
storages.add_unique_non_send_sync(CubePrimitive(vert, index));
|
||||
}
|
||||
{
|
||||
let vert = VertexBuffer::immutable(
|
||||
&display.display,
|
||||
CENTERED_CUBE_VERTICES
|
||||
).unwrap();
|
||||
let index = IndexBuffer::immutable(
|
||||
&display.display,
|
||||
PrimitiveType::TrianglesList,
|
||||
CUBE_INDICES
|
||||
).unwrap();
|
||||
storages.add_unique_non_send_sync(CenteredCubePrimitive(vert, index));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
// use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
// use crate::rendering::Renderer;
|
||||
// use super::PositionOnlyVertex2d;
|
||||
|
||||
// #[derive(Unique)]
|
||||
// pub struct RectPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||
|
||||
// const RECT_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||
// PositionOnlyVertex2d { position: [0., 0.] },
|
||||
// PositionOnlyVertex2d { position: [1., 0.] },
|
||||
// PositionOnlyVertex2d { position: [0., 1.] },
|
||||
// PositionOnlyVertex2d { position: [1., 1.] },
|
||||
// ];
|
||||
// const RECT_INDEX: &[u16] = &[0, 1, 2, 1, 3, 2];
|
||||
|
||||
// pub(super) fn init_rect_primitive(
|
||||
// storages: AllStoragesView,
|
||||
// display: NonSendSync<UniqueView<Renderer>>
|
||||
// ) {
|
||||
// let vert = VertexBuffer::immutable(
|
||||
// &display.display,
|
||||
// RECT_VERTEX
|
||||
// ).unwrap();
|
||||
// let index = IndexBuffer::immutable(
|
||||
// &display.display,
|
||||
// PrimitiveType::TrianglesList,
|
||||
// RECT_INDEX
|
||||
// ).unwrap();
|
||||
// storages.add_unique_non_send_sync(RectPrimitive(vert, index));
|
||||
// }
|
||||
use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
use crate::rendering::Renderer;
|
||||
use super::PositionOnlyVertex2d;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct RectPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||
|
||||
const RECT_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||
PositionOnlyVertex2d { position: [0., 0.] },
|
||||
PositionOnlyVertex2d { position: [1., 0.] },
|
||||
PositionOnlyVertex2d { position: [0., 1.] },
|
||||
PositionOnlyVertex2d { position: [1., 1.] },
|
||||
];
|
||||
const RECT_INDEX: &[u16] = &[0, 1, 2, 1, 3, 2];
|
||||
|
||||
pub(super) fn init_rect_primitive(
|
||||
storages: AllStoragesView,
|
||||
display: NonSendSync<UniqueView<Renderer>>
|
||||
) {
|
||||
let vert = VertexBuffer::immutable(
|
||||
&display.display,
|
||||
RECT_VERTEX
|
||||
).unwrap();
|
||||
let index = IndexBuffer::immutable(
|
||||
&display.display,
|
||||
PrimitiveType::TrianglesList,
|
||||
RECT_INDEX
|
||||
).unwrap();
|
||||
storages.add_unique_non_send_sync(RectPrimitive(vert, index));
|
||||
}
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
// use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
// use crate::rendering::Renderer;
|
||||
// use super::PositionOnlyVertex2d;
|
||||
use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
use crate::rendering::Renderer;
|
||||
use super::PositionOnlyVertex2d;
|
||||
|
||||
// #[derive(Unique)]
|
||||
// pub struct STriPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||
#[derive(Unique)]
|
||||
pub struct STriPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||
|
||||
// const STRI_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||
// PositionOnlyVertex2d { position: [-1., -1.] },
|
||||
// PositionOnlyVertex2d { position: [ 3., -1.] },
|
||||
// PositionOnlyVertex2d { position: [-1., 3.] },
|
||||
// ];
|
||||
// const STRI_INDEX: &[u16] = &[0, 1, 2];
|
||||
const STRI_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||
PositionOnlyVertex2d { position: [-1., -1.] },
|
||||
PositionOnlyVertex2d { position: [ 3., -1.] },
|
||||
PositionOnlyVertex2d { position: [-1., 3.] },
|
||||
];
|
||||
const STRI_INDEX: &[u16] = &[0, 1, 2];
|
||||
|
||||
// pub(super) fn init_stri_primitive(
|
||||
// storages: AllStoragesView,
|
||||
// display: NonSendSync<UniqueView<Renderer>>
|
||||
// ) {
|
||||
// let vert = VertexBuffer::immutable(
|
||||
// &display.display,
|
||||
// STRI_VERTEX
|
||||
// ).unwrap();
|
||||
// let index = IndexBuffer::immutable(
|
||||
// &display.display,
|
||||
// PrimitiveType::TrianglesList,
|
||||
// STRI_INDEX
|
||||
// ).unwrap();
|
||||
// storages.add_unique_non_send_sync(STriPrimitive(vert, index));
|
||||
// }
|
||||
pub(super) fn init_stri_primitive(
|
||||
storages: AllStoragesView,
|
||||
display: NonSendSync<UniqueView<Renderer>>
|
||||
) {
|
||||
let vert = VertexBuffer::immutable(
|
||||
&display.display,
|
||||
STRI_VERTEX
|
||||
).unwrap();
|
||||
let index = IndexBuffer::immutable(
|
||||
&display.display,
|
||||
PrimitiveType::TrianglesList,
|
||||
STRI_INDEX
|
||||
).unwrap();
|
||||
storages.add_unique_non_send_sync(STriPrimitive(vert, index));
|
||||
}
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
// use glam::{Mat4, Vec3, Quat};
|
||||
// use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut, UniqueView};
|
||||
// use glium::{
|
||||
// Surface,
|
||||
// DrawParameters,
|
||||
// BackfaceCullingMode,
|
||||
// Blend, Depth, DepthTest,
|
||||
// uniform,
|
||||
// };
|
||||
// use crate::{
|
||||
// world::raycast::LookingAtBlock,
|
||||
// camera::Camera,
|
||||
// prefabs::ColoredShaderPrefab
|
||||
// };
|
||||
// use super::{
|
||||
// RenderTarget,
|
||||
// primitives::cube::CubePrimitive,
|
||||
// };
|
||||
|
||||
// const SMOL: f32 = 0.0025;
|
||||
|
||||
// pub fn render_selection_box(
|
||||
// lookat: View<LookingAtBlock>,
|
||||
// camera: View<Camera>,
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
// buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||
// ) {
|
||||
// let camera = camera.iter().next().unwrap();
|
||||
// let Some(lookat) = lookat.iter().next() else { return };
|
||||
// let Some(lookat) = lookat.0 else { return };
|
||||
|
||||
// //Darken block
|
||||
// target.0.draw(
|
||||
// &buffers.0,
|
||||
// &buffers.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// color: [0., 0., 0., 0.5_f32],
|
||||
// model: Mat4::from_scale_rotation_translation(
|
||||
// Vec3::splat(1. + SMOL * 2.),
|
||||
// Quat::default(),
|
||||
// lookat.block_position.as_vec3() - Vec3::splat(SMOL)
|
||||
// ).to_cols_array_2d(),
|
||||
// perspective: camera.perspective_matrix.to_cols_array_2d(),
|
||||
// view: camera.view_matrix.to_cols_array_2d(),
|
||||
// },
|
||||
// &DrawParameters {
|
||||
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
// blend: Blend::alpha_blending(),
|
||||
// depth: Depth {
|
||||
// //this may be unreliable... unless scale is applied! hacky...
|
||||
// test: DepthTest::IfLessOrEqual,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// ..Default::default()
|
||||
// }
|
||||
// ).unwrap();
|
||||
// }
|
||||
use glam::{Mat4, Vec3, Quat};
|
||||
use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut, UniqueView};
|
||||
use glium::{
|
||||
Surface,
|
||||
DrawParameters,
|
||||
BackfaceCullingMode,
|
||||
Blend, Depth, DepthTest,
|
||||
uniform,
|
||||
};
|
||||
use crate::{
|
||||
world::raycast::LookingAtBlock,
|
||||
camera::Camera,
|
||||
prefabs::ColoredShaderPrefab
|
||||
};
|
||||
use super::{
|
||||
RenderTarget,
|
||||
primitives::cube::CubePrimitive,
|
||||
};
|
||||
|
||||
const SMOL: f32 = 0.0025;
|
||||
|
||||
pub fn render_selection_box(
|
||||
lookat: View<LookingAtBlock>,
|
||||
camera: View<Camera>,
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||
) {
|
||||
let camera = camera.iter().next().unwrap();
|
||||
let Some(lookat) = lookat.iter().next() else { return };
|
||||
let Some(lookat) = lookat.0 else { return };
|
||||
|
||||
//Darken block
|
||||
target.0.draw(
|
||||
&buffers.0,
|
||||
&buffers.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
color: [0., 0., 0., 0.5_f32],
|
||||
model: Mat4::from_scale_rotation_translation(
|
||||
Vec3::splat(1. + SMOL * 2.),
|
||||
Quat::default(),
|
||||
lookat.block_position.as_vec3() - Vec3::splat(SMOL)
|
||||
).to_cols_array_2d(),
|
||||
perspective: camera.perspective_matrix.to_cols_array_2d(),
|
||||
view: camera.view_matrix.to_cols_array_2d(),
|
||||
},
|
||||
&DrawParameters {
|
||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
blend: Blend::alpha_blending(),
|
||||
depth: Depth {
|
||||
//this may be unreliable... unless scale is applied! hacky...
|
||||
test: DepthTest::IfLessOrEqual,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
).unwrap();
|
||||
}
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
// use glium::{uniform, Blend, DrawParameters, Surface};
|
||||
// use kubi_shared::transform::Transform;
|
||||
// use shipyard::{IntoIter, NonSendSync, UniqueView, UniqueViewMut, View};
|
||||
// use crate::{
|
||||
// player::MainPlayer,
|
||||
// prefabs::Colored2ShaderPrefab,
|
||||
// rendering::primitives::stri::STriPrimitive,
|
||||
// world::ChunkStorage,
|
||||
// };
|
||||
// use super::RenderTarget;
|
||||
use glium::{uniform, Blend, DrawParameters, Surface};
|
||||
use kubi_shared::transform::Transform;
|
||||
use shipyard::{IntoIter, NonSendSync, UniqueView, UniqueViewMut, View};
|
||||
use crate::{
|
||||
player::MainPlayer,
|
||||
prefabs::Colored2ShaderPrefab,
|
||||
rendering::primitives::stri::STriPrimitive,
|
||||
world::ChunkStorage,
|
||||
};
|
||||
use super::RenderTarget;
|
||||
|
||||
// pub fn render_submerged_view(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// primitive: NonSendSync<UniqueView<STriPrimitive>>,
|
||||
// program: NonSendSync<UniqueView<Colored2ShaderPrefab>>,
|
||||
// plr: View<MainPlayer>,
|
||||
// trans: View<Transform>,
|
||||
// world: UniqueView<ChunkStorage>,
|
||||
// ) {
|
||||
// let (_, plr_trans) = (&plr, &trans).iter().next().expect("Main player MIA");
|
||||
// let plr_pos = plr_trans.0.to_scale_rotation_translation().2;
|
||||
// let block_at_pos = world.get_block(plr_pos.floor().as_ivec3());
|
||||
// let Some(block_at_pos) = block_at_pos else { return };
|
||||
// let Some(color) = block_at_pos.descriptor().submerge else { return };
|
||||
pub fn render_submerged_view(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
primitive: NonSendSync<UniqueView<STriPrimitive>>,
|
||||
program: NonSendSync<UniqueView<Colored2ShaderPrefab>>,
|
||||
plr: View<MainPlayer>,
|
||||
trans: View<Transform>,
|
||||
world: UniqueView<ChunkStorage>,
|
||||
) {
|
||||
let (_, plr_trans) = (&plr, &trans).iter().next().expect("Main player MIA");
|
||||
let plr_pos = plr_trans.0.to_scale_rotation_translation().2;
|
||||
let block_at_pos = world.get_block(plr_pos.floor().as_ivec3());
|
||||
let Some(block_at_pos) = block_at_pos else { return };
|
||||
let Some(color) = block_at_pos.descriptor().submerge else { return };
|
||||
|
||||
// let draw_parameters = DrawParameters {
|
||||
// blend: Blend::alpha_blending(),
|
||||
// ..Default::default()
|
||||
// };
|
||||
// target.0.draw(
|
||||
// &primitive.0,
|
||||
// &primitive.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// color: color.to_array(),
|
||||
// },
|
||||
// &draw_parameters,
|
||||
// ).unwrap();
|
||||
// }
|
||||
let draw_parameters = DrawParameters {
|
||||
blend: Blend::alpha_blending(),
|
||||
..Default::default()
|
||||
};
|
||||
target.0.draw(
|
||||
&primitive.0,
|
||||
&primitive.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
color: color.to_array(),
|
||||
},
|
||||
&draw_parameters,
|
||||
).unwrap();
|
||||
}
|
||||
|
|
|
@ -1,31 +1,38 @@
|
|||
use bytemuck::{Pod, Zeroable};
|
||||
use glam::IVec3;
|
||||
use shipyard::{AllStoragesView, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||
use kubi_shared::transform::Transform;
|
||||
use crate::{camera::Camera, settings::GameSettings, world::{ChunkMeshStorage, ChunkStorage}};
|
||||
use super::Renderer;
|
||||
use glam::{ivec3, IVec3, Mat4, Quat, Vec3};
|
||||
use shipyard::{track, AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||
use glium::{
|
||||
draw_parameters::{
|
||||
BackfaceCullingMode, Depth, DepthTest, PolygonMode
|
||||
}, implement_vertex, uniform, uniforms::{
|
||||
MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerBehavior, SamplerWrapFunction
|
||||
}, Blend, DrawParameters, Smooth, Surface
|
||||
};
|
||||
use crate::{
|
||||
camera::Camera,
|
||||
player::MainPlayer,
|
||||
transform::Transform,
|
||||
prefabs::{
|
||||
ChunkShaderPrefab,
|
||||
BlockTexturesPrefab,
|
||||
ColoredShaderPrefab,
|
||||
},
|
||||
world::{
|
||||
ChunkStorage,
|
||||
ChunkMeshStorage,
|
||||
chunk::CHUNK_SIZE,
|
||||
}, settings::GameSettings,
|
||||
};
|
||||
use super::{RenderTarget, primitives::cube::CubePrimitive};
|
||||
|
||||
#[derive(Clone, Copy, Pod, Zeroable)]
|
||||
#[repr(C, packed)]
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct ChunkVertex {
|
||||
pub position: [f32; 3],
|
||||
pub normal: [f32; 3],
|
||||
pub uv: [f32; 2],
|
||||
pub tex_index: u8,
|
||||
}
|
||||
|
||||
impl ChunkVertex {
|
||||
pub const LAYOUT: wgpu::VertexBufferLayout<'static> = wgpu::VertexBufferLayout {
|
||||
array_stride: std::mem::size_of::<ChunkVertex>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![
|
||||
0 => Float32x3,
|
||||
1 => Float32x3,
|
||||
2 => Float32x2,
|
||||
3 => Uint32,
|
||||
],
|
||||
};
|
||||
}
|
||||
implement_vertex!(ChunkVertex, position, normal, uv, tex_index);
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct TransChunkQueue(pub Vec<IVec3>);
|
||||
|
@ -34,221 +41,208 @@ pub fn init_trans_chunk_queue(storages: AllStoragesView) {
|
|||
storages.add_unique(TransChunkQueue(Vec::with_capacity(512)));
|
||||
}
|
||||
|
||||
fn draw_params(settings: &GameSettings) -> DrawParameters {
|
||||
DrawParameters {
|
||||
depth: Depth {
|
||||
test: DepthTest::IfLess,
|
||||
write: true,
|
||||
..Default::default()
|
||||
},
|
||||
multisampling: settings.msaa.is_some(),
|
||||
polygon_mode: PolygonMode::Fill, //Change to Line for wireframe
|
||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn texture_sampler<'a, T>(texture: &'a T, settings: &GameSettings) -> Sampler<'a, T> {
|
||||
Sampler(texture, SamplerBehavior {
|
||||
minify_filter: MinifySamplerFilter::LinearMipmapLinear,
|
||||
magnify_filter: MagnifySamplerFilter::Nearest,
|
||||
max_anisotropy: settings.max_anisotropy.unwrap_or_default(),
|
||||
wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp),
|
||||
depth_texture_comparison: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn draw_world(
|
||||
(render_pass, renderer): (&mut wgpu::RenderPass, &Renderer),
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
chunks: UniqueView<ChunkStorage>,
|
||||
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||
texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||
transform: View<Transform>,
|
||||
camera: View<Camera>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||
) {
|
||||
//TODO
|
||||
// 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 = camera.iter().next().expect("No cameras in the scene");
|
||||
let view = camera.view_matrix.to_cols_array_2d();
|
||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
let draw_parameters = draw_params(&settings);
|
||||
let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||
|
||||
for (&position, chunk) in &chunks.chunks {
|
||||
if let Some(key) = chunk.mesh_index {
|
||||
let mesh = meshes.get(key).expect("Mesh index pointing to nothing");
|
||||
let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||
|
||||
//Skip mesh if its empty
|
||||
if mesh.index_buffer.len() == 0 && mesh.trans_index_buffer.len() == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
//Frustum culling
|
||||
{
|
||||
let minp = world_position;
|
||||
let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32);
|
||||
if !camera.frustum.is_box_visible(minp, maxp) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
//Draw chunk mesh
|
||||
if mesh.index_buffer.len() > 0 {
|
||||
target.0.draw(
|
||||
&mesh.vertex_buffer,
|
||||
&mesh.index_buffer,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
position_offset: world_position.to_array(),
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
tex: texture_sampler,
|
||||
discard_alpha: true,
|
||||
},
|
||||
&draw_parameters
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
if mesh.trans_index_buffer.len() > 0 {
|
||||
trans_queue.0.push(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const HALF_CHUNK_SIZE: IVec3 = IVec3::splat((CHUNK_SIZE >> 1) as i32);
|
||||
// trans_queue.0.sort_by_cached_key(|&pos| -(
|
||||
// (pos + HALF_CHUNK_SIZE).distance_squared(camera_position.as_ivec3())
|
||||
// ));
|
||||
}
|
||||
|
||||
pub fn draw_world_trans(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
chunks: UniqueView<ChunkStorage>,
|
||||
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||
texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||
camera: View<Camera>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||
) {
|
||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
let view = camera.view_matrix.to_cols_array_2d();
|
||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
// fn draw_params(settings: &GameSettings) -> DrawParameters {
|
||||
// DrawParameters {
|
||||
// depth: Depth {
|
||||
// test: DepthTest::IfLess,
|
||||
// write: true,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// multisampling: settings.msaa.is_some(),
|
||||
// polygon_mode: PolygonMode::Fill, //Change to Line for wireframe
|
||||
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
// ..Default::default()
|
||||
// }
|
||||
// }
|
||||
let mut draw_parameters = draw_params(&settings);
|
||||
draw_parameters.blend = Blend::alpha_blending();
|
||||
draw_parameters.backface_culling = BackfaceCullingMode::CullingDisabled;
|
||||
draw_parameters.smooth = Some(Smooth::Fastest);
|
||||
|
||||
// fn texture_sampler<'a, T>(texture: &'a T, settings: &GameSettings) -> Sampler<'a, T> {
|
||||
// Sampler(texture, SamplerBehavior {
|
||||
// minify_filter: MinifySamplerFilter::LinearMipmapLinear,
|
||||
// magnify_filter: MagnifySamplerFilter::Nearest,
|
||||
// max_anisotropy: settings.max_anisotropy.unwrap_or_default(),
|
||||
// wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp),
|
||||
// depth_texture_comparison: None,
|
||||
// })
|
||||
// }
|
||||
let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||
|
||||
// pub fn draw_world(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// chunks: UniqueView<ChunkStorage>,
|
||||
// meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
// program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||
// texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||
// transform: View<Transform>,
|
||||
// camera: View<Camera>,
|
||||
// settings: UniqueView<GameSettings>,
|
||||
// mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||
// ) {
|
||||
// // let (camera, transform) = (&camera, &transform).iter().next().expect("No cameras in the scene");
|
||||
// // let camera_position = transform.0.to_scale_rotation_translation().2;
|
||||
for position in trans_queue.0.drain(..).rev() {
|
||||
let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||
let mesh_idx = chunks.chunks[&position].mesh_index.expect("No mesh index");
|
||||
let mesh = meshes.get(mesh_idx).expect("Mesh index pointing to nothing");
|
||||
target.0.draw(
|
||||
&mesh.trans_vertex_buffer,
|
||||
&mesh.trans_index_buffer,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
position_offset: world_position.to_array(),
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
tex: texture_sampler,
|
||||
discard_alpha: false,
|
||||
},
|
||||
&draw_parameters
|
||||
).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
// let view = camera.view_matrix.to_cols_array_2d();
|
||||
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
// let draw_parameters = draw_params(&settings);
|
||||
// let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||
|
||||
// for (&position, chunk) in &chunks.chunks {
|
||||
// if let Some(key) = chunk.mesh_index {
|
||||
// let mesh = meshes.get(key).expect("Mesh index pointing to nothing");
|
||||
// let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||
|
||||
// //Skip mesh if its empty
|
||||
// if mesh.index_buffer.len() == 0 && mesh.trans_index_buffer.len() == 0 {
|
||||
// continue
|
||||
// }
|
||||
|
||||
// //Frustum culling
|
||||
// {
|
||||
// let minp = world_position;
|
||||
// let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32);
|
||||
// if !camera.frustum.is_box_visible(minp, maxp) {
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
|
||||
// //Draw chunk mesh
|
||||
// if mesh.index_buffer.len() > 0 {
|
||||
// target.0.draw(
|
||||
// &mesh.vertex_buffer,
|
||||
// &mesh.index_buffer,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// position_offset: world_position.to_array(),
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// tex: texture_sampler,
|
||||
// discard_alpha: true,
|
||||
// },
|
||||
// &draw_parameters
|
||||
// ).unwrap();
|
||||
// }
|
||||
|
||||
// if mesh.trans_index_buffer.len() > 0 {
|
||||
// trans_queue.0.push(position);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // const HALF_CHUNK_SIZE: IVec3 = IVec3::splat((CHUNK_SIZE >> 1) as i32);
|
||||
// // trans_queue.0.sort_by_cached_key(|&pos| -(
|
||||
// // (pos + HALF_CHUNK_SIZE).distance_squared(camera_position.as_ivec3())
|
||||
// // ));
|
||||
// }
|
||||
|
||||
// pub fn draw_world_trans(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// chunks: UniqueView<ChunkStorage>,
|
||||
// meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
// program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||
// texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||
// camera: View<Camera>,
|
||||
// settings: UniqueView<GameSettings>,
|
||||
// mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||
// ) {
|
||||
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
// let view = camera.view_matrix.to_cols_array_2d();
|
||||
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
// let mut draw_parameters = draw_params(&settings);
|
||||
// draw_parameters.blend = Blend::alpha_blending();
|
||||
// draw_parameters.backface_culling = BackfaceCullingMode::CullingDisabled;
|
||||
// draw_parameters.smooth = Some(Smooth::Fastest);
|
||||
|
||||
// let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||
|
||||
// for position in trans_queue.0.drain(..).rev() {
|
||||
// let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||
// let mesh_idx = chunks.chunks[&position].mesh_index.expect("No mesh index");
|
||||
// let mesh = meshes.get(mesh_idx).expect("Mesh index pointing to nothing");
|
||||
// target.0.draw(
|
||||
// &mesh.trans_vertex_buffer,
|
||||
// &mesh.trans_index_buffer,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// position_offset: world_position.to_array(),
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// tex: texture_sampler,
|
||||
// discard_alpha: false,
|
||||
// },
|
||||
// &draw_parameters
|
||||
// ).unwrap();
|
||||
// }
|
||||
// }
|
||||
|
||||
// pub fn draw_current_chunk_border(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// player: View<MainPlayer>,
|
||||
// transforms: View<Transform, track::All>,
|
||||
// buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
// camera: View<Camera>,
|
||||
// settings: UniqueView<GameSettings>,
|
||||
// ) {
|
||||
// if cfg!(target_os = "android") {
|
||||
// return
|
||||
// }
|
||||
// if !settings.debug_draw_current_chunk_border {
|
||||
// return
|
||||
// }
|
||||
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
// let view = camera.view_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_position) = player_transform.0.to_scale_rotation_translation();
|
||||
// let player_in_chunk = ivec3(
|
||||
// (player_position.x 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),
|
||||
// );
|
||||
// let world_position = player_in_chunk.as_vec3() * CHUNK_SIZE as f32;
|
||||
// target.0.draw(
|
||||
// &buffers.0,
|
||||
// &buffers.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// model: Mat4::from_scale_rotation_translation(
|
||||
// Vec3::splat(CHUNK_SIZE as f32),
|
||||
// Quat::default(),
|
||||
// world_position
|
||||
// ).to_cols_array_2d(),
|
||||
// color: [0.25f32; 4],
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// },
|
||||
// &DrawParameters {
|
||||
// depth: Depth {
|
||||
// test: DepthTest::IfLess,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// blend: Blend::alpha_blending(),
|
||||
// ..Default::default()
|
||||
// }
|
||||
// ).unwrap();
|
||||
// target.0.draw(
|
||||
// &buffers.0,
|
||||
// &buffers.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// model: Mat4::from_scale_rotation_translation(
|
||||
// Vec3::splat(CHUNK_SIZE as f32),
|
||||
// Quat::default(),
|
||||
// world_position
|
||||
// ).to_cols_array_2d(),
|
||||
// color: [0.0f32; 4],
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// },
|
||||
// &DrawParameters {
|
||||
// polygon_mode: PolygonMode::Point,
|
||||
// line_width: Some(2.),
|
||||
// point_size: Some(5.),
|
||||
// ..Default::default()
|
||||
// }
|
||||
// ).unwrap();
|
||||
// }
|
||||
pub fn draw_current_chunk_border(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
player: View<MainPlayer>,
|
||||
transforms: View<Transform, track::All>,
|
||||
buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
camera: View<Camera>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
) {
|
||||
if cfg!(target_os = "android") {
|
||||
return
|
||||
}
|
||||
if !settings.debug_draw_current_chunk_border {
|
||||
return
|
||||
}
|
||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
let view = camera.view_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_position) = player_transform.0.to_scale_rotation_translation();
|
||||
let player_in_chunk = ivec3(
|
||||
(player_position.x 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),
|
||||
);
|
||||
let world_position = player_in_chunk.as_vec3() * CHUNK_SIZE as f32;
|
||||
target.0.draw(
|
||||
&buffers.0,
|
||||
&buffers.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
model: Mat4::from_scale_rotation_translation(
|
||||
Vec3::splat(CHUNK_SIZE as f32),
|
||||
Quat::default(),
|
||||
world_position
|
||||
).to_cols_array_2d(),
|
||||
color: [0.25f32; 4],
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
},
|
||||
&DrawParameters {
|
||||
depth: Depth {
|
||||
test: DepthTest::IfLess,
|
||||
..Default::default()
|
||||
},
|
||||
blend: Blend::alpha_blending(),
|
||||
..Default::default()
|
||||
}
|
||||
).unwrap();
|
||||
target.0.draw(
|
||||
&buffers.0,
|
||||
&buffers.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
model: Mat4::from_scale_rotation_translation(
|
||||
Vec3::splat(CHUNK_SIZE as f32),
|
||||
Quat::default(),
|
||||
world_position
|
||||
).to_cols_array_2d(),
|
||||
color: [0.0f32; 4],
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
},
|
||||
&DrawParameters {
|
||||
polygon_mode: PolygonMode::Point,
|
||||
line_width: Some(2.),
|
||||
point_size: Some(5.),
|
||||
..Default::default()
|
||||
}
|
||||
).unwrap();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use hui::{
|
|||
UiElementExt,
|
||||
},
|
||||
layout::{Alignment, Direction},
|
||||
rect_frame, size,
|
||||
frame_rect, size,
|
||||
};
|
||||
use shipyard::{UniqueView, UniqueViewMut, Workload, NonSendSync, IntoWorkload};
|
||||
use winit::keyboard::KeyCode;
|
||||
|
@ -28,7 +28,7 @@ pub fn loading_screen_base(bg_alpha: f32, xui: impl FnOnce(&mut ElementList)) ->
|
|||
.with_children(|ui| {
|
||||
Container::default()
|
||||
.with_size(size!(400, auto))
|
||||
.with_background(rect_frame! {
|
||||
.with_background(frame_rect! {
|
||||
color: (0.2, 0.2, 0.2),
|
||||
corner_radius: 8.
|
||||
})
|
||||
|
@ -63,11 +63,11 @@ fn render_loading_ui(
|
|||
ProgressBar::default()
|
||||
.with_value(value)
|
||||
.with_size(size!(100%, 15))
|
||||
.with_background(rect_frame! {
|
||||
.with_background(frame_rect! {
|
||||
color: (0.1, 0.1, 0.1),
|
||||
corner_radius: 2.
|
||||
})
|
||||
.with_foreground(rect_frame! {
|
||||
.with_foreground(frame_rect! {
|
||||
color: (0.4, 0.4, 1.0),
|
||||
corner_radius: 2.
|
||||
})
|
||||
|
|
|
@ -2,7 +2,7 @@ use hui::{
|
|||
element::{br::Break, container::Container, slider::Slider, text::Text, UiElementExt},
|
||||
layout::{Alignment, Direction},
|
||||
signal::Signal,
|
||||
rect_frame, size,
|
||||
frame_rect, size,
|
||||
};
|
||||
use shipyard::{NonSendSync, UniqueView, UniqueViewMut};
|
||||
use winit::keyboard::KeyCode;
|
||||
|
@ -34,7 +34,7 @@ pub fn render_settings_ui(
|
|||
.with_align(Alignment::Center)
|
||||
.with_children(|ui| {
|
||||
Container::default()
|
||||
.with_background(rect_frame! {
|
||||
.with_background(frame_rect! {
|
||||
color: (0.2, 0.2, 0.2),
|
||||
corner_radius: 8.
|
||||
})
|
||||
|
|
|
@ -102,7 +102,6 @@ impl ChunkMeshStorage {
|
|||
pub fn init_game_world(
|
||||
storages: AllStoragesView,
|
||||
) {
|
||||
log::info!("init_game_world called");
|
||||
storages.add_unique_non_send_sync(ChunkMeshStorage::new());
|
||||
storages.add_unique(ChunkStorage::new());
|
||||
storages.add_unique(ChunkTaskManager::new());
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
use glam::IVec3;
|
||||
use atomic::Atomic;
|
||||
use glium::{VertexBuffer, IndexBuffer};
|
||||
use kubi_shared::worldgen::AbortState;
|
||||
use crate::rendering::{world::ChunkVertex, BufferPair};
|
||||
use crate::rendering::world::ChunkVertex;
|
||||
|
||||
pub use kubi_shared::chunk::{CHUNK_SIZE, BlockData};
|
||||
|
||||
|
@ -17,8 +18,10 @@ impl ChunkData {
|
|||
}
|
||||
|
||||
pub struct ChunkMesh {
|
||||
pub main: BufferPair,
|
||||
pub trans: BufferPair,
|
||||
pub vertex_buffer: VertexBuffer<ChunkVertex>,
|
||||
pub index_buffer: IndexBuffer<u32>,
|
||||
pub trans_vertex_buffer: VertexBuffer<ChunkVertex>,
|
||||
pub trans_index_buffer: IndexBuffer<u32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use std::sync::Arc;
|
||||
use atomic::{Atomic, Ordering};
|
||||
use glam::{IVec3, ivec3};
|
||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
use kubi_shared::{networking::{channels::Channel, messages::ClientToServerMessage}, worldgen::AbortState};
|
||||
use shipyard::{View, UniqueView, UniqueViewMut, IntoIter, Workload, IntoWorkload, NonSendSync, track};
|
||||
use uflow::SendMode;
|
||||
use wgpu::util::DeviceExt;
|
||||
use crate::{
|
||||
networking::UdpClient,
|
||||
player::MainPlayer,
|
||||
rendering::{world::ChunkVertex, BufferPair, Renderer},
|
||||
settings::GameSettings,
|
||||
state::GameState,
|
||||
transform::Transform,
|
||||
settings::GameSettings,
|
||||
rendering::Renderer,
|
||||
state::GameState,
|
||||
networking::UdpClient,
|
||||
};
|
||||
use super::{
|
||||
ChunkStorage, ChunkMeshStorage,
|
||||
|
@ -327,47 +327,12 @@ fn process_completed_tasks(
|
|||
|
||||
//apply the mesh
|
||||
//TODO: Skip if mesh is empty? (i.e. set to None)
|
||||
//TODO
|
||||
|
||||
let vtx_buffer = renderer.device().create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("chunk_vertex_buffer"),
|
||||
contents: bytemuck::cast_slice(&vertices),
|
||||
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::VERTEX,
|
||||
});
|
||||
|
||||
let idx_buffer = renderer.device().create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("chunk_vertex_buffer"),
|
||||
contents: bytemuck::cast_slice(&indices),
|
||||
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::INDEX,
|
||||
});
|
||||
|
||||
let vtx_buffer_trans = renderer.device().create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("chunk_trans_vertex_buffer"),
|
||||
contents: bytemuck::cast_slice(&trans_vertices),
|
||||
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::VERTEX,
|
||||
});
|
||||
|
||||
let idx_buffer_trans = renderer.device().create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("chunk_trans_index_buffer"),
|
||||
contents: bytemuck::cast_slice(&trans_indices),
|
||||
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::INDEX,
|
||||
});
|
||||
|
||||
let main_buffer_pair = BufferPair {
|
||||
vertex: vtx_buffer,
|
||||
index: idx_buffer,
|
||||
};
|
||||
|
||||
let trans_buffer_pair = BufferPair {
|
||||
vertex: vtx_buffer_trans,
|
||||
index: idx_buffer_trans,
|
||||
};
|
||||
|
||||
let mesh = ChunkMesh {
|
||||
main: main_buffer_pair,
|
||||
trans: trans_buffer_pair,
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue