diff options
Diffstat (limited to 'bindgen/rust/celeritas-sys')
-rw-r--r-- | bindgen/rust/celeritas-sys/Cargo.lock | 1035 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/Cargo.toml | 9 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/README.md | 3 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/build.rs | 54 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/examples/glfw.rs | 224 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/examples/gui_test.rs | 283 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/examples/main_loop.rs | 108 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/src/egui_utils.rs | 72 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/src/lib.rs | 7 |
9 files changed, 1795 insertions, 0 deletions
diff --git a/bindgen/rust/celeritas-sys/Cargo.lock b/bindgen/rust/celeritas-sys/Cargo.lock new file mode 100644 index 0000000..de49f83 --- /dev/null +++ b/bindgen/rust/celeritas-sys/Cargo.lock @@ -0,0 +1,1035 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ab_glyph" +version = "0.2.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79faae4620f45232f599d9bc7b290f88247a0834162c4495ab2f02d60004adfb" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.71", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "cc" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" + +[[package]] +name = "celeritas" +version = "0.1.0" +dependencies = [ + "bindgen", + "egui", + "egui_glfw", + "gl", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cli-clipboard" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04087c1d4a2aa259784a563932aee09cbb0869d490775e051096174b070f3e3d" +dependencies = [ + "clipboard-win", + "objc", + "objc-foundation", + "objc_id", + "wl-clipboard-rs", + "x11-clipboard", +] + +[[package]] +name = "clipboard-win" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" +dependencies = [ + "error-code", + "str-buf", + "winapi", +] + +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + +[[package]] +name = "derive-new" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "ecolor" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20930a432bbd57a6d55e07976089708d4893f3d556cf42a0d79e9e321fa73b10" + +[[package]] +name = "egui" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "584c5d1bf9a67b25778a3323af222dbe1a1feb532190e103901187f92c7fe29a" +dependencies = [ + "ahash", + "epaint", + "nohash-hasher", +] + +[[package]] +name = "egui_glfw" +version = "0.55.1" +source = "git+https://github.com/omnisci3nce/egui_glfw.git?rev=67b432695433feb59761f3ae984b966ca3da31db#67b432695433feb59761f3ae984b966ca3da31db" +dependencies = [ + "cli-clipboard", + "egui", + "gl", + "glfw", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "emath" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c3a552cfca14630702449d35f41c84a0d15963273771c6059175a803620f3f" + +[[package]] +name = "epaint" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b381f8b149657a4acf837095351839f32cd5c4aec1817fc4df84e18d76334176" +dependencies = [ + "ab_glyph", + "ahash", + "ecolor", + "emath", + "nohash-hasher", + "parking_lot", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "error-code" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" +dependencies = [ + "libc", + "str-buf", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "gl" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a94edab108827d67608095e269cf862e60d920f144a5026d3dbcfd8b877fb404" +dependencies = [ + "gl_generator", +] + +[[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 = "glfw" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a310dfc7966e5340f5d0e314fa7eed8888f1cd3bfcaa433d35cbd32d430e50c" +dependencies = [ + "bitflags 1.3.2", + "glfw-sys", + "objc", + "raw-window-handle 0.5.2", + "raw-window-handle 0.6.2", + "winapi", +] + +[[package]] +name = "glfw-sys" +version = "5.0.0+3.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dfc32d45fb58ff38b112696907963a7d671e9cf742b16f882062169a053cf88" +dependencies = [ + "cmake", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libloading" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "os_pipe" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29d73ba8daf8fac13b0501d1abeddcfe21ba7401ada61a819144b6c2a4f32209" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "490d3a563d3122bf7c911a59b0add9389e5ec0f5f0c3ac6b91ff235a0e6a7f90" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn 2.0.71", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "raw-window-handle" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "str-buf" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys", +] + +[[package]] +name = "thiserror" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "tree_magic_mini" +version = "3.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469a727cac55b41448315cc10427c069c618ac59bb6a4480283fcd811749bdc2" +dependencies = [ + "fnv", + "home", + "memchr", + "nom", + "once_cell", + "petgraph", +] + +[[package]] +name = "ttf-parser" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8686b91785aff82828ed725225925b33b4fde44c4bb15876e5f7c832724c420a" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wayland-client" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" +dependencies = [ + "bitflags 1.3.2", + "downcast-rs", + "libc", + "nix", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + +[[package]] +name = "wayland-commons" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" +dependencies = [ + "nix", + "once_cell", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-protocols" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" +dependencies = [ + "bitflags 1.3.2", + "wayland-client", + "wayland-commons", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" +dependencies = [ + "proc-macro2", + "quote", + "xml-rs", +] + +[[package]] +name = "wayland-sys" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-wsapoll" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1eafc5f679c576995526e81635d0cf9695841736712b4e892f87abbe6fed3f28" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wl-clipboard-rs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "981a303dfbb75d659f6612d05a14b2e363c103d24f676a2d44a00d18507a1ad9" +dependencies = [ + "derive-new", + "libc", + "log", + "nix", + "os_pipe", + "tempfile", + "thiserror", + "tree_magic_mini", + "wayland-client", + "wayland-protocols", +] + +[[package]] +name = "x11-clipboard" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "980b9aa9226c3b7de8e2adb11bf20124327c054e0e5812d2aac0b5b5a87e7464" +dependencies = [ + "x11rb", +] + +[[package]] +name = "x11rb" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" +dependencies = [ + "gethostname", + "nix", + "winapi", + "winapi-wsapoll", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67" +dependencies = [ + "nix", +] + +[[package]] +name = "xml-rs" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] diff --git a/bindgen/rust/celeritas-sys/Cargo.toml b/bindgen/rust/celeritas-sys/Cargo.toml new file mode 100644 index 0000000..6755fb2 --- /dev/null +++ b/bindgen/rust/celeritas-sys/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "celeritas-sys" +version = "0.1.0" +edition = "2021" + +[dependencies] + +[build-dependencies] +bindgen = "0.69.4" diff --git a/bindgen/rust/celeritas-sys/README.md b/bindgen/rust/celeritas-sys/README.md new file mode 100644 index 0000000..f4b4a01 --- /dev/null +++ b/bindgen/rust/celeritas-sys/README.md @@ -0,0 +1,3 @@ +# Rust bindings + examples. + +**WIP**: GLFW passthrough to egui
\ No newline at end of file diff --git a/bindgen/rust/celeritas-sys/build.rs b/bindgen/rust/celeritas-sys/build.rs new file mode 100644 index 0000000..4f85bc6 --- /dev/null +++ b/bindgen/rust/celeritas-sys/build.rs @@ -0,0 +1,54 @@ +use std::env; +use std::path::PathBuf; + +fn main() { + // Tell cargo to look for shared libraries in the specified directory + println!("cargo:rustc-link-search=../../../build/macosx/arm64/debug"); + // println!("cargo:rustc-link-search=../../build/windows/x64/debug"); + + // Tell cargo to tell rustc to link the system bzip2 + // shared library. + println!("cargo:rustc-link-lib=core_static"); + println!("cargo:rustc-link-lib=glfw3"); + + // The bindgen::Builder is the main entry point + // to bindgen, and lets you build up options for + // the resulting bindings. + let bindings = bindgen::Builder::default() + // The input header we would like to generate + // bindings for. + .header("../../../include/amalgamation.h") + // -- our code + .clang_arg("-I../../../src") + .clang_arg("-I../../../src/core") + .clang_arg("-I../../../src/maths") + .clang_arg("-I../../../src/new_render") + .clang_arg("-I../../../src/platform") + .clang_arg("-I../../../src/ral") + .clang_arg("-I../../../src/ral/backends/opengl") + .clang_arg("-I../../../src/resources") + .clang_arg("-I../../../src/std") + .clang_arg("-I../../../src/std/containers") + .clang_arg("-I../../../src/systems") + // -- dependencies + .clang_arg("-I../../../deps/cgltf") + .clang_arg("-I../../../deps/glfw-3.3.8/include/GLFW") + .clang_arg("-I../../../deps/glad/include") + .clang_arg("-I../../../deps/stb_image") + .clang_arg("-I../../../deps/stb_image_write") + .clang_arg("-I../../../deps/stb_truetype") + .generate_inline_functions(true) + // Tell cargo to invalidate the built crate whenever any of the + // included header files changed. + .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) + // Finish the builder and generate the bindings. + .generate() + // Unwrap the Result and panic on failure. + .expect("Unable to generate bindings"); + + // Write the bindings to the $OUT_DIR/bindings.rs file. + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings!"); +} diff --git a/bindgen/rust/celeritas-sys/examples/glfw.rs b/bindgen/rust/celeritas-sys/examples/glfw.rs new file mode 100644 index 0000000..0514032 --- /dev/null +++ b/bindgen/rust/celeritas-sys/examples/glfw.rs @@ -0,0 +1,224 @@ +use std::ffi::CString; +use std::ptr::addr_of_mut; + +use celeritas::*; +use egui_backend::egui::{vec2, Pos2, Rect}; +use egui_glfw as egui_backend; +use egui_glfw::glfw::{fail_on_errors, Context}; + +use egui_glfw::glfw; + +const SCREEN_WIDTH: u32 = 1000; +const SCREEN_HEIGHT: u32 = 1000; + +fn main() { + unsafe { + let mut glfw = glfw::init(glfw::fail_on_errors!()).unwrap(); + glfw.window_hint(glfw::WindowHint::ContextVersion(4, 1)); + glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true)); + glfw.window_hint(glfw::WindowHint::OpenGlProfile( + glfw::OpenGlProfileHint::Core, + )); + glfw.window_hint(glfw::WindowHint::DoubleBuffer(true)); + glfw.window_hint(glfw::WindowHint::Resizable(false)); + + let (mut window, events) = glfw + .create_window( + SCREEN_WIDTH, + SCREEN_HEIGHT, + "Egui in GLFW!", + glfw::WindowMode::Windowed, + ) + .expect("Failed to create GLFW window."); + + window.set_all_polling(true); + window.make_current(); + // glfw.set_swap_interval(glfw::SwapInterval::None); + glfw.set_swap_interval(glfw::SwapInterval::Adaptive); + + gl::load_with(|symbol| window.get_proc_address(symbol) as *const _); + + let window_ptr = window.window_ptr(); + unsafe { + // Cast the window pointer to the expected type + let window_ptr = window_ptr as *mut celeritas::GLFWwindow; + Core_Bringup(window_ptr); + }; + + let mut painter = egui_backend::Painter::new(&mut window); + let egui_ctx = egui::Context::default(); + + let (width, height) = window.get_framebuffer_size(); + let native_pixels_per_point = window.get_content_scale().0; + let native_pixels_per_point = 1.0; + // egui_ctx.set_pixels_per_point(2.0); + + let mut egui_input_state = egui_backend::EguiInputState::new(egui::RawInput { + screen_rect: Some(Rect::from_min_size( + Pos2::new(0f32, 0f32), + vec2(width as f32, height as f32) / native_pixels_per_point, + )), + ..Default::default() + }); + + egui_input_state.input.time = Some(0.01); + + // let triangle = triangle::Triangle::new(); + let slider = &mut 0.0; + + // C data + let camera_pos = Vec3 { + x: 18.9, + y: 10.6, + z: 11.6, + }; + let camera_front = Vec3 { + x: -0.6, + y: -0.2, + z: -0.7, + }; + let camera = Camera_Create( + camera_pos, + camera_front, + Vec3 { + x: 0.0, + y: 1.0, + z: 0.0, + }, + 45.0, + ); + SetCamera(camera); + + let mut cube_geo = Geo_CreateCuboid(f32x3 { + x: 2.0, + y: 2.0, + z: 2.0, + }); + let mut crate_mesh = Mesh_Create(addr_of_mut!(cube_geo), false); + let albedo_map = TextureLoadFromFile( + CString::new("assets/demo/crate/Wood_Crate_001_basecolor.jpg") + .unwrap() + .as_ptr() as *const i8, + ); + let roughness_map = TextureLoadFromFile( + CString::new("assets/demo/crate/Wood_Crate_001_roughness.jpg") + .unwrap() + .as_ptr() as *const i8, + ); + let normal_map = TextureLoadFromFile( + CString::new("assets/demo/crate/Wood_Crate_001_normal.jpg") + .unwrap() + .as_ptr() as *const i8, + ); + let ao_map = TextureLoadFromFile( + CString::new("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg") + .unwrap() + .as_ptr() as *const i8, + ); + let name: [i8; 64] = [0; 64]; + let mut crate_mat = Material { + name: name, + kind: 0, + param_albedo: Vec3 { + x: 0.0, + y: 0.0, + z: 0.0, + }, + param_metallic: 0.0, + param_roughness: 0.0, + param_ao: 0.0, + pbr_albedo_map: albedo_map, + pbr_normal_map: normal_map, + metal_roughness_combined: true, + pbr_metallic_map: TextureHandle { raw: 99999 }, + pbr_roughness_map: roughness_map, + pbr_ao_map: ao_map, + }; + let crate_renderent = RenderEnt { + mesh: addr_of_mut!(crate_mesh), + material: addr_of_mut!(crate_mat), + affine: mat4_ident(), + casts_shadows: true, + }; + let mut render_ents: [RenderEnt; 1] = [crate_renderent]; + let mut skybox = Skybox_Default(); + + // Main rendering loop + while !window.should_close() { + glfw.poll_events(); + + egui_ctx.begin_frame(egui_input_state.input.take()); + + unsafe { + gl::ClearColor(0.455, 0.302, 0.663, 1.0); + gl::Clear(gl::COLOR_BUFFER_BIT); + gl::Clear(gl::DEPTH_TEST); + } + + Frame_Begin(); + gl::Enable(gl::DEPTH_TEST); + gl::Enable(gl::CULL_FACE); + + Skybox_Draw(addr_of_mut!(skybox), camera); + Render_RenderEntities(render_ents.as_mut_ptr(), render_ents.len()); + + // Frame_End(); + + // triangle.draw(); + + gl::Disable(gl::DEPTH_TEST); + gl::Disable(gl::CULL_FACE); + + egui::Window::new("Egui with GLFW").show(&egui_ctx, |ui| { + ui.label("Celeritas in-game editor"); + let btn_m = &mut ui.button("-"); + let btn_p = &mut ui.button("+"); + + ui.add(egui::Slider::new(slider, 0.0..=100.0).text("My value")); + + if btn_m.clicked() && *slider > 0.0 { + *slider -= 1.0; + } + + if btn_p.clicked() && *slider < 100.0 { + *slider += 1.0; + } + }); + + let egui::FullOutput { + platform_output, + textures_delta, + shapes, + .. + } = egui_ctx.end_frame(); + + //Handle cut, copy text from egui + if !platform_output.copied_text.is_empty() { + egui_backend::copy_to_clipboard(&mut egui_input_state, platform_output.copied_text); + } + + //Note: passing a bg_color to paint_jobs will clear any previously drawn stuff. + //Use this only if egui is being used for all drawing and you aren't mixing your own Open GL + //drawing calls with it. + //Since we are custom drawing an OpenGL Triangle we don't need egui to clear the background. + + let clipped_shapes = egui_ctx.tessellate(shapes, native_pixels_per_point); + painter.paint_and_update_textures( + native_pixels_per_point, + &clipped_shapes, + &textures_delta, + ); + + for (_, event) in glfw::flush_messages(&events) { + match event { + glfw::WindowEvent::Close => window.set_should_close(true), + _ => { + egui_backend::handle_event(event, &mut egui_input_state); + } + } + } + + window.swap_buffers(); + } + } +} diff --git a/bindgen/rust/celeritas-sys/examples/gui_test.rs b/bindgen/rust/celeritas-sys/examples/gui_test.rs new file mode 100644 index 0000000..ddd8b86 --- /dev/null +++ b/bindgen/rust/celeritas-sys/examples/gui_test.rs @@ -0,0 +1,283 @@ +// // #![windows_subsystem = "windows"] // to turn off console. + +// use std::ptr; +// use std::{ffi::CString, ptr::addr_of_mut}; + +// use celeritas::*; +// use egui::DragValue; +// use egui_overlay::{EguiOverlay, OverlayApp}; +// use egui_render_three_d::ThreeDBackend; +// use egui_window_glfw_passthrough::glfw::Context; +// use egui_window_glfw_passthrough::{GlfwBackend, GlfwConfig}; + +// fn main() { +// // use tracing_subscriber::{fmt, prelude::*, EnvFilter}; +// // if RUST_LOG is not set, we will use the following filters +// // tracing_subscriber::registry() +// // .with(fmt::layer()) +// // .with( +// // EnvFilter::try_from_default_env() +// // .unwrap_or(EnvFilter::new("debug,wgpu=warn,naga=warn")), +// // ) +// // .init(); + +// unsafe { +// // let p: *mut GLFWwindow = ptr::null_mut(); +// // Core_Bringup(p); + +// // let core = get_global_core(); +// // let glfw_window_ptr = Core_GetGlfwWindowPtr(core); + +// let mut glfw_backend = GlfwBackend::new(GlfwConfig { +// // this closure will be called before creating a window +// glfw_callback: Box::new(|gtx| { +// // some defualt hints. it is empty atm, but in future we might add some convenience hints to it. +// (egui_window_glfw_passthrough::GlfwConfig::default().glfw_callback)(gtx); +// // scale the window size based on monitor scale. as 800x600 looks too small on a 4k screen, compared to a hd screen in absolute pixel sizes. +// gtx.window_hint( +// egui_window_glfw_passthrough::glfw::WindowHint::ScaleToMonitor(true), +// ); +// }), +// opengl_window: Some(true), // macos doesn't support opengl. +// transparent_window: Some(false), +// window_title: "Celeritas egui".into(), +// ..Default::default() +// }); + +// // always on top +// // glfw_backend.window.set_floating(true); +// // disable borders/titlebar +// // glfw_backend.window.set_decorated(false); + +// let latest_size = glfw_backend.window.get_framebuffer_size(); +// let latest_size = [latest_size.0 as _, latest_size.1 as _]; + +// let default_gfx_backend = { +// ThreeDBackend::new( +// egui_render_three_d::ThreeDConfig { +// ..Default::default() +// }, +// |s| glfw_backend.get_proc_address(s), +// latest_size, +// ) +// }; + +// let glfw_window_ptr = glfw_backend.window.window_ptr(); +// unsafe { +// // Cast the window pointer to the expected type +// let window_ptr = glfw_window_ptr as *mut crate::GLFWwindow; +// Core_Bringup(window_ptr); +// }; + +// // cam pos: 18.871811 10.658584 11.643305 cam frontL -0.644326 -0.209243 -0.735569 +// let camera_pos = Vec3 { +// x: 18.9, +// y: 10.6, +// z: 11.6, +// }; +// let camera_front = Vec3 { +// x: -0.6, +// y: -0.2, +// z: -0.7, +// }; +// let camera = Camera_Create( +// camera_pos, +// camera_front, +// Vec3 { +// x: 0.0, +// y: 1.0, +// z: 0.0, +// }, +// 45.0, +// ); +// SetCamera(camera); + +// let mut cube_geo = Geo_CreateCuboid(f32x3 { +// x: 2.0, +// y: 2.0, +// z: 2.0, +// }); +// let mut crate_mesh = Mesh_Create(addr_of_mut!(cube_geo), false); +// let albedo_map = TextureLoadFromFile( +// CString::new("assets/demo/crate/Wood_Crate_001_basecolor.jpg") +// .unwrap() +// .as_ptr() as *const i8, +// ); +// let roughness_map = TextureLoadFromFile( +// CString::new("assets/demo/crate/Wood_Crate_001_roughness.jpg") +// .unwrap() +// .as_ptr() as *const i8, +// ); +// let normal_map = TextureLoadFromFile( +// CString::new("assets/demo/crate/Wood_Crate_001_normal.jpg") +// .unwrap() +// .as_ptr() as *const i8, +// ); +// let ao_map = TextureLoadFromFile( +// CString::new("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg") +// .unwrap() +// .as_ptr() as *const i8, +// ); +// let name: [i8; 64] = [0; 64]; +// let mut crate_mat = Material { +// name: name, +// kind: 0, +// param_albedo: Vec3 { +// x: 0.0, +// y: 0.0, +// z: 0.0, +// }, +// param_metallic: 0.0, +// param_roughness: 0.0, +// param_ao: 0.0, +// pbr_albedo_map: albedo_map, +// pbr_normal_map: normal_map, +// metal_roughness_combined: true, +// pbr_metallic_map: TextureHandle { raw: 99999 }, +// pbr_roughness_map: roughness_map, +// pbr_ao_map: ao_map, +// }; +// let crate_renderent = RenderEnt { +// mesh: addr_of_mut!(crate_mesh), +// material: addr_of_mut!(crate_mat), +// affine: mat4_ident(), +// casts_shadows: true, +// }; +// let mut render_ents: [RenderEnt; 1] = [crate_renderent]; + +// let world_state = HelloWorld { +// frame: 0, +// render_entities: render_ents, +// }; + +// let overlap_app = OverlayApp { +// user_data: world_state, +// egui_context: Default::default(), +// default_gfx_backend, +// glfw_backend, +// }; + +// overlap_app.enter_event_loop(); + +// // celeritas::egui_utils::start(HelloWorld { frame: 0}); +// } +// } + +// pub struct HelloWorld { +// pub frame: u64, +// pub render_entities: [RenderEnt; 1], +// } +// impl EguiOverlay for HelloWorld { +// fn gui_run( +// &mut self, +// egui_context: &egui::Context, +// _default_gfx_backend: &mut ThreeDBackend, +// glfw_backend: &mut egui_window_glfw_passthrough::GlfwBackend, +// ) { +// unsafe { +// // Frame_Begin(); +// // Render_RenderEntities( +// // self.render_entities.as_mut_ptr(), +// // self.render_entities.len(), +// // ); +// // Frame_End(); +// } + +// // just some controls to show how you can use glfw_backend +// egui::Window::new("controls").show(egui_context, |ui| { +// ui.set_width(300.0); +// self.frame += 1; +// ui.label(format!("current frame number: {}", self.frame)); +// // sometimes, you want to see the borders to understand where the overlay is. +// let mut borders = glfw_backend.window.is_decorated(); +// if ui.checkbox(&mut borders, "window borders").changed() { +// glfw_backend.window.set_decorated(borders); +// } + +// ui.label(format!( +// "pixels_per_virtual_unit: {}", +// glfw_backend.physical_pixels_per_virtual_unit +// )); +// ui.label(format!("window scale: {}", glfw_backend.scale)); +// ui.label(format!("cursor pos x: {}", glfw_backend.cursor_pos[0])); +// ui.label(format!("cursor pos y: {}", glfw_backend.cursor_pos[1])); + +// ui.label(format!( +// "passthrough: {}", +// glfw_backend.window.is_mouse_passthrough() +// )); +// // how to change size. +// // WARNING: don't use drag value, because window size changing while dragging ui messes things up. +// let mut size = glfw_backend.window_size_logical; +// let mut changed = false; +// ui.horizontal(|ui| { +// ui.label("width: "); +// ui.add_enabled(false, DragValue::new(&mut size[0])); +// if ui.button("inc").clicked() { +// size[0] += 10.0; +// changed = true; +// } +// if ui.button("dec").clicked() { +// size[0] -= 10.0; +// changed = true; +// } +// }); +// ui.horizontal(|ui| { +// ui.label("height: "); +// ui.add_enabled(false, DragValue::new(&mut size[1])); +// if ui.button("inc").clicked() { +// size[1] += 10.0; +// changed = true; +// } +// if ui.button("dec").clicked() { +// size[1] -= 10.0; +// changed = true; +// } +// }); +// if changed { +// glfw_backend.set_window_size(size); +// } +// // how to change size. +// // WARNING: don't use drag value, because window size changing while dragging ui messes things up. +// let mut pos = glfw_backend.window_position; +// let mut changed = false; +// ui.horizontal(|ui| { +// ui.label("x: "); +// ui.add_enabled(false, DragValue::new(&mut pos[0])); +// if ui.button("inc").clicked() { +// pos[0] += 10; +// changed = true; +// } +// if ui.button("dec").clicked() { +// pos[0] -= 10; +// changed = true; +// } +// }); +// ui.horizontal(|ui| { +// ui.label("y: "); +// ui.add_enabled(false, DragValue::new(&mut pos[1])); +// if ui.button("inc").clicked() { +// pos[1] += 10; +// changed = true; +// } +// if ui.button("dec").clicked() { +// pos[1] -= 10; +// changed = true; +// } +// }); +// if changed { +// glfw_backend.window.set_pos(pos[0], pos[1]); +// } +// }); + +// // here you decide if you want to be passthrough or not. +// if egui_context.wants_pointer_input() || egui_context.wants_keyboard_input() { +// // we need input, so we need the window to be NOT passthrough +// glfw_backend.set_passthrough(false); +// } else { +// // we don't care about input, so the window can be passthrough now +// glfw_backend.set_passthrough(true) +// } +// egui_context.request_repaint(); +// } +// } diff --git a/bindgen/rust/celeritas-sys/examples/main_loop.rs b/bindgen/rust/celeritas-sys/examples/main_loop.rs new file mode 100644 index 0000000..65f4137 --- /dev/null +++ b/bindgen/rust/celeritas-sys/examples/main_loop.rs @@ -0,0 +1,108 @@ +use std::{ + ffi::CString, + ptr::{self, addr_of_mut}, +}; + +use celeritas::*; + +unsafe fn run_game() { + // init + let p: *mut GLFWwindow = ptr::null_mut(); + Core_Bringup(p); + + let core = get_global_core(); + let glfw_window_ptr = Core_GetGlfwWindowPtr(core); + + // cam pos: 18.871811 10.658584 11.643305 cam frontL -0.644326 -0.209243 -0.735569 + let camera_pos = Vec3 { + x: 18.9, + y: 10.6, + z: 11.6, + }; + let camera_front = Vec3 { + x: -0.6, + y: -0.2, + z: -0.7, + }; + let camera = Camera_Create( + camera_pos, + camera_front, + Vec3 { + x: 0.0, + y: 1.0, + z: 0.0, + }, + 45.0, + ); + SetCamera(camera); + + let mut cube_geo = Geo_CreateCuboid(f32x3 { + x: 2.0, + y: 2.0, + z: 2.0, + }); + let mut crate_mesh = Mesh_Create(addr_of_mut!(cube_geo), false); + let albedo_map = TextureLoadFromFile( + CString::new("assets/demo/crate/Wood_Crate_001_basecolor.jpg") + .unwrap() + .as_ptr() as *const i8, + ); + let roughness_map = TextureLoadFromFile( + CString::new("assets/demo/crate/Wood_Crate_001_roughness.jpg") + .unwrap() + .as_ptr() as *const i8, + ); + let normal_map = TextureLoadFromFile( + CString::new("assets/demo/crate/Wood_Crate_001_normal.jpg") + .unwrap() + .as_ptr() as *const i8, + ); + let ao_map = TextureLoadFromFile( + CString::new("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg") + .unwrap() + .as_ptr() as *const i8, + ); + let name: [i8; 64] = [0; 64]; + let mut crate_mat = Material { + name: name, + kind: 0, + param_albedo: Vec3 { + x: 0.0, + y: 0.0, + z: 0.0, + }, + param_metallic: 0.0, + param_roughness: 0.0, + param_ao: 0.0, + pbr_albedo_map: albedo_map, + pbr_normal_map: normal_map, + metal_roughness_combined: true, + pbr_metallic_map: TextureHandle { raw: 99999 }, + pbr_roughness_map: roughness_map, + pbr_ao_map: ao_map, + }; + let crate_renderent = RenderEnt { + mesh: addr_of_mut!(crate_mesh), + material: addr_of_mut!(crate_mat), + affine: mat4_ident(), + casts_shadows: true, + }; + let mut render_entities: [RenderEnt; 1] = [crate_renderent]; + + // main loop + while !ShouldExit() { + Frame_Begin(); + + Render_RenderEntities(render_entities.as_mut_ptr(), render_entities.len()); + + Frame_End(); + } +} + +fn main() { + println!("Running from Rust!"); + + unsafe { + run_game(); + } +} diff --git a/bindgen/rust/celeritas-sys/src/egui_utils.rs b/bindgen/rust/celeritas-sys/src/egui_utils.rs new file mode 100644 index 0000000..5432d81 --- /dev/null +++ b/bindgen/rust/celeritas-sys/src/egui_utils.rs @@ -0,0 +1,72 @@ +// use egui_overlay::{EguiOverlay, OverlayApp}; +// use egui_render_three_d::ThreeDBackend; +// use egui_window_glfw_passthrough::glfw::Context; +// use egui_window_glfw_passthrough::{GlfwBackend, GlfwConfig}; + +// use crate::Core_Bringup; + +// // struct CustomEguiOverlay { +// // backend: +// // } + +// fn init() { +// let mut glfw_backend = GlfwBackend::new(GlfwConfig::default()); +// let mut glfw_window_ptr = glfw_backend.window.window_ptr(); + +// unsafe { +// // Cast the window pointer to the expected type +// let window_ptr = glfw_window_ptr as *mut crate::GLFWwindow; +// Core_Bringup(window_ptr); +// }; +// } + +// /// After implementing [`EguiOverlay`], just call this function with your app data +// pub fn start<T: EguiOverlay + 'static>(user_data: T) { +// let mut glfw_backend = GlfwBackend::new(GlfwConfig { +// // this closure will be called before creating a window +// glfw_callback: Box::new(|gtx| { +// // some defualt hints. it is empty atm, but in future we might add some convenience hints to it. +// (egui_window_glfw_passthrough::GlfwConfig::default().glfw_callback)(gtx); +// // scale the window size based on monitor scale. as 800x600 looks too small on a 4k screen, compared to a hd screen in absolute pixel sizes. +// gtx.window_hint(egui_window_glfw_passthrough::glfw::WindowHint::ScaleToMonitor(true)); +// }), +// opengl_window: Some(true), // macos doesn't support opengl. +// transparent_window: Some(false), +// window_title: "Celeritas egui".into(), +// ..Default::default() +// }); + +// // always on top +// // glfw_backend.window.set_floating(true); +// // disable borders/titlebar +// // glfw_backend.window.set_decorated(false); + +// let latest_size = glfw_backend.window.get_framebuffer_size(); +// let latest_size = [latest_size.0 as _, latest_size.1 as _]; + +// let default_gfx_backend = { +// ThreeDBackend::new( +// egui_render_three_d::ThreeDConfig { +// ..Default::default() +// }, +// |s| glfw_backend.get_proc_address(s), +// latest_size, +// ) +// }; + +// let glfw_window_ptr = glfw_backend.window.window_ptr(); +// unsafe { +// // Cast the window pointer to the expected type +// let window_ptr = glfw_window_ptr as *mut crate::GLFWwindow; +// Core_Bringup(window_ptr); +// }; + +// let overlap_app = OverlayApp { +// user_data, +// egui_context: Default::default(), +// default_gfx_backend, +// glfw_backend, +// }; + +// overlap_app.enter_event_loop(); +// } diff --git a/bindgen/rust/celeritas-sys/src/lib.rs b/bindgen/rust/celeritas-sys/src/lib.rs new file mode 100644 index 0000000..1f64680 --- /dev/null +++ b/bindgen/rust/celeritas-sys/src/lib.rs @@ -0,0 +1,7 @@ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +pub mod egui_utils; + +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); |