diff --git a/Cargo.lock b/Cargo.lock index e47c8da..712ae33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,257 +2,34 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "RustyXML" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9222d58bccd9e6e3b82098a2ec142ad34e5d433de986d46cec03ad3a2b5fd529" - -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - -[[package]] -name = "aho-corasick" -version = "0.7.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" -dependencies = [ - "memchr", -] - -[[package]] -name = "alga" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f823d037a7ec6ea2197046bafd4ae150e6bc36f9ca347404f46a46823fa84f2" -dependencies = [ - "approx", - "num-complex", - "num-traits", -] - -[[package]] -name = "alsa-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0edcbbf9ef68f15ae1b620f722180b82a98b6f0628d30baa6b8d2a5abc87d58" -dependencies = [ - "libc", - "pkg-config", -] - -[[package]] -name = "andrew" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e" -dependencies = [ - "bitflags", - "line_drawing", - "rusttype 0.7.9", - "walkdir", - "xdg", - "xml-rs", -] - -[[package]] -name = "android_glue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "approx" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" -dependencies = [ - "num-traits", -] - -[[package]] -name = "ascii-canvas" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b385d69402821a1c254533a011a312531cbcc0e3e24f19bbb4747a5a2daf37e2" -dependencies = [ - "term", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" -dependencies = [ - "addr2line", - "cc", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base-x" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc19a4937b4fbd3fe3379793130e42060d10627a360f2127802b10b87e7baf74" - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - [[package]] name = "bindgen" -version = "0.59.2" +version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ "bitflags", "cexpr", "clang-sys", - "lazy_static 1.4.0", + "lazy_static", "lazycell", + "log", "peeking_take_while", - "proc-macro2 1.0.39", - "quote 1.0.18", + "proc-macro2", + "quote", "regex", "rustc-hash", "shlex", + "syn", + "which", ] -[[package]] -name = "bit-set" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "bumpalo" -version = "3.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cc" -version = "1.0.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - [[package]] name = "cexpr" version = "0.6.0" @@ -262,445 +39,28 @@ dependencies = [ "nom", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cgl" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e7ec0b74fe5897894cbc207092c577e87c52f8a59e8ca8d97ef37551f60a49" -dependencies = [ - "gleam", - "libc", -] - [[package]] name = "clang-sys" -version = "1.3.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" +checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" dependencies = [ "glob", "libc", - "libloading 0.7.3", + "libloading", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - -[[package]] -name = "claxon" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bfbf56724aa9eca8afa4fcfadeb479e722935bb2a0900c2d37e0cc477af0688" - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "cocoa" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54" -dependencies = [ - "bitflags", - "block", - "core-foundation", - "core-graphics", - "foreign-types", - "libc", - "objc", -] - -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - -[[package]] -name = "core-foundation" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" -dependencies = [ - "core-foundation-sys 0.6.2", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa" -dependencies = [ - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" - -[[package]] -name = "core-graphics" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" -dependencies = [ - "bitflags", - "core-foundation", - "foreign-types", - "libc", -] - -[[package]] -name = "coreaudio-rs" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f229761965dad3e9b11081668a6ea00f1def7aa46062321b5ec245b834f6e491" -dependencies = [ - "bitflags", - "coreaudio-sys", -] - -[[package]] -name = "coreaudio-sys" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dff444d80630d7073077d38d40b4501fd518bd2b922c2a55edcc8b0f7be57e6" -dependencies = [ - "bindgen", -] - -[[package]] -name = "cpal" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58ae1ed6536b1b233f5e3aeb6997a046ddb4d05e3f61701b58a92eb254a829e" -dependencies = [ - "alsa-sys", - "core-foundation-sys 0.5.1", - "coreaudio-rs", - "lazy_static 1.4.0", - "libc", - "stdweb 0.1.3", - "winapi 0.3.9", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" -dependencies = [ - "autocfg 1.1.0", - "cfg-if 1.0.0", - "crossbeam-utils", - "lazy_static 1.4.0", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" -dependencies = [ - "cfg-if 1.0.0", - "lazy_static 1.4.0", -] - -[[package]] -name = "cty" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" - -[[package]] -name = "debug_unreachable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3" -dependencies = [ - "unreachable", -] - -[[package]] -name = "deflate" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" -dependencies = [ - "adler32", - "byteorder", -] - -[[package]] -name = "diff" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "dirs" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" -dependencies = [ - "cfg-if 0.1.10", - "dirs-sys", -] - -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi 0.3.9", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - -[[package]] -name = "dlib" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76" -dependencies = [ - "libloading 0.6.7", -] - -[[package]] -name = "docopt" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f3f119846c823f9eafcf953a8f6ffb6ed69bf6240883261a7f13b634579a51f" -dependencies = [ - "lazy_static 1.4.0", - "regex", - "serde 1.0.137", - "strsim 0.10.0", -] - -[[package]] -name = "downcast-rs" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" - [[package]] name = "either" -version = "1.6.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "ena" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00" -dependencies = [ - "log", -] - -[[package]] -name = "encoding" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" -dependencies = [ - "encoding-index-japanese", - "encoding-index-korean", - "encoding-index-simpchinese", - "encoding-index-singlebyte", - "encoding-index-tradchinese", -] - -[[package]] -name = "encoding-index-japanese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-korean" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-simpchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-singlebyte" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-tradchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding_index_tests" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fixedbitset" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "futf" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" -dependencies = [ - "mac", - "new_debug_unreachable", -] - -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "getrandom" @@ -708,322 +68,16 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", - "stdweb 0.4.20", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.10.2+wasi-snapshot-preview1", -] - -[[package]] -name = "gif" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "471d90201b3b223f3451cd4ad53e34295f16a1df17b1edf3736d47761c3981af" -dependencies = [ - "color_quant", - "lzw", -] - -[[package]] -name = "gimli" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" - -[[package]] -name = "gl" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b411c7e0bfc599e3606412c190e786b5bb48cf00073e1635f9bb6f88fe7d84a" -dependencies = [ - "gl_generator 0.13.1", -] - -[[package]] -name = "gl_generator" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a" -dependencies = [ - "khronos_api", - "log", - "xml-rs", -] - -[[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 = "gleam" -version = "0.6.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae10d7c99d0e77b4766e850a60898a17c1abaf01075531f1066f03dc7dc5fc5" -dependencies = [ - "gl_generator 0.13.1", + "wasi", ] [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - -[[package]] -name = "glutin" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5371b35b309dace06be1b81b5f6adb1c9de578b7dbe1e74bf7e4ef762cf6febd" -dependencies = [ - "android_glue", - "cgl", - "cocoa", - "core-foundation", - "core-graphics", - "glutin_egl_sys", - "glutin_emscripten_sys", - "glutin_gles2_sys", - "glutin_glx_sys", - "glutin_wgl_sys", - "lazy_static 1.4.0", - "libloading 0.5.2", - "objc", - "osmesa-sys", - "parking_lot", - "wayland-client", - "winapi 0.3.9", - "winit", -] - -[[package]] -name = "glutin_egl_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2abb6aa55523480c4adc5a56bbaa249992e2dddb2fc63dc96e04a3355364c211" -dependencies = [ - "gl_generator 0.14.0", - "winapi 0.3.9", -] - -[[package]] -name = "glutin_emscripten_sys" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1" - -[[package]] -name = "glutin_gles2_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103" -dependencies = [ - "gl_generator 0.14.0", - "objc", -] - -[[package]] -name = "glutin_glx_sys" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e393c8fc02b807459410429150e9c4faffdb312d59b8c038566173c81991351" -dependencies = [ - "gl_generator 0.14.0", - "x11-dl", -] - -[[package]] -name = "glutin_wgl_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696" -dependencies = [ - "gl_generator 0.14.0", -] - -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hound" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a164bb2ceaeff4f42542bdb847c41517c78a60f5649671b2a07312b6e117549" - -[[package]] -name = "html2runes" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c63600dd0709cc75da234e89e48f096c249f8197276f0a7ad6437ff49297559" -dependencies = [ - "clap", - "html5ever", - "html5ever-atoms", - "tendril", -] - -[[package]] -name = "html5ever" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d60508177ec4e5774a112efcf4d4d5f123cb00a43476fa5940b7da568371a165" -dependencies = [ - "html5ever-atoms", - "log", - "mac", - "phf", - "phf_codegen", - "quote 0.3.15", - "rustc-serialize", - "syn 0.11.11", - "tendril", -] - -[[package]] -name = "html5ever-atoms" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c626dc6733babf7110d3a5078b1529e9d0eaaacf6c488ef6a7437b7d515844bb" -dependencies = [ - "string_cache 0.4.0", - "string_cache_codegen 0.3.1", -] - -[[package]] -name = "image" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35371e467cd7b0b3d1d6013d619203658467df12d61b0ca43cd67b743b1965eb" -dependencies = [ - "byteorder", - "gif", - "jpeg-decoder", - "lzw", - "num-iter", - "num-rational", - "num-traits", - "png", - "scoped_threadpool", - "tiff", -] - -[[package]] -name = "inflate" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" -dependencies = [ - "adler32", -] - -[[package]] -name = "itertools" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" - -[[package]] -name = "jpeg-decoder" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" -dependencies = [ - "rayon", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "khronos_api" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" - -[[package]] -name = "lalrpop" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2e80bee40b22bca46665b4ef1f3cd88ed0fb043c971407eac17a0712c02572" -dependencies = [ - "ascii-canvas", - "atty", - "bit-set", - "diff", - "docopt", - "ena", - "itertools", - "lalrpop-util", - "petgraph", - "regex", - "regex-syntax", - "serde 1.0.137", - "serde_derive", - "sha2", - "string_cache 0.7.5", - "term", - "unicode-xid 0.1.0", -] - -[[package]] -name = "lalrpop-util" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b27d8490dbe1f9704b0088d61e8d46edc10d5673a8829836c6ded26a9912c7" - -[[package]] -name = "lazy_static" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "lazy_static" @@ -1041,20 +95,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" name = "ld45_one_and_all" version = "0.1.1" dependencies = [ - "quicksilver", - "rand 0.7.3", - "serde 1.0.137", -] - -[[package]] -name = "lewton" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d542c1a317036c45c2aa1cf10cc9d403ca91eb2d333ef1a4917e5cb10628bd0" -dependencies = [ - "byteorder", - "ogg", - "smallvec", + "bindgen", + "rand", + "serde", ] [[package]] @@ -1065,56 +108,12 @@ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "libloading" -version = "0.5.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ - "cc", - "winapi 0.3.9", -] - -[[package]] -name = "libloading" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" -dependencies = [ - "cfg-if 1.0.0", - "winapi 0.3.9", -] - -[[package]] -name = "libloading" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" -dependencies = [ - "cfg-if 1.0.0", - "winapi 0.3.9", -] - -[[package]] -name = "libm" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db" - -[[package]] -name = "line_drawing" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" -dependencies = [ - "num-traits", -] - -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", + "cfg-if", + "winapi", ] [[package]] @@ -1123,320 +122,36 @@ version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] -[[package]] -name = "lzw" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" - -[[package]] -name = "mac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - -[[package]] -name = "matches" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" - -[[package]] -name = "matrixmultiply" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1" -dependencies = [ - "rawpointer", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg 1.1.0", -] - [[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "minimp3" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce0cff6a0bfd3f8b6b2350819bbddd63bc65cc45e53888bdd0ff49dde16d2d5" -dependencies = [ - "minimp3-sys", - "slice-deque", -] - -[[package]] -name = "minimp3-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e21c73734c69dc95696c9ed8926a2b393171d98b3f5f5935686a26a487ab9b90" -dependencies = [ - "cc", -] - -[[package]] -name = "miniz_oxide" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" -dependencies = [ - "adler", -] - -[[package]] -name = "nalgebra" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaa9fddbc34c8c35dd2108515587b8ce0cab396f17977b8c738568e4edb521a2" -dependencies = [ - "alga", - "approx", - "generic-array", - "matrixmultiply", - "num-complex", - "num-rational", - "num-traits", - "rand 0.6.5", - "typenum", -] - -[[package]] -name = "new_debug_unreachable" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" - -[[package]] -name = "nix" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" -dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", -] - [[package]] name = "nom" -version = "7.1.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", ] [[package]] -name = "num-complex" -version = "0.2.4" +name = "once_cell" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg 1.1.0", - "num-traits", -] - -[[package]] -name = "num-derive" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eafd0b45c5537c3ba526f79d3e75120036502bebacbb3f3220914067ce39dbf2" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg 1.1.0", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg 1.1.0", - "libm", -] - -[[package]] -name = "num_cpus" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", -] - -[[package]] -name = "object" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" -dependencies = [ - "memchr", -] - -[[package]] -name = "ogg" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e571c3517af9e1729d4c63571a27edd660ade0667973bfc74a67c660c2b651" -dependencies = [ - "byteorder", -] - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "ordered-float" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" -dependencies = [ - "num-traits", -] - -[[package]] -name = "ordermap" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" - -[[package]] -name = "osmesa-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" -dependencies = [ - "shared_library", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api", - "parking_lot_core", - "rustc_version", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "rustc_version", - "smallvec", - "winapi 0.3.9", -] +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "peeking_take_while" @@ -1444,172 +159,28 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "petgraph" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" -dependencies = [ - "fixedbitset", - "ordermap", -] - -[[package]] -name = "phf" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" -dependencies = [ - "phf_shared", -] - -[[package]] -name = "phf_codegen" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" -dependencies = [ - "phf_shared", - "rand 0.6.5", -] - -[[package]] -name = "phf_shared" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pkg-config" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" - -[[package]] -name = "png" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63daf481fdd0defa2d1d2be15c674fbfa1b0fd71882c303a91f9a79b3252c359" -dependencies = [ - "bitflags", - "deflate", - "inflate", - "num-iter", -] - [[package]] name = "ppv-lite86" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" -[[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - [[package]] name = "proc-macro2" -version = "0.4.30" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] -[[package]] -name = "quicksilver" -version = "0.3.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7496c53e5d2c09e2eb55e133dc2a022ccd3958adab84ac07f1adab9d54c6a7f" -dependencies = [ - "base64", - "dirs 2.0.2", - "futures", - "gl", - "glutin", - "image", - "rand 0.7.3", - "rodio", - "rusttype 0.7.9", - "serde 1.0.137", - "serde_derive", - "serde_json", - "stdweb 0.4.20", - "webgl_stdweb", - "winit", -] - -[[package]] -name = "quote" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" dependencies = [ - "proc-macro2 1.0.39", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.9", + "proc-macro2", ] [[package]] @@ -1618,21 +189,11 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.16", + "getrandom", "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", + "rand_chacha", + "rand_core", + "rand_hc", ] [[package]] @@ -1642,40 +203,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", + "getrandom", ] [[package]] @@ -1684,183 +221,23 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "raw-window-handle" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28f55143d0548dad60bb4fbdc835a3d7ac6acc3324506450c5fdd6e42903a76" -dependencies = [ - "libc", - "raw-window-handle 0.4.3", -] - -[[package]] -name = "raw-window-handle" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" -dependencies = [ - "cty", -] - -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - -[[package]] -name = "rayon" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" -dependencies = [ - "autocfg 1.1.0", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "redox_syscall" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom 0.2.6", - "redox_syscall 0.2.13", - "thiserror", + "rand_core", ] [[package]] name = "regex" -version = "1.5.6" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ - "aho-corasick", - "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" - -[[package]] -name = "rodio" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0f961b254e66d147a7b550c78b01308934c97d807a34b417fd0f5a0a0f3a2d" -dependencies = [ - "claxon", - "cpal", - "hound", - "lazy_static 1.4.0", - "lewton", - "minimp3", - "nalgebra", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rustc-hash" @@ -1868,155 +245,24 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "rusttype" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5" -dependencies = [ - "rusttype 0.8.3", -] - -[[package]] -name = "rusttype" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0" -dependencies = [ - "approx", - "ordered-float", - "stb_truetype", -] - -[[package]] -name = "ryu" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "scoped_threadpool" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" -version = "0.9.15" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34b623917345a631dc9608d5194cc206b3fe6c3554cd1c75b937e55e285254af" - -[[package]] -name = "serde" -version = "1.0.137" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] - -[[package]] -name = "serde_json" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" -dependencies = [ - "itoa", - "ryu", - "serde 1.0.137", -] - -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "shared_library" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" -dependencies = [ - "lazy_static 1.4.0", - "libc", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2025,367 +271,23 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" -[[package]] -name = "siphasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" - -[[package]] -name = "slice-deque" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ef6ee280cdefba6d2d0b4b78a84a1c1a3f3a4cec98c2d4231c8bc225de0f25" -dependencies = [ - "libc", - "mach", - "winapi 0.3.9", -] - -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "smithay-client-toolkit" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccb8c57049b2a34d2cc2b203fa785020ba0129d31920ef0d317430adaf748fa" -dependencies = [ - "andrew", - "bitflags", - "dlib", - "lazy_static 1.4.0", - "memmap", - "nix", - "wayland-client", - "wayland-commons", - "wayland-protocols", -] - -[[package]] -name = "stb_truetype" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51" -dependencies = [ - "byteorder", -] - -[[package]] -name = "stdweb" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" - -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version", - "serde 1.0.137", - "serde_json", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "serde 1.0.137", - "serde_derive", - "syn 1.0.96", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2 1.0.39", - "quote 1.0.18", - "serde 1.0.137", - "serde_derive", - "serde_json", - "sha1", - "syn 1.0.96", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - -[[package]] -name = "string_cache" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19dbe4d2552673a8c4ec0e91523670ee2b73ba3560d935703ce5d64a40f864c" -dependencies = [ - "debug_unreachable", - "lazy_static 0.2.11", - "phf_shared", - "serde 0.9.15", - "string_cache_codegen 0.3.1", - "string_cache_shared", -] - -[[package]] -name = "string_cache" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89c058a82f9fd69b1becf8c274f412281038877c553182f1d02eb027045a2d67" -dependencies = [ - "lazy_static 1.4.0", - "new_debug_unreachable", - "phf_shared", - "precomputed-hash", - "serde 1.0.137", - "string_cache_codegen 0.4.4", - "string_cache_shared", -] - -[[package]] -name = "string_cache_codegen" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9dfe1a7c8bba1ecb90730d269fdc08afe93d23c28dd6c4aa5cabd79a05a05e" -dependencies = [ - "phf_generator", - "string_cache_shared", -] - -[[package]] -name = "string_cache_codegen" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" -dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2 1.0.39", - "quote 1.0.18", - "string_cache_shared", -] - -[[package]] -name = "string_cache_shared" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "syn" -version = "0.11.11" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ - "quote 0.3.15", - "synom", - "unicode-xid 0.0.4", -] - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.96" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", + "proc-macro2", + "quote", "unicode-ident", ] -[[package]] -name = "synom" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -dependencies = [ - "unicode-xid 0.0.4", -] - -[[package]] -name = "tendril" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ce04c250d202db8004921e3d3bc95eaa4f2126c6937a428ae39d12d0e38df62" -dependencies = [ - "encoding", - "futf", - "mac", - "utf-8", -] - -[[package]] -name = "term" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" -dependencies = [ - "kernel32-sys", - "winapi 0.2.8", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] - -[[package]] -name = "tiff" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4834f28a0330cb9f3f2c87d2649dca723cb33802e2bdcf18da32759fbec7ce" -dependencies = [ - "byteorder", - "lzw", - "num-derive", - "num-traits", -] - -[[package]] -name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - [[package]] name = "unicode-ident" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - -[[package]] -name = "unicode-xid" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unreachable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91" -dependencies = [ - "void", -] - -[[package]] -name = "utf-8" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aee9ba280438b56d1ebc5329f2094f0ff457f811eeeff0b278d75aa99db400" -dependencies = [ - "matches", -] - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "walkdir" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi 0.3.9", - "winapi-util", -] - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2393,167 +295,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +name = "which" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - -[[package]] -name = "wasm-bindgen" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" -dependencies = [ - "bumpalo", - "lazy_static 1.4.0", - "log", - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" -dependencies = [ - "quote 1.0.18", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" - -[[package]] -name = "wayland-client" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713" -dependencies = [ - "bitflags", - "downcast-rs", + "either", "libc", - "nix", - "wayland-commons", - "wayland-scanner", - "wayland-sys", + "once_cell", ] -[[package]] -name = "wayland-commons" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec" -dependencies = [ - "nix", - "wayland-sys", -] - -[[package]] -name = "wayland-protocols" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145" -dependencies = [ - "bitflags", - "wayland-client", - "wayland-commons", - "wayland-scanner", - "wayland-sys", -] - -[[package]] -name = "wayland-scanner" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "xml-rs", -] - -[[package]] -name = "wayland-sys" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628" -dependencies = [ - "dlib", - "lazy_static 1.4.0", -] - -[[package]] -name = "webgl_generator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d749d56274af7e25dfe9f7ed92d4f1e7452b2de3ea6208529f31048032b5895" -dependencies = [ - "RustyXML", - "heck", - "html2runes", - "khronos_api", - "regex", - "webidl", -] - -[[package]] -name = "webgl_stdweb" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ce7301ae86629fd8d450c2c558a8faf3774d5500db4675bebbf97c5fbd2e30" -dependencies = [ - "serde 1.0.137", - "serde_derive", - "stdweb 0.4.20", - "stdweb-derive", - "webgl_generator", -] - -[[package]] -name = "webidl" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f807f7488d680893f7188aa09d7672a3a0a8461975a098a2edf0a52e3fee29" -dependencies = [ - "lalrpop", - "lalrpop-util", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -2564,81 +315,14 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[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-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi 0.3.9", -] - [[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 = "winit" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e96eb4bb472fa43e718e8fa4aef82f86cd9deac9483a1e1529230babdb394a8" -dependencies = [ - "android_glue", - "backtrace", - "bitflags", - "cocoa", - "core-foundation", - "core-graphics", - "image", - "lazy_static 1.4.0", - "libc", - "log", - "objc", - "parking_lot", - "percent-encoding", - "raw-window-handle 0.3.4", - "smithay-client-toolkit", - "wayland-client", - "winapi 0.3.9", - "x11-dl", -] - -[[package]] -name = "x11-dl" -version = "2.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea26926b4ce81a6f5d9d0f3a0bc401e5a37c6ae14a1bfaa8ff6099ca80038c59" -dependencies = [ - "lazy_static 1.4.0", - "libc", - "pkg-config", -] - -[[package]] -name = "xdg" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" -dependencies = [ - "dirs 4.0.0", -] - -[[package]] -name = "xml-rs" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" diff --git a/Cargo.toml b/Cargo.toml index 4f70c77..aeb771b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,11 +2,23 @@ name = "ld45_one_and_all" version = "0.1.1" authors = ["Stephen Seo "] -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -quicksilver = { version = "0.3.19", default-features = false, features = [ "fonts", "saving", "sounds" ] } +#quicksilver = { version = "0.3.19", default-features = false, features = [ "fonts", "saving", "sounds" ] } rand = "0.7.2" serde = { version = "1.0.101", features = ["derive"] } + +[build-dependencies] +bindgen = "0.64" + +[lib] +name = "ld45_lib" +path = "src/lib.rs" +crate-type = ["rlib", "staticlib"] + +[[bin]] +name = "ld45_bin" +path = "src/bin.rs" diff --git a/LICENSE b/LICENSE index f9de6c5..b70e9ef 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Stephen Seo +Copyright (c) 2019,2023 Stephen Seo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 7345467..f34fe55 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,12 @@ # Disclaimer -The hosted WASM versions of this game still work, but I am not entirely sure if -the security issues with this game apply to the WASM versions. **USE AT YOUR OWN -RISK**. - -This game was created in a manner such that it was tightly coupled with the -`quicksilver` dependency. However, `quicksilver` is no longer (actively) -maintained, and its old dependencies no longer allow this game to run properly -(crashes on native, cannot serve WASM version). +This game has been ported away from quicksilver. A WASM version of the new +version will be made soon. # Entry for LD45 - Start with Nothing -This game is a Rust project using the quicksilver 2D game framework. +This game is a Rust project that originally used the quicksilver 2D game +framework. It now uses Raylib. It can be run locally by invoking `cargo run` in the project directory. diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..1bb9aed --- /dev/null +++ b/build.rs @@ -0,0 +1,22 @@ +extern crate bindgen; + +use std::env; +use std::path::PathBuf; + +fn main() { + println!("cargo:rustc-link-lib=raylib"); + println!("cargo:rustc-link-lib=OpenGL"); + println!("cargo:rerun-if-changed=raylib/raylib.h"); + + let bindings = bindgen::Builder::default() + .header("raylib/raylib.h") + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + .clang_arg("-fvisibility=default") + .generate() + .expect("Unable to generate bindings"); + + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + bindings + .write_to_file(out_path.join("raylib_bindings.rs")) + .expect("Couldn't write bindings!"); +} diff --git a/raylib/raylib.h b/raylib/raylib.h new file mode 100644 index 0000000..8a5d50c --- /dev/null +++ b/raylib/raylib.h @@ -0,0 +1,1568 @@ +/********************************************************************************************** +* +* raylib v4.2 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) +* +* FEATURES: +* - NO external dependencies, all required libraries included with raylib +* - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly, +* MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5. +* - Written in plain C code (C99) in PascalCase/camelCase notation +* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3 or ES2 - choose at compile) +* - Unique OpenGL abstraction layer (usable as standalone module): [rlgl] +* - Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts) +* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC) +* - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more! +* - Flexible Materials system, supporting classic maps and PBR maps +* - Animated 3D models supported (skeletal bones animation) (IQM) +* - Shaders support, including Model shaders and Postprocessing shaders +* - Powerful math module for Vector, Matrix and Quaternion operations: [raymath] +* - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD) +* - VR stereo rendering with configurable HMD device parameters +* - Bindings to multiple programming languages available! +* +* NOTES: +* - One default Font is loaded on InitWindow()->LoadFontDefault() [core, text] +* - One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 [rlgl] (OpenGL 3.3 or ES2) +* - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2) +* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2) +* +* DEPENDENCIES (included): +* [rcore] rglfw (Camilla Löwy - github.com/glfw/glfw) for window/context management and input (PLATFORM_DESKTOP) +* [rlgl] glad (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading (PLATFORM_DESKTOP) +* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management +* +* OPTIONAL DEPENDENCIES (included): +* [rcore] msf_gif (Miles Fogle) for GIF recording +* [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm +* [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm +* [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...) +* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG) +* [rtextures] stb_image_resize (Sean Barret) for image resizing algorithms +* [rtext] stb_truetype (Sean Barret) for ttf fonts loading +* [rtext] stb_rect_pack (Sean Barret) for rectangles packing +* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation +* [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL) +* [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF) +* [raudio] dr_wav (David Reid) for WAV audio file loading +* [raudio] dr_flac (David Reid) for FLAC audio file loading +* [raudio] dr_mp3 (David Reid) for MP3 audio file loading +* [raudio] stb_vorbis (Sean Barret) for OGG audio loading +* [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading +* [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading +* +* +* LICENSE: zlib/libpng +* +* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software: +* +* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5) +* +* This software is provided "as-is", without any express or implied warranty. In no event +* will the authors be held liable for any damages arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, including commercial +* applications, and to alter it and redistribute it freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not claim that you +* wrote the original software. If you use this software in a product, an acknowledgment +* in the product documentation would be appreciated but is not required. +* +* 2. Altered source versions must be plainly marked as such, and must not be misrepresented +* as being the original software. +* +* 3. This notice may not be removed or altered from any source distribution. +* +**********************************************************************************************/ + +#ifndef RAYLIB_H +#define RAYLIB_H + +#include // Required for: va_list - Only used by TraceLogCallback + +#define RAYLIB_VERSION "4.2" + +// Function specifiers in case library is build/used as a shared library (Windows) +// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll +#if defined(_WIN32) + #if defined(BUILD_LIBTYPE_SHARED) + #if defined(__TINYC__) + #define __declspec(x) __attribute__((x)) + #endif + #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) + #elif defined(USE_LIBTYPE_SHARED) + #define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll) + #endif +#endif + +#ifndef RLAPI + #define RLAPI // Functions defined as 'extern' by default (implicit specifiers) +#endif + +//---------------------------------------------------------------------------------- +// Some basic Defines +//---------------------------------------------------------------------------------- +#ifndef PI + #define PI 3.14159265358979323846f +#endif +#ifndef DEG2RAD + #define DEG2RAD (PI/180.0f) +#endif +#ifndef RAD2DEG + #define RAD2DEG (180.0f/PI) +#endif + +// Allow custom memory allocators +// NOTE: Require recompiling raylib sources +#ifndef RL_MALLOC + #define RL_MALLOC(sz) malloc(sz) +#endif +#ifndef RL_CALLOC + #define RL_CALLOC(n,sz) calloc(n,sz) +#endif +#ifndef RL_REALLOC + #define RL_REALLOC(ptr,sz) realloc(ptr,sz) +#endif +#ifndef RL_FREE + #define RL_FREE(ptr) free(ptr) +#endif + +// NOTE: MSVC C++ compiler does not support compound literals (C99 feature) +// Plain structures in C++ (without constructors) can be initialized with { } +#if defined(__cplusplus) + #define CLITERAL(type) type +#else + #define CLITERAL(type) (type) +#endif + +// NOTE: We set some defines with some data types declared by raylib +// Other modules (raymath, rlgl) also require some of those types, so, +// to be able to use those other modules as standalone (not depending on raylib) +// this defines are very useful for internal check and avoid type (re)definitions +#define RL_COLOR_TYPE +#define RL_RECTANGLE_TYPE +#define RL_VECTOR2_TYPE +#define RL_VECTOR3_TYPE +#define RL_VECTOR4_TYPE +#define RL_QUATERNION_TYPE +#define RL_MATRIX_TYPE + +// Some Basic Colors +// NOTE: Custom raylib color palette for amazing visuals on WHITE background +#define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 } // Light Gray +#define GRAY CLITERAL(Color){ 130, 130, 130, 255 } // Gray +#define DARKGRAY CLITERAL(Color){ 80, 80, 80, 255 } // Dark Gray +#define YELLOW CLITERAL(Color){ 253, 249, 0, 255 } // Yellow +#define GOLD CLITERAL(Color){ 255, 203, 0, 255 } // Gold +#define ORANGE CLITERAL(Color){ 255, 161, 0, 255 } // Orange +#define PINK CLITERAL(Color){ 255, 109, 194, 255 } // Pink +#define RED CLITERAL(Color){ 230, 41, 55, 255 } // Red +#define MAROON CLITERAL(Color){ 190, 33, 55, 255 } // Maroon +#define GREEN CLITERAL(Color){ 0, 228, 48, 255 } // Green +#define LIME CLITERAL(Color){ 0, 158, 47, 255 } // Lime +#define DARKGREEN CLITERAL(Color){ 0, 117, 44, 255 } // Dark Green +#define SKYBLUE CLITERAL(Color){ 102, 191, 255, 255 } // Sky Blue +#define BLUE CLITERAL(Color){ 0, 121, 241, 255 } // Blue +#define DARKBLUE CLITERAL(Color){ 0, 82, 172, 255 } // Dark Blue +#define PURPLE CLITERAL(Color){ 200, 122, 255, 255 } // Purple +#define VIOLET CLITERAL(Color){ 135, 60, 190, 255 } // Violet +#define DARKPURPLE CLITERAL(Color){ 112, 31, 126, 255 } // Dark Purple +#define BEIGE CLITERAL(Color){ 211, 176, 131, 255 } // Beige +#define BROWN CLITERAL(Color){ 127, 106, 79, 255 } // Brown +#define DARKBROWN CLITERAL(Color){ 76, 63, 47, 255 } // Dark Brown + +#define WHITE CLITERAL(Color){ 255, 255, 255, 255 } // White +#define BLACK CLITERAL(Color){ 0, 0, 0, 255 } // Black +#define BLANK CLITERAL(Color){ 0, 0, 0, 0 } // Blank (Transparent) +#define MAGENTA CLITERAL(Color){ 255, 0, 255, 255 } // Magenta +#define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 } // My own White (raylib logo) + +//---------------------------------------------------------------------------------- +// Structures Definition +//---------------------------------------------------------------------------------- +// Boolean type +#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) + #include +#elif !defined(__cplusplus) && !defined(bool) + typedef enum bool { false = 0, true = !false } bool; + #define RL_BOOL_TYPE +#endif + +// Vector2, 2 components +typedef struct Vector2 { + float x; // Vector x component + float y; // Vector y component +} Vector2; + +// Vector3, 3 components +typedef struct Vector3 { + float x; // Vector x component + float y; // Vector y component + float z; // Vector z component +} Vector3; + +// Vector4, 4 components +typedef struct Vector4 { + float x; // Vector x component + float y; // Vector y component + float z; // Vector z component + float w; // Vector w component +} Vector4; + +// Quaternion, 4 components (Vector4 alias) +typedef Vector4 Quaternion; + +// Matrix, 4x4 components, column major, OpenGL style, right handed +typedef struct Matrix { + float m0, m4, m8, m12; // Matrix first row (4 components) + float m1, m5, m9, m13; // Matrix second row (4 components) + float m2, m6, m10, m14; // Matrix third row (4 components) + float m3, m7, m11, m15; // Matrix fourth row (4 components) +} Matrix; + +// Color, 4 components, R8G8B8A8 (32bit) +typedef struct Color { + unsigned char r; // Color red value + unsigned char g; // Color green value + unsigned char b; // Color blue value + unsigned char a; // Color alpha value +} Color; + +// Rectangle, 4 components +typedef struct Rectangle { + float x; // Rectangle top-left corner position x + float y; // Rectangle top-left corner position y + float width; // Rectangle width + float height; // Rectangle height +} Rectangle; + +// Image, pixel data stored in CPU memory (RAM) +typedef struct Image { + void *data; // Image raw data + int width; // Image base width + int height; // Image base height + int mipmaps; // Mipmap levels, 1 by default + int format; // Data format (PixelFormat type) +} Image; + +// Texture, tex data stored in GPU memory (VRAM) +typedef struct Texture { + unsigned int id; // OpenGL texture id + int width; // Texture base width + int height; // Texture base height + int mipmaps; // Mipmap levels, 1 by default + int format; // Data format (PixelFormat type) +} Texture; + +// Texture2D, same as Texture +typedef Texture Texture2D; + +// TextureCubemap, same as Texture +typedef Texture TextureCubemap; + +// RenderTexture, fbo for texture rendering +typedef struct RenderTexture { + unsigned int id; // OpenGL framebuffer object id + Texture texture; // Color buffer attachment texture + Texture depth; // Depth buffer attachment texture +} RenderTexture; + +// RenderTexture2D, same as RenderTexture +typedef RenderTexture RenderTexture2D; + +// NPatchInfo, n-patch layout info +typedef struct NPatchInfo { + Rectangle source; // Texture source rectangle + int left; // Left border offset + int top; // Top border offset + int right; // Right border offset + int bottom; // Bottom border offset + int layout; // Layout of the n-patch: 3x3, 1x3 or 3x1 +} NPatchInfo; + +// GlyphInfo, font characters glyphs info +typedef struct GlyphInfo { + int value; // Character value (Unicode) + int offsetX; // Character offset X when drawing + int offsetY; // Character offset Y when drawing + int advanceX; // Character advance position X + Image image; // Character image data +} GlyphInfo; + +// Font, font texture and GlyphInfo array data +typedef struct Font { + int baseSize; // Base size (default chars height) + int glyphCount; // Number of glyph characters + int glyphPadding; // Padding around the glyph characters + Texture2D texture; // Texture atlas containing the glyphs + Rectangle *recs; // Rectangles in texture for the glyphs + GlyphInfo *glyphs; // Glyphs info data +} Font; + +// Camera, defines position/orientation in 3d space +typedef struct Camera3D { + Vector3 position; // Camera position + Vector3 target; // Camera target it looks-at + Vector3 up; // Camera up vector (rotation over its axis) + float fovy; // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic + int projection; // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC +} Camera3D; + +typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D + +// Camera2D, defines position/orientation in 2d space +typedef struct Camera2D { + Vector2 offset; // Camera offset (displacement from target) + Vector2 target; // Camera target (rotation and zoom origin) + float rotation; // Camera rotation in degrees + float zoom; // Camera zoom (scaling), should be 1.0f by default +} Camera2D; + +// Mesh, vertex data and vao/vbo +typedef struct Mesh { + int vertexCount; // Number of vertices stored in arrays + int triangleCount; // Number of triangles stored (indexed or not) + + // Vertex attributes data + float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + float *texcoords2; // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5) + float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) + float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) + unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + unsigned short *indices; // Vertex indices (in case vertex data comes indexed) + + // Animation vertex data + float *animVertices; // Animated vertex positions (after bones transformations) + float *animNormals; // Animated normals (after bones transformations) + unsigned char *boneIds; // Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning) + float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning) + + // OpenGL identifiers + unsigned int vaoId; // OpenGL Vertex Array Object id + unsigned int *vboId; // OpenGL Vertex Buffer Objects id (default vertex data) +} Mesh; + +// Shader +typedef struct Shader { + unsigned int id; // Shader program id + int *locs; // Shader locations array (RL_MAX_SHADER_LOCATIONS) +} Shader; + +// MaterialMap +typedef struct MaterialMap { + Texture2D texture; // Material map texture + Color color; // Material map color + float value; // Material map value +} MaterialMap; + +// Material, includes shader and maps +typedef struct Material { + Shader shader; // Material shader + MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS) + float params[4]; // Material generic parameters (if required) +} Material; + +// Transform, vectex transformation data +typedef struct Transform { + Vector3 translation; // Translation + Quaternion rotation; // Rotation + Vector3 scale; // Scale +} Transform; + +// Bone, skeletal animation bone +typedef struct BoneInfo { + char name[32]; // Bone name + int parent; // Bone parent +} BoneInfo; + +// Model, meshes, materials and animation data +typedef struct Model { + Matrix transform; // Local transform matrix + + int meshCount; // Number of meshes + int materialCount; // Number of materials + Mesh *meshes; // Meshes array + Material *materials; // Materials array + int *meshMaterial; // Mesh material number + + // Animation data + int boneCount; // Number of bones + BoneInfo *bones; // Bones information (skeleton) + Transform *bindPose; // Bones base transformation (pose) +} Model; + +// ModelAnimation +typedef struct ModelAnimation { + int boneCount; // Number of bones + int frameCount; // Number of animation frames + BoneInfo *bones; // Bones information (skeleton) + Transform **framePoses; // Poses array by frame +} ModelAnimation; + +// Ray, ray for raycasting +typedef struct Ray { + Vector3 position; // Ray position (origin) + Vector3 direction; // Ray direction +} Ray; + +// RayCollision, ray hit information +typedef struct RayCollision { + bool hit; // Did the ray hit something? + float distance; // Distance to nearest hit + Vector3 point; // Point of nearest hit + Vector3 normal; // Surface normal of hit +} RayCollision; + +// BoundingBox +typedef struct BoundingBox { + Vector3 min; // Minimum vertex box-corner + Vector3 max; // Maximum vertex box-corner +} BoundingBox; + +// Wave, audio wave data +typedef struct Wave { + unsigned int frameCount; // Total number of frames (considering channels) + unsigned int sampleRate; // Frequency (samples per second) + unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) + unsigned int channels; // Number of channels (1-mono, 2-stereo, ...) + void *data; // Buffer data pointer +} Wave; + +// Opaque structs declaration +// NOTE: Actual structs are defined internally in raudio module +typedef struct rAudioBuffer rAudioBuffer; +typedef struct rAudioProcessor rAudioProcessor; + +// AudioStream, custom audio stream +typedef struct AudioStream { + rAudioBuffer *buffer; // Pointer to internal data used by the audio system + rAudioProcessor *processor; // Pointer to internal data processor, useful for audio effects + + unsigned int sampleRate; // Frequency (samples per second) + unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) + unsigned int channels; // Number of channels (1-mono, 2-stereo, ...) +} AudioStream; + +// Sound +typedef struct Sound { + AudioStream stream; // Audio stream + unsigned int frameCount; // Total number of frames (considering channels) +} Sound; + +// Music, audio stream, anything longer than ~10 seconds should be streamed +typedef struct Music { + AudioStream stream; // Audio stream + unsigned int frameCount; // Total number of frames (considering channels) + bool looping; // Music looping enable + + int ctxType; // Type of music context (audio filetype) + void *ctxData; // Audio context data, depends on type +} Music; + +// VrDeviceInfo, Head-Mounted-Display device parameters +typedef struct VrDeviceInfo { + int hResolution; // Horizontal resolution in pixels + int vResolution; // Vertical resolution in pixels + float hScreenSize; // Horizontal size in meters + float vScreenSize; // Vertical size in meters + float vScreenCenter; // Screen center in meters + float eyeToScreenDistance; // Distance between eye and display in meters + float lensSeparationDistance; // Lens separation distance in meters + float interpupillaryDistance; // IPD (distance between pupils) in meters + float lensDistortionValues[4]; // Lens distortion constant parameters + float chromaAbCorrection[4]; // Chromatic aberration correction parameters +} VrDeviceInfo; + +// VrStereoConfig, VR stereo rendering configuration for simulator +typedef struct VrStereoConfig { + Matrix projection[2]; // VR projection matrices (per eye) + Matrix viewOffset[2]; // VR view offset matrices (per eye) + float leftLensCenter[2]; // VR left lens center + float rightLensCenter[2]; // VR right lens center + float leftScreenCenter[2]; // VR left screen center + float rightScreenCenter[2]; // VR right screen center + float scale[2]; // VR distortion scale + float scaleIn[2]; // VR distortion scale in +} VrStereoConfig; + +// File path list +typedef struct FilePathList { + unsigned int capacity; // Filepaths max entries + unsigned int count; // Filepaths entries count + char **paths; // Filepaths entries +} FilePathList; + +//---------------------------------------------------------------------------------- +// Enumerators Definition +//---------------------------------------------------------------------------------- +// System/Window config flags +// NOTE: Every bit registers one state (use it with bit masks) +// By default all flags are set to 0 +typedef enum { + FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU + FLAG_FULLSCREEN_MODE = 0x00000002, // Set to run program in fullscreen + FLAG_WINDOW_RESIZABLE = 0x00000004, // Set to allow resizable window + FLAG_WINDOW_UNDECORATED = 0x00000008, // Set to disable window decoration (frame and buttons) + FLAG_WINDOW_HIDDEN = 0x00000080, // Set to hide window + FLAG_WINDOW_MINIMIZED = 0x00000200, // Set to minimize window (iconify) + FLAG_WINDOW_MAXIMIZED = 0x00000400, // Set to maximize window (expanded to monitor) + FLAG_WINDOW_UNFOCUSED = 0x00000800, // Set to window non focused + FLAG_WINDOW_TOPMOST = 0x00001000, // Set to window always on top + FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized + FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer + FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI + FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED + FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X + FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D) +} ConfigFlags; + +// Trace log level +// NOTE: Organized by priority level +typedef enum { + LOG_ALL = 0, // Display all logs + LOG_TRACE, // Trace logging, intended for internal use only + LOG_DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds + LOG_INFO, // Info logging, used for program execution info + LOG_WARNING, // Warning logging, used on recoverable failures + LOG_ERROR, // Error logging, used on unrecoverable failures + LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE) + LOG_NONE // Disable logging +} TraceLogLevel; + +// Keyboard keys (US keyboard layout) +// NOTE: Use GetKeyPressed() to allow redefining +// required keys for alternative layouts +typedef enum { + KEY_NULL = 0, // Key: NULL, used for no key pressed + // Alphanumeric keys + KEY_APOSTROPHE = 39, // Key: ' + KEY_COMMA = 44, // Key: , + KEY_MINUS = 45, // Key: - + KEY_PERIOD = 46, // Key: . + KEY_SLASH = 47, // Key: / + KEY_ZERO = 48, // Key: 0 + KEY_ONE = 49, // Key: 1 + KEY_TWO = 50, // Key: 2 + KEY_THREE = 51, // Key: 3 + KEY_FOUR = 52, // Key: 4 + KEY_FIVE = 53, // Key: 5 + KEY_SIX = 54, // Key: 6 + KEY_SEVEN = 55, // Key: 7 + KEY_EIGHT = 56, // Key: 8 + KEY_NINE = 57, // Key: 9 + KEY_SEMICOLON = 59, // Key: ; + KEY_EQUAL = 61, // Key: = + KEY_A = 65, // Key: A | a + KEY_B = 66, // Key: B | b + KEY_C = 67, // Key: C | c + KEY_D = 68, // Key: D | d + KEY_E = 69, // Key: E | e + KEY_F = 70, // Key: F | f + KEY_G = 71, // Key: G | g + KEY_H = 72, // Key: H | h + KEY_I = 73, // Key: I | i + KEY_J = 74, // Key: J | j + KEY_K = 75, // Key: K | k + KEY_L = 76, // Key: L | l + KEY_M = 77, // Key: M | m + KEY_N = 78, // Key: N | n + KEY_O = 79, // Key: O | o + KEY_P = 80, // Key: P | p + KEY_Q = 81, // Key: Q | q + KEY_R = 82, // Key: R | r + KEY_S = 83, // Key: S | s + KEY_T = 84, // Key: T | t + KEY_U = 85, // Key: U | u + KEY_V = 86, // Key: V | v + KEY_W = 87, // Key: W | w + KEY_X = 88, // Key: X | x + KEY_Y = 89, // Key: Y | y + KEY_Z = 90, // Key: Z | z + KEY_LEFT_BRACKET = 91, // Key: [ + KEY_BACKSLASH = 92, // Key: '\' + KEY_RIGHT_BRACKET = 93, // Key: ] + KEY_GRAVE = 96, // Key: ` + // Function keys + KEY_SPACE = 32, // Key: Space + KEY_ESCAPE = 256, // Key: Esc + KEY_ENTER = 257, // Key: Enter + KEY_TAB = 258, // Key: Tab + KEY_BACKSPACE = 259, // Key: Backspace + KEY_INSERT = 260, // Key: Ins + KEY_DELETE = 261, // Key: Del + KEY_RIGHT = 262, // Key: Cursor right + KEY_LEFT = 263, // Key: Cursor left + KEY_DOWN = 264, // Key: Cursor down + KEY_UP = 265, // Key: Cursor up + KEY_PAGE_UP = 266, // Key: Page up + KEY_PAGE_DOWN = 267, // Key: Page down + KEY_HOME = 268, // Key: Home + KEY_END = 269, // Key: End + KEY_CAPS_LOCK = 280, // Key: Caps lock + KEY_SCROLL_LOCK = 281, // Key: Scroll down + KEY_NUM_LOCK = 282, // Key: Num lock + KEY_PRINT_SCREEN = 283, // Key: Print screen + KEY_PAUSE = 284, // Key: Pause + KEY_F1 = 290, // Key: F1 + KEY_F2 = 291, // Key: F2 + KEY_F3 = 292, // Key: F3 + KEY_F4 = 293, // Key: F4 + KEY_F5 = 294, // Key: F5 + KEY_F6 = 295, // Key: F6 + KEY_F7 = 296, // Key: F7 + KEY_F8 = 297, // Key: F8 + KEY_F9 = 298, // Key: F9 + KEY_F10 = 299, // Key: F10 + KEY_F11 = 300, // Key: F11 + KEY_F12 = 301, // Key: F12 + KEY_LEFT_SHIFT = 340, // Key: Shift left + KEY_LEFT_CONTROL = 341, // Key: Control left + KEY_LEFT_ALT = 342, // Key: Alt left + KEY_LEFT_SUPER = 343, // Key: Super left + KEY_RIGHT_SHIFT = 344, // Key: Shift right + KEY_RIGHT_CONTROL = 345, // Key: Control right + KEY_RIGHT_ALT = 346, // Key: Alt right + KEY_RIGHT_SUPER = 347, // Key: Super right + KEY_KB_MENU = 348, // Key: KB menu + // Keypad keys + KEY_KP_0 = 320, // Key: Keypad 0 + KEY_KP_1 = 321, // Key: Keypad 1 + KEY_KP_2 = 322, // Key: Keypad 2 + KEY_KP_3 = 323, // Key: Keypad 3 + KEY_KP_4 = 324, // Key: Keypad 4 + KEY_KP_5 = 325, // Key: Keypad 5 + KEY_KP_6 = 326, // Key: Keypad 6 + KEY_KP_7 = 327, // Key: Keypad 7 + KEY_KP_8 = 328, // Key: Keypad 8 + KEY_KP_9 = 329, // Key: Keypad 9 + KEY_KP_DECIMAL = 330, // Key: Keypad . + KEY_KP_DIVIDE = 331, // Key: Keypad / + KEY_KP_MULTIPLY = 332, // Key: Keypad * + KEY_KP_SUBTRACT = 333, // Key: Keypad - + KEY_KP_ADD = 334, // Key: Keypad + + KEY_KP_ENTER = 335, // Key: Keypad Enter + KEY_KP_EQUAL = 336, // Key: Keypad = + // Android key buttons + KEY_BACK = 4, // Key: Android back button + KEY_MENU = 82, // Key: Android menu button + KEY_VOLUME_UP = 24, // Key: Android volume up button + KEY_VOLUME_DOWN = 25 // Key: Android volume down button +} KeyboardKey; + +// Add backwards compatibility support for deprecated names +#define MOUSE_LEFT_BUTTON MOUSE_BUTTON_LEFT +#define MOUSE_RIGHT_BUTTON MOUSE_BUTTON_RIGHT +#define MOUSE_MIDDLE_BUTTON MOUSE_BUTTON_MIDDLE + +// Mouse buttons +typedef enum { + MOUSE_BUTTON_LEFT = 0, // Mouse button left + MOUSE_BUTTON_RIGHT = 1, // Mouse button right + MOUSE_BUTTON_MIDDLE = 2, // Mouse button middle (pressed wheel) + MOUSE_BUTTON_SIDE = 3, // Mouse button side (advanced mouse device) + MOUSE_BUTTON_EXTRA = 4, // Mouse button extra (advanced mouse device) + MOUSE_BUTTON_FORWARD = 5, // Mouse button fordward (advanced mouse device) + MOUSE_BUTTON_BACK = 6, // Mouse button back (advanced mouse device) +} MouseButton; + +// Mouse cursor +typedef enum { + MOUSE_CURSOR_DEFAULT = 0, // Default pointer shape + MOUSE_CURSOR_ARROW = 1, // Arrow shape + MOUSE_CURSOR_IBEAM = 2, // Text writing cursor shape + MOUSE_CURSOR_CROSSHAIR = 3, // Cross shape + MOUSE_CURSOR_POINTING_HAND = 4, // Pointing hand cursor + MOUSE_CURSOR_RESIZE_EW = 5, // Horizontal resize/move arrow shape + MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape + MOUSE_CURSOR_RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape + MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape + MOUSE_CURSOR_RESIZE_ALL = 9, // The omni-directional resize/move cursor shape + MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape +} MouseCursor; + +// Gamepad buttons +typedef enum { + GAMEPAD_BUTTON_UNKNOWN = 0, // Unknown button, just for error checking + GAMEPAD_BUTTON_LEFT_FACE_UP, // Gamepad left DPAD up button + GAMEPAD_BUTTON_LEFT_FACE_RIGHT, // Gamepad left DPAD right button + GAMEPAD_BUTTON_LEFT_FACE_DOWN, // Gamepad left DPAD down button + GAMEPAD_BUTTON_LEFT_FACE_LEFT, // Gamepad left DPAD left button + GAMEPAD_BUTTON_RIGHT_FACE_UP, // Gamepad right button up (i.e. PS3: Triangle, Xbox: Y) + GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, // Gamepad right button right (i.e. PS3: Square, Xbox: X) + GAMEPAD_BUTTON_RIGHT_FACE_DOWN, // Gamepad right button down (i.e. PS3: Cross, Xbox: A) + GAMEPAD_BUTTON_RIGHT_FACE_LEFT, // Gamepad right button left (i.e. PS3: Circle, Xbox: B) + GAMEPAD_BUTTON_LEFT_TRIGGER_1, // Gamepad top/back trigger left (first), it could be a trailing button + GAMEPAD_BUTTON_LEFT_TRIGGER_2, // Gamepad top/back trigger left (second), it could be a trailing button + GAMEPAD_BUTTON_RIGHT_TRIGGER_1, // Gamepad top/back trigger right (one), it could be a trailing button + GAMEPAD_BUTTON_RIGHT_TRIGGER_2, // Gamepad top/back trigger right (second), it could be a trailing button + GAMEPAD_BUTTON_MIDDLE_LEFT, // Gamepad center buttons, left one (i.e. PS3: Select) + GAMEPAD_BUTTON_MIDDLE, // Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX) + GAMEPAD_BUTTON_MIDDLE_RIGHT, // Gamepad center buttons, right one (i.e. PS3: Start) + GAMEPAD_BUTTON_LEFT_THUMB, // Gamepad joystick pressed button left + GAMEPAD_BUTTON_RIGHT_THUMB // Gamepad joystick pressed button right +} GamepadButton; + +// Gamepad axis +typedef enum { + GAMEPAD_AXIS_LEFT_X = 0, // Gamepad left stick X axis + GAMEPAD_AXIS_LEFT_Y = 1, // Gamepad left stick Y axis + GAMEPAD_AXIS_RIGHT_X = 2, // Gamepad right stick X axis + GAMEPAD_AXIS_RIGHT_Y = 3, // Gamepad right stick Y axis + GAMEPAD_AXIS_LEFT_TRIGGER = 4, // Gamepad back trigger left, pressure level: [1..-1] + GAMEPAD_AXIS_RIGHT_TRIGGER = 5 // Gamepad back trigger right, pressure level: [1..-1] +} GamepadAxis; + +// Material map index +typedef enum { + MATERIAL_MAP_ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE) + MATERIAL_MAP_METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR) + MATERIAL_MAP_NORMAL, // Normal material + MATERIAL_MAP_ROUGHNESS, // Roughness material + MATERIAL_MAP_OCCLUSION, // Ambient occlusion material + MATERIAL_MAP_EMISSION, // Emission material + MATERIAL_MAP_HEIGHT, // Heightmap material + MATERIAL_MAP_CUBEMAP, // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + MATERIAL_MAP_IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + MATERIAL_MAP_PREFILTER, // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + MATERIAL_MAP_BRDF // Brdf material +} MaterialMapIndex; + +#define MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO +#define MATERIAL_MAP_SPECULAR MATERIAL_MAP_METALNESS + +// Shader location index +typedef enum { + SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position + SHADER_LOC_VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01 + SHADER_LOC_VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02 + SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal + SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent + SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color + SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection + SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform) + SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection + SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform) + SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal + SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view + SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color + SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color + SHADER_LOC_COLOR_AMBIENT, // Shader location: vector uniform: ambient color + SHADER_LOC_MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE) + SHADER_LOC_MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR) + SHADER_LOC_MAP_NORMAL, // Shader location: sampler2d texture: normal + SHADER_LOC_MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness + SHADER_LOC_MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion + SHADER_LOC_MAP_EMISSION, // Shader location: sampler2d texture: emission + SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: height + SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap + SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance + SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter + SHADER_LOC_MAP_BRDF // Shader location: sampler2d texture: brdf +} ShaderLocationIndex; + +#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO +#define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS + +// Shader uniform data type +typedef enum { + SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float + SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float) + SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float) + SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float) + SHADER_UNIFORM_INT, // Shader uniform type: int + SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int) + SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int) + SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int) + SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d +} ShaderUniformDataType; + +// Shader attribute data types +typedef enum { + SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float + SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float) + SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float) + SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float) +} ShaderAttributeDataType; + +// Pixel formats +// NOTE: Support depends on OpenGL version and platform +typedef enum { + PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) + PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) + PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp + PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp + PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) + PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) + PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp + PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float) + PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) + PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) + PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) + PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) + PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp + PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp + PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp + PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp + PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp + PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp + PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp + PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp + PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA // 2 bpp +} PixelFormat; + +// Texture parameters: filter mode +// NOTE 1: Filtering considers mipmaps if available in the texture +// NOTE 2: Filter is accordingly set for minification and magnification +typedef enum { + TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation + TEXTURE_FILTER_BILINEAR, // Linear filtering + TEXTURE_FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps) + TEXTURE_FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x + TEXTURE_FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x + TEXTURE_FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x +} TextureFilter; + +// Texture parameters: wrap mode +typedef enum { + TEXTURE_WRAP_REPEAT = 0, // Repeats texture in tiled mode + TEXTURE_WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode + TEXTURE_WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode + TEXTURE_WRAP_MIRROR_CLAMP // Mirrors and clamps to border the texture in tiled mode +} TextureWrap; + +// Cubemap layouts +typedef enum { + CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type + CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces + CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces + CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces + CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces + CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirectangular map) +} CubemapLayout; + +// Font type, defines generation method +typedef enum { + FONT_DEFAULT = 0, // Default font generation, anti-aliased + FONT_BITMAP, // Bitmap font generation, no anti-aliasing + FONT_SDF // SDF font generation, requires external shader +} FontType; + +// Color blending modes (pre-defined) +typedef enum { + BLEND_ALPHA = 0, // Blend textures considering alpha (default) + BLEND_ADDITIVE, // Blend textures adding colors + BLEND_MULTIPLIED, // Blend textures multiplying colors + BLEND_ADD_COLORS, // Blend textures adding colors (alternative) + BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) + BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha + BLEND_CUSTOM // Blend textures using custom src/dst factors (use rlSetBlendMode()) +} BlendMode; + +// Gesture +// NOTE: It could be used as flags to enable only some gestures +typedef enum { + GESTURE_NONE = 0, // No gesture + GESTURE_TAP = 1, // Tap gesture + GESTURE_DOUBLETAP = 2, // Double tap gesture + GESTURE_HOLD = 4, // Hold gesture + GESTURE_DRAG = 8, // Drag gesture + GESTURE_SWIPE_RIGHT = 16, // Swipe right gesture + GESTURE_SWIPE_LEFT = 32, // Swipe left gesture + GESTURE_SWIPE_UP = 64, // Swipe up gesture + GESTURE_SWIPE_DOWN = 128, // Swipe down gesture + GESTURE_PINCH_IN = 256, // Pinch in gesture + GESTURE_PINCH_OUT = 512 // Pinch out gesture +} Gesture; + +// Camera system modes +typedef enum { + CAMERA_CUSTOM = 0, // Custom camera + CAMERA_FREE, // Free camera + CAMERA_ORBITAL, // Orbital camera + CAMERA_FIRST_PERSON, // First person camera + CAMERA_THIRD_PERSON // Third person camera +} CameraMode; + +// Camera projection +typedef enum { + CAMERA_PERSPECTIVE = 0, // Perspective projection + CAMERA_ORTHOGRAPHIC // Orthographic projection +} CameraProjection; + +// N-patch layout +typedef enum { + NPATCH_NINE_PATCH = 0, // Npatch layout: 3x3 tiles + NPATCH_THREE_PATCH_VERTICAL, // Npatch layout: 1x3 tiles + NPATCH_THREE_PATCH_HORIZONTAL // Npatch layout: 3x1 tiles +} NPatchLayout; + +// Callbacks to hook some internal functions +// WARNING: This callbacks are intended for advance users +typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages +typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data +typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data +typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data +typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data + +//------------------------------------------------------------------------------------ +// Global Variables Definition +//------------------------------------------------------------------------------------ +// It's lonely here... + +//------------------------------------------------------------------------------------ +// Window and Graphics Device Functions (Module: core) +//------------------------------------------------------------------------------------ + +#if defined(__cplusplus) +extern "C" { // Prevents name mangling of functions +#endif + +// Window-related functions +RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context +RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed +RLAPI void CloseWindow(void); // Close window and unload OpenGL context +RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully +RLAPI bool IsWindowFullscreen(void); // Check if window is currently fullscreen +RLAPI bool IsWindowHidden(void); // Check if window is currently hidden (only PLATFORM_DESKTOP) +RLAPI bool IsWindowMinimized(void); // Check if window is currently minimized (only PLATFORM_DESKTOP) +RLAPI bool IsWindowMaximized(void); // Check if window is currently maximized (only PLATFORM_DESKTOP) +RLAPI bool IsWindowFocused(void); // Check if window is currently focused (only PLATFORM_DESKTOP) +RLAPI bool IsWindowResized(void); // Check if window has been resized last frame +RLAPI bool IsWindowState(unsigned int flag); // Check if one specific window flag is enabled +RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags (only PLATFORM_DESKTOP) +RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags +RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) +RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP) +RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP) +RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP) +RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP) +RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP) +RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) +RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) +RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) +RLAPI void SetWindowSize(int width, int height); // Set window dimensions +RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) +RLAPI void *GetWindowHandle(void); // Get native window handle +RLAPI int GetScreenWidth(void); // Get current screen width +RLAPI int GetScreenHeight(void); // Get current screen height +RLAPI int GetRenderWidth(void); // Get current render width (it considers HiDPI) +RLAPI int GetRenderHeight(void); // Get current render height (it considers HiDPI) +RLAPI int GetMonitorCount(void); // Get number of connected monitors +RLAPI int GetCurrentMonitor(void); // Get current connected monitor +RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position +RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor) +RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor) +RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres +RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres +RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate +RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor +RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor +RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor +RLAPI void SetClipboardText(const char *text); // Set clipboard text content +RLAPI const char *GetClipboardText(void); // Get clipboard text content +RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling +RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling + +// Custom frame control functions +// NOTE: Those functions are intended for advance users that want full control over the frame processing +// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents() +// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL +RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing) +RLAPI void PollInputEvents(void); // Register all input events +RLAPI void WaitTime(double seconds); // Wait for some time (halt program execution) + +// Cursor-related functions +RLAPI void ShowCursor(void); // Shows cursor +RLAPI void HideCursor(void); // Hides cursor +RLAPI bool IsCursorHidden(void); // Check if cursor is not visible +RLAPI void EnableCursor(void); // Enables cursor (unlock cursor) +RLAPI void DisableCursor(void); // Disables cursor (lock cursor) +RLAPI bool IsCursorOnScreen(void); // Check if cursor is on the screen + +// Drawing-related functions +RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color) +RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing +RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) +RLAPI void BeginMode2D(Camera2D camera); // Begin 2D mode with custom camera (2D) +RLAPI void EndMode2D(void); // Ends 2D mode with custom camera +RLAPI void BeginMode3D(Camera3D camera); // Begin 3D mode with custom camera (3D) +RLAPI void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode +RLAPI void BeginTextureMode(RenderTexture2D target); // Begin drawing to render texture +RLAPI void EndTextureMode(void); // Ends drawing to render texture +RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing +RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader) +RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied, subtract, custom) +RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending) +RLAPI void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing) +RLAPI void EndScissorMode(void); // End scissor mode +RLAPI void BeginVrStereoMode(VrStereoConfig config); // Begin stereo rendering (requires VR simulator) +RLAPI void EndVrStereoMode(void); // End stereo rendering (requires VR simulator) + +// VR stereo config functions for VR simulator +RLAPI VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); // Load VR stereo config for VR simulator device parameters +RLAPI void UnloadVrStereoConfig(VrStereoConfig config); // Unload VR stereo config + +// Shader management functions +// NOTE: Shader functionality is not available on OpenGL 1.1 +RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations +RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations +RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location +RLAPI int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location +RLAPI void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value +RLAPI void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count); // Set shader uniform value vector +RLAPI void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat); // Set shader uniform value (matrix 4x4) +RLAPI void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); // Set shader uniform value for texture (sampler2d) +RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM) + +// Screen-space-related functions +RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from mouse position +RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix) +RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix +RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position +RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position +RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position +RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position + +// Timing-related functions +RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum) +RLAPI int GetFPS(void); // Get current FPS +RLAPI float GetFrameTime(void); // Get time in seconds for last frame drawn (delta time) +RLAPI double GetTime(void); // Get elapsed time in seconds since InitWindow() + +// Misc. functions +RLAPI int GetRandomValue(int min, int max); // Get a random value between min and max (both included) +RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator +RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format) +RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS) + +RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) +RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level +RLAPI void *MemAlloc(int size); // Internal memory allocator +RLAPI void *MemRealloc(void *ptr, int size); // Internal memory reallocator +RLAPI void MemFree(void *ptr); // Internal memory free + +RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available) + +// Set custom callbacks +// WARNING: Callbacks setup is intended for advance users +RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log +RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader +RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver +RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader +RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver + +// Files management functions +RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read) +RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData() +RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success +RLAPI bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName); // Export data to code (.h), returns true on success +RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string +RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText() +RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success +RLAPI bool FileExists(const char *fileName); // Check if file exists +RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists +RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (including point: .png, .wav) +RLAPI int GetFileLength(const char *fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) +RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png') +RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string +RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string) +RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string) +RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string) +RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string) +RLAPI const char *GetApplicationDirectory(void); // Get the directory if the running application (uses static string) +RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success +RLAPI bool IsPathFile(const char *path); // Check if a given path is a file or a directory +RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths +RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan +RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths +RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window +RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths +RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths +RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time) + +// Compression/Encoding functionality +RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree() +RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree() +RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree() +RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree() + +//------------------------------------------------------------------------------------ +// Input Handling Functions (Module: core) +//------------------------------------------------------------------------------------ + +// Input-related functions: keyboard +RLAPI bool IsKeyPressed(int key); // Check if a key has been pressed once +RLAPI bool IsKeyDown(int key); // Check if a key is being pressed +RLAPI bool IsKeyReleased(int key); // Check if a key has been released once +RLAPI bool IsKeyUp(int key); // Check if a key is NOT being pressed +RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC) +RLAPI int GetKeyPressed(void); // Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty +RLAPI int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty + +// Input-related functions: gamepads +RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available +RLAPI const char *GetGamepadName(int gamepad); // Get gamepad internal name id +RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once +RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed +RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once +RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Check if a gamepad button is NOT being pressed +RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed +RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad +RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis +RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB) + +// Input-related functions: mouse +RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once +RLAPI bool IsMouseButtonDown(int button); // Check if a mouse button is being pressed +RLAPI bool IsMouseButtonReleased(int button); // Check if a mouse button has been released once +RLAPI bool IsMouseButtonUp(int button); // Check if a mouse button is NOT being pressed +RLAPI int GetMouseX(void); // Get mouse position X +RLAPI int GetMouseY(void); // Get mouse position Y +RLAPI Vector2 GetMousePosition(void); // Get mouse position XY +RLAPI Vector2 GetMouseDelta(void); // Get mouse delta between frames +RLAPI void SetMousePosition(int x, int y); // Set mouse position XY +RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset +RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling +RLAPI float GetMouseWheelMove(void); // Get mouse wheel movement for X or Y, whichever is larger +RLAPI Vector2 GetMouseWheelMoveV(void); // Get mouse wheel movement for both X and Y +RLAPI void SetMouseCursor(int cursor); // Set mouse cursor + +// Input-related functions: touch +RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size) +RLAPI int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size) +RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size) +RLAPI int GetTouchPointId(int index); // Get touch point identifier for given index +RLAPI int GetTouchPointCount(void); // Get number of touch points + +//------------------------------------------------------------------------------------ +// Gestures and Touch Handling Functions (Module: rgestures) +//------------------------------------------------------------------------------------ +RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags +RLAPI bool IsGestureDetected(int gesture); // Check if a gesture have been detected +RLAPI int GetGestureDetected(void); // Get latest detected gesture +RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds +RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector +RLAPI float GetGestureDragAngle(void); // Get gesture drag angle +RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta +RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle + +//------------------------------------------------------------------------------------ +// Camera System Functions (Module: rcamera) +//------------------------------------------------------------------------------------ +RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available) +RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode + +RLAPI void SetCameraPanControl(int keyPan); // Set camera pan key to combine with mouse movement (free camera) +RLAPI void SetCameraAltControl(int keyAlt); // Set camera alt key to combine with mouse movement (free camera) +RLAPI void SetCameraSmoothZoomControl(int keySmoothZoom); // Set camera smooth zoom key to combine with mouse (free camera) +RLAPI void SetCameraMoveControls(int keyFront, int keyBack, int keyRight, int keyLeft, int keyUp, int keyDown); // Set camera move controls (1st person and 3rd person cameras) + +//------------------------------------------------------------------------------------ +// Basic Shapes Drawing Functions (Module: shapes) +//------------------------------------------------------------------------------------ +// Set texture and rectangle to be used on shapes drawing +// NOTE: It can be useful when using basic shapes and one single font, +// defining a font char white rectangle would allow drawing everything in a single draw call +RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Set texture and rectangle to be used on shapes drawing + +// Basic shapes drawing functions +RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel +RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version) +RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line +RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version) +RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness +RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out +RLAPI void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color); // Draw line using quadratic bezier curves with a control point +RLAPI void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color); // Draw line using cubic bezier curves with 2 control points +RLAPI void DrawLineStrip(Vector2 *points, int pointCount, Color color); // Draw lines sequence +RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle +RLAPI void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw a piece of a circle +RLAPI void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw circle sector outline +RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle +RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version) +RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline +RLAPI void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse +RLAPI void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse outline +RLAPI void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); // Draw ring +RLAPI void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); // Draw ring outline +RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle +RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version) +RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle +RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters +RLAPI void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a vertical-gradient-filled rectangle +RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle +RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors +RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline +RLAPI void DrawRectangleLinesEx(Rectangle rec, float lineThick, Color color); // Draw rectangle outline with extended parameters +RLAPI void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); // Draw rectangle with rounded edges +RLAPI void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, float lineThick, Color color); // Draw rectangle with rounded edges outline +RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!) +RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline (vertex in counter-clockwise order!) +RLAPI void DrawTriangleFan(Vector2 *points, int pointCount, Color color); // Draw a triangle fan defined by points (first vertex is the center) +RLAPI void DrawTriangleStrip(Vector2 *points, int pointCount, Color color); // Draw a triangle strip defined by points +RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version) +RLAPI void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a polygon outline of n sides +RLAPI void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color); // Draw a polygon outline of n sides with extended parameters + +// Basic shapes collision detection functions +RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles +RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles +RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle +RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle +RLAPI bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle +RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle +RLAPI bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint); // Check the collision between two lines defined by two points each, returns collision point by reference +RLAPI bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold); // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] +RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision + +//------------------------------------------------------------------------------------ +// Texture Loading and Drawing Functions (Module: textures) +//------------------------------------------------------------------------------------ + +// Image loading functions +// NOTE: This functions do not require GPU access +RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM) +RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data +RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data) +RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png' +RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data +RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot) +RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM) +RLAPI bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success +RLAPI bool ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes, returns true on success + +// Image generation functions +RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color +RLAPI Image GenImageGradientV(int width, int height, Color top, Color bottom); // Generate image: vertical gradient +RLAPI Image GenImageGradientH(int width, int height, Color left, Color right); // Generate image: horizontal gradient +RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient +RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked +RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise +RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm, bigger tileSize means bigger cells + +// Image manipulation functions +RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations) +RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece +RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font) +RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font) +RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format +RLAPI void ImageToPOT(Image *image, Color fill); // Convert image to POT (power-of-two) +RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle +RLAPI void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value +RLAPI void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color +RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image +RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel +RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm) +RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm) +RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color +RLAPI void ImageMipmaps(Image *image); // Compute all mipmap levels for a provided image +RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) +RLAPI void ImageFlipVertical(Image *image); // Flip image vertically +RLAPI void ImageFlipHorizontal(Image *image); // Flip image horizontally +RLAPI void ImageRotateCW(Image *image); // Rotate image clockwise 90deg +RLAPI void ImageRotateCCW(Image *image); // Rotate image counter-clockwise 90deg +RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint +RLAPI void ImageColorInvert(Image *image); // Modify image color: invert +RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale +RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) +RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) +RLAPI void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color +RLAPI Color *LoadImageColors(Image image); // Load color data from image as a Color array (RGBA - 32bit) +RLAPI Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorCount); // Load colors palette from image as a Color array (RGBA - 32bit) +RLAPI void UnloadImageColors(Color *colors); // Unload color data loaded with LoadImageColors() +RLAPI void UnloadImagePalette(Color *colors); // Unload colors palette loaded with LoadImagePalette() +RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle +RLAPI Color GetImageColor(Image image, int x, int y); // Get image pixel color at (x, y) position + +// Image drawing functions +// NOTE: Image software-rendering functions (CPU) +RLAPI void ImageClearBackground(Image *dst, Color color); // Clear image background with given color +RLAPI void ImageDrawPixel(Image *dst, int posX, int posY, Color color); // Draw pixel within an image +RLAPI void ImageDrawPixelV(Image *dst, Vector2 position, Color color); // Draw pixel within an image (Vector version) +RLAPI void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw line within an image +RLAPI void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color); // Draw line within an image (Vector version) +RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle within an image +RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw circle within an image (Vector version) +RLAPI void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle within an image +RLAPI void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color); // Draw rectangle within an image (Vector version) +RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image +RLAPI void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image +RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); // Draw a source image within a destination image (tint applied to source) +RLAPI void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) within an image (destination) +RLAPI void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination) + +// Texture loading functions +// NOTE: These functions require GPU access +RLAPI Texture2D LoadTexture(const char *fileName); // Load texture from file into GPU memory (VRAM) +RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data +RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout); // Load cubemap from image, multiple image cubemap layouts supported +RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer) +RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM) +RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM) +RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data +RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data + +// Texture configuration functions +RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture +RLAPI void SetTextureFilter(Texture2D texture, int filter); // Set texture scaling filter mode +RLAPI void SetTextureWrap(Texture2D texture, int wrap); // Set texture wrapping mode + +// Texture drawing functions +RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D +RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2 +RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters +RLAPI void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle +RLAPI void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint); // Draw texture quad with tiling and offset parameters +RLAPI void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint); // Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest. +RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters +RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely +RLAPI void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint); // Draw a textured polygon + +// Color/pixel related functions +RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f +RLAPI int ColorToInt(Color color); // Get hexadecimal value for a Color +RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1] +RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1] +RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1] +RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1] +RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f +RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint +RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value +RLAPI Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format +RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer +RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format + +//------------------------------------------------------------------------------------ +// Font Loading and Text Drawing Functions (Module: text) +//------------------------------------------------------------------------------------ + +// Font loading/unloading functions +RLAPI Font GetFontDefault(void); // Get the default Font +RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM) +RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount); // Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set +RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style) +RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf' +RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type); // Load font data for further use +RLAPI Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **recs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info +RLAPI void UnloadFontData(GlyphInfo *chars, int glyphCount); // Unload font chars info data (RAM) +RLAPI void UnloadFont(Font font); // Unload font from GPU memory (VRAM) +RLAPI bool ExportFontAsCode(Font font, const char *fileName); // Export font as code file, returns true on success + +// Text drawing functions +RLAPI void DrawFPS(int posX, int posY); // Draw current FPS +RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) +RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters +RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation) +RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint) +RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint) + +// Text font info functions +RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font +RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font +RLAPI int GetGlyphIndex(Font font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found +RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint); // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found +RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found + +// Text codepoints management functions (unicode characters) +RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter +RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory +RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string +RLAPI int GetCodepoint(const char *text, int *bytesProcessed); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure +RLAPI const char *CodepointToUTF8(int codepoint, int *byteSize); // Encode one codepoint into UTF-8 byte array (array length returned as parameter) +RLAPI char *TextCodepointsToUTF8(const int *codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) + +// Text strings management functions (no UTF-8 strings, only byte chars) +// NOTE: Some strings allocate memory internally for returned strings, just be careful! +RLAPI int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied +RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal +RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending +RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf() style) +RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string +RLAPI char *TextReplace(char *text, const char *replace, const char *by); // Replace text string (WARNING: memory must be freed!) +RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (WARNING: memory must be freed!) +RLAPI const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter +RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings +RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor! +RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string +RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string +RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string +RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string +RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported) + +//------------------------------------------------------------------------------------ +// Basic 3d Shapes Drawing Functions (Module: models) +//------------------------------------------------------------------------------------ + +// Basic geometric 3D shapes drawing functions +RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space +RLAPI void DrawPoint3D(Vector3 position, Color color); // Draw a point in 3D space, actually a small line +RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space +RLAPI void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!) +RLAPI void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color); // Draw a triangle strip defined by points +RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube +RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version) +RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires +RLAPI void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version) +RLAPI void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured +RLAPI void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture +RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere +RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters +RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires +RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone +RLAPI void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder with base at startPos and top at endPos +RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires +RLAPI void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder wires with base at startPos and top at endPos +RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ +RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line +RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) + +//------------------------------------------------------------------------------------ +// Model 3d Loading and Drawing Functions (Module: models) +//------------------------------------------------------------------------------------ + +// Model management functions +RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials) +RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material) +RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM) +RLAPI void UnloadModelKeepMeshes(Model model); // Unload model (but not meshes) from memory (RAM and/or VRAM) +RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes) + +// Model drawing functions +RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set) +RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters +RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set) +RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters +RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires) +RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint); // Draw a billboard texture +RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); // Draw a billboard texture defined by source +RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation + +// Mesh management functions +RLAPI void UploadMesh(Mesh *mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids +RLAPI void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset); // Update mesh vertex data in GPU for a specific buffer index +RLAPI void UnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU +RLAPI void DrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform +RLAPI void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances); // Draw multiple mesh instances with material and different transforms +RLAPI bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success +RLAPI BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits +RLAPI void GenMeshTangents(Mesh *mesh); // Compute mesh tangents + +// Mesh generation functions +RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh +RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions) +RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh +RLAPI Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere) +RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap) +RLAPI Mesh GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh +RLAPI Mesh GenMeshCone(float radius, float height, int slices); // Generate cone/pyramid mesh +RLAPI Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh +RLAPI Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh +RLAPI Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data +RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data + +// Material loading/unloading functions +RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file +RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) +RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM) +RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...) +RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh + +// Model animations loading/unloading functions +RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount); // Load model animations from file +RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose +RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data +RLAPI void UnloadModelAnimations(ModelAnimation *animations, unsigned int count); // Unload animation array data +RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match + +// Collision detection functions +RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres +RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes +RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere +RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere +RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box +RLAPI RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh +RLAPI RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle +RLAPI RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad + +//------------------------------------------------------------------------------------ +// Audio Loading and Playing Functions (Module: audio) +//------------------------------------------------------------------------------------ +typedef void (*AudioCallback)(void *bufferData, unsigned int frames); + +// Audio device management functions +RLAPI void InitAudioDevice(void); // Initialize audio device and context +RLAPI void CloseAudioDevice(void); // Close the audio device and context +RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully +RLAPI void SetMasterVolume(float volume); // Set master volume (listener) + +// Wave/Sound loading/unloading functions +RLAPI Wave LoadWave(const char *fileName); // Load wave data from file +RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav' +RLAPI Sound LoadSound(const char *fileName); // Load sound from file +RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data +RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data +RLAPI void UnloadWave(Wave wave); // Unload wave data +RLAPI void UnloadSound(Sound sound); // Unload sound +RLAPI bool ExportWave(Wave wave, const char *fileName); // Export wave data to file, returns true on success +RLAPI bool ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h), returns true on success + +// Wave/Sound management functions +RLAPI void PlaySound(Sound sound); // Play a sound +RLAPI void StopSound(Sound sound); // Stop playing a sound +RLAPI void PauseSound(Sound sound); // Pause a sound +RLAPI void ResumeSound(Sound sound); // Resume a paused sound +RLAPI void PlaySoundMulti(Sound sound); // Play a sound (using multichannel buffer pool) +RLAPI void StopSoundMulti(void); // Stop any sound playing (using multichannel buffer pool) +RLAPI int GetSoundsPlaying(void); // Get number of sounds playing in the multichannel +RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing +RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level) +RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level) +RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (0.5 is center) +RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave +RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range +RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format +RLAPI float *LoadWaveSamples(Wave wave); // Load samples data from wave as a 32bit float data array +RLAPI void UnloadWaveSamples(float *samples); // Unload samples data loaded with LoadWaveSamples() + +// Music management functions +RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file +RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data +RLAPI void UnloadMusicStream(Music music); // Unload music stream +RLAPI void PlayMusicStream(Music music); // Start music playing +RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing +RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming +RLAPI void StopMusicStream(Music music); // Stop music playing +RLAPI void PauseMusicStream(Music music); // Pause music playing +RLAPI void ResumeMusicStream(Music music); // Resume playing paused music +RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds) +RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level) +RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level) +RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (0.5 is center) +RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds) +RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds) + +// AudioStream management functions +RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data) +RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory +RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data +RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill +RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream +RLAPI void PauseAudioStream(AudioStream stream); // Pause audio stream +RLAPI void ResumeAudioStream(AudioStream stream); // Resume audio stream +RLAPI bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playing +RLAPI void StopAudioStream(AudioStream stream); // Stop audio stream +RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level) +RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level) +RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (0.5 is centered) +RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams +RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data + +RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream +RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream + +#if defined(__cplusplus) +} +#endif + +#endif // RAYLIB_H diff --git a/src/agnostic_interface.rs b/src/agnostic_interface.rs new file mode 100644 index 0000000..acb7250 --- /dev/null +++ b/src/agnostic_interface.rs @@ -0,0 +1,119 @@ +pub mod raylib_impl; + +use std::path::Path; + +use crate::faux_quicksilver::{Circle, Color, Rectangle, Transform, Vector}; + +pub trait ImageInterface { + fn draw(&mut self, x: f32, y: f32, color: Color) -> Result<(), String>; + fn draw_sub( + &mut self, + sub_rect: Rectangle, + dest_rect: Rectangle, + color: Color, + ) -> Result<(), String>; + fn draw_transform( + &mut self, + x: f32, + y: f32, + color: Color, + transform: Transform, + origin: Vector, + ) -> Result<(), String>; + fn draw_sub_transform( + &mut self, + sub_rect: Rectangle, + dest_rect: Rectangle, + color: Color, + transform: Transform, + origin: Vector, + ) -> Result<(), String>; + fn get_w(&self) -> usize; + fn get_h(&self) -> usize; + fn get_wh_rect(&self) -> Rectangle; +} + +pub trait FontInterface { + fn draw(&mut self, s: &str, size: u32, x: f32, y: f32, color: Color) -> Result<(), String>; +} + +pub trait SoundInterface { + fn play(&mut self, vol: f32) -> Result<(), String>; +} + +pub trait MusicInterface { + fn play(&mut self, vol: f32) -> Result<(), String>; + fn pause(&mut self) -> Result<(), String>; + fn stop(&mut self) -> Result<(), String>; + fn set_loop(&mut self, loop_enable: bool) -> Result<(), String>; + fn update(&mut self) -> Result<(), String>; +} + +pub trait ShaderInterface { + fn set_transform_attrib(&mut self, transform: Transform) -> Result<(), String>; + fn set_origin_attrib(&mut self, origin: Vector) -> Result<(), String>; + fn set_camera_attrib(&mut self, camera: Vector) -> Result<(), String>; + fn begin_draw_shader(&self) -> Result<(), String>; + fn end_draw_shader(&self) -> Result<(), String>; +} + +pub trait CameraInterface { + fn get_view_xy(&self) -> Result<(f32, f32), String>; + fn set_view_xy(&mut self, x: f32, y: f32) -> Result<(), String>; +} + +pub trait GameInterface { + fn get_dimensions(&self) -> Result<(f32, f32), String>; + fn get_key_pressed(&mut self, key: char) -> Result; + fn get_mouse_pressed(&mut self) -> Result, String>; + fn get_mouse_released(&mut self) -> Result; + fn get_mouse_down(&mut self) -> Result, String>; + fn get_mouse_xy(&self) -> Result<(f32, f32), String>; + fn get_mouse_xy_vec(&self) -> Result; + fn xy_to_world(&self, x: f32, y: f32) -> Result; + fn vec_to_world(&self, vec: Vector) -> Result; + fn get_delta_time(&self) -> f32; + fn clear_window(&mut self, color: Color) -> Result<(), String>; + fn begin_drawing(&mut self) -> Result<(), String>; + fn end_drawing(&mut self) -> Result<(), String>; + + fn draw_circle(&mut self, circle: Circle, color: Color) -> Result<(), String>; + fn draw_circle_transform( + &mut self, + circle: Circle, + color: Color, + transform: Transform, + origin: Vector, + ) -> Result<(), String>; + fn draw_rect(&mut self, rect: Rectangle, color: Color) -> Result<(), String>; + fn draw_rect_ex( + &mut self, + rect: Rectangle, + color: Color, + origin: Vector, + rot: f32, + ) -> Result<(), String>; + fn draw_rect_transform( + &mut self, + rect: Rectangle, + color: Color, + transform: Transform, + origin: Vector, + ) -> Result<(), String>; + + fn load_image(&mut self, path: &Path) -> Result, String>; + fn load_font(&mut self, path: &Path) -> Result, String>; + fn load_sound(&mut self, path: &Path) -> Result, String>; + fn load_music(&mut self, path: &Path) -> Result, String>; + fn load_shader( + &mut self, + name: String, + vs: &Path, + fs: &Path, + ) -> Result, String>; + + fn get_camera(&mut self) -> Result, String>; + fn get_default_camera(&mut self) -> Result, String>; + fn set_camera(&mut self, camera: &Box) -> Result<(), String>; + fn set_camera_xy(&mut self, x: f32, y: f32) -> Result<(), String>; +} diff --git a/src/agnostic_interface/raylib_impl.rs b/src/agnostic_interface/raylib_impl.rs new file mode 100644 index 0000000..e0eb388 --- /dev/null +++ b/src/agnostic_interface/raylib_impl.rs @@ -0,0 +1,1075 @@ +pub mod ffi { + #![allow(non_upper_case_globals)] + #![allow(non_camel_case_types)] + #![allow(non_snake_case)] + #![allow(dead_code)] + + include!(concat!(env!("OUT_DIR"), "/raylib_bindings.rs")); +} + +use std::{ + cell::RefCell, + collections::HashMap, + ffi::CString, + os::raw::{c_char, c_int}, + path::{Path, PathBuf}, + rc::Rc, + str::FromStr, +}; + +use crate::{ + faux_quicksilver::{Transform, Vector}, + shaders::{get_attrib_location, set_attr_2f, set_transform_3f}, +}; + +use super::{ + CameraInterface, FontInterface, GameInterface, ImageInterface, MusicInterface, ShaderInterface, + SoundInterface, +}; + +fn fqcolor_to_color(c: crate::faux_quicksilver::Color) -> ffi::Color { + ffi::Color { + r: c.r, + g: c.g, + b: c.b, + a: c.a, + } +} + +fn fqrect_to_rect(r: crate::faux_quicksilver::Rectangle) -> ffi::Rectangle { + ffi::Rectangle { + x: r.x, + y: r.y, + width: r.w, + height: r.h, + } +} + +fn fqvector_to_vector2(v: crate::faux_quicksilver::Vector) -> ffi::Vector2 { + ffi::Vector2 { x: v.x, y: v.y } +} + +#[derive(Clone, Debug)] +pub struct RaylibShader { + shader: ffi::Shader, +} + +impl RaylibShader { + pub fn get_shader_id(&self) -> ::std::os::raw::c_uint { + self.shader.id as ::std::os::raw::c_uint + } + + fn set_transform_attrib(&mut self, transform: Transform) -> Result<(), String> { + let transform_cstr = CString::new("transform") + .map_err(|_| String::from("Failed to create \"transform\" CString!"))?; + let attr_loc = get_attrib_location(self, &transform_cstr); + set_transform_3f(attr_loc, transform); + Ok(()) + } + + fn begin_draw_shader(&self) -> Result<(), String> { + unsafe { + ffi::BeginShaderMode(self.shader); + } + Ok(()) + } + + fn end_draw_shader(&self) -> Result<(), String> { + unsafe { + ffi::EndShaderMode(); + } + Ok(()) + } + + fn set_origin_attrib(&mut self, origin: Vector) -> Result<(), String> { + let origin_cstr = CString::new("origin") + .map_err(|_| String::from("Failed to create \"origin\" CString!"))?; + let attr_loc = get_attrib_location(self, &origin_cstr); + set_attr_2f(attr_loc, origin); + Ok(()) + } + + fn set_camera_attrib(&mut self, camera: Vector) -> Result<(), String> { + let camera_cstr = CString::new("camera") + .map_err(|_| String::from("Failed to create \"camera\" CString!"))?; + let attr_loc = get_attrib_location(self, &camera_cstr); + set_attr_2f(attr_loc, camera); + Ok(()) + } +} + +#[derive(Clone, Debug)] +struct RaylibShaderHandler { + shader: Rc>, +} + +impl ShaderInterface for RaylibShaderHandler { + fn set_transform_attrib(&mut self, transform: Transform) -> Result<(), String> { + self.shader.borrow_mut().set_transform_attrib(transform) + } + + fn begin_draw_shader(&self) -> Result<(), String> { + self.shader.borrow().begin_draw_shader() + } + + fn end_draw_shader(&self) -> Result<(), String> { + self.shader.borrow().end_draw_shader() + } + + fn set_origin_attrib(&mut self, origin: Vector) -> Result<(), String> { + self.shader.borrow_mut().set_origin_attrib(origin) + } + + fn set_camera_attrib(&mut self, camera: Vector) -> Result<(), String> { + self.shader.borrow_mut().set_camera_attrib(camera) + } +} + +impl RaylibShaderHandler { + pub fn load_shader(vs: &Path, fs: &Path) -> Result { + unsafe { + let vs_cstr: CString = CString::from_vec_unchecked( + vs.to_str() + .ok_or_else(|| format!("Cannot convert path \"{vs:?}\" to str!"))? + .as_bytes() + .to_owned(), + ); + let fs_cstr: CString = CString::from_vec_unchecked( + fs.to_str() + .ok_or_else(|| format!("Cannot convert path \"{fs:?}\" to str!"))? + .as_bytes() + .to_owned(), + ); + Ok(Self { + shader: Rc::new(RefCell::new(RaylibShader { + shader: ffi::LoadShader(vs_cstr.as_ptr(), fs_cstr.as_ptr()), + })), + }) + } + } +} + +#[derive(Clone, Debug)] +struct RaylibImage { + image: ffi::Image, + texture: Option, +} + +#[derive(Clone, Debug)] +struct RaylibImageHandler { + image: Rc>, + tr_or_cam_shader: Rc>>, + cam_shader: Rc>>, + camera: Rc>, +} + +impl RaylibImageHandler { + fn image_to_texture(&mut self) -> Result<(), String> { + if self.image.borrow().texture.is_none() { + unsafe { + let texture = ffi::LoadTextureFromImage(self.image.borrow().image); + self.image.borrow_mut().texture = Some(texture); + } + } + Ok(()) + } +} + +impl ImageInterface for RaylibImageHandler { + fn draw( + &mut self, + x: f32, + y: f32, + color: crate::faux_quicksilver::Color, + ) -> Result<(), String> { + self.image_to_texture()?; + if let Some(cam_shader) = self.cam_shader.borrow_mut().as_mut() { + cam_shader.set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.begin_draw_shader()?; + unsafe { + ffi::DrawTexture( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + x.round() as i32, + y.round() as i32, + fqcolor_to_color(color), + ); + } + cam_shader.end_draw_shader()?; + } else { + unsafe { + ffi::DrawTexture( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + x.round() as i32, + y.round() as i32, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn draw_sub( + &mut self, + sub_rect: crate::faux_quicksilver::Rectangle, + dest_rect: crate::faux_quicksilver::Rectangle, + color: crate::faux_quicksilver::Color, + ) -> Result<(), String> { + self.image_to_texture()?; + if let Some(cam_shader) = self.cam_shader.borrow_mut().as_mut() { + cam_shader.set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.begin_draw_shader()?; + unsafe { + ffi::DrawTexturePro( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + fqrect_to_rect(sub_rect), + fqrect_to_rect(dest_rect), + ffi::Vector2 { x: 0.0, y: 0.0 }, + 0.0, + fqcolor_to_color(color), + ); + } + cam_shader.end_draw_shader()?; + } else { + unsafe { + ffi::DrawTexturePro( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + fqrect_to_rect(sub_rect), + fqrect_to_rect(dest_rect), + ffi::Vector2 { x: 0.0, y: 0.0 }, + 0.0, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn draw_transform( + &mut self, + x: f32, + y: f32, + color: crate::faux_quicksilver::Color, + transform: crate::faux_quicksilver::Transform, + origin: Vector, + ) -> Result<(), String> { + self.image_to_texture()?; + if let Some(shader) = self.tr_or_cam_shader.borrow_mut().as_mut() { + shader.set_origin_attrib(origin)?; + shader.set_transform_attrib(transform)?; + shader.set_camera_attrib(self.camera.borrow().pos)?; + shader.begin_draw_shader()?; + unsafe { + ffi::DrawTexture( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + x.round() as i32, + y.round() as i32, + fqcolor_to_color(color), + ); + } + shader.end_draw_shader()?; + } else if let Some(cam_shader) = self.cam_shader.borrow_mut().as_mut() { + cam_shader.set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.begin_draw_shader()?; + unsafe { + ffi::DrawTexture( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + x.round() as i32, + y.round() as i32, + fqcolor_to_color(color), + ); + } + cam_shader.end_draw_shader()?; + } else { + unsafe { + ffi::DrawTexture( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + x.round() as i32, + y.round() as i32, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn draw_sub_transform( + &mut self, + sub_rect: crate::faux_quicksilver::Rectangle, + dest_rect: crate::faux_quicksilver::Rectangle, + color: crate::faux_quicksilver::Color, + transform: crate::faux_quicksilver::Transform, + origin: Vector, + ) -> Result<(), String> { + self.image_to_texture()?; + if let Some(shader) = self.tr_or_cam_shader.borrow_mut().as_mut() { + shader.set_origin_attrib(origin)?; + shader.set_transform_attrib(transform)?; + shader.set_camera_attrib(self.camera.borrow().pos)?; + shader.begin_draw_shader()?; + unsafe { + ffi::DrawTexturePro( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + fqrect_to_rect(sub_rect), + fqrect_to_rect(dest_rect), + ffi::Vector2 { x: 0.0, y: 0.0 }, + 0.0, + fqcolor_to_color(color), + ); + } + shader.end_draw_shader()?; + } else if let Some(cam_shader) = self.cam_shader.borrow_mut().as_mut() { + cam_shader.set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.begin_draw_shader()?; + unsafe { + ffi::DrawTexturePro( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + fqrect_to_rect(sub_rect), + fqrect_to_rect(dest_rect), + ffi::Vector2 { x: 0.0, y: 0.0 }, + 0.0, + fqcolor_to_color(color), + ); + } + cam_shader.end_draw_shader()?; + } else { + unsafe { + ffi::DrawTexturePro( + *self + .image + .borrow() + .texture + .as_ref() + .ok_or_else(|| String::from("RaylibImage has no Texture!"))?, + fqrect_to_rect(sub_rect), + fqrect_to_rect(dest_rect), + ffi::Vector2 { x: 0.0, y: 0.0 }, + 0.0, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn get_w(&self) -> usize { + self.image.borrow().image.width as usize + } + + fn get_h(&self) -> usize { + self.image.borrow().image.height as usize + } + + fn get_wh_rect(&self) -> crate::faux_quicksilver::Rectangle { + crate::faux_quicksilver::Rectangle { + x: 0.0, + y: 0.0, + w: self.image.borrow().image.width as f32, + h: self.image.borrow().image.height as f32, + } + } +} + +#[derive(Clone, Debug)] +struct RaylibFont { + font: ffi::Font, +} + +#[derive(Clone, Debug)] +struct RaylibFontHandler { + font: Rc, +} + +impl FontInterface for RaylibFontHandler { + fn draw( + &mut self, + s: &str, + size: u32, + x: f32, + y: f32, + color: crate::faux_quicksilver::Color, + ) -> Result<(), String> { + unsafe { + let cstring = CString::from_vec_unchecked(s.as_bytes().into()); + ffi::DrawTextEx( + self.font.font, + cstring.as_ptr(), + ffi::Vector2 { x, y }, + size as f32, + (size / 10) as f32, + fqcolor_to_color(color), + ); + } + Ok(()) + } +} + +#[derive(Clone, Debug)] +struct RaylibSound { + sound: ffi::Sound, +} + +#[derive(Clone, Debug)] +struct RaylibSoundHandler { + sound: Rc, +} + +impl SoundInterface for RaylibSoundHandler { + fn play(&mut self, vol: f32) -> Result<(), String> { + unsafe { + ffi::SetSoundVolume(self.sound.sound, vol); + ffi::PlaySound(self.sound.sound); + } + Ok(()) + } +} + +#[derive(Clone, Debug)] +struct RaylibMusic { + music: ffi::Music, +} + +impl RaylibMusic { + pub fn update(&mut self) { + unsafe { + ffi::UpdateMusicStream(self.music); + } + } +} + +#[derive(Clone, Debug)] +struct RaylibMusicHandler { + music: Rc>, +} + +impl MusicInterface for RaylibMusicHandler { + fn play(&mut self, vol: f32) -> Result<(), String> { + unsafe { + ffi::SetMusicVolume(self.music.borrow().music, vol); + ffi::PlayMusicStream(self.music.borrow().music); + } + Ok(()) + } + + fn pause(&mut self) -> Result<(), String> { + unsafe { + ffi::PauseMusicStream(self.music.borrow().music); + } + Ok(()) + } + + fn stop(&mut self) -> Result<(), String> { + unsafe { + ffi::StopMusicStream(self.music.borrow().music); + } + Ok(()) + } + + fn set_loop(&mut self, loop_enable: bool) -> Result<(), String> { + self.music.borrow_mut().music.looping = loop_enable; + Ok(()) + } + + fn update(&mut self) -> Result<(), String> { + self.music.borrow_mut().update(); + Ok(()) + } +} + +#[derive(Debug, Clone)] +struct Camera { + pos: Vector, +} + +impl Default for Camera { + fn default() -> Self { + Self { + pos: Vector { x: 0.0, y: 0.0 }, + } + } +} + +impl CameraInterface for Camera { + fn get_view_xy(&self) -> Result<(f32, f32), String> { + Ok((self.pos.x, self.pos.y)) + } + + fn set_view_xy(&mut self, x: f32, y: f32) -> Result<(), String> { + self.pos.x = x; + self.pos.y = y; + Ok(()) + } +} + +pub struct RaylibGame { + images: HashMap>>, + fonts: HashMap>, + sounds: HashMap>, + music: HashMap>>, + shaders: HashMap>>, + camera: Rc>, +} + +impl RaylibGame { + #[cfg(not(target_arch = "wasm32"))] + fn native_setup() { + unsafe { + ffi::SetTargetFPS(60); + } + } + + #[cfg(target_arch = "wasm32")] + fn native_setup() {} + + pub fn new_boxed(width: u32, height: u32) -> Box { + unsafe { + let string = "One and All LD45\0"; + ffi::InitWindow( + width as c_int, + height as c_int, + string.as_ptr() as *const c_char, + ); + } + + Self::native_setup(); + unsafe { + while !ffi::IsAudioDeviceReady() { + ffi::InitAudioDevice(); + } + } + + let mut self_unboxed = Self { + images: HashMap::new(), + fonts: HashMap::new(), + sounds: HashMap::new(), + music: HashMap::new(), + shaders: HashMap::new(), + camera: Rc::new(RefCell::new(Camera::default())), + }; + if let Err(e) = self_unboxed.load_transform_origin_shader() { + println!("WARNING: {e:?}"); + } + if let Err(e) = self_unboxed.load_camera_shader() { + println!("WARNING: {e:?}"); + } + Box::new(self_unboxed) + } +} + +impl Drop for RaylibGame { + fn drop(&mut self) { + unsafe { + for (_, shader) in &self.shaders { + ffi::UnloadShader(shader.borrow().shader); + } + for (_, image) in &self.images { + if let Some(texture) = image.borrow_mut().texture.take() { + ffi::UnloadTexture(texture); + } + ffi::UnloadImage(image.borrow().image); + } + for (_, font) in &self.fonts { + ffi::UnloadFont(font.font); + } + for (_, sound) in &self.sounds { + ffi::UnloadSound(sound.sound); + } + for (_, music) in &self.music { + ffi::UnloadMusicStream(music.borrow().music); + } + ffi::CloseWindow(); + } + } +} + +impl GameInterface for RaylibGame { + fn get_dimensions(&self) -> Result<(f32, f32), String> { + unsafe { Ok((ffi::GetScreenWidth() as f32, ffi::GetScreenHeight() as f32)) } + } + + fn get_key_pressed(&mut self, key: char) -> Result { + unsafe { Ok(ffi::IsKeyPressed(key.to_ascii_uppercase() as c_int)) } + } + + fn get_mouse_pressed(&mut self) -> Result, String> { + unsafe { + if ffi::IsMouseButtonPressed(0) { + Ok(Some((ffi::GetTouchX() as f32, ffi::GetTouchY() as f32))) + } else { + Ok(None) + } + } + } + + fn get_mouse_released(&mut self) -> Result { + unsafe { + if ffi::IsMouseButtonReleased(0) { + Ok(true) + } else { + Ok(false) + } + } + } + + fn get_mouse_down(&mut self) -> Result, String> { + unsafe { + if ffi::IsMouseButtonDown(0) { + Ok(Some((ffi::GetTouchX() as f32, ffi::GetTouchY() as f32))) + } else { + Ok(None) + } + } + } + + fn get_mouse_xy(&self) -> Result<(f32, f32), String> { + unsafe { Ok((ffi::GetTouchX() as f32, ffi::GetTouchY() as f32)) } + } + + fn get_mouse_xy_vec(&self) -> Result { + unsafe { + Ok(crate::faux_quicksilver::Vector { + x: ffi::GetTouchX() as f32, + y: ffi::GetTouchY() as f32, + }) + } + } + + fn get_delta_time(&self) -> f32 { + unsafe { ffi::GetFrameTime() } + } + + fn clear_window(&mut self, color: crate::faux_quicksilver::Color) -> Result<(), String> { + unsafe { + ffi::ClearBackground(fqcolor_to_color(color)); + } + Ok(()) + } + + fn begin_drawing(&mut self) -> Result<(), String> { + unsafe { + ffi::BeginDrawing(); + } + Ok(()) + } + + fn end_drawing(&mut self) -> Result<(), String> { + unsafe { + ffi::EndDrawing(); + } + Ok(()) + } + + fn draw_circle( + &mut self, + circle: crate::faux_quicksilver::Circle, + color: crate::faux_quicksilver::Color, + ) -> Result<(), String> { + if let Some(cam_shader) = self.shaders.get_mut("camera") { + cam_shader + .borrow_mut() + .set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.borrow().begin_draw_shader()?; + unsafe { + ffi::DrawCircle( + circle.x.round() as i32, + circle.y.round() as i32, + circle.r, + fqcolor_to_color(color), + ); + } + cam_shader.borrow().end_draw_shader()?; + } else { + unsafe { + ffi::DrawCircle( + circle.x.round() as i32, + circle.y.round() as i32, + circle.r, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn draw_circle_transform( + &mut self, + circle: crate::faux_quicksilver::Circle, + color: crate::faux_quicksilver::Color, + transform: crate::faux_quicksilver::Transform, + origin: Vector, + ) -> Result<(), String> { + if let Some(shader) = self.shaders.get_mut("transform_origin") { + shader.borrow_mut().set_origin_attrib(origin)?; + shader.borrow_mut().set_transform_attrib(transform)?; + shader + .borrow_mut() + .set_camera_attrib(self.camera.borrow().pos)?; + shader.borrow().begin_draw_shader()?; + unsafe { + ffi::DrawCircle( + circle.x.round() as i32, + circle.y.round() as i32, + circle.r, + fqcolor_to_color(color), + ); + } + shader.borrow().end_draw_shader()?; + } else if let Some(cam_shader) = self.shaders.get_mut("camera") { + cam_shader + .borrow_mut() + .set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.borrow().begin_draw_shader()?; + unsafe { + ffi::DrawCircle( + circle.x.round() as i32, + circle.y.round() as i32, + circle.r, + fqcolor_to_color(color), + ); + } + cam_shader.borrow().end_draw_shader()?; + } else { + unsafe { + ffi::DrawCircle( + circle.x.round() as i32, + circle.y.round() as i32, + circle.r, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn draw_rect( + &mut self, + rect: crate::faux_quicksilver::Rectangle, + color: crate::faux_quicksilver::Color, + ) -> Result<(), String> { + if let Some(cam_shader) = self.shaders.get_mut("camera") { + cam_shader + .borrow_mut() + .set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.borrow().begin_draw_shader()?; + unsafe { + ffi::DrawRectangle( + rect.x.round() as i32, + rect.y.round() as i32, + rect.w.round() as i32, + rect.h.round() as i32, + fqcolor_to_color(color), + ); + } + cam_shader.borrow().end_draw_shader()?; + } else { + unsafe { + ffi::DrawRectangle( + rect.x.round() as i32, + rect.y.round() as i32, + rect.w.round() as i32, + rect.h.round() as i32, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn draw_rect_ex( + &mut self, + rect: crate::faux_quicksilver::Rectangle, + color: crate::faux_quicksilver::Color, + origin: crate::faux_quicksilver::Vector, + rot: f32, + ) -> Result<(), String> { + if let Some(cam_shader) = self.shaders.get_mut("camera") { + cam_shader + .borrow_mut() + .set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.borrow().begin_draw_shader()?; + unsafe { + ffi::DrawRectanglePro( + fqrect_to_rect(rect), + fqvector_to_vector2(origin), + rot, + fqcolor_to_color(color), + ); + } + cam_shader.borrow().end_draw_shader()?; + } else { + unsafe { + ffi::DrawRectanglePro( + fqrect_to_rect(rect), + fqvector_to_vector2(origin), + rot, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn draw_rect_transform( + &mut self, + rect: crate::faux_quicksilver::Rectangle, + color: crate::faux_quicksilver::Color, + transform: crate::faux_quicksilver::Transform, + origin: Vector, + ) -> Result<(), String> { + if let Some(shader) = self.shaders.get_mut("transform_origin") { + shader.borrow_mut().set_origin_attrib(origin)?; + shader.borrow_mut().set_transform_attrib(transform)?; + shader + .borrow_mut() + .set_camera_attrib(self.camera.borrow().pos)?; + shader.borrow().begin_draw_shader()?; + unsafe { + ffi::DrawRectangle( + rect.x.round() as i32, + rect.y.round() as i32, + rect.w.round() as i32, + rect.h.round() as i32, + fqcolor_to_color(color), + ); + } + shader.borrow().end_draw_shader()?; + } else if let Some(cam_shader) = self.shaders.get_mut("camera") { + cam_shader + .borrow_mut() + .set_camera_attrib(self.camera.borrow().pos)?; + cam_shader.borrow().begin_draw_shader()?; + unsafe { + ffi::DrawRectangle( + rect.x.round() as i32, + rect.y.round() as i32, + rect.w.round() as i32, + rect.h.round() as i32, + fqcolor_to_color(color), + ); + } + cam_shader.borrow().end_draw_shader()?; + } else { + unsafe { + ffi::DrawRectangle( + rect.x.round() as i32, + rect.y.round() as i32, + rect.w.round() as i32, + rect.h.round() as i32, + fqcolor_to_color(color), + ); + } + } + Ok(()) + } + + fn load_image( + &mut self, + path: &std::path::Path, + ) -> Result, String> { + unsafe { + let path_str = path + .to_str() + .ok_or_else(|| format!("Failed to convert \"{path:?}\" to str!"))?; + let path_buf: Vec = path_str.as_bytes().into(); + let cstring: CString = CString::from_vec_unchecked(path_buf); + let image = ffi::LoadImage(cstring.as_ptr()); + let tr_or_cam_shader: Option = + if let Some(shader) = self.shaders.get("transform_origin") { + Some(RaylibShaderHandler { + shader: shader.clone(), + }) + } else { + None + }; + let cam_shader: Option = + if let Some(shader) = self.shaders.get("camera") { + Some(RaylibShaderHandler { + shader: shader.clone(), + }) + } else { + None + }; + let raylib_image_handler = RaylibImageHandler { + image: Rc::new(RefCell::new(RaylibImage { + image, + texture: None, + })), + tr_or_cam_shader: Rc::new(RefCell::new(tr_or_cam_shader)), + cam_shader: Rc::new(RefCell::new(cam_shader)), + camera: self.camera.clone(), + }; + self.images + .insert(path_str.to_owned(), raylib_image_handler.image.clone()); + Ok(Box::new(raylib_image_handler)) + } + } + + fn load_font( + &mut self, + path: &std::path::Path, + ) -> Result, String> { + unsafe { + let path_str = path + .to_str() + .ok_or_else(|| format!("Failed to convert \"{path:?}\" to str!"))?; + let path_buf: Vec = path_str.as_bytes().into(); + let cstring: CString = CString::from_vec_unchecked(path_buf); + let font = ffi::LoadFont(cstring.as_ptr()); + let raylib_font_handler = RaylibFontHandler { + font: Rc::new(RaylibFont { font }), + }; + self.fonts + .insert(path_str.to_owned(), raylib_font_handler.font.clone()); + Ok(Box::new(raylib_font_handler)) + } + } + + fn load_sound( + &mut self, + path: &std::path::Path, + ) -> Result, String> { + unsafe { + let path_str = path + .to_str() + .ok_or_else(|| format!("Failed to convert \"{path:?}\" to str!"))?; + let path_buf: Vec = path_str.as_bytes().into(); + let cstring: CString = CString::from_vec_unchecked(path_buf); + let sound = ffi::LoadSound(cstring.as_ptr()); + let raylib_sound_handler = RaylibSoundHandler { + sound: Rc::new(RaylibSound { sound }), + }; + self.sounds + .insert(path_str.to_owned(), raylib_sound_handler.sound.clone()); + Ok(Box::new(raylib_sound_handler)) + } + } + + fn load_music( + &mut self, + path: &std::path::Path, + ) -> Result, String> { + unsafe { + let path_str = path + .to_str() + .ok_or_else(|| format!("Failed to convert \"{path:?}\" to str!"))?; + let path_buf: Vec = path_str.as_bytes().into(); + let cstring: CString = CString::from_vec_unchecked(path_buf); + let music = ffi::LoadMusicStream(cstring.as_ptr()); + let raylib_music_handler = RaylibMusicHandler { + music: Rc::new(RefCell::new(RaylibMusic { music })), + }; + self.music + .insert(path_str.to_owned(), raylib_music_handler.music.clone()); + Ok(Box::new(raylib_music_handler)) + } + } + + fn load_shader( + &mut self, + name: String, + vs: &Path, + fs: &Path, + ) -> Result, String> { + let raylib_shader = RaylibShaderHandler::load_shader(vs, fs)?; + self.shaders.insert(name, raylib_shader.shader.clone()); + Ok(Box::new(raylib_shader)) + } + + fn get_camera(&mut self) -> Result, String> { + Ok(Box::new(self.camera.borrow().clone())) + } + + fn get_default_camera(&mut self) -> Result, String> { + Ok(Box::new(Camera::default())) + } + + fn set_camera(&mut self, camera: &Box) -> Result<(), String> { + self.camera.borrow_mut().pos = camera.as_ref().get_view_xy()?.into(); + Ok(()) + } + + fn set_camera_xy(&mut self, x: f32, y: f32) -> Result<(), String> { + self.camera.borrow_mut().pos = Vector { x, y }; + Ok(()) + } + + fn xy_to_world(&self, x: f32, y: f32) -> Result { + Ok(Vector { + x: x + self.camera.borrow().pos.x, + y: y + self.camera.borrow().pos.y, + }) + } + + fn vec_to_world(&self, vec: Vector) -> Result { + Ok(Vector { + x: vec.x + self.camera.borrow().pos.x, + y: vec.y + self.camera.borrow().pos.y, + }) + } +} + +impl RaylibGame { + fn load_transform_origin_shader(&mut self) -> Result, String> { + self.load_shader( + String::from("transform_origin"), + &PathBuf::from_str("static/transform.vs") + .map_err(|_| String::from("Failed to convert \"static/transform.vs\" to path!"))?, + &PathBuf::from_str("static/simple.fs") + .map_err(|_| String::from("Failed to convert \"static/simple.fs\" to path!"))?, + ) + } + + fn load_camera_shader(&mut self) -> Result, String> { + self.load_shader( + String::from("camera"), + &PathBuf::from_str("static/camera.vs") + .map_err(|_| String::from("Failed to convert \"static/camera.vs\" to path!"))?, + &PathBuf::from_str("static/simple.fs") + .map_err(|_| String::from("Failed to convert \"static/camera.vs\" to path!"))?, + ) + } +} diff --git a/src/bin.rs b/src/bin.rs new file mode 100644 index 0000000..cdbbb6f --- /dev/null +++ b/src/bin.rs @@ -0,0 +1,17 @@ +use ld45_lib::agnostic_interface; + +fn will_close() -> bool { + unsafe { agnostic_interface::raylib_impl::ffi::WindowShouldClose() } +} + +fn main() { + let state_ptr = ld45_lib::ld45_initialize(); + + while !will_close() { + ld45_lib::ld45_iterate(state_ptr); + } + + unsafe { + drop(Box::from_raw(state_ptr as *mut ld45_lib::WasmState)); + } +} diff --git a/src/faux_quicksilver.rs b/src/faux_quicksilver.rs new file mode 100644 index 0000000..b1ba0e7 --- /dev/null +++ b/src/faux_quicksilver.rs @@ -0,0 +1,352 @@ +use std::collections::HashMap; +use std::ops::{Add, AddAssign, Mul, Sub, SubAssign}; +use std::path::Path; + +use serde::{Deserialize, Serialize}; + +use crate::agnostic_interface::{ + FontInterface, GameInterface, ImageInterface, MusicInterface, SoundInterface, +}; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct Color { + pub r: u8, + pub g: u8, + pub b: u8, + pub a: u8, +} + +impl Color { + pub const WHITE: Self = Self { + r: 255, + g: 255, + b: 255, + a: 255, + }; + + pub const BLACK: Self = Self { + r: 0, + g: 0, + b: 0, + a: 255, + }; + + pub const GREEN: Self = Self { + r: 0, + g: 255, + b: 0, + a: 255, + }; + + pub fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Self { + Self { r, g, b, a } + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Rectangle { + pub x: f32, + pub y: f32, + pub w: f32, + pub h: f32, +} + +impl Rectangle { + pub fn new(x: f32, y: f32, w: f32, h: f32) -> Self { + Self { x, y, w, h } + } + + pub fn pos_add_vec(&mut self, v: Vector) { + self.x += v.x; + self.y += v.y; + } +} + +impl Default for Rectangle { + fn default() -> Self { + Self { + x: 0.0, + y: 0.0, + w: 1.0, + h: 1.0, + } + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Circle { + pub x: f32, + pub y: f32, + pub r: f32, +} + +impl Circle { + pub fn new(x: f32, y: f32, r: f32) -> Self { + Self { x, y, r } + } + + pub fn pos_add_vec(&mut self, v: Vector) { + self.x += v.x; + self.y += v.y; + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vector { + pub x: f32, + pub y: f32, +} + +impl Add for Vector { + type Output = Vector; + + fn add(self, rhs: Vector) -> Self::Output { + Vector { + x: self.x + rhs.x, + y: self.y + rhs.y, + } + } +} + +impl Sub for Vector { + type Output = Vector; + + fn sub(self, rhs: Vector) -> Self::Output { + Vector { + x: self.x - rhs.x, + y: self.y - rhs.y, + } + } +} + +impl AddAssign for Vector { + fn add_assign(&mut self, rhs: Vector) { + self.x += rhs.x; + self.y += rhs.y; + } +} + +impl SubAssign for Vector { + fn sub_assign(&mut self, rhs: Vector) { + self.x -= rhs.x; + self.y -= rhs.y; + } +} + +impl Mul for Vector { + type Output = Vector; + + fn mul(self, rhs: f32) -> Self::Output { + Vector { + x: self.x * rhs, + y: self.y * rhs, + } + } +} + +impl Vector { + pub fn new(x: f32, y: f32) -> Self { + Self { x, y } + } +} + +impl From<(f32, f32)> for Vector { + fn from(t: (f32, f32)) -> Self { + Self { x: t.0, y: t.1 } + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Transform { + pub mat: [f32; 9], +} + +impl Default for Transform { + fn default() -> Self { + Self { + mat: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0], + } + } +} + +impl Mul for Transform { + type Output = Vector; + + fn mul(self, rhs: Vector) -> Self::Output { + Vector { + x: rhs.x * self.mat[0] + rhs.y * self.mat[1] + self.mat[2], + y: rhs.x * self.mat[3] + rhs.y * self.mat[4] + self.mat[5], + } + } +} + +impl Mul for Transform { + type Output = Transform; + + fn mul(self, rhs: Transform) -> Self::Output { + Self { + mat: [ + self.mat[0] * rhs.mat[0] + self.mat[1] * rhs.mat[3] + self.mat[2] * rhs.mat[6], + self.mat[0] * rhs.mat[1] + self.mat[1] * rhs.mat[4] + self.mat[2] * rhs.mat[7], + self.mat[0] * rhs.mat[2] + self.mat[1] * rhs.mat[5] + self.mat[2] * rhs.mat[8], + self.mat[3] * rhs.mat[0] + self.mat[4] * rhs.mat[3] + self.mat[5] * rhs.mat[6], + self.mat[3] * rhs.mat[1] + self.mat[4] * rhs.mat[4] + self.mat[5] * rhs.mat[7], + self.mat[3] * rhs.mat[2] + self.mat[4] * rhs.mat[5] + self.mat[5] * rhs.mat[8], + self.mat[6] * rhs.mat[0] + self.mat[7] * rhs.mat[3] + self.mat[8] * rhs.mat[6], + self.mat[6] * rhs.mat[1] + self.mat[7] * rhs.mat[4] + self.mat[8] * rhs.mat[7], + self.mat[6] * rhs.mat[2] + self.mat[7] * rhs.mat[5] + self.mat[8] * rhs.mat[8], + ], + } + } +} + +impl Transform { + pub const IDENTITY: Self = Self { + mat: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0], + }; + + pub fn rotate(rot: f32) -> Self { + Self { + mat: [ + rot.cos(), + -rot.sin(), + 0.0, + rot.sin(), + rot.cos(), + 0.0, + 0.0, + 0.0, + 1.0, + ], + } + } + + pub fn translate(x: f32, y: f32) -> Self { + Self { + mat: [1.0, 0.0, x, 0.0, 1.0, y, 0.0, 0.0, 1.0], + } + } +} + +pub struct Window { + gi: Box, + images: HashMap>, + fonts: HashMap>, + sounds: HashMap>, + music: HashMap>, +} + +impl Window { + pub fn new(gi: Box) -> Self { + Self { + gi, + images: HashMap::new(), + fonts: HashMap::new(), + sounds: HashMap::new(), + music: HashMap::new(), + } + } + + pub fn get_gi(&self) -> &dyn GameInterface { + self.gi.as_ref() + } + + pub fn get_gi_mut(&mut self) -> &mut dyn GameInterface { + self.gi.as_mut() + } + + pub fn load_image(&mut self, path: &Path, name: String) -> Result<(), String> { + self.images.insert(name, self.gi.load_image(path)?); + + Ok(()) + } + + pub fn load_font(&mut self, path: &Path, name: String) -> Result<(), String> { + self.fonts.insert(name, self.gi.load_font(path)?); + + Ok(()) + } + + pub fn load_sound(&mut self, path: &Path, name: String) -> Result<(), String> { + self.sounds.insert(name, self.gi.load_sound(path)?); + + Ok(()) + } + + pub fn load_music(&mut self, path: &Path, name: String) -> Result<(), String> { + self.music.insert(name, self.gi.load_music(path)?); + + Ok(()) + } + + pub fn get_image(&self, name: &str) -> Result<&dyn ImageInterface, String> { + Ok(self + .images + .get(name) + .ok_or_else(|| format!("Image \"{name}\" not found"))? + .as_ref()) + } + + pub fn get_image_mut(&mut self, name: &str) -> Result<&mut dyn ImageInterface, String> { + Ok(self + .images + .get_mut(name) + .ok_or_else(|| format!("Image \"{name}\" not found"))? + .as_mut()) + } + + pub fn get_font(&self, name: &str) -> Result<&dyn FontInterface, String> { + Ok(self + .fonts + .get(name) + .ok_or_else(|| format!("Font \"{name}\" not found"))? + .as_ref()) + } + + pub fn get_font_mut(&mut self, name: &str) -> Result<&mut dyn FontInterface, String> { + Ok(self + .fonts + .get_mut(name) + .ok_or_else(|| format!("Font \"{name}\" not found"))? + .as_mut()) + } + + pub fn get_sound(&self, name: &str) -> Result<&dyn SoundInterface, String> { + Ok(self + .sounds + .get(name) + .ok_or_else(|| format!("Sound \"{name}\" not found"))? + .as_ref()) + } + + pub fn get_sound_mut(&mut self, name: &str) -> Result<&mut dyn SoundInterface, String> { + Ok(self + .sounds + .get_mut(name) + .ok_or_else(|| format!("Sound \"{name}\" not found"))? + .as_mut()) + } + + pub fn get_music(&self, name: &str) -> Result<&dyn MusicInterface, String> { + Ok(self + .music + .get(name) + .ok_or_else(|| format!("Music \"{name}\" not found"))? + .as_ref()) + } + + pub fn get_music_mut(&mut self, name: &str) -> Result<&mut dyn MusicInterface, String> { + Ok(self + .music + .get_mut(name) + .ok_or_else(|| format!("Music \"{name}\" not found"))? + .as_mut()) + } + + pub fn update_music(&mut self) -> Result<(), String> { + for (_, music) in &mut self.music { + music.update()?; + } + Ok(()) + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..7e6484f --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,48 @@ +pub mod agnostic_interface; +mod faux_quicksilver; +mod original_impl; +mod shaders; + +use agnostic_interface::raylib_impl::RaylibGame; +use faux_quicksilver::Window; +use original_impl::GameState; + +pub struct WasmState { + pub window: Window, + pub game_state: GameState, +} + +impl WasmState { + pub fn get_window_mut(&mut self) -> &mut Window { + &mut self.window + } + + pub fn get_state_mut(&mut self) -> &mut GameState { + &mut self.game_state + } +} + +#[no_mangle] +pub extern "C" fn ld45_initialize() -> *mut ::std::os::raw::c_void { + let game_interface = RaylibGame::new_boxed(800, 600); + let mut window = Window::new(game_interface); + let game_state = GameState::new(&mut window).unwrap(); + + Box::into_raw(Box::new(WasmState { window, game_state })) as *mut ::std::os::raw::c_void +} + +#[no_mangle] +pub extern "C" fn ld45_iterate(context: *mut ::std::os::raw::c_void) { + let state_ptr = context as *mut WasmState; + unsafe { + (*state_ptr).get_window_mut().update_music().unwrap(); + (*state_ptr) + .get_state_mut() + .update(&mut (*state_ptr).get_window_mut()) + .unwrap(); + (*state_ptr) + .get_state_mut() + .draw(&mut (*state_ptr).get_window_mut()) + .unwrap(); + } +} diff --git a/src/main.rs b/src/original_impl.rs similarity index 52% rename from src/main.rs rename to src/original_impl.rs index 7be6cad..600aaaf 100644 --- a/src/main.rs +++ b/src/original_impl.rs @@ -1,31 +1,23 @@ -use quicksilver::{ - geom::{Circle, Rectangle, Transform, Vector}, - graphics::{ - Background::{Blended, Col, Img}, - Color, Font, FontStyle, Image, View, - }, - input::{ButtonState, Key}, - lifecycle::{run, Asset, Event, Settings, State, Window}, - saving::{load, save}, - sound::Sound, - Result, -}; +use std::{path::PathBuf, str::FromStr}; + +use crate::agnostic_interface::CameraInterface; +use crate::faux_quicksilver::{Circle, Color, Rectangle, Transform, Vector, Window}; use rand::prelude::*; use serde::{Deserialize, Serialize}; const WIDTH_F: f32 = 800.0; const HEIGHT_F: f32 = 600.0; -const MUSIC2_LENGTH: f64 = 2.0 * 60.0 * 1000.0; -const TEXT_RATE: f64 = 100.0; -const PP_GEN_RATE: f64 = 75.0; -const PARTICLE_RAND_VEL_RANGE: f32 = 0.2; +const MUSIC2_LENGTH: f32 = 2.0 * 60.0 * 1000.0; +const TEXT_RATE: f32 = 0.1; +const PP_GEN_RATE: f32 = 0.075; +const PARTICLE_RAND_VEL_RANGE: f32 = 80.0; const PARTICLE_RAND_VEL_DIST: f32 = 0.2828427; // dist where x and y = 0.2 -const PARTICLE_RAND_ROT_RANGE: f32 = 0.5; -const JOINING_OPACITY_RATE: f32 = 0.00013; +const PARTICLE_RAND_ROT_RANGE: f32 = 5.0; +const JOINING_OPACITY_RATE: f32 = 0.13; const JOINING_FAR_DIST: f32 = 700.0; const JOINING_NEAR_DIST: f32 = 150.0; -const DOUBLE_CLICK_TIME: f64 = 350.0; -const SL_NOTIF_TIME: f64 = 5000.0; +const DOUBLE_CLICK_TIME: f32 = 0.350; +const SL_NOTIF_TIME: f32 = 5000.0; const MAX_MOONS: usize = 5; fn interp_sq_inv(x: f32) -> f32 { @@ -50,28 +42,25 @@ fn interp_sq(x: f32) -> f32 { enum MenuItemType { Button { text: &'static str, - text_image: Option, text_c: Color, h_c: Color, c: Color, }, AppearingText { text: &'static str, - text_image: Option, - current_text: String, + text_idx: usize, text_size: f32, text_c: Color, - timer: f64, + timer: f32, }, InstantText { text: &'static str, - text_image: Option, text_size: f32, text_color: Color, }, Pause { - timer: f64, - length: f64, + timer: f32, + length: f32, }, } @@ -115,7 +104,6 @@ impl Menu { h, item_type: MenuItemType::Button { text: s, - text_image: None, text_c: t_color, h_c: boxh_color, c: box_color, @@ -134,10 +122,9 @@ impl Menu { h: 150.0, item_type: MenuItemType::Button { text: "Start the Game", - text_image: None, text_c: Color::WHITE, - h_c: Color::from_rgba(0x66, 0xFF, 0xFF, 1.0), - c: Color::from_rgba(0x33, 0xDD, 0xDD, 1.0), + h_c: Color::from_rgba(0x66, 0xFF, 0xFF, 255), + c: Color::from_rgba(0x33, 0xDD, 0xDD, 255), }, is_hover: false, is_focus: false, @@ -150,28 +137,21 @@ impl Menu { Menu::instant_text( 70.0, 50.0, - 55.0, + 45.0, true, "One And All - A Ludum Dare 45 Entry", ), Menu::instant_text( 25.0, HEIGHT_F - 100.0, - 30.0, + 27.0, true, - "Made with quicksilver which is licensed with either", - ), - Menu::instant_text( - 70.0, - HEIGHT_F - 80.0, - 30.0, - true, - "MIT License or Apache License Version 2.0", + "Made with Raylib which is licensed with the zlib license", ), Menu::instant_text( 25.0, HEIGHT_F - 50.0, - 30.0, + 27.0, true, "Uses Clear-Sans which is licensed with Apache License Version 2.0", ), @@ -187,7 +167,6 @@ impl Menu { h: 0.0, item_type: MenuItemType::InstantText { text: s, - text_image: None, text_size, text_color: Color::WHITE, }, @@ -205,11 +184,10 @@ impl Menu { h: 0.0, item_type: MenuItemType::AppearingText { text: s, - text_image: None, text_size, - current_text: String::new(), text_c: Color::WHITE, timer: 0.0, + text_idx: 0, }, is_hover: false, is_focus: false, @@ -217,7 +195,7 @@ impl Menu { } } - fn pause(length: f64, first: bool) -> MenuItem { + fn pause(length: f32, first: bool) -> MenuItem { MenuItem { x: 0.0, y: 0.0, @@ -233,9 +211,9 @@ impl Menu { fn s_01() -> Menu { Menu { items: vec![ - Menu::pause(500.0, true), + Menu::pause(0.500, true), Menu::text(50.0, HEIGHT_F - 140.0, 40.0, false, "This is how it is."), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 50.0, HEIGHT_F - 100.0, @@ -243,9 +221,9 @@ impl Menu { false, "Nothing is, and everything is nothing.", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text(50.0, HEIGHT_F - 60.0, 40.0, false, "...until you appeared."), - Menu::pause(100.0, false), + Menu::pause(0.100, false), Menu::text( 570.0, HEIGHT_F - 50.0, @@ -267,7 +245,7 @@ impl Menu { true, "Just by being, you brought light into existence.", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 50.0, HEIGHT_F - 110.0, @@ -275,7 +253,7 @@ impl Menu { false, "What brings you here? What drives you?", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 50.0, HEIGHT_F - 70.0, @@ -291,7 +269,7 @@ impl Menu { "Hope", Color::WHITE, Color::BLACK, - Color::from_rgba(0x33, 0x33, 0x33, 1.0), + Color::from_rgba(0x33, 0x33, 0x33, 255), false, ), Menu::button( @@ -302,7 +280,7 @@ impl Menu { "Miracles", Color::WHITE, Color::BLACK, - Color::from_rgba(0x33, 0x33, 0x33, 1.0), + Color::from_rgba(0x33, 0x33, 0x33, 255), false, ), Menu::button( @@ -313,7 +291,7 @@ impl Menu { "Kindness", Color::WHITE, Color::BLACK, - Color::from_rgba(0x33, 0x33, 0x33, 1.0), + Color::from_rgba(0x33, 0x33, 0x33, 255), false, ), Menu::button( @@ -324,7 +302,7 @@ impl Menu { "Determination", Color::WHITE, Color::BLACK, - Color::from_rgba(0x33, 0x33, 0x33, 1.0), + Color::from_rgba(0x33, 0x33, 0x33, 255), false, ), ], @@ -342,7 +320,7 @@ impl Menu { true, "Hope... hope that your actions will inspire others..", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 50.0, HEIGHT_F - 130.0, @@ -350,7 +328,7 @@ impl Menu { false, "Hope that a brighter future will come tomorrow...", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 50.0, HEIGHT_F - 90.0, @@ -373,7 +351,7 @@ impl Menu { true, "Miracles huh?.. I see, then your appearance is special.", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 30.0, HEIGHT_F - 130.0, @@ -381,7 +359,7 @@ impl Menu { false, "With your appearance, things may change for the better..", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 30.0, HEIGHT_F - 90.0, @@ -404,7 +382,7 @@ impl Menu { true, "Kindness?.. I am in your debt.", ), - Menu::pause(250.0, false), + Menu::pause(0.250, false), Menu::text( 50.0, HEIGHT_F - 130.0, @@ -413,7 +391,7 @@ impl Menu { "It has been a long time since I have encountered", ), Menu::text(50.0, HEIGHT_F - 90.0, 40.0, false, "another being..."), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text(270.0, HEIGHT_F - 90.0, 40.0, false, "... Thank you..."), ], } @@ -430,7 +408,7 @@ impl Menu { true, "Determination.. I see...", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 400.0, HEIGHT_F - 170.0, @@ -445,7 +423,7 @@ impl Menu { false, "must have been difficult to come here..", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 50.0, HEIGHT_F - 90.0, @@ -474,7 +452,7 @@ impl Menu { false, "creation for all that will be.", ), - Menu::pause(200.0, false), + Menu::pause(0.200, false), Menu::text( 50.0, HEIGHT_F - 50.0, @@ -501,7 +479,7 @@ impl Menu { fn s_09() -> Menu { Menu { items: vec![ - Menu::pause(400.0, true), + Menu::pause(0.400, true), Menu::text( 50.0, HEIGHT_F - 140.0, @@ -509,7 +487,7 @@ impl Menu { false, "A new planet... It has most certainly been a while.", ), - Menu::pause(500.0, false), + Menu::pause(0.500, false), Menu::text( 50.0, HEIGHT_F - 100.0, @@ -517,7 +495,7 @@ impl Menu { false, "Please, go out and create the new universe, and again..", ), - Menu::pause(300.0, false), + Menu::pause(0.300, false), Menu::text(50.0, HEIGHT_F - 60.0, 40.0, false, "Thank you."), ], } @@ -533,13 +511,13 @@ impl Menu { true, "Single click to move, Double-click to create something", ), - Menu::instant_text( - 20.0, - HEIGHT_F - 20.0, - 20.0, - true, - "S - save; L - load (can load from the start); R - reset", - ), + //Menu::instant_text( + // 20.0, + // HEIGHT_F - 20.0, + // 20.0, + // true, + // "S - save; L - load (can load from the start); R - reset", + //), ], } } @@ -554,16 +532,16 @@ struct Particle { vely: f32, velr: f32, r: f32, - lifetime: f64, - life_timer: f64, + lifetime: f32, + life_timer: f32, } #[derive(Serialize, Deserialize, Clone)] struct ParticleSystem { particles: Vec, - spawn_timer: f64, - spawn_time: f64, - lifetime: f64, + spawn_timer: f32, + spawn_time: f32, + lifetime: f32, host_rect: Rectangle, host_circle: Circle, is_rect: bool, @@ -575,8 +553,8 @@ struct ParticleSystem { impl ParticleSystem { fn new( - spawn_time: f64, - lifetime: f64, + spawn_time: f32, + lifetime: f32, host_rect: Rectangle, host_circle: Circle, is_rect: bool, @@ -600,19 +578,19 @@ impl ParticleSystem { } } - fn update(&mut self, dt: f64) { + fn update(&mut self, dt: f32) { for i in (0..self.particles.len()).rev() { self.particles[i].life_timer += dt; if self.particles[i].life_timer > self.particles[i].lifetime { self.particles.swap_remove(i); } else { if self.is_rect { - self.particles[i].rect.pos.x += self.particles[i].velx * dt as f32; - self.particles[i].rect.pos.y += self.particles[i].vely * dt as f32; + self.particles[i].rect.x += self.particles[i].velx * dt as f32; + self.particles[i].rect.y += self.particles[i].vely * dt as f32; self.particles[i].r += self.particles[i].velr * dt as f32; } else { - self.particles[i].circle.pos.x += self.particles[i].velx * dt as f32; - self.particles[i].circle.pos.y += self.particles[i].vely * dt as f32; + self.particles[i].circle.x += self.particles[i].velx * dt as f32; + self.particles[i].circle.y += self.particles[i].vely * dt as f32; } } } @@ -649,20 +627,38 @@ impl ParticleSystem { return; } for particle in &mut self.particles { - self.color.a = (1.0 - (particle.life_timer / particle.lifetime) as f32) * self.opacity; + self.color.a = ((1.0 - (particle.life_timer / particle.lifetime) as f32) + * self.opacity + * 255.0) as u8; if particle.is_rect { - let pre_transform = Transform::translate(( - -particle.rect.size.x / 2.0, - -particle.rect.size.y / 2.0, - )) * Transform::rotate(particle.r); - window.draw_ex( - &particle.rect, - Col(self.color), - transform * pre_transform, - 1, - ); + let pre_transform = + Transform::translate(particle.rect.w / 2.0, particle.rect.h / 2.0) + * Transform::rotate(particle.r); + window + .get_gi_mut() + .draw_rect_transform( + particle.rect, + self.color, + transform * pre_transform, + Vector { + x: particle.rect.x + particle.rect.w / 2.0, + y: particle.rect.y + particle.rect.h / 2.0, + }, + ) + .ok(); } else { - window.draw_ex(&particle.circle, Col(self.color), transform, 1); + window + .get_gi_mut() + .draw_circle_transform( + particle.circle, + self.color, + transform, + Vector { + x: particle.circle.x, + y: particle.circle.y, + }, + ) + .ok(); } } } @@ -704,8 +700,8 @@ struct RotatingParticleSystem { impl RotatingParticleSystem { fn new( - spawn_time: f64, - lifetime: f64, + spawn_time: f32, + lifetime: f32, host_rect: Rectangle, host_circle: Circle, is_rect: bool, @@ -735,21 +731,23 @@ impl RotatingParticleSystem { } } - fn update(&mut self, dt: f64) { + fn update(&mut self, dt: f32) { if self.particle_system.is_rect { let saved_rect = self.particle_system.host_rect; - self.particle_system.host_rect.pos += - Transform::rotate(self.r) * Vector::new(self.offset, 0.0); + self.particle_system + .host_rect + .pos_add_vec(Transform::rotate(self.r) * Vector::new(self.offset, 0.0)); self.particle_system.update(dt); self.particle_system.host_rect = saved_rect; } else { let saved_cir = self.particle_system.host_circle; - self.particle_system.host_circle.pos += - Transform::rotate(self.r) * Vector::new(self.offset, 0.0); + self.particle_system + .host_circle + .pos_add_vec(Transform::rotate(self.r) * Vector::new(self.offset, 0.0)); self.particle_system.update(dt); self.particle_system.host_circle = saved_cir; } - self.r += self.velr * dt as f32; + self.r += self.velr * dt as f32 * 10.0; } fn draw(&mut self, window: &mut Window, transform: Transform) { @@ -761,23 +759,38 @@ impl RotatingParticleSystem { self.particle_system.draw(window, transform); if self.particle_system.is_rect { let mut moved_rect = self.particle_system.host_rect; - moved_rect.pos += Transform::rotate(self.r) * Vector::new(self.offset, 0.0); + moved_rect.pos_add_vec(Transform::rotate(self.r) * Vector::new(self.offset, 0.0)); let mut solid_color = self.particle_system.color; - solid_color.a = self.particle_system.opacity; - window.draw_ex( - &moved_rect, - Col(solid_color), - transform - * Transform::translate((-moved_rect.size.x / 2.0, -moved_rect.size.y / 2.0)) - * Transform::rotate(self.r * 1.3), - 1, - ); + solid_color.a = (self.particle_system.opacity * 255.0) as u8; + window + .get_gi_mut() + .draw_rect_transform( + moved_rect, + solid_color, + transform * Transform::rotate(self.r * 1.3), + Vector { + x: moved_rect.x, + y: moved_rect.y, + }, + ) + .ok(); } else { let mut moved_cir = self.particle_system.host_circle; - moved_cir.pos += Transform::rotate(self.r) * Vector::new(self.offset, 0.0); + moved_cir.pos_add_vec(Transform::rotate(self.r) * Vector::new(self.offset, 0.0)); let mut solid_color = self.particle_system.color; - solid_color.a = self.particle_system.opacity; - window.draw_ex(&moved_cir, Col(solid_color), transform, 1); + solid_color.a = (self.particle_system.opacity * 255.0) as u8; + window + .get_gi_mut() + .draw_circle_transform( + moved_cir, + solid_color, + transform, + Vector { + x: moved_cir.x, + y: moved_cir.y, + }, + ) + .ok(); } } } @@ -790,15 +803,15 @@ struct ExplConvCircleParticle { struct ExplConvParticleSystem { particles: Vec, - lifetime: f64, + lifetime: f32, host_circle: Circle, color: Color, opacity: f32, - life_timer: f64, + life_timer: f32, } impl ExplConvParticleSystem { - fn new(lifetime: f64, host_circle: Circle, color: Color, opacity: f32) -> Self { + fn new(lifetime: f32, host_circle: Circle, color: Color, opacity: f32) -> Self { ExplConvParticleSystem { particles: Vec::new(), lifetime, @@ -821,7 +834,7 @@ impl ExplConvParticleSystem { } // returns true if finished - fn update(&mut self, dt: f64, planets: &mut Vec) -> bool { + fn update(&mut self, dt: f32, planets: &mut Vec) -> bool { self.life_timer += dt; if self.life_timer >= self.lifetime { if !self.particles.is_empty() { @@ -837,14 +850,16 @@ impl ExplConvParticleSystem { for particle in &mut self.particles { let dir = Transform::rotate(particle.r) * Vector::new(particle.offset * amount, 0.0); - particle.circle.pos = dir + self.host_circle.pos; + particle.circle.x = dir.x + self.host_circle.x; + particle.circle.y = dir.y + self.host_circle.y; } } else { let amount = 1.0 - interp_sq(((self.life_timer / self.lifetime) as f32 - 0.5) * 2.0); for particle in &mut self.particles { let dir = Transform::rotate(particle.r) * Vector::new(particle.offset * amount, 0.0); - particle.circle.pos = dir + self.host_circle.pos; + particle.circle.x = dir.x + self.host_circle.x; + particle.circle.y = dir.y + self.host_circle.y; } } return false; @@ -855,8 +870,21 @@ impl ExplConvParticleSystem { return; } for particle in &mut self.particles { - self.color.a = ((self.life_timer / self.lifetime) as f32 / 2.0 + 0.5) * self.opacity; - window.draw_ex(&particle.circle, Col(self.color), transform, 1); + self.color.a = (((self.life_timer / self.lifetime) as f32 / 2.0 + 0.5) + * self.opacity + * 255.0) as u8; + window + .get_gi_mut() + .draw_circle_transform( + particle.circle, + self.color, + transform, + Vector { + x: particle.circle.x, + y: particle.circle.y, + }, + ) + .ok(); } } } @@ -872,14 +900,14 @@ struct Planet { impl Planet { fn new(circle: Circle, color: Color) -> Self { let mut smaller_circle = circle; - smaller_circle.radius /= 4.0; + smaller_circle.r /= 4.0; let mut planet = Planet { circle, color, particle_system: ParticleSystem::new( - rand::thread_rng().gen_range(2000.0, 3800.0), - 900.0, - Rectangle::new((0.0, 0.0), (1.0, 1.0)), + rand::thread_rng().gen_range(2.0, 3.8), + 0.9, + Rectangle::new(0.0, 0.0, 1.0, 1.0), circle, false, Vector::new(0.0, 0.0), @@ -894,9 +922,9 @@ impl Planet { let clockwise = rand::thread_rng().gen_bool(0.5); for i in 0..rand::thread_rng().gen_range(0, MAX_MOONS) { planet.moons.push(RotatingParticleSystem::new( - rand::thread_rng().gen_range(1000.0, 2600.0), - 600.0, - Rectangle::new((0.0, 0.0), (1.0, 1.0)), + rand::thread_rng().gen_range(1.0, 2.6), + 0.6, + Rectangle::new(0.0, 0.0, 1.0, 1.0), smaller_circle, false, Vector::new(0.0, 0.0), @@ -916,18 +944,31 @@ impl Planet { planet } - fn update(&mut self, dt: f64) { - self.particle_system.host_circle.pos = self.circle.pos; + fn update(&mut self, dt: f32) { + self.particle_system.host_circle.x = self.circle.x; + self.particle_system.host_circle.y = self.circle.y; self.particle_system.update(dt); for moon in &mut self.moons { - moon.particle_system.host_circle.pos = self.circle.pos; + moon.particle_system.host_circle.x = self.circle.x; + moon.particle_system.host_circle.y = self.circle.y; moon.update(dt); } } fn draw(&mut self, window: &mut Window, transform: Transform) { self.particle_system.draw(window, transform); - window.draw_ex(&self.circle, Col(self.color), transform, 1); + window + .get_gi_mut() + .draw_circle_transform( + self.circle, + self.color, + transform, + Vector { + x: self.circle.x, + y: self.circle.y, + }, + ) + .ok(); for moon in &mut self.moons { moon.draw(window, transform); } @@ -947,9 +988,9 @@ impl Star { let mut star = Star { color, particle_system: ParticleSystem::new( - rand::thread_rng().gen_range(80.0, 200.0), - 850.0, - Rectangle::new((0.0, 0.0), (1.0, 1.0)), + rand::thread_rng().gen_range(0.08, 0.2), + 0.85, + Rectangle::new(0.0, 0.0, 1.0, 1.0), circle, false, Vector::new(0.0, 0.0), @@ -961,14 +1002,14 @@ impl Star { r, }; - if star.color.r < 0.75 { - star.color.r = 0.75; + if star.color.r < (0.75 * 255.0) as u8 { + star.color.r = (0.75 * 255.0) as u8; } - if star.color.g < 0.75 { - star.color.g = 0.75; + if star.color.g < (0.75 * 255.0) as u8 { + star.color.g = (0.75 * 255.0) as u8; } - if star.color.b < 0.75 { - star.color.b = 0.75; + if star.color.b < (0.75 * 255.0) as u8 { + star.color.b = (0.75 * 255.0) as u8; } star.particle_system .force_spawn(rand::thread_rng().gen_range(20, 45)); @@ -976,21 +1017,29 @@ impl Star { star } - fn update(&mut self, dt: f64) { + fn update(&mut self, dt: f32) { self.particle_system.update(dt); self.r += self.velr * dt as f32; } - fn draw(&mut self, image: &mut Image, window: &mut Window, transform: Transform) { + fn draw(&mut self, image: &str, window: &mut Window, transform: Transform) { self.particle_system.draw(window, transform); - let mut image_rect = image.area(); - image_rect.pos = self.particle_system.host_circle.pos - image_rect.size / 2.0; - window.draw_ex( - &image_rect, - Blended(image, self.color), - transform * Transform::rotate(self.r), - 1, - ); + let image = window.get_image_mut(image).expect("Should be loaded image"); + let mut image_rect = image.get_wh_rect(); + image_rect.x = self.particle_system.host_circle.x - image_rect.w / 2.0; + image_rect.y = self.particle_system.host_circle.y - image_rect.h / 2.0; + image + .draw_transform( + image_rect.x, + image_rect.y, + self.color, + transform * Transform::rotate(self.r), + Vector { + x: image_rect.x + image_rect.w / 2.0, + y: image_rect.y + image_rect.h / 2.0, + }, + ) + .ok(); } } @@ -998,12 +1047,14 @@ impl Star { struct Fish { pos: Vector, r: f32, - swim_time: f64, - swim_timer: f64, + swim_time: f32, + swim_timer: f32, swim_v: f32, - anim_timer: f64, - anim_time: f64, + anim_timer: f32, + anim_time: f32, color: Color, + body_rect: Rectangle, + tail_rect: Rectangle, } enum FishState { @@ -1013,42 +1064,54 @@ enum FishState { impl Fish { fn new(pos: Vector, r: f32, color: Color) -> Self { - let anim_timer = rand::thread_rng().gen_range(800.0, 1000.0); + let anim_timer = rand::thread_rng().gen_range(0.8, 1.0); Self { pos, r, - swim_time: 800.0, - swim_timer: 800.0, + swim_time: 0.8, + swim_timer: 0.8, swim_v: 0.2, anim_timer, anim_time: anim_timer, color, + body_rect: Rectangle { + x: 0.0, + y: 0.0, + w: 32.0, + h: 16.0, + }, + tail_rect: Rectangle { + x: 32.0, + y: 0.0, + w: 16.0, + h: 16.0, + }, } } fn set_next(&mut self, state: FishState) { match state { FishState::Idle => { - self.swim_time = rand::thread_rng().gen_range(1100.0, 2400.0); + self.swim_time = rand::thread_rng().gen_range(1.1, 2.4); self.swim_timer = self.swim_time; - self.anim_timer = 1600.0; - self.anim_time = 1600.0; + self.anim_timer = 2.8; + self.anim_time = 1.6; self.swim_v = 0.0; } FishState::Swim => { - self.swim_time = rand::thread_rng().gen_range(1400.0, 2300.0); + self.swim_time = rand::thread_rng().gen_range(1.4, 2.3); self.swim_timer = self.swim_time; - self.r = rand::thread_rng().gen_range(0.0, 360.0); - self.anim_timer = rand::thread_rng().gen_range(600.0, 1000.0); + self.r = rand::thread_rng().gen_range(0.0, std::f32::consts::PI * 2.0); + self.anim_timer = rand::thread_rng().gen_range(1.6, 2.0); self.anim_time = self.anim_timer; - self.swim_v = (self.anim_timer / 8000.0) as f32; + self.swim_v = (self.anim_timer / 8.0) as f32; } } } - fn update(&mut self, dt: f64) { + fn update(&mut self, dt: f32) { self.swim_time -= dt; - if self.swim_time < 220.0 { + if self.swim_time < 0.22 { self.swim_v /= 1.1; } if self.swim_time <= 0.0 { @@ -1064,43 +1127,52 @@ impl Fish { self.anim_timer = self.anim_time; } - self.pos += Transform::rotate(self.r) * Vector::new(self.swim_v, 0.0) * dt as f32; + self.pos -= Transform::rotate(self.r) * Vector::new(self.swim_v, 0.0) * dt as f32 * 200.0; } - fn draw( - &mut self, - fish_body: &Image, - fish_tail: &Image, - window: &mut Window, - transform: Transform, - ) { - let anim_angle = ((self.anim_timer / self.anim_time) * std::f64::consts::PI * 2.0).sin(); - let mut body_rect = fish_body.area(); - body_rect.pos = self.pos - body_rect.size / 2.0; - let body_tr = - Transform::rotate(anim_angle as f32 * 30.0) * Transform::rotate(self.r + 180.0); - window.draw_ex( - &body_rect, - Blended(fish_body, self.color), - transform * body_tr, - 1, - ); - let mut tail_rect = fish_tail.area(); - tail_rect.pos = self.pos - tail_rect.size / 2.0; - let anim_angle = ((self.anim_timer / self.anim_time) * std::f64::consts::PI * 2.0 - - std::f64::consts::PI / 3.0) + fn draw(&mut self, i_fish: &str, window: &mut Window, transform: Transform) { + let fish_img = window + .get_image_mut(i_fish) + .expect("\"fish\" Image should be loaded"); + let anim_angle = ((self.anim_timer / self.anim_time) * std::f32::consts::PI * 2.0).sin(); + let mut body_rect = self.body_rect; + body_rect.x = self.pos.x - self.body_rect.w / 2.0; + body_rect.y = self.pos.y - self.body_rect.h / 2.0; + let body_tr = Transform::rotate(anim_angle as f32 + self.r); + fish_img + .draw_sub_transform( + self.body_rect, + body_rect, + self.color, + transform * body_tr, + Vector { + x: self.pos.x, + y: self.pos.y, + }, + ) + .ok(); + let mut tail_rect = self.tail_rect; + tail_rect.x = self.pos.x + body_rect.w / 2.0; + tail_rect.y = self.pos.y - body_rect.h / 2.0; + let anim_angle = ((self.anim_timer / self.anim_time) * std::f32::consts::PI * 2.0 + - std::f32::consts::PI / 3.0) .sin(); let tail_tr = body_tr - * Transform::translate((body_rect.size.x / 1.5, 0.0)) - * Transform::translate((-tail_rect.size.x / 2.0, 0.0)) - * Transform::rotate(-anim_angle as f32 * 45.0) - * Transform::translate((tail_rect.size.x / 2.0, 0.0)); - window.draw_ex( - &tail_rect, - Blended(fish_tail, self.color), - transform * tail_tr, - 1, - ); + * Transform::translate(-body_rect.w / 2.0, 0.0) + * Transform::rotate(-anim_angle as f32) + * Transform::translate(body_rect.w / 2.0, 0.0); + fish_img + .draw_sub_transform( + self.tail_rect, + tail_rect, + self.color, + transform * tail_tr, + Vector { + x: self.pos.x, + y: self.pos.y, + }, + ) + .ok(); } } @@ -1114,26 +1186,22 @@ struct SaveData { } enum SaveLoadNotification { - Save { text: Option, timer: f64 }, - Load { text: Option, timer: f64 }, + Save { text: Option, timer: f32 }, + Load { text: Option, timer: f32 }, } -struct GameState { - s_boom: Asset, - s_get: Asset, - s_power_up: Asset, - s_tap: Asset, - s_speak_m: Asset, - s_speak_f: Asset, - font: Asset, - music2: Asset, - i_star: Option>, - i_star_actual: Option, - i_fish: Asset, - i_fish_body: Option, - i_fish_tail: Option, +pub struct GameState { + s_boom: String, + s_get: String, + s_power_up: String, + s_tap: String, + s_speak_m: String, + s_speak_f: String, + font: String, + music2: String, + i_star: String, + i_fish: String, music_on: bool, - music_timer: f64, menu: Menu, state: u32, state_dirty: bool, @@ -1141,55 +1209,118 @@ struct GameState { current_item: Option, current_finished: bool, player: Rectangle, - player_r: f64, + player_r: f32, player_particles: ParticleSystem, joining_particles: RotatingParticleSystem, is_create_mode: bool, - click_release_time: f64, - dbl_click_timeout: Option, - click_time: Option, + click_release_time: f32, + dbl_click_timeout: Option, + click_time: Option, click_pos: Vector, mouse_pos: Vector, expl_conv_p_systems: Vec, planets: Vec, stars: Vec, fishes: Vec, - camera: Rectangle, + camera: Box, move_to: Vector, save_load_notification: Option, } -impl State for GameState { - fn new() -> Result { +impl GameState { + pub fn new(window: &mut Window) -> Result { + let s_boom = String::from("boom.mp3"); + window.load_sound( + &PathBuf::from_str("static/boom.mp3") + .map_err(|_| String::from("Failed to load \"static/boom.mp3\""))?, + s_boom.clone(), + )?; + let s_get = String::from("get.mp3"); + window.load_sound( + &PathBuf::from_str("static/get.mp3") + .map_err(|_| String::from("Failed to load \"static/get.mp3\""))?, + s_get.clone(), + )?; + let s_power_up = String::from("power_up.mp3"); + window.load_sound( + &PathBuf::from_str("static/power_up.mp3") + .map_err(|_| String::from("Failed to load \"static/power_up.mp3\""))?, + s_power_up.clone(), + )?; + let s_tap = String::from("tap.mp3"); + window.load_sound( + &PathBuf::from_str("static/tap.mp3") + .map_err(|_| String::from("Failed to load \"static/tap.mp3\""))?, + s_tap.clone(), + )?; + let s_speak_m = String::from("speak_m.mp3"); + window.load_sound( + &PathBuf::from_str("static/speak_m.mp3") + .map_err(|_| String::from("Failed to load \"static/speak_m.mp3\""))?, + s_speak_m.clone(), + )?; + let s_speak_f = String::from("speak_f.mp3"); + window.load_sound( + &PathBuf::from_str("static/speak_f.mp3") + .map_err(|_| String::from("Failed to load \"static/speak_f.mp3\""))?, + s_speak_f.clone(), + )?; + + let font = String::from("ClearSans-Regular.ttf"); + window.load_font( + &PathBuf::from_str("static/ClearSans-Regular.ttf") + .map_err(|_| String::from("Failed to load \"static/ClearSans-Regular.ttf\""))?, + font.clone(), + )?; + + let music2 = String::from("music2.mp3"); + window.load_music( + &PathBuf::from_str("static/music2.mp3") + .map_err(|_| String::from("Failed to load \"static/music2.mp3\""))?, + music2.clone(), + )?; + + let i_star = String::from("star.png"); + window.load_image( + &PathBuf::from_str("static/star.png") + .map_err(|_| String::from("Failed to load \"static/star.png\""))?, + i_star.clone(), + )?; + + let i_fish = String::from("fish.png"); + window.load_image( + &PathBuf::from_str("static/fish.png") + .map_err(|_| String::from("Failed to load \"static/fish.png\""))?, + i_fish.clone(), + )?; + + let mut camera = window.get_gi_mut().get_default_camera()?; + camera.set_view_xy(0.0, 0.0)?; Ok(Self { - s_boom: Asset::new(Sound::load("boom.mp3")), - s_get: Asset::new(Sound::load("get.mp3")), - s_power_up: Asset::new(Sound::load("power_up.mp3")), - s_tap: Asset::new(Sound::load("tap.mp3")), - s_speak_m: Asset::new(Sound::load("speak_m.mp3")), - s_speak_f: Asset::new(Sound::load("speak_f.mp3")), - font: Asset::new(Font::load("ClearSans-Regular.ttf")), - music2: Asset::new(Sound::load("music2.mp3")), - i_star: Some(Asset::new(Image::load("star.png"))), - i_star_actual: None, - i_fish: Asset::new(Image::load("fish.png")), - i_fish_body: None, - i_fish_tail: None, + s_boom, + s_get, + s_power_up, + s_tap, + s_speak_m, + s_speak_f, + font, + music2, + i_star, + i_fish, music_on: false, - music_timer: 0.0, menu: Menu::start(), state: 0, state_dirty: false, selection_mode: true, current_item: None, current_finished: true, - player: Rectangle::new((400.0, 300.0), (32.0, 32.0)), + player: Rectangle::new(400.0, 300.0, 32.0, 32.0), player_r: 0.0, player_particles: ParticleSystem::new( PP_GEN_RATE, - 1000.0, - Rectangle::new((400.0, 300.0), (32.0, 32.0)), - Circle::new((100.0, 100.0), 32.0), + 1.0, + Rectangle::new(400.0, 300.0, 32.0, 32.0), + Circle::new(100.0, 100.0, 32.0), true, Vector::new(0.0, 0.0), Color::WHITE, @@ -1198,9 +1329,9 @@ impl State for GameState { ), joining_particles: RotatingParticleSystem::new( PP_GEN_RATE, - 1000.0, - Rectangle::new((400.0, 300.0), (16.0, 16.0)), - Circle::new((100.0, 100.0), 32.0), + 1.0, + Rectangle::new(400.0, 300.0, 16.0, 16.0), + Circle::new(100.0, 100.0, 32.0), true, Vector::new(0.0, 0.0), Color::GREEN, @@ -1220,289 +1351,259 @@ impl State for GameState { planets: Vec::new(), stars: Vec::new(), fishes: Vec::new(), - camera: Rectangle::new((0.0, 0.0), (WIDTH_F, HEIGHT_F)), + camera, move_to: Vector::new(400.0, 300.0), save_load_notification: None, }) } - fn event(&mut self, event: &Event, window: &mut Window) -> Result<()> { - match event { - Event::MouseMoved(v) => { - self.mouse_pos = *v; - let mut hovered = false; - for i in 0..self.menu.items.len() { - if self.menu.items[i].is_inside(v.x, v.y) { - self.menu.items[i].is_hover = true; - self.current_item = Some(i); - hovered = true; - } else { - self.menu.items[i].is_hover = false; - } - } - if !hovered { - self.current_item = None; - } - } - Event::MouseButton(button, state) => { - if let ButtonState::Released = state { - if self.dbl_click_timeout.is_none() { - self.click_release_time = 0.0; - } - } else if let ButtonState::Pressed = state { - if self.current_finished { - if self.is_create_mode { - if self.click_release_time < DOUBLE_CLICK_TIME { - self.click_release_time = DOUBLE_CLICK_TIME; - self.dbl_click_timeout = Some(0.0); - self.click_time = None; - if self.state == 8 { - let mut expl_conv_system = ExplConvParticleSystem::new( - 1500.0, - Circle::new(self.mouse_pos, 20.0), - Color::from_rgba(0x99, 0xFF, 0x99, 1.0), - 1.0, - ); - expl_conv_system.activate(30, 200.0); - self.expl_conv_p_systems.push(expl_conv_system); - self.state = 9; - self.state_dirty = true; - self.s_boom.execute(|s| { - s.set_volume(0.8); - s.play() - })?; - } else if self.state == 10 { - let mut rng = rand::thread_rng(); - let rand_out = rng.gen_range(0.0, 1.0); - if rand_out < 0.6 { - // spawn planet - let mut expl_conv_system = ExplConvParticleSystem::new( - rng.gen_range(1200.0, 1600.0), - Circle::new(self.mouse_pos, rng.gen_range(15.0, 25.0)), - Color::from_rgba( - rng.gen_range(0x44, 0xFF), - rng.gen_range(0x44, 0xFF), - rng.gen_range(0x44, 0xFF), - 1.0, - ), - 1.0, - ); - expl_conv_system.activate( - rng.gen_range(13, 40), - rng.gen_range(150.0, 300.0), - ); - self.expl_conv_p_systems.push(expl_conv_system); - } else if rand_out < 0.85 { - // spawn star - let rot_clockwise = rng.gen_bool(0.5); - self.stars.push(Star::new( - Circle::new(self.mouse_pos, rng.gen_range(3.0, 7.0)), - Color::from_rgba( - rng.gen_range(0x58, 0xFF), - rng.gen_range(0x58, 0xFF), - rng.gen_range(0x58, 0xFF), - 1.0, - ), - if rot_clockwise { - rng.gen_range(0.1, 0.3) - } else { - rng.gen_range(-0.3, -0.1) - }, - rng.gen_range(0.0, 90.0), - )); - } else { - // spawn fish - for i in 0..rng.gen_range(1, 4) { - self.fishes.push(Fish::new( - self.mouse_pos, - rng.gen_range(0.0, 360.0), - Color::from_rgba( - rng.gen_range(0x44, 0xFF), - rng.gen_range(0x44, 0xFF), - rng.gen_range(0x44, 0xFF), - 1.0, - ), - )); - } - } - self.s_boom.execute(|s| { - s.set_volume(0.8); - s.play() - })?; - } - } else if self.state == 10 { - self.click_time = Some(0.0); - self.click_pos = self.mouse_pos; - } - } else if self.selection_mode { - if let Some(idx) = self.current_item { - match self.state { - 0 => { - self.state += 1; - self.state_dirty = true; - } - 2 => { - if idx == 5 { - // hope - self.state = 3; - self.state_dirty = true; - self.joining_particles.particle_system.color = - Color::from_rgba(0xAA, 0xCC, 0xFF, 1.0); - } else if idx == 6 { - // miracles - self.state = 4; - self.state_dirty = true; - self.joining_particles.particle_system.color = - Color::from_rgba(0xFF, 0xFF, 0xAA, 1.0); - } else if idx == 7 { - // kindness - self.state = 5; - self.state_dirty = true; - self.joining_particles.particle_system.color = - Color::from_rgba(0xBB, 0xFF, 0xBB, 1.0); - } else { - // determination - self.state = 6; - self.state_dirty = true; - self.joining_particles.particle_system.color = - Color::from_rgba(0xFF, 0xAA, 0xAA, 1.0); - } - self.s_get.execute(|s| { - s.set_volume(0.7); - s.play() - })?; - } - _ => { - self.state = 0; - self.state_dirty = true; - } - } - } - } else { - match self.state { - 0 | 1 => self.state += 1, - 3 | 4 | 5 | 6 => self.state = 7, - 7 => self.state = 8, - 9 => self.state = 10, - _ => self.state = 0, - } - self.state_dirty = true; - } - } else { - for mi in &mut self.menu.items { - match &mut mi.item_type { - MenuItemType::AppearingText { - text, - text_image, - current_text, - text_size, - text_c, - timer, - } => { - self.font.execute(|f| { - *current_text = text.to_string(); - let style = FontStyle::new(*text_size, *text_c); - *text_image = Some(f.render(text, &style)?); - Ok(()) - })?; - } - MenuItemType::Button { - text, - text_image, - text_c, - h_c, - c, - } => { - if text_image.is_none() { - self.font.execute(|font| { - let style = FontStyle::new(42.0, *text_c); - *text_image = Some(font.render(text, &style)?); - Ok(()) - })?; - } - } - MenuItemType::Pause { timer, length } => (), - MenuItemType::InstantText { - text, - text_image, - text_size, - text_color, - } => { - if text_image.is_none() { - self.font.execute(|f| { - let style = FontStyle::new(*text_size, *text_color); - *text_image = Some(f.render(text, &style)?); - Ok(()) - })?; - } - } - } - mi.is_loaded = true; - } - self.current_finished = true; - } - } - } - Event::Key(key, state) => { - if let ButtonState::Pressed = state { - match key { - Key::S => { - if self.state == 10 { - let save_data = SaveData { - planets: self.planets.clone(), - stars: self.stars.clone(), - fishes: self.fishes.clone(), - player: self.player.clone(), - joining_particles: self.joining_particles.clone(), - }; - save("OneAndAll_LD45", "slot0", &save_data)?; - self.save_load_notification = Some(SaveLoadNotification::Save { - text: None, - timer: SL_NOTIF_TIME, - }); - } - } - Key::L => { - let load_result = load::("OneAndAll_LD45", "slot0"); - if let Ok(save_data) = load_result { - self.planets = save_data.planets; - self.stars = save_data.stars; - self.fishes = save_data.fishes; - self.player = save_data.player; - self.joining_particles = save_data.joining_particles; - self.expl_conv_p_systems.clear(); - self.move_to = self.player.pos; - self.camera.pos = - self.player.pos - Vector::new(WIDTH_F / 2.0, HEIGHT_F / 2.0); - self.dbl_click_timeout = None; - self.click_time = None; - self.click_release_time = DOUBLE_CLICK_TIME; + pub fn update(&mut self, window: &mut Window) -> Result<(), String> { + let dt = window.get_gi().get_delta_time(); - self.state = 10; - self.state_dirty = true; - self.save_load_notification = Some(SaveLoadNotification::Load { - text: None, - timer: SL_NOTIF_TIME, - }); + // check mouse pos + { + self.mouse_pos = window.get_gi().get_mouse_xy_vec()?; + //self.mouse_pos = window.get_gi().vec_to_world(self.mouse_pos)?; + let mut hovered = false; + for i in 0..self.menu.items.len() { + if self.menu.items[i].is_inside(self.mouse_pos.x, self.mouse_pos.y) { + self.menu.items[i].is_hover = true; + self.current_item = Some(i); + hovered = true; + } else { + self.menu.items[i].is_hover = false; + } + } + if !hovered { + self.current_item = None; + } + } + + // check mouse down + if window.get_gi_mut().get_mouse_released()? { + if self.dbl_click_timeout.is_none() { + self.click_release_time = 0.0; + } + } else if window.get_gi_mut().get_mouse_pressed()?.is_some() { + if self.current_finished { + if self.is_create_mode { + let click_pos = window.get_gi().vec_to_world(self.mouse_pos)?; + if self.click_release_time < DOUBLE_CLICK_TIME { + self.click_release_time = DOUBLE_CLICK_TIME; + self.dbl_click_timeout = Some(0.0); + self.click_time = None; + if self.state == 8 { + let mut expl_conv_system = ExplConvParticleSystem::new( + 1.5, + Circle::new(click_pos.x, click_pos.y, 20.0), + Color::from_rgba(0x99, 0xFF, 0x99, 255), + 1.0, + ); + expl_conv_system.activate(30, 200.0); + self.expl_conv_p_systems.push(expl_conv_system); + self.state = 9; + self.state_dirty = true; + window.get_sound_mut(&self.s_boom)?.play(0.8)?; + } else if self.state == 10 { + let mut rng = rand::thread_rng(); + let rand_out = rng.gen_range(0.0, 1.0); + if rand_out < 0.6 { + // spawn planet + let mut expl_conv_system = ExplConvParticleSystem::new( + rng.gen_range(1.2, 1.6), + Circle::new( + click_pos.x, + click_pos.y, + rng.gen_range(15.0, 25.0), + ), + Color::from_rgba( + rng.gen_range(0x44, 0xFF), + rng.gen_range(0x44, 0xFF), + rng.gen_range(0x44, 0xFF), + 255, + ), + 1.0, + ); + expl_conv_system + .activate(rng.gen_range(13, 40), rng.gen_range(150.0, 300.0)); + self.expl_conv_p_systems.push(expl_conv_system); + } else if rand_out < 0.85 { + // spawn star + let rot_clockwise = rng.gen_bool(0.5); + self.stars.push(Star::new( + Circle::new(click_pos.x, click_pos.y, rng.gen_range(3.0, 7.0)), + Color::from_rgba( + rng.gen_range(0x58, 0xFF), + rng.gen_range(0x58, 0xFF), + rng.gen_range(0x58, 0xFF), + 255, + ), + if rot_clockwise { + rng.gen_range(0.1, 0.3) + } else { + rng.gen_range(-0.3, -0.1) + }, + rng.gen_range(0.0, 90.0), + )); + } else { + // spawn fish + for i in 0..rng.gen_range(1, 4) { + self.fishes.push(Fish::new( + click_pos, + rng.gen_range(0.0, 360.0), + Color::from_rgba( + rng.gen_range(0x44, 0xFF), + rng.gen_range(0x44, 0xFF), + rng.gen_range(0x44, 0xFF), + 255, + ), + )); + } } + window.get_sound_mut(&self.s_boom)?.play(0.8)?; } - Key::R => { - if self.state == 10 { + } else if self.state == 10 { + self.click_time = Some(0.0); + self.click_pos = click_pos; + } + } else if self.selection_mode { + if let Some(idx) = self.current_item { + match self.state { + 0 => { + self.state += 1; + self.state_dirty = true; + } + 2 => { + if idx == 5 { + // hope + self.state = 3; + self.state_dirty = true; + self.joining_particles.particle_system.color = + Color::from_rgba(0xAA, 0xCC, 0xFF, 255); + } else if idx == 6 { + // miracles + self.state = 4; + self.state_dirty = true; + self.joining_particles.particle_system.color = + Color::from_rgba(0xFF, 0xFF, 0xAA, 255); + } else if idx == 7 { + // kindness + self.state = 5; + self.state_dirty = true; + self.joining_particles.particle_system.color = + Color::from_rgba(0xBB, 0xFF, 0xBB, 255); + } else { + // determination + self.state = 6; + self.state_dirty = true; + self.joining_particles.particle_system.color = + Color::from_rgba(0xFF, 0xAA, 0xAA, 255); + } + window.get_sound_mut(&self.s_get)?.play(0.7)?; + } + _ => { self.state = 0; self.state_dirty = true; } } - _ => (), } + } else { + match self.state { + 0 | 1 => self.state += 1, + 3 | 4 | 5 | 6 => self.state = 7, + 7 => self.state = 8, + 9 => self.state = 10, + _ => self.state = 0, + } + self.state_dirty = true; } + } else { + for mi in &mut self.menu.items { + match &mut mi.item_type { + MenuItemType::AppearingText { + text, + text_idx, + text_size, + text_c, + timer, + } => { + *text_idx = text.len(); + } + MenuItemType::Button { + text, + text_c, + h_c, + c, + } => { + //let style = FontStyle::new(42.0, *text_c); + } + MenuItemType::Pause { timer, length } => (), + MenuItemType::InstantText { + text, + text_size, + text_color, + } => {} + } + mi.is_loaded = true; + } + self.current_finished = true; } - _ => (), } - Ok(()) - } - fn update(&mut self, window: &mut Window) -> Result<()> { - let dt = window.update_rate(); + // check pressed keys + if window.get_gi_mut().get_key_pressed('s')? { + if self.state == 10 { + let save_data = SaveData { + planets: self.planets.clone(), + stars: self.stars.clone(), + fishes: self.fishes.clone(), + player: self.player.clone(), + joining_particles: self.joining_particles.clone(), + }; + // TODO + //save("OneAndAll_LD45", "slot0", &save_data)?; + self.save_load_notification = Some(SaveLoadNotification::Save { + text: None, + timer: SL_NOTIF_TIME, + }); + } + } else if window.get_gi_mut().get_key_pressed('l')? { + // TODO + //let load_result = load::("OneAndAll_LD45", "slot0"); + //if let Ok(save_data) = load_result { + // self.planets = save_data.planets; + // self.stars = save_data.stars; + // self.fishes = save_data.fishes; + // self.player = save_data.player; + // self.joining_particles = save_data.joining_particles; + // self.expl_conv_p_systems.clear(); + // self.move_to = Vector { + // x: self.player.x, + // y: self.player.y, + // }; + // self.camera.set_view_xy( + // self.player.x - WIDTH_F / 2.0, + // self.player.y - HEIGHT_F / 2.0, + // ); + // self.dbl_click_timeout = None; + // self.click_time = None; + // self.click_release_time = DOUBLE_CLICK_TIME; + + // self.state = 10; + // self.state_dirty = true; + // self.save_load_notification = Some(SaveLoadNotification::Load { + // text: None, + // timer: SL_NOTIF_TIME, + // }); + //} + } else if window.get_gi_mut().get_key_pressed('r')? { + if self.state == 10 { + self.state = 0; + self.state_dirty = true; + window.get_music_mut(&self.music2)?.stop()?; + self.music_on = false; + } + } self.click_release_time += dt; if let Some(t) = &mut self.click_time { @@ -1514,34 +1615,35 @@ impl State for GameState { if let Some(t) = &mut self.dbl_click_timeout { *t += dt; - if *t > 300.0 { + if *t > 0.3 { self.dbl_click_timeout = None; } } - self.player.pos += (self.move_to - self.player.pos) / 20.0; - self.player_particles.host_rect.pos = self.player.pos; - self.joining_particles.particle_system.host_rect.pos += - (self.player.pos - self.joining_particles.particle_system.host_rect.pos) / 30.0; - self.camera.pos += - (self.player.pos - Vector::new(WIDTH_F / 2.0, HEIGHT_F / 2.0) - self.camera.pos) / 40.0; - window.set_view(View::new(self.camera)); + self.player.x += (self.move_to.x - self.player.x) / 20.0; + self.player.y += (self.move_to.y - self.player.y) / 20.0; + self.player_particles.host_rect.x = self.player.x; + self.player_particles.host_rect.y = self.player.y; + self.joining_particles.particle_system.host_rect.x += + (self.player.x - self.joining_particles.particle_system.host_rect.x) / 30.0; + self.joining_particles.particle_system.host_rect.y += + (self.player.y - self.joining_particles.particle_system.host_rect.y) / 30.0; + let (cx, cy) = self.camera.get_view_xy()?; + self.camera.set_view_xy( + cx + (self.player.x - WIDTH_F / 2.0 - cx) / 40.0, + cy + (self.player.y - HEIGHT_F / 2.0 - cy) / 40.0, + )?; + window.get_gi_mut().set_camera(&self.camera)?; self.player_r += dt / 10.0; if self.state_dirty { self.state_dirty = false; if self.state > 1 && !self.music_on { - let mut music_on = false; - self.music2.execute(|m2| { - music_on = true; - m2.set_volume(0.6); - m2.play() - })?; - if music_on { - self.music_on = true; - self.music_timer = 0.0; - } + let music = window.get_music_mut(&self.music2)?; + music.set_loop(true)?; + music.play(0.5)?; + self.music_on = true; } match self.state { 1 => { @@ -1609,9 +1711,10 @@ impl State for GameState { self.planets.clear(); self.stars.clear(); self.fishes.clear(); - self.player.pos = Vector::new(WIDTH_F / 2.0, HEIGHT_F / 2.0); + self.player.x = WIDTH_F / 2.0; + self.player.y = HEIGHT_F / 2.0; self.move_to = Vector::new(WIDTH_F / 2.0, HEIGHT_F / 2.0); - self.camera.pos = Vector::new(0.0, 0.0); + self.camera.set_view_xy(0.0, 0.0)?; self.click_time = None; } } @@ -1628,29 +1731,19 @@ impl State for GameState { } if self.player_particles.opacity < 1.0 && self.state > 1 { - self.player_particles.opacity += dt as f32 / 7000.0; + self.player_particles.opacity += dt as f32 / 7.0; if self.player_particles.opacity > 1.0 { self.player_particles.opacity = 1.0; } } if self.music_on { - self.music_timer += dt; - if self.music_timer > MUSIC2_LENGTH { - self.music_timer = 0.0; - self.music2.execute(|m2| m2.play())?; - } } else if self.state == 10 { let mut music_on = false; - self.music2.execute(|m2| { - music_on = true; - m2.set_volume(0.6); - m2.play() - })?; - if music_on { - self.music_on = true; - self.music_timer = 0.0; - } + let music = window.get_music_mut(&self.music2)?; + music.set_loop(true)?; + music.play(0.5)?; + self.music_on = true; } for i in 0..self.menu.items.len() { @@ -1659,29 +1752,27 @@ impl State for GameState { match &mut mi.item_type { MenuItemType::Button { text, - text_image, text_c, h_c, c, } => { - self.font.execute(|font| { - let style = FontStyle::new(42.0, *text_c); - *text_image = Some(font.render(text, &style)?); - Ok(()) - })?; - if text_image.is_some() { - mi.is_loaded = true; - if i + 1 < self.menu.items.len() { - self.menu.items[i + 1].is_loaded = false; - } else { - self.current_finished = true; - } + //self.font.execute(|font| { + // let style = FontStyle::new(42.0, *text_c); + // *text_image = Some(font.render(text, &style)?); + // Ok(()) + //})?; + //if text_image.is_some() { + mi.is_loaded = true; + if i + 1 < self.menu.items.len() { + self.menu.items[i + 1].is_loaded = false; + } else { + self.current_finished = true; } + //} } MenuItemType::AppearingText { text, - text_image, - current_text, + text_idx, text_size, text_c, timer, @@ -1689,14 +1780,9 @@ impl State for GameState { *timer += dt; if *timer > TEXT_RATE { *timer -= TEXT_RATE; - let next = text.chars().nth(current_text.len()); - if let Some(next_t) = next { - current_text.push(next_t); - self.s_tap.execute(|s| { - s.set_volume(0.2); - s.play() - })?; - } else { + *text_idx += 1; + window.get_sound_mut(&self.s_tap).unwrap().play(0.2)?; + if *text_idx >= text.len() { mi.is_loaded = true; if i + 1 < self.menu.items.len() { self.menu.items[i + 1].is_loaded = false; @@ -1705,11 +1791,11 @@ impl State for GameState { } continue; } - self.font.execute(|font| { - let style = FontStyle::new(*text_size, *text_c); - *text_image = Some(font.render(current_text, &style)?); - Ok(()) - })?; + //self.font.execute(|font| { + // let style = FontStyle::new(*text_size, *text_c); + // *text_image = Some(font.render(current_text, &style)?); + // Ok(()) + //})?; } } MenuItemType::Pause { timer, length } => { @@ -1725,25 +1811,24 @@ impl State for GameState { } MenuItemType::InstantText { text, - text_image, text_size, text_color, } => { - if text_image.is_none() { - self.font.execute(|f| { - let style = FontStyle::new(*text_size, *text_color); - *text_image = Some(f.render(text, &style)?); - Ok(()) - })?; - } - if text_image.is_some() { - mi.is_loaded = true; - if i + 1 < self.menu.items.len() { - self.menu.items[i + 1].is_loaded = false; - } else { - self.current_finished = true; - } + //if text_image.is_none() { + // self.font.execute(|f| { + // let style = FontStyle::new(*text_size, *text_color); + // *text_image = Some(f.render(text, &style)?); + // Ok(()) + // })?; + //} + //if text_image.is_some() { + mi.is_loaded = true; + if i + 1 < self.menu.items.len() { + self.menu.items[i + 1].is_loaded = false; + } else { + self.current_finished = true; } + //} } } } @@ -1772,12 +1857,12 @@ impl State for GameState { if *timer <= 0.0 { self.save_load_notification = None; } else if text.is_none() { - self.font.execute(|f| { - *text = Some( - f.render("Saved the Game", &FontStyle::new(45.0, Color::WHITE))?, - ); - Ok(()) - })?; + //self.font.execute(|f| { + // *text = Some( + // f.render("Saved the Game", &FontStyle::new(45.0, Color::WHITE))?, + // ); + // Ok(()) + //})?; } } SaveLoadNotification::Load { text, timer } => { @@ -1785,48 +1870,17 @@ impl State for GameState { if *timer <= 0.0 { self.save_load_notification = None; } else if text.is_none() { - self.font.execute(|f| { - *text = Some( - f.render("Loaded the Game", &FontStyle::new(45.0, Color::WHITE))?, - ); - Ok(()) - })?; + //self.font.execute(|f| { + // *text = Some( + // f.render("Loaded the Game", &FontStyle::new(45.0, Color::WHITE))?, + // ); + // Ok(()) + //})?; } } } } - if self.i_star_actual.is_none() { - if let Some(i_s) = &mut self.i_star { - let mut star: Option = None; - i_s.execute(|i| { - star = Some(i.clone()); - Ok(()) - })?; - self.i_star_actual = star; - } - if self.i_star_actual.is_some() { - self.i_star = None; - } - } - - if self.i_fish_body.is_none() { - let mut body: Option = None; - self.i_fish.execute(|i| { - body = Some(i.subimage(Rectangle::new((0.0, 0.0), (32.0, 16.0)))); - Ok(()) - })?; - self.i_fish_body = body; - } - if self.i_fish_tail.is_none() { - let mut tail: Option = None; - self.i_fish.execute(|i| { - tail = Some(i.subimage(Rectangle::new((32.0, 0.0), (16.0, 16.0)))); - Ok(()) - })?; - self.i_fish_tail = tail; - } - for fish in &mut self.fishes { fish.update(dt); } @@ -1834,78 +1888,77 @@ impl State for GameState { Ok(()) } - fn draw(&mut self, window: &mut Window) -> Result<()> { - window.clear(Color::BLACK)?; + pub fn draw(&mut self, window: &mut Window) -> Result<(), String> { + window.get_gi_mut().begin_drawing()?; + window.get_gi_mut().clear_window(Color::BLACK)?; let mut rect = Rectangle::default(); for mi in &mut self.menu.items { - rect.pos.x = mi.x; - rect.pos.y = mi.y; - rect.size.x = mi.w; - rect.size.y = mi.h; + rect.x = mi.x; + rect.y = mi.y; + rect.w = mi.w; + rect.h = mi.h; match &mut mi.item_type { MenuItemType::Button { text, - text_image, text_c, h_c, c, } => { if mi.is_hover { - window.draw(&rect, Col(*h_c)); + window.get_gi_mut().draw_rect(rect, *h_c)?; } else { - window.draw(&rect, Col(*c)); - } - if let Some(i) = text_image { - let mut image_rect = i.area(); - image_rect.pos.x = mi.x + (mi.w - image_rect.size.x) / 2.0; - image_rect.pos.y = mi.y + (mi.h - image_rect.size.y) / 2.0; - window.draw(&image_rect, Img(i)); + window.get_gi_mut().draw_rect(rect, *c)?; } + window + .get_font_mut(&self.font)? + .draw(text, 20, rect.x, rect.y, *text_c)?; } MenuItemType::AppearingText { text, - text_image, - current_text, + text_idx, text_size, text_c, timer, } => { - if let Some(i) = text_image { - let mut image_rect = i.area(); - image_rect.pos.x = mi.x; - image_rect.pos.y = mi.y; - window.draw(&image_rect, Img(i)); - } + window.get_font_mut(&self.font)?.draw( + if *text_idx < text.len() { + &text[0..*text_idx] + } else { + text + }, + 20, + rect.x, + rect.y, + *text_c, + )?; } MenuItemType::InstantText { text, - text_image, text_size, text_color, } => { - if let Some(i) = text_image { - let mut image_rect = i.area(); - image_rect.pos.x = mi.x; - image_rect.pos.y = mi.y; - window.draw(&image_rect, Img(i)); - } + window.get_font_mut(&self.font)?.draw( + text, + text_size.round() as u32, + rect.x, + rect.y, + *text_color, + )?; } MenuItemType::Pause { timer, length } => (), } } self.player_particles.draw(window, Transform::IDENTITY); - window.draw_ex( - &self.player, - Col(Color::from_rgba( - 0xFF, - 0xFF, - 0xFF, - self.player_particles.opacity, - )), - Transform::translate((-self.player.size.x / 2.0, -self.player.size.y / 2.0)) + window.get_gi_mut().draw_rect_transform( + self.player, + Color::from_rgba(255, 255, 255, (self.player_particles.opacity * 255.0) as u8), + Transform::translate(self.player.w / 2.0, self.player.h / 2.0) * Transform::rotate(self.player_r as f32), - 1, - ); + Vector { + x: self.player.x + self.player.w / 2.0, + y: self.player.y + self.player.h / 2.0, + }, + )?; self.joining_particles.draw(window, Transform::IDENTITY); for expl_conv_ps in &mut self.expl_conv_p_systems { expl_conv_ps.draw(window, Transform::IDENTITY); @@ -1914,43 +1967,32 @@ impl State for GameState { planet.draw(window, Transform::IDENTITY); } - if let Some(i) = &mut self.i_star_actual { - for star in &mut self.stars { - star.draw(i, window, Transform::IDENTITY); - } + for star in &mut self.stars { + star.draw(&self.i_star, window, Transform::IDENTITY); } - if let Some(body) = &self.i_fish_body { - if let Some(tail) = &self.i_fish_tail { - for fish in &mut self.fishes { - fish.draw(body, tail, window, Transform::IDENTITY); - } - } + for fish in &mut self.fishes { + fish.draw(&self.i_fish, window, Transform::IDENTITY); } - if let Some(sl) = &mut self.save_load_notification { - match sl { - SaveLoadNotification::Save { text, timer } - | SaveLoadNotification::Load { text, timer } => { - if let Some(i) = text { - let mut c = Color::WHITE; - c.a = (*timer / SL_NOTIF_TIME) as f32; - let mut image_rect = i.area(); - image_rect.pos = self.camera.pos + Vector::new(20.0, 20.0); - window.draw(&image_rect, Blended(i, c)); - } - } - } - } + // TODO + //if let Some(sl) = &mut self.save_load_notification { + // match sl { + // SaveLoadNotification::Save { text, timer } + // | SaveLoadNotification::Load { text, timer } => { + // if let Some(i) = text { + // let mut c = Color::WHITE; + // c.a = ((*timer / SL_NOTIF_TIME) as f32 * 255.0) as u8; + // let mut image_rect = i.area_rect(); + // image_rect.x = self.camera.x + 20.0; + // image_rect.y = self.camera.y + 20.0; + // window.draw(&image_rect, Blended(i, c)); + // } + // } + // } + //} + window.get_gi_mut().end_drawing()?; Ok(()) } } - -fn main() { - run::( - "One And All - a Ludum Dare 45 compo entry", - Vector::new(800, 600), - Settings::default(), - ); -} diff --git a/src/shaders.rs b/src/shaders.rs new file mode 100644 index 0000000..7e36794 --- /dev/null +++ b/src/shaders.rs @@ -0,0 +1,47 @@ +use crate::{ + agnostic_interface::raylib_impl::RaylibShader, + faux_quicksilver::{Transform, Vector}, +}; +use std::ffi::CStr; + +extern "C" { + pub fn glVertexAttrib2f(index: ::std::os::raw::c_uint, x: f32, y: f32); +} +extern "C" { + pub fn glVertexAttrib3f(index: ::std::os::raw::c_uint, x: f32, y: f32, z: f32); +} +extern "C" { + pub fn glVertexAttrib4f(index: ::std::os::raw::c_uint, x: f32, y: f32, z: f32, w: f32); +} +extern "C" { + pub fn glGetAttribLocation( + program: ::std::os::raw::c_uint, + name: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} + +pub fn get_attrib_location(raylib_shader: &RaylibShader, name: &CStr) -> ::std::os::raw::c_uint { + unsafe { + glGetAttribLocation(raylib_shader.get_shader_id(), name.as_ptr()) as ::std::os::raw::c_uint + } +} + +pub fn set_transform_3f(index: ::std::os::raw::c_uint, transform: Transform) { + // OpenGL stores matrix indices in column major order. + for (i, idx) in (index..(index + 3)).enumerate() { + unsafe { + glVertexAttrib3f( + idx, + transform.mat[0 + i as usize], + transform.mat[3 + i as usize], + transform.mat[6 + i as usize], + ); + } + } +} + +pub fn set_attr_2f(index: ::std::os::raw::c_uint, origin: Vector) { + unsafe { + glVertexAttrib2f(index, origin.x, origin.y); + } +} diff --git a/static/camera.vs b/static/camera.vs new file mode 100644 index 0000000..e2db57a --- /dev/null +++ b/static/camera.vs @@ -0,0 +1,23 @@ +#version 100 + +// Input vertex attributes +attribute vec3 vertexPosition; +attribute vec2 vertexTexCoord; +attribute vec4 vertexColor; + +// Input uniform values +uniform mat4 mvp; + +// Output vertex attributes (to fragment shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// custom +attribute vec2 camera; + +void main() { + fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + + gl_Position = mvp * vec4(vertexPosition - vec3(camera, 0.0), 1.0); +} diff --git a/static/simple.fs b/static/simple.fs new file mode 100644 index 0000000..3884320 --- /dev/null +++ b/static/simple.fs @@ -0,0 +1,20 @@ +#version 100 + +// Default fragment shader used by Raylib. + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +void main() { + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + gl_FragColor = texelColor*colDiffuse*fragColor; +} diff --git a/static/transform.vs b/static/transform.vs new file mode 100644 index 0000000..1df0de6 --- /dev/null +++ b/static/transform.vs @@ -0,0 +1,26 @@ +#version 100 + +// Input vertex attributes +attribute vec3 vertexPosition; +attribute vec2 vertexTexCoord; +attribute vec4 vertexColor; + +// Input uniform values +uniform mat4 mvp; + +// Output vertex attributes (to fragment shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// custom +attribute vec2 camera; +attribute vec2 origin; +attribute mat3 transform; + +void main() { + fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + + vec3 pos = transform * (vertexPosition - vec3(origin, 0.0)) + vec3(origin, 0.0); + gl_Position = mvp * vec4(pos - vec3(camera, 0.0), 1.0); +} diff --git a/wasm/.gitignore b/wasm/.gitignore new file mode 100644 index 0000000..b9cd2ac --- /dev/null +++ b/wasm/.gitignore @@ -0,0 +1,5 @@ +/ld45.html +/ld45.js +/ld45.data +/ld45.wasm +/index.html diff --git a/wasm/Makefile b/wasm/Makefile new file mode 100644 index 0000000..743349b --- /dev/null +++ b/wasm/Makefile @@ -0,0 +1,32 @@ +CC = source "${HOME}/git/emsdk/emsdk_env.sh" && emcc + +all: ld45.html + +ld45.html: src/main.c ../target/wasm32-unknown-emscripten/release/libld45_lib.a + ${CC} -o ld45.html -s USE_GLFW=3 -Iinclude \ + -Llib -lraylib \ + -L../target/wasm32-unknown-emscripten/release -lld45_lib \ + -sTOTAL_MEMORY=1024MB \ + -sALLOW_MEMORY_GROWTH=1 \ + -O2 \ +-fsanitize=address \ + -sEXPORTED_FUNCTIONS="['_malloc', '_main']" \ + -sEXPORTED_RUNTIME_METHODS=ccall,cwrap \ + --preload-file ../static src/main.c + ln -sf ld45.html index.html + +#-fsanitize=address \ +#-sWARN_UNALIGNED=1 \ + +../target/wasm32-unknown-emscripten/release/libld45_lib.a: ../src/lib.rs + cd ..; source "${HOME}/git/emsdk/emsdk_env.sh"; cargo build --lib --release --target wasm32-unknown-emscripten + +.PHONY: clean + +clean: + rm -f ld45.html + rm -f ld45.js + rm -f ld45.wasm + rm -f ld45.data + rm -f index.html + cd ..; cargo clean diff --git a/wasm/emsdk_version b/wasm/emsdk_version new file mode 100644 index 0000000..381c34a --- /dev/null +++ b/wasm/emsdk_version @@ -0,0 +1 @@ +3.1.32 diff --git a/wasm/include/ld45_lib.h b/wasm/include/ld45_lib.h new file mode 100644 index 0000000..cb87442 --- /dev/null +++ b/wasm/include/ld45_lib.h @@ -0,0 +1,8 @@ +#ifndef LD45_ONE_AND_ALL_LIB_H_ +#define LD45_ONE_AND_ALL_LIB_H_ + +extern void *ld45_initialize(); + +extern void ld45_iterate(void *context); + +#endif diff --git a/wasm/include/raylib.h b/wasm/include/raylib.h new file mode 120000 index 0000000..187d613 --- /dev/null +++ b/wasm/include/raylib.h @@ -0,0 +1 @@ +../../raylib/raylib.h \ No newline at end of file diff --git a/wasm/lib/libraylib.a b/wasm/lib/libraylib.a new file mode 100644 index 0000000..09e9745 Binary files /dev/null and b/wasm/lib/libraylib.a differ diff --git a/wasm/src/main.c b/wasm/src/main.c new file mode 100644 index 0000000..8363297 --- /dev/null +++ b/wasm/src/main.c @@ -0,0 +1,18 @@ +#include +#include + +#include + +#include + +void main_loop(void *ud) { + ld45_iterate(ud); +} + +int main(void) { + void *ld45_context = ld45_initialize(); + + emscripten_set_main_loop_arg(main_loop, ld45_context, 0, 1); + + return 0; +}