actually draw the level

This commit is contained in:
Michael Zhang 2019-07-27 14:43:29 -05:00
parent 2d8a62bc86
commit c0ce496ce0
No known key found for this signature in database
GPG key ID: 5BAEFE5D04F0CE6C
15 changed files with 612 additions and 42 deletions

246
Cargo.lock generated
View file

@ -1,5 +1,10 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "adler32"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "alga"
version = "0.9.1"
@ -150,6 +155,11 @@ dependencies = [
"objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "color_quant"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "core-foundation"
version = "0.6.4"
@ -175,6 +185,54 @@ dependencies = [
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-deque"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-epoch"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-queue"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-utils"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "deflate"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "derivative"
version = "1.0.2"
@ -206,6 +264,11 @@ name = "downcast-rs"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "either"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fake-simd"
version = "0.1.2"
@ -242,6 +305,15 @@ dependencies = [
"typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gif"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gl_generator"
version = "0.11.0"
@ -340,6 +412,40 @@ dependencies = [
"gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "image"
version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gif 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"jpeg-decoder 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"tiff 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "inflate"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "jpeg-decoder"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "json5"
version = "0.2.5"
@ -404,6 +510,11 @@ dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lzw"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "malloc_buf"
version = "0.0.6"
@ -434,6 +545,14 @@ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memoffset"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nalgebra"
version = "0.18.0"
@ -486,6 +605,45 @@ dependencies = [
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-derive"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-integer"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-iter"
version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-rational"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-traits"
version = "0.2.8"
@ -494,6 +652,14 @@ dependencies = [
"autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num_cpus"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "objc"
version = "0.2.6"
@ -601,6 +767,17 @@ name = "pkg-config"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "png"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"deflate 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)",
"inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "0.4.30"
@ -718,6 +895,28 @@ name = "rawpointer"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rayon"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rayon-core"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rdrand"
version = "0.4.0"
@ -758,11 +957,21 @@ dependencies = [
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "scoped_threadpool"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "semver"
version = "0.9.0"
@ -860,6 +1069,17 @@ name = "takeable-option"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "tiff"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "typenum"
version = "1.10.0"
@ -949,6 +1169,7 @@ name = "wedge"
version = "0.1.0"
dependencies = [
"glium 0.25.1 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)",
"json5 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"nalgebra 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nalgebra-glm 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1027,6 +1248,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
"checksum alga 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d708cb68c7106ed1844de68f50f0157a7788c2909a6926fad5a87546ef6a4ff8"
"checksum andrew 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e"
"checksum android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"
@ -1046,19 +1268,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "55e7ec0b74fe5897894cbc207092c577e87c52f8a59e8ca8d97ef37551f60a49"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum cocoa 0.18.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf79daa4e11e5def06e55306aa3601b87de6b5149671529318da048f67cdd77b"
"checksum color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd"
"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
"checksum core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9"
"checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13"
"checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9"
"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b"
"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
"checksum deflate 0.7.20 (registry+https://github.com/rust-lang/crates.io-index)" = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4"
"checksum derivative 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6073e9676dbebdddeabaeb63e3b7cefd23c86f5c41d381ee1237cc77b1079898"
"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
"checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
"checksum downcast-rs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b92dfd5c2f75260cbf750572f95d387e7ca0ba5e3fbe9e1a33f23025be020f"
"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
"checksum gif 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "86c2f2b597d6e05c86ee5947b2223bda468fe8dad3e88e2a6520869322aaf568"
"checksum gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39a23d5e872a275135d66895d954269cf5e8661d234eb1c2480f4ce0d586acbd"
"checksum gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "c8a455b5a3ccd35daeb89fdb8a89ebb0a1fe23c05c7a7f9017840bc3ae176f71"
"checksum glium 0.25.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d7d887755ee729c5204e151db1c81b0b5beb809ef5e01d0eb14847e80a71256"
@ -1068,6 +1298,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum glutin_gles2_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89996c30857ae1b4de4b5189abf1ea822a20a9fe9e1c93e5e7b862ff0bdd5cdf"
"checksum glutin_glx_sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1290a5ca5e46fcfa7f66f949cc9d9194b2cb6f2ed61892c8c2b82343631dba57"
"checksum glutin_wgl_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f801bbc91efc22dd1c4818a47814fc72bf74d024510451b119381579bfa39021"
"checksum image 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "99198e595d012efccf12abf4abc08da2d97be0b0355a2b08d101347527476ba4"
"checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
"checksum jpeg-decoder 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b7d43206b34b3f94ea9445174bda196e772049b9bddbc620c9d29b2d20110d"
"checksum json5 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "85fb48cdfbe18a1ef5ce0a0edc30b8b8f61422f7073f709dd09311c2b3d2bba6"
"checksum khronos_api 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
@ -1077,16 +1310,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3"
"checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084"
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
"checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43"
"checksum matrixmultiply 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfed72d871629daa12b25af198f110e8095d7650f5f4c61c5bac28364604f9b"
"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f"
"checksum nalgebra 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e12856109b5cb8e2934b5e45e4624839416e1c6c1f7d286711a7a66b79db29d"
"checksum nalgebra-glm 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f2c7f8b7093ddb95018d5f48ce453304c49b624d078cbeed157b8f0d45d9872f"
"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb0cf31fb3ff77e6d2a6ebd6800df7fdcd106f2ad89113c9130bcd07f93dffc"
"checksum num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "eafd0b45c5537c3ba526f79d3e75120036502bebacbb3f3220914067ce39dbf2"
"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
"checksum num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e"
"checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454"
"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32"
"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273"
"checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d"
"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409"
"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518"
@ -1100,6 +1340,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646"
"checksum pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f249ea6de7c7b7aba92b4ff4376a994c6dbd98fd2166c89d5c4947397ecb574d"
"checksum pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c1d2cfa5a714db3b5f24f0915e74fcdf91d09d496ba61329705dda7774d2af"
"checksum png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "63daf481fdd0defa2d1d2be15c674fbfa1b0fd71882c303a91f9a79b3252c359"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
@ -1113,12 +1354,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
"checksum rawpointer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebac11a9d2e11f2af219b8b8d833b76b1ea0e054aa0e8d8e9e4cbde353bdf019"
"checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4"
"checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rusttype 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "654103d61a05074b268a107cf6581ce120f0fc0115f2610ed9dfea363bb81139"
"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421"
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72"
@ -1131,6 +1376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum stb_truetype 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "69b7df505db8e81d54ff8be4693421e5b543e08214bd8d99eb761fcb4d5668ba"
"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e"
"checksum takeable-option 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d77adff586b9bd922afef7791341ed94b09845e11225929217efe949e6366d43"
"checksum tiff 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4834f28a0330cb9f3f2c87d2649dca723cb33802e2bdcf18da32759fbec7ce"
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
"checksum ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8f00ed7be0c1ff1e24f46c3d2af4859f7e863672ba3a6e92e7cff702bf9f06c2"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"

View file

@ -6,8 +6,9 @@ edition = "2018"
[dependencies]
glium = "0.25"
serde = "1.0"
serde_derive = "1.0"
image = "0.21"
json5 = "0.2"
nalgebra = "0.18"
nalgebra-glm = "0.4"
nalgebra-glm = "0.4"
serde = "1.0"
serde_derive = "1.0"

View file

@ -13,13 +13,61 @@
"blocks": [
{
"movable": true,
"push_dir": 0,
"orientation": 1,
"position": [1, 3],
"color": [255, 10, 100],
"segments": [
[0, 0, 0, 0],
[1, 0, 4, 0],
],
}
},
{
"movable": true,
"orientation": 2,
"position": [2, 4],
"color": [105, 210, 50],
"segments": [
[0, 0, 2, 0],
[0, 1, 0, 0],
],
},
{
"movable": true,
"orientation": 2,
"position": [0, 4],
"color": [35, 150, 100],
"segments": [
[0, 0, 1, 1],
[0, 1, 0, 1],
],
},
{
"movable": true,
"orientation": 1,
"position": [0, 3],
"color": [25, 120, 10],
"segments": [
[0, 0, 3, 1],
[1, 0, 0, 1],
],
},
{
"movable": false,
"orientation": 0,
"position": [0, 2],
"color": [15, 15, 15],
"segments": [
[0, 0, 0, 0],
],
},
{
"movable": false,
"orientation": 0,
"position": [2, 2],
"color": [15, 15, 15],
"segments": [
[0, 0, 0, 1],
],
},
]
}

View file

@ -1,7 +1,21 @@
#version 330
out vec4 color;
in vec4 pos;
out vec4 outcolor;
uniform vec4 color;
const float threshold = 0.05;
const vec4 top = vec4(0.5, 0.5, 0.5, 1.0);
const vec4 bot = vec4(0.4, 0.4, 0.4, 1.0);
void main() {
color = vec4(1.0, 1.0, 1.0, 1.0);
outcolor = 0.2 * (bot * (1 - pos.y) + top * (1 - pos.x)) + 0.2;
// if ((pos.x > -threshold && pos.x < threshold)
// || (pos.y > -threshold && pos.y < threshold)
// || (pos.x > 1.0-threshold && pos.x < 1.0+threshold)
// || (pos.y > 1.0-threshold && pos.y < 1.0+threshold)) {
// outcolor = vec4(0.0, 0.0, 0.0, 1.0);
// }
}

View file

@ -1,10 +1,12 @@
#version 330
in vec2 point;
out vec4 pos;
uniform mat4 target;
uniform mat4 projection;
void main() {
gl_Position = projection * target * vec4(point, 0.0, 1.0);
pos = vec4(point, 0.0, 1.0);
gl_Position = projection * target * pos;
}

11
shaders/segment.frag Normal file
View file

@ -0,0 +1,11 @@
#version 330
in vec2 v_tex_coords;
out vec4 outcolor;
uniform sampler2D tex;
uniform vec4 tint;
void main() {
outcolor = tint * texture(tex, v_tex_coords);
}

13
shaders/segment.vert Normal file
View file

@ -0,0 +1,13 @@
#version 330
in vec2 pos;
in vec2 tex;
out vec2 v_tex_coords;
uniform mat4 target;
uniform mat4 projection;
void main() {
v_tex_coords = tex;
gl_Position = projection * target * vec4(pos, 0.0, 1.0);
}

View file

@ -7,7 +7,7 @@ pub struct PlayerData {
#[derive(Debug, Deserialize)]
pub struct BlockData {
pub movable: bool,
pub push_dir: u32,
pub orientation: u32,
pub position: [u32; 2],
pub color: [u32; 3],
pub segments: Vec<[u32; 4]>,

View file

@ -15,9 +15,21 @@ impl From<u32> for Board {
}
#[derive(Copy, Clone)]
pub enum MotionDir {
Horizontal,
Vertical,
pub enum Orientation {
Both = 0,
Horizontal = 1,
Vertical = 2,
}
impl From<u32> for Orientation {
fn from(n: u32) -> Self {
match n {
0 => Orientation::Both,
1 => Orientation::Horizontal,
2 => Orientation::Vertical,
_ => panic!("expecting 0..2, got {}", n),
}
}
}
#[derive(Copy, Clone)]

View file

@ -6,9 +6,13 @@ use crate::level::Level;
use crate::renderer::Renderer;
use crate::resources::Resources;
const SEGMENT_VERT: &str = include_str!("../shaders/segment.vert");
const SEGMENT_FRAG: &str = include_str!("../shaders/segment.frag");
const CELL_VERT: &str = include_str!("../shaders/cell.vert");
const CELL_FRAG: &str = include_str!("../shaders/cell.frag");
const SEGMENT_IMAGE: &[u8] = include_bytes!("../textures/segment.png");
const LEVEL_TUTORIAL: &str = include_str!("../levels/tutorial.json");
pub struct Game<'a> {
@ -21,6 +25,12 @@ pub struct Game<'a> {
impl<'a> Game<'a> {
pub fn new(display: &'a Display) -> Game {
let mut resources = Resources::default();
resources
.load_image_from_memory(display, "segment", &SEGMENT_IMAGE, false)
.unwrap();
resources
.load_shader(display, "segment", &SEGMENT_VERT, &SEGMENT_FRAG)
.unwrap();
resources
.load_shader(display, "cell", &CELL_VERT, &CELL_FRAG)
.unwrap();

View file

@ -1,7 +1,7 @@
use std::collections::VecDeque;
use crate::data::LevelData;
use crate::enums::{Board, Shape};
use crate::enums::{Board, Orientation, Shape};
use crate::renderer::Renderer;
use crate::{GAME_HEIGHT, GAME_WIDTH};
@ -13,6 +13,9 @@ pub struct Level {
#[derive(Clone)]
pub struct Block {
position: (u32, u32),
color: (f32, f32, f32),
orientation: Orientation,
segments: Vec<Segment>,
}
@ -28,6 +31,7 @@ impl Level {
.blocks
.iter()
.map(|block| {
let position = (block.position[0], block.position[1]);
let segments = block
.segments
.iter()
@ -35,7 +39,18 @@ impl Level {
Segment(segment[0], segment[1], segment[2].into(), segment[3].into())
})
.collect();
Block { segments }
let orientation = block.orientation.into();
let color = (
block.color[0] as f32 / 256.0,
block.color[1] as f32 / 256.0,
block.color[2] as f32 / 256.0,
);
Block {
position,
color,
segments,
orientation,
}
})
.collect();
@ -70,6 +85,25 @@ impl Level {
offset.1 + 2 * scale,
);
renderer.render_cell(left_off, 50, Shape::Full);
// render the grid
for x in 0..self.dimensions.0 {
for y in 0..self.dimensions.1 {
renderer.render_cell((left_off.0 + x * scale, left_off.1 + y * scale), scale);
renderer.render_cell((right_off.0 + x * scale, right_off.1 + y * scale), scale);
}
}
// render blocks
for block in self.blocks.iter() {
for segment in block.segments.iter() {
let offset = match &segment.3 {
Board::Left => left_off,
Board::Right => right_off,
};
let coord = (segment.0 + block.position.0, segment.1 + block.position.1);
let location = (offset.0 + coord.0 * scale, offset.1 + coord.1 * scale);
renderer.render_segment(location, scale, block.color, block.orientation, segment.2);
}
}
}
}

View file

@ -13,10 +13,9 @@ mod resources;
use std::time::Instant;
use glium::glutin::{
dpi::PhysicalSize, ContextBuilder, Event, EventsLoop, WindowBuilder, WindowEvent,
};
use glium::{Display, Rect};
use glium::glutin::dpi::PhysicalSize;
use glium::glutin::{ContextBuilder, Event, EventsLoop, WindowBuilder, WindowEvent};
use glium::{Display, Rect, Surface};
use crate::game::Game;
@ -36,6 +35,12 @@ fn main() {
let cb = ContextBuilder::new();
let display = Display::new(wb, cb, &events_loop).unwrap();
{
let gl_window = display.gl_window();
let window = gl_window.window();
println!("size: {:?}", window.get_inner_size());
}
let game = Game::new(&display);
let mut closed = false;
@ -53,6 +58,7 @@ fn main() {
});
let mut target = display.draw();
target.clear(None, Some((0.0, 0.0, 0.0, 1.0)), true, None, None);
let mut renderer = game.create_renderer(&mut target);
game.render(&mut renderer);
target.finish().unwrap();

View file

@ -1,29 +1,32 @@
use glium::draw_parameters::{Blend, DrawParameters};
use glium::index::{NoIndices, PrimitiveType};
use glium::{Display, Frame, Program, Surface, VertexBuffer};
use nalgebra::Matrix4;
use glium::{Display, Frame, Program, Surface, Texture2d, VertexBuffer};
use nalgebra::{Matrix4, Vector4};
use crate::enums::Shape;
use crate::enums::{Orientation, Shape};
use crate::game::Game;
use crate::{GAME_HEIGHT, GAME_WIDTH};
pub struct Renderer<'a, 'b> {
target: &'a mut Frame,
display: &'b Display,
program: &'b Program,
cell_program: &'b Program,
segment_program: &'b Program,
segment_texture: &'b Texture2d,
}
impl<'a, 'b> Renderer<'a, 'b> {
pub fn new(game: &'b Game, target: &'a mut Frame) -> Self {
let program = game.resources.get_shader("cell").unwrap();
Renderer {
target,
display: &game.display,
program,
cell_program: game.resources.get_shader("cell").unwrap(),
segment_program: game.resources.get_shader("segment").unwrap(),
segment_texture: game.resources.get_texture("segment").unwrap(),
}
}
pub fn render_cell(&mut self, location: (u32, u32), scale: u32, shape: Shape) {
pub fn render_cell(&mut self, location: (u32, u32), scale: u32) {
#[derive(Copy, Clone)]
struct Vertex {
point: [f32; 2],
@ -32,21 +35,12 @@ impl<'a, 'b> Renderer<'a, 'b> {
let indices = NoIndices(PrimitiveType::TrianglesList);
let mut vertices = Vec::<Vertex>::new();
match shape {
Shape::Full => {
vertices.push(Vertex { point: [0.0, 0.0] });
vertices.push(Vertex { point: [1.0, 0.0] });
vertices.push(Vertex { point: [0.0, 1.0] });
vertices.push(Vertex { point: [1.0, 1.0] });
vertices.push(Vertex { point: [0.0, 1.0] });
vertices.push(Vertex { point: [1.0, 0.0] });
}
_ => {
vertices.push(Vertex { point: [0.0, 0.0] });
vertices.push(Vertex { point: [1.0, 0.0] });
vertices.push(Vertex { point: [0.0, 1.0] });
}
}
vertices.push(Vertex { point: [0.0, 0.0] });
vertices.push(Vertex { point: [1.0, 0.0] });
vertices.push(Vertex { point: [0.0, 1.0] });
vertices.push(Vertex { point: [1.0, 1.0] });
vertices.push(Vertex { point: [0.0, 1.0] });
vertices.push(Vertex { point: [1.0, 0.0] });
let vertex_buffer = VertexBuffer::new(self.display, &vertices).unwrap();
let projection =
@ -55,16 +49,157 @@ impl<'a, 'b> Renderer<'a, 'b> {
matrix = matrix.append_nonuniform_scaling(&[scale as f32, scale as f32, 1.0].into());
matrix = matrix.append_translation(&[location.0 as f32, location.1 as f32, 0.0].into());
let color = Vector4::from([0.6, 0.6, 0.8, 1.0f32]);
let uniforms = uniform! {
target: *matrix.as_ref(),
projection: *projection.as_ref(),
color: *color.as_ref(),
};
self.target
.draw(
&vertex_buffer,
&indices,
&self.program,
&self.cell_program,
&uniforms,
&DrawParameters {
blend: Blend::alpha_blending(),
..Default::default()
},
)
.unwrap();
}
pub fn render_segment(
&mut self,
location: (u32, u32),
scale: u32,
color: (f32, f32, f32),
orientation: Orientation,
shape: Shape,
) {
#[derive(Copy, Clone)]
struct Vertex {
pos: [f32; 2],
tex: [f32; 2],
}
implement_vertex!(Vertex, pos, tex);
let indices = NoIndices(PrimitiveType::TrianglesList);
let mut vertices = Vec::new();
match shape {
Shape::BottomLeft => {
vertices.push(Vertex {
pos: [1.0, 1.0],
tex: [1.0, 1.0],
});
vertices.push(Vertex {
pos: [1.0, 0.0],
tex: [1.0, 0.0],
});
vertices.push(Vertex {
pos: [0.0, 0.0],
tex: [0.0, 0.0],
});
}
Shape::TopLeft => {
vertices.push(Vertex {
pos: [0.0, 1.0],
tex: [0.0, 1.0],
});
vertices.push(Vertex {
pos: [1.0, 1.0],
tex: [1.0, 1.0],
});
vertices.push(Vertex {
pos: [1.0, 0.0],
tex: [1.0, 0.0],
});
}
Shape::TopRight => {
vertices.push(Vertex {
pos: [1.0, 1.0],
tex: [1.0, 1.0],
});
vertices.push(Vertex {
pos: [0.0, 1.0],
tex: [0.0, 1.0],
});
vertices.push(Vertex {
pos: [0.0, 0.0],
tex: [0.0, 0.0],
});
}
Shape::BottomRight => {
vertices.push(Vertex {
pos: [0.0, 1.0],
tex: [0.0, 1.0],
});
vertices.push(Vertex {
pos: [1.0, 0.0],
tex: [1.0, 0.0],
});
vertices.push(Vertex {
pos: [0.0, 0.0],
tex: [0.0, 0.0],
});
}
_ => {
vertices.push(Vertex {
pos: [0.0, 1.0],
tex: [0.0, 1.0],
});
vertices.push(Vertex {
pos: [1.0, 0.0],
tex: [1.0, 0.0],
});
vertices.push(Vertex {
pos: [0.0, 0.0],
tex: [0.0, 0.0],
});
vertices.push(Vertex {
pos: [0.0, 1.0],
tex: [0.0, 1.0],
});
vertices.push(Vertex {
pos: [1.0, 1.0],
tex: [1.0, 1.0],
});
vertices.push(Vertex {
pos: [1.0, 0.0],
tex: [1.0, 0.0],
});
}
}
let vertex_buffer = VertexBuffer::new(self.display, &vertices).unwrap();
let tint = Vector4::from([color.0, color.1, color.2, 1.0f32]);
let projection =
glm::ortho::<f32>(0.0, GAME_WIDTH as f32, GAME_HEIGHT as f32, 0.0, -1.0, 1.0);
let mut matrix = Matrix4::<f32>::identity();
matrix = matrix.append_nonuniform_scaling(&[scale as f32, scale as f32, 1.0].into());
matrix = matrix.append_translation(&[location.0 as f32, location.1 as f32, 0.0].into());
let rotate_texture = match orientation {
Orientation::Both => false,
Orientation::Vertical => true,
Orientation::Horizontal => false,
};
let uniforms = uniform! {
target: *matrix.as_ref(),
rotate_texture: rotate_texture,
projection: *projection.as_ref(),
tint: *tint.as_ref(),
tex: self.segment_texture,
};
self.target
.draw(
&vertex_buffer,
&indices,
&self.segment_program,
&uniforms,
&DrawParameters {
blend: Blend::alpha_blending(),

View file

@ -1,14 +1,52 @@
use std::collections::HashMap;
use glium::texture::RawImage2d;
use glium::{Display, Program, ProgramCreationError, Texture2d};
use image::{DynamicImage, GenericImageView, ImageBuffer, ImageError, Rgba};
#[derive(Default)]
pub struct Resources {
pub window_dimensions: (u32, u32),
textures: HashMap<String, Texture2d>,
shaders: HashMap<String, Program>,
}
impl Resources {
pub fn load_image_from_memory(
&mut self,
display: &Display,
name: impl AsRef<str>,
buffer: &[u8],
alpha: bool,
) -> Result<(), ImageError> {
let image = image::load_from_memory(buffer)?;
self.load_image(display, name, image, alpha);
Ok(())
}
pub fn load_image(
&mut self,
display: &Display,
name: impl AsRef<str>,
image: DynamicImage,
alpha: bool,
) {
let name = name.as_ref().to_owned();
let dimensions = image.dimensions();
let image = if alpha {
RawImage2d::from_raw_rgba_reversed(&image.raw_pixels(), dimensions)
} else {
RawImage2d::from_raw_rgb_reversed(&image.raw_pixels(), dimensions)
};
// TODO: don't unwrap
let texture = Texture2d::new(display, image).unwrap();
self.textures.insert(name, texture);
}
pub fn get_texture(&self, name: impl AsRef<str>) -> Option<&Texture2d> {
self.textures.get(name.as_ref())
}
pub fn load_shader(
&mut self,
display: &Display,

BIN
textures/segment.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB