trying to eat the spaghetti (make it less)
This commit is contained in:
parent
3dd1a0caee
commit
4ad7d2ebd0
42 changed files with 189 additions and 668 deletions
335
Cargo.lock
generated
335
Cargo.lock
generated
|
|
@ -18,21 +18,6 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b2187590a23ab1e3df8681afdf0987c48504d80291f002fcdb651f0ef5e25169"
|
checksum = "b2187590a23ab1e3df8681afdf0987c48504d80291f002fcdb651f0ef5e25169"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "addr2line"
|
|
||||||
version = "0.24.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
|
||||||
dependencies = [
|
|
||||||
"gimli",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "adler2"
|
|
||||||
version = "2.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ahash"
|
name = "ahash"
|
||||||
version = "0.8.12"
|
version = "0.8.12"
|
||||||
|
|
@ -97,27 +82,6 @@ version = "1.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "autocfg"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "backtrace"
|
|
||||||
version = "0.3.75"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
|
|
||||||
dependencies = [
|
|
||||||
"addr2line",
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"miniz_oxide",
|
|
||||||
"object",
|
|
||||||
"rustc-demangle",
|
|
||||||
"windows-targets 0.52.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
|
|
@ -136,7 +100,7 @@ version = "0.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
|
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -212,15 +176,6 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cgl"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "colored"
|
name = "colored"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
|
|
@ -228,7 +183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
|
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -308,16 +263,6 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dispatch2"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.1",
|
|
||||||
"objc2 0.6.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dlib"
|
name = "dlib"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
|
|
@ -365,12 +310,6 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fnv"
|
|
||||||
version = "1.0.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "foreign-types"
|
name = "foreign-types"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
|
@ -420,106 +359,6 @@ dependencies = [
|
||||||
"wasi",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gimli"
|
|
||||||
version = "0.31.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gl_generator"
|
|
||||||
version = "0.14.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
|
|
||||||
dependencies = [
|
|
||||||
"khronos_api",
|
|
||||||
"log",
|
|
||||||
"xml-rs",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glium"
|
|
||||||
version = "0.36.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8cf52ce4f5ce1501bb056627f35484a819e812d1d93f0f3da413676421b1bbe0"
|
|
||||||
dependencies = [
|
|
||||||
"backtrace",
|
|
||||||
"fnv",
|
|
||||||
"gl_generator",
|
|
||||||
"glutin",
|
|
||||||
"glutin-winit",
|
|
||||||
"memoffset",
|
|
||||||
"raw-window-handle",
|
|
||||||
"smallvec",
|
|
||||||
"winit",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glutin"
|
|
||||||
version = "0.32.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.1",
|
|
||||||
"cfg_aliases",
|
|
||||||
"cgl",
|
|
||||||
"dispatch2",
|
|
||||||
"glutin_egl_sys",
|
|
||||||
"glutin_glx_sys",
|
|
||||||
"glutin_wgl_sys",
|
|
||||||
"libloading",
|
|
||||||
"objc2 0.6.1",
|
|
||||||
"objc2-app-kit 0.3.1",
|
|
||||||
"objc2-core-foundation",
|
|
||||||
"objc2-foundation 0.3.1",
|
|
||||||
"once_cell",
|
|
||||||
"raw-window-handle",
|
|
||||||
"wayland-sys",
|
|
||||||
"windows-sys 0.52.0",
|
|
||||||
"x11-dl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glutin-winit"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "85edca7075f8fc728f28cb8fbb111a96c3b89e930574369e3e9c27eb75d3788f"
|
|
||||||
dependencies = [
|
|
||||||
"cfg_aliases",
|
|
||||||
"glutin",
|
|
||||||
"raw-window-handle",
|
|
||||||
"winit",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glutin_egl_sys"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4c4680ba6195f424febdc3ba46e7a42a0e58743f2edb115297b86d7f8ecc02d2"
|
|
||||||
dependencies = [
|
|
||||||
"gl_generator",
|
|
||||||
"windows-sys 0.52.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glutin_glx_sys"
|
|
||||||
version = "0.6.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8a7bb2938045a88b612499fbcba375a77198e01306f52272e692f8c1f3751185"
|
|
||||||
dependencies = [
|
|
||||||
"gl_generator",
|
|
||||||
"x11-dl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glutin_wgl_sys"
|
|
||||||
version = "0.6.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e"
|
|
||||||
dependencies = [
|
|
||||||
"gl_generator",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.15.4"
|
version = "0.15.4"
|
||||||
|
|
@ -590,12 +429,6 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "khronos_api"
|
|
||||||
version = "3.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
|
@ -662,32 +495,11 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memoffset"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "miniz_oxide"
|
|
||||||
version = "0.8.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
|
||||||
dependencies = [
|
|
||||||
"adler2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "moonhare_engine"
|
name = "moonhare_engine"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fern",
|
"moonhare_internal",
|
||||||
"glium",
|
|
||||||
"log",
|
|
||||||
"winit",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -698,6 +510,16 @@ version = "0.1.0"
|
||||||
name = "moonhare_graphics"
|
name = "moonhare_graphics"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "moonhare_internal"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"moonhare_event",
|
||||||
|
"moonhare_graphics",
|
||||||
|
"moonhare_log",
|
||||||
|
"moonhare_window",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "moonhare_log"
|
name = "moonhare_log"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
@ -710,6 +532,9 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "moonhare_window"
|
name = "moonhare_window"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"winit",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ndk"
|
name = "ndk"
|
||||||
|
|
@ -779,15 +604,6 @@ dependencies = [
|
||||||
"objc2-encode",
|
"objc2-encode",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "objc2"
|
|
||||||
version = "0.6.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "88c6597e14493ab2e44ce58f2fdecf095a51f12ca57bec060a11c57332520551"
|
|
||||||
dependencies = [
|
|
||||||
"objc2-encode",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2-app-kit"
|
name = "objc2-app-kit"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
|
@ -797,25 +613,13 @@ dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"block2",
|
"block2",
|
||||||
"libc",
|
"libc",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-core-data",
|
"objc2-core-data",
|
||||||
"objc2-core-image",
|
"objc2-core-image",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
"objc2-quartz-core",
|
"objc2-quartz-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "objc2-app-kit"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.1",
|
|
||||||
"objc2 0.6.1",
|
|
||||||
"objc2-core-foundation",
|
|
||||||
"objc2-foundation 0.3.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2-cloud-kit"
|
name = "objc2-cloud-kit"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
|
@ -824,9 +628,9 @@ checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-core-location",
|
"objc2-core-location",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -836,8 +640,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889"
|
checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -848,19 +652,8 @@ checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "objc2-core-foundation"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.1",
|
|
||||||
"dispatch2",
|
|
||||||
"objc2 0.6.1",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -870,8 +663,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80"
|
checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
"objc2-metal",
|
"objc2-metal",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -882,9 +675,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781"
|
checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-contacts",
|
"objc2-contacts",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -903,18 +696,7 @@ dependencies = [
|
||||||
"block2",
|
"block2",
|
||||||
"dispatch",
|
"dispatch",
|
||||||
"libc",
|
"libc",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "objc2-foundation"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.1",
|
|
||||||
"objc2 0.6.1",
|
|
||||||
"objc2-core-foundation",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -924,9 +706,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398"
|
checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-app-kit 0.2.2",
|
"objc2-app-kit",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -937,8 +719,8 @@ checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -949,8 +731,8 @@ checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
"objc2-metal",
|
"objc2-metal",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -960,8 +742,8 @@ version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc"
|
checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -972,12 +754,12 @@ checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-cloud-kit",
|
"objc2-cloud-kit",
|
||||||
"objc2-core-data",
|
"objc2-core-data",
|
||||||
"objc2-core-image",
|
"objc2-core-image",
|
||||||
"objc2-core-location",
|
"objc2-core-location",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
"objc2-link-presentation",
|
"objc2-link-presentation",
|
||||||
"objc2-quartz-core",
|
"objc2-quartz-core",
|
||||||
"objc2-symbols",
|
"objc2-symbols",
|
||||||
|
|
@ -992,8 +774,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe"
|
checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1004,18 +786,9 @@ checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"block2",
|
"block2",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-core-location",
|
"objc2-core-location",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "object"
|
|
||||||
version = "0.36.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1084,9 +857,7 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||||
name = "playground"
|
name = "playground"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glium",
|
|
||||||
"moonhare_engine",
|
"moonhare_engine",
|
||||||
"moonhare_log",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1169,12 +940,6 @@ dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-demangle"
|
|
||||||
version = "0.1.25"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.38.44"
|
version = "0.38.44"
|
||||||
|
|
@ -1955,9 +1720,9 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"ndk",
|
"ndk",
|
||||||
"objc2 0.5.2",
|
"objc2",
|
||||||
"objc2-app-kit 0.2.2",
|
"objc2-app-kit",
|
||||||
"objc2-foundation 0.2.2",
|
"objc2-foundation",
|
||||||
"objc2-ui-kit",
|
"objc2-ui-kit",
|
||||||
"orbclient",
|
"orbclient",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
|
|
@ -2059,12 +1824,6 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
|
checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xml-rs"
|
|
||||||
version = "0.8.27"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6fd8403733700263c6eb89f192880191f1b83e332f7a20371ddcf421c4a337c7"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.8.26"
|
version = "0.8.26"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "3"
|
resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
"moonhare_engine", "moonhare_event",
|
"crates/*",
|
||||||
"moonhare_graphics",
|
"moonhare_engine",
|
||||||
"moonhare_log",
|
|
||||||
"moonhare_window",
|
|
||||||
"playground"
|
"playground"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
11
crates/moonhare_internal/Cargo.toml
Normal file
11
crates/moonhare_internal/Cargo.toml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "moonhare_internal"
|
||||||
|
edition = "2024"
|
||||||
|
version.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
moonhare_event = { path = "../moonhare_event" }
|
||||||
|
moonhare_graphics = { path = "../moonhare_graphics" }
|
||||||
|
moonhare_log = { path = "../moonhare_log" }
|
||||||
|
moonhare_window = { path = "../moonhare_window" }
|
||||||
4
crates/moonhare_internal/src/lib.rs
Normal file
4
crates/moonhare_internal/src/lib.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
pub use moonhare_event as event;
|
||||||
|
pub use moonhare_graphics as graphics;
|
||||||
|
pub use moonhare_log as log;
|
||||||
|
pub use moonhare_window as window;
|
||||||
|
|
@ -63,23 +63,23 @@ pub fn configere_logger() -> Result<(), fern::InitError>{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mh_info<T: Display>(arg: T) {
|
pub fn info<T: Display>(arg: T) {
|
||||||
log::info!("{}", arg);
|
log::info!("{}", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mh_warn<T: Display>(arg: T) {
|
pub fn warn<T: Display>(arg: T) {
|
||||||
log::warn!("{}", arg);
|
log::warn!("{}", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mh_debug<T: Display>(arg: T) {
|
pub fn debug<T: Display>(arg: T) {
|
||||||
log::debug!("{}", arg);
|
log::debug!("{}", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mh_trace<T: Display>(arg: T) {
|
pub fn trace<T: Display>(arg: T) {
|
||||||
log::trace!("{}", arg);
|
log::trace!("{}", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mh_error<T: Display>(arg: T) {
|
pub fn error<T: Display>(arg: T) {
|
||||||
log::error!("{}", arg);
|
log::error!("{}", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5,3 +5,4 @@ version.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
winit = "0.30.12"
|
||||||
2
crates/moonhare_window/src/lib.rs
Normal file
2
crates/moonhare_window/src/lib.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod window_config;
|
||||||
|
pub mod winit_window;
|
||||||
55
crates/moonhare_window/src/window_config.rs
Normal file
55
crates/moonhare_window/src/window_config.rs
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
use std::{any::Any, string};
|
||||||
|
|
||||||
|
/// General Config for [`WinitWindow`](crate::winit::winit_window::WinitWindow)
|
||||||
|
pub struct WindowConfig {
|
||||||
|
pub title: String,
|
||||||
|
pub width: u32,
|
||||||
|
pub height: u32,
|
||||||
|
pub visble: bool,
|
||||||
|
pub decorations: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for WindowConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
title: "Moonhare Engine".to_owned(),
|
||||||
|
width: 1280,
|
||||||
|
height: 720,
|
||||||
|
visble: default_visibility(),
|
||||||
|
decorations: default_decorations(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Todo: Set Functions should be inside WinitWindow i guess?
|
||||||
|
impl WindowConfig {
|
||||||
|
fn set_window_name(mut self, name: String) {
|
||||||
|
self.title = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_window_height(mut self, new_height: u32) {
|
||||||
|
self.height = new_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_window_width(mut self, new_width: u32) {
|
||||||
|
self.width = new_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_window_visible(mut self, visible: bool) {
|
||||||
|
self.visble = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_window_decoration(mut self, decoration: bool) {
|
||||||
|
self.decorations = decoration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fn default_visibility() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_decorations() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
54
crates/moonhare_window/src/winit_window.rs
Normal file
54
crates/moonhare_window/src/winit_window.rs
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
|
use winit::{application::ApplicationHandler, dpi::LogicalSize, event::WindowEvent, event_loop::{ActiveEventLoop, EventLoop}, window::{Window, WindowAttributes, WindowId}};
|
||||||
|
|
||||||
|
use crate::window_config::WindowConfig;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct WinitWindow {
|
||||||
|
pub window: Option<Window>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WinitWindow {
|
||||||
|
pub fn create_window(&mut self, event_loop: &ActiveEventLoop, config: WindowConfig) -> WinitWindow {
|
||||||
|
let mut window_attributes = WindowAttributes::default()
|
||||||
|
.with_title(config.title);
|
||||||
|
|
||||||
|
let logical_size = LogicalSize::new(config.width, config.height);
|
||||||
|
window_attributes = window_attributes.with_inner_size(logical_size);
|
||||||
|
window_attributes = window_attributes.with_max_inner_size(logical_size);
|
||||||
|
|
||||||
|
// Set Visible
|
||||||
|
window_attributes = window_attributes.with_visible(config.visble);
|
||||||
|
window_attributes = window_attributes.with_decorations(config.decorations);
|
||||||
|
|
||||||
|
let window = event_loop.create_window(window_attributes).unwrap();
|
||||||
|
|
||||||
|
Self { window: Some(window) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ApplicationHandler for WinitWindow {
|
||||||
|
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn window_event(
|
||||||
|
&mut self,
|
||||||
|
event_loop: &ActiveEventLoop,
|
||||||
|
window_id: winit::window::WindowId,
|
||||||
|
event: winit::event::WindowEvent,
|
||||||
|
) {
|
||||||
|
match event {
|
||||||
|
WindowEvent::CloseRequested => {
|
||||||
|
event_loop.exit();
|
||||||
|
},
|
||||||
|
WindowEvent::RedrawRequested => {
|
||||||
|
|
||||||
|
},
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -4,7 +4,5 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glium = "0.36.0"
|
moonhare_internal = { path = "../crates/moonhare_internal" }
|
||||||
log = "0.4"
|
|
||||||
fern = "0.7"
|
|
||||||
winit = "0.30.12"
|
|
||||||
|
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
use std::{ops::{ControlFlow, DerefMut}, sync::Mutex};
|
|
||||||
|
|
||||||
use glium::{glutin::{api::egl::surface::Surface, surface::WindowSurface}, winit::{self, event::{self, WindowEvent}, event_loop::{self, EventLoop}, window::Window}, Display};
|
|
||||||
use winit::application::ApplicationHandler;
|
|
||||||
|
|
||||||
use crate::{core::game, game_plugin::GamePlugin, window::winit_window::WinitWindow, ENGINE_NAME};
|
|
||||||
|
|
||||||
|
|
||||||
pub struct Game {
|
|
||||||
pub running: bool,
|
|
||||||
pub game_plugin: Option<Box<dyn GamePlugin>>,
|
|
||||||
pub window: WinitWindow,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Game {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
let _event_loop: EventLoop<()> = EventLoop::new().unwrap();
|
|
||||||
|
|
||||||
let mut game_window = WinitWindow::default();
|
|
||||||
_event_loop.run_app(&mut game_window);
|
|
||||||
|
|
||||||
Game {
|
|
||||||
running: true,
|
|
||||||
game_plugin: None,
|
|
||||||
window: game_window,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn register_plugin(&mut self, plugin: Box<dyn GamePlugin>) {
|
|
||||||
self.game_plugin = Some(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn init(&mut self) {
|
|
||||||
if let Some(ref mut game_plugin) = self.game_plugin {
|
|
||||||
game_plugin.init();
|
|
||||||
} else {
|
|
||||||
panic!("Needs Game Plugin to run!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update(&mut self) {
|
|
||||||
if let Some(ref mut game_plugin) = self.game_plugin {
|
|
||||||
game_plugin.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn render(&mut self) {
|
|
||||||
//let mut target = display.draw();
|
|
||||||
|
|
||||||
//if let Some(ref mut game_plugin) = self.game_plugin {
|
|
||||||
// game_plugin.render(&mut target);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//target.finish().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn cleanup(&mut self) {
|
|
||||||
if let Some(ref mut game_plugin) = self.game_plugin {
|
|
||||||
game_plugin.cleanup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run(&mut self) {
|
|
||||||
while self.running {
|
|
||||||
self.update();
|
|
||||||
self.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.cleanup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
pub mod game;
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
use glium::Frame;
|
|
||||||
|
|
||||||
|
|
||||||
pub trait GamePlugin {
|
|
||||||
fn init(&mut self);
|
|
||||||
fn update(&mut self);
|
|
||||||
fn render(&mut self, target: &mut Frame);
|
|
||||||
fn cleanup(&mut self);
|
|
||||||
fn handle_events(&mut self);
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +1,3 @@
|
||||||
pub mod vertex;
|
pub use moonhare_internal::*;
|
||||||
pub mod core;
|
|
||||||
pub mod game_plugin;
|
|
||||||
pub mod window;
|
|
||||||
pub mod logger;
|
|
||||||
|
|
||||||
const ENGINE_NAME: &str = "Moonhare Engine";
|
|
||||||
|
|
||||||
|
|
||||||
pub struct CPointer<T>(T);
|
|
||||||
|
|
||||||
impl<T> Drop for CPointer<T> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
println!("Dropping")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rescaling: position *= factor;
|
|
||||||
// rotating: new_position = vec2(pos.x * cos(angle) - pos.y * sin(angle), pos.x * sin(single) + pos.y * cos(angle));
|
|
||||||
// skewing: position.x += position.y * factor;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pub const ENGINE_NAME: &str = "Moonhare Engine";
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
pub struct Logger {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
use glium::implement_vertex;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub struct Vertex {
|
|
||||||
pub position: [f32; 2],
|
|
||||||
pub color: [f32; 3],
|
|
||||||
}
|
|
||||||
implement_vertex!(Vertex, position, color);
|
|
||||||
|
|
||||||
impl Vertex {
|
|
||||||
pub fn define_shape(v1: Vertex, v2: Vertex, v3: Vertex) -> Vec<Vertex> {
|
|
||||||
let shape = vec![
|
|
||||||
v1,
|
|
||||||
v2,
|
|
||||||
v3
|
|
||||||
];
|
|
||||||
return shape;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
pub mod winit_window;
|
|
||||||
pub mod window_config;
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
use glium::{backend::glutin::SimpleWindowBuilder, glutin::config::{ConfigTemplate, ConfigTemplateBuilder}, winit::window::WindowAttributes};
|
|
||||||
|
|
||||||
use crate::ENGINE_NAME;
|
|
||||||
|
|
||||||
/// General Config for [`WinitWindow`](crate::winit::winit_window::WinitWindow)
|
|
||||||
pub struct WindowConfig {
|
|
||||||
pub title: &'static str,
|
|
||||||
pub width: u32,
|
|
||||||
pub height: u32,
|
|
||||||
pub visble: bool,
|
|
||||||
pub decorations: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for WindowConfig {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
title: ENGINE_NAME,
|
|
||||||
width: 1280,
|
|
||||||
height: 720,
|
|
||||||
visble: default_visibility(),
|
|
||||||
decorations: default_decorations(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_visibility() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_decorations() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
|
|
||||||
use glium::{backend::{glutin::SimpleWindowBuilder, Context}, glutin::{display::GetGlDisplay, prelude::GlContext, surface::WindowSurface}, winit::{self, dpi::LogicalSize, event_loop::{ActiveEventLoop, EventLoop}, raw_window_handle::HasDisplayHandle, window::{Window, WindowAttributes}}, Display};
|
|
||||||
use winit::application::ApplicationHandler;
|
|
||||||
|
|
||||||
use crate::window::window_config::WindowConfig;
|
|
||||||
|
|
||||||
use crate::ENGINE_NAME;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct WinitWindow {
|
|
||||||
pub window: Option<Window>,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl ApplicationHandler for WinitWindow {
|
|
||||||
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
|
||||||
let config = WindowConfig::default();
|
|
||||||
|
|
||||||
let mut window_attributes = WindowAttributes::default();
|
|
||||||
|
|
||||||
let logical_size = LogicalSize::new(config.width, config.height);
|
|
||||||
window_attributes = window_attributes.with_inner_size(logical_size);
|
|
||||||
window_attributes = window_attributes.with_max_inner_size(logical_size);
|
|
||||||
|
|
||||||
window_attributes = window_attributes.with_title(config.title)
|
|
||||||
.with_fullscreen(None);
|
|
||||||
|
|
||||||
// Set Visible
|
|
||||||
window_attributes = window_attributes.with_visible(true);
|
|
||||||
|
|
||||||
window_attributes = winit::platform::wayland::WindowAttributesExtWayland::with_name(window_attributes, ENGINE_NAME, "");
|
|
||||||
|
|
||||||
|
|
||||||
self.window = Some(event_loop.create_window(window_attributes).unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn window_event(
|
|
||||||
&mut self,
|
|
||||||
event_loop: &ActiveEventLoop,
|
|
||||||
window_id: winit::window::WindowId,
|
|
||||||
event: winit::event::WindowEvent,
|
|
||||||
) {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
pub fn add(left: u64, right: u64) -> u64 {
|
|
||||||
left + right
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
let result = add(2, 2);
|
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,5 +5,3 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
moonhare_engine = { path = "../moonhare_engine" }
|
moonhare_engine = { path = "../moonhare_engine" }
|
||||||
moonhare_log = { path = "../moonhare_log" }
|
|
||||||
glium = "0.36.0"
|
|
||||||
|
|
|
||||||
|
|
@ -1,144 +1,6 @@
|
||||||
use std::fs::read_to_string;
|
use moonhare_engine::{event, log::{self}, window::{self, winit_window::WinitWindow}};
|
||||||
|
|
||||||
use glium::{index::NoIndices, Frame, Program, VertexBuffer};
|
|
||||||
use glium::{uniform, Surface};
|
|
||||||
use moonhare_engine::{core::game::Game, game_plugin::GamePlugin, vertex::Vertex};
|
|
||||||
use moonhare_log::{mh_debug, mh_error, mh_info, mh_trace, mh_warn};
|
|
||||||
|
|
||||||
struct PlaygroundGame {
|
|
||||||
t: f32,
|
|
||||||
shape: Vec<Vertex>,
|
|
||||||
vertex_buffer: Option<VertexBuffer<Vertex>>,
|
|
||||||
indices: Option<NoIndices>,
|
|
||||||
program: Option<Program>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GamePlugin for PlaygroundGame {
|
|
||||||
fn init(&mut self) {
|
|
||||||
self.t = 0.0;
|
|
||||||
}
|
|
||||||
fn update(&mut self) {
|
|
||||||
self.t += 0.02;
|
|
||||||
// use 't' as an offset -> smooth animation
|
|
||||||
|
|
||||||
}
|
|
||||||
fn render(&mut self, target: &mut Frame) {
|
|
||||||
|
|
||||||
target.clear_color(
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
1.0
|
|
||||||
);
|
|
||||||
let x_offset = self.t.sin() * 0.5;
|
|
||||||
|
|
||||||
// Note: In OpenGL matrices are column-major
|
|
||||||
// Standard mathematical notation is row major:
|
|
||||||
// 1.0 0.0 0.0 x_offset
|
|
||||||
// 0.0 1.0 0.0 0.0
|
|
||||||
// 0.0 0.0 1.0 0.0
|
|
||||||
// 0.0 0.0 0.0 1.0
|
|
||||||
let uniforms = uniform! {
|
|
||||||
matrix: [
|
|
||||||
[1.0, 0.0, 0.0, 0.0],
|
|
||||||
[0.0, 1.0, 0.0, 0.0],
|
|
||||||
[0.0, 0.0, 1.0, 0.0],
|
|
||||||
[x_offset, 0.0, 0.0, 1.0f32],
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
target.draw(
|
|
||||||
self.vertex_buffer.as_ref().unwrap(),
|
|
||||||
&self.indices.unwrap(),
|
|
||||||
self.program.as_ref().unwrap(),
|
|
||||||
&uniforms,
|
|
||||||
&Default::default()
|
|
||||||
).unwrap();
|
|
||||||
}
|
|
||||||
fn cleanup(&mut self) {
|
|
||||||
|
|
||||||
}
|
|
||||||
fn handle_events(&mut self) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = moonhare_log::configere_logger();
|
let _ = log::configere_logger();
|
||||||
mh_info("Blub");
|
log::info("test");
|
||||||
mh_debug("blub");
|
|
||||||
mh_warn("blug");
|
|
||||||
mh_trace("trace");
|
|
||||||
mh_error("error");
|
|
||||||
println!("Blaa");
|
|
||||||
/*
|
|
||||||
let mut game = Game::new();
|
|
||||||
game.register_plugin(Box::new(PlaygroundGame{ t: 0.0, shape: Default::default(), vertex_buffer: None, indices: None, program: None }));
|
|
||||||
game.init();
|
|
||||||
|
|
||||||
let binding = Some(game.display.clone()).unwrap();
|
|
||||||
// todo: unwraps on none
|
|
||||||
let display = binding;
|
|
||||||
|
|
||||||
let shape = Vertex::define_shape(
|
|
||||||
Vertex { position: [-0.5, -0.5], color: [1.0, 0.0, 0.0] },
|
|
||||||
Vertex { position: [ 0.0, 0.5], color: [0.0, 1.0, 0.0] },
|
|
||||||
Vertex { position: [ 0.5, -0.5], color: [0.0, 0.0, 1.0] }
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// "Upload" shape to the memory of the GPU (Vertex Buffer)
|
|
||||||
// Isn't strictly necessary but, makes tge drawing operation faster
|
|
||||||
|
|
||||||
let vertex_buffer: VertexBuffer<Vertex> = VertexBuffer::new(&display, &shape).unwrap();
|
|
||||||
|
|
||||||
|
|
||||||
// Complex shapes consist of hundreds/thousands of vertices -> need to have a list of vertices and tell OpenGL how to link these
|
|
||||||
// vertices together to obtain triangles.
|
|
||||||
// For only one triangle -> pass dummy marker to glium
|
|
||||||
// This line tells OpenGl that we don't use indices and instand want to draw a certain number of seperate triangles
|
|
||||||
let indices = glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList);
|
|
||||||
|
|
||||||
// (Simplified) Render Pipeline:
|
|
||||||
// Vertex Shader -> Fragment (Pixel) Shader
|
|
||||||
// uniform:
|
|
||||||
// value is set when we draw by passing its value to the draw function
|
|
||||||
// (easiest way is uniform! macro)
|
|
||||||
// Important to write matrix * vertex -> Matrix operations produce different results depending on the order
|
|
||||||
// out: defines a variable that is going to be passed along to the fragment shader
|
|
||||||
|
|
||||||
let vertex_shader_src = read_to_string("playground/src/shaders/vertex_shader.glsl").unwrap_or("vertex shader failed to unwrap".to_owned());
|
|
||||||
let fragment_shader_src = read_to_string("playground/src/shaders/fragment_shader.glsl").unwrap_or("fragment shader failed to unwrap".to_owned());
|
|
||||||
|
|
||||||
// send shader source code to glium
|
|
||||||
let program = match glium::Program::from_source(
|
|
||||||
&display,
|
|
||||||
&vertex_shader_src,
|
|
||||||
&fragment_shader_src,
|
|
||||||
None
|
|
||||||
) {
|
|
||||||
Ok(program) => program,
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("Shader compilation error: {:?}", err);
|
|
||||||
panic!("Failed to compile shaders")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
let pg_game = PlaygroundGame {
|
|
||||||
t: 0.0,
|
|
||||||
shape: shape,
|
|
||||||
vertex_buffer: Some(vertex_buffer),
|
|
||||||
indices: Some(indices),
|
|
||||||
program: Some(program),
|
|
||||||
};
|
|
||||||
|
|
||||||
//let mut a = game.borrow_mut();
|
|
||||||
game.register_plugin(Box::new(pg_game));
|
|
||||||
|
|
||||||
game.run();
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue