android tests
This commit is contained in:
parent
ef1bd9e234
commit
575609a4a5
12 changed files with 1918 additions and 1426 deletions
444
Cargo.lock
generated
444
Cargo.lock
generated
|
@ -8,6 +8,57 @@ version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android-activity"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "40bc1575e653f158cbdc6ebcd917b9564e66321c5325c232c3591269c257be69"
|
||||||
|
dependencies = [
|
||||||
|
"android-properties",
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"cc",
|
||||||
|
"jni-sys",
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
"ndk",
|
||||||
|
"ndk-context",
|
||||||
|
"ndk-sys 0.4.1+23.1.7779620",
|
||||||
|
"num_enum 0.6.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android-properties"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_log-sys"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_logger"
|
||||||
|
version = "0.11.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a"
|
||||||
|
dependencies = [
|
||||||
|
"android_log-sys",
|
||||||
|
"env_logger",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -20,6 +71,12 @@ version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
version = "0.10.4"
|
version = "0.10.4"
|
||||||
|
@ -29,6 +86,21 @@ dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytes"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.0.79"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||||
|
dependencies = [
|
||||||
|
"jobserver",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cesu8"
|
name = "cesu8"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -41,6 +113,16 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "combine"
|
||||||
|
version = "4.6.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.2.9"
|
version = "0.2.9"
|
||||||
|
@ -106,6 +188,46 @@ version = "1.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
|
checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_logger"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
|
||||||
|
dependencies = [
|
||||||
|
"humantime",
|
||||||
|
"is-terminal",
|
||||||
|
"log",
|
||||||
|
"regex",
|
||||||
|
"termcolor",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "equivalent"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
|
||||||
|
dependencies = [
|
||||||
|
"errno-dragonfly",
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno-dragonfly"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fdeflate"
|
name = "fdeflate"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
@ -187,7 +309,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.27",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -267,6 +389,45 @@ version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "humantime"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
|
||||||
|
dependencies = [
|
||||||
|
"equivalent",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is-terminal"
|
||||||
|
version = "0.4.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.9"
|
version = "1.0.9"
|
||||||
|
@ -296,13 +457,33 @@ dependencies = [
|
||||||
"sha2",
|
"sha2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "j4rs_derive"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b3c5dc2ed9c8da7de8d9e3b7eac1d6eeaf8bc7a0521de8c1ff2a4fd1f7b0a78d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "j_game"
|
name = "j_game"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"android-activity",
|
||||||
|
"android_logger",
|
||||||
|
"env_logger",
|
||||||
"gl_matrix",
|
"gl_matrix",
|
||||||
"j4rs",
|
"j4rs",
|
||||||
|
"j4rs_derive",
|
||||||
|
"jni",
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
"miniquad",
|
"miniquad",
|
||||||
|
"ndk",
|
||||||
|
"ndk-context",
|
||||||
"png",
|
"png",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -317,12 +498,35 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jni"
|
||||||
|
version = "0.20.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c"
|
||||||
|
dependencies = [
|
||||||
|
"cesu8",
|
||||||
|
"combine",
|
||||||
|
"jni-sys",
|
||||||
|
"log",
|
||||||
|
"thiserror",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jni-sys"
|
name = "jni-sys"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jobserver"
|
||||||
|
version = "0.1.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
|
@ -345,6 +549,12 @@ dependencies = [
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.19"
|
version = "0.4.19"
|
||||||
|
@ -368,10 +578,11 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniquad"
|
name = "miniquad"
|
||||||
version = "0.3.15"
|
version = "0.4.0-alpha.6"
|
||||||
|
source = "git+https://github.com/jusax23/miniquad?branch=jni#269c55a512e242c39e9598026bf0123b7e3dd813"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"ndk-sys",
|
"ndk-sys 0.2.2",
|
||||||
"objc",
|
"objc",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
@ -386,12 +597,83 @@ dependencies = [
|
||||||
"simd-adler32",
|
"simd-adler32",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ndk"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"jni-sys",
|
||||||
|
"ndk-sys 0.4.1+23.1.7779620",
|
||||||
|
"num_enum 0.5.11",
|
||||||
|
"raw-window-handle",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ndk-context"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ndk-sys"
|
name = "ndk-sys"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121"
|
checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ndk-sys"
|
||||||
|
version = "0.4.1+23.1.7779620"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3"
|
||||||
|
dependencies = [
|
||||||
|
"jni-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_enum"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9"
|
||||||
|
dependencies = [
|
||||||
|
"num_enum_derive 0.5.11",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_enum"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1"
|
||||||
|
dependencies = [
|
||||||
|
"num_enum_derive 0.6.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_enum_derive"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-crate",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_enum_derive"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-crate",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.27",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc"
|
name = "objc"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
@ -401,6 +683,12 @@ dependencies = [
|
||||||
"malloc_buf",
|
"malloc_buf",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "option-ext"
|
name = "option-ext"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -425,7 +713,7 @@ version = "0.17.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11"
|
checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags 1.3.2",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"fdeflate",
|
"fdeflate",
|
||||||
"flate2",
|
"flate2",
|
||||||
|
@ -438,6 +726,16 @@ version = "0.2.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-crate"
|
||||||
|
version = "1.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"toml_edit",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.66"
|
version = "1.0.66"
|
||||||
|
@ -497,13 +795,19 @@ dependencies = [
|
||||||
"rand_core",
|
"rand_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "raw-window-handle"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags 1.3.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -517,6 +821,48 @@ dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.3.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "0.38.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.3.3",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.15"
|
version = "1.0.15"
|
||||||
|
@ -524,23 +870,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "same-file"
|
||||||
version = "1.0.177"
|
version = "1.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "63ba2516aa6bf82e0b19ca8b50019d52df58455d3cf9bdaf6315225fdd0c560a"
|
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.178"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "60363bdd39a7be0266a520dab25fdc9241d2f987b08a01e01f0ec6d06a981348"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.177"
|
version = "1.0.178"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "401797fe7833d72109fedec6bfcbe67c0eed9b99772f26eb8afd261f0abc6fd3"
|
checksum = "f28482318d6641454cb273da158647922d1be6b5a2fcc6165cd89ebdd7ed576b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.27",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -580,6 +935,17 @@ dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.109"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.27"
|
version = "2.0.27"
|
||||||
|
@ -591,6 +957,15 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "termcolor"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.44"
|
version = "1.0.44"
|
||||||
|
@ -608,7 +983,24 @@ checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.27",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_datetime"
|
||||||
|
version = "0.6.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_edit"
|
||||||
|
version = "0.19.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"toml_datetime",
|
||||||
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -629,6 +1021,16 @@ version = "0.9.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "walkdir"
|
||||||
|
version = "2.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
|
||||||
|
dependencies = [
|
||||||
|
"same-file",
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.9.0+wasi-snapshot-preview1"
|
version = "0.9.0+wasi-snapshot-preview1"
|
||||||
|
@ -657,6 +1059,15 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-util"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -728,3 +1139,12 @@ name = "windows_x86_64_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winnow"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "25b5872fa2e10bd067ae946f927e726d7d603eaeb6e02fa6a350e0722d2b8c11"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
31
Cargo.toml
31
Cargo.toml
|
@ -2,13 +2,40 @@
|
||||||
name = "j_game"
|
name = "j_game"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
debug = true
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
debug = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gl_matrix = "0.0.2"
|
gl_matrix = "0.0.2"
|
||||||
j4rs = "0.17.0"
|
j4rs = "0.17.0"
|
||||||
miniquad = { path = '../jucraft/miniquad' }
|
j4rs_derive = "0.1.0"
|
||||||
|
miniquad = { git = "https://github.com/jusax23/miniquad", branch = "jni" }
|
||||||
|
#miniquad = { path = '../jucraft/miniquad' }
|
||||||
png = "0.17.9"
|
png = "0.17.9"
|
||||||
serde = "1.0.177"
|
serde = "1.0.177"
|
||||||
|
log = "0.4.14"
|
||||||
|
env_logger = "0.10.0"
|
||||||
|
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
|
jni = "0.20"
|
||||||
|
libc = "0.2"
|
||||||
|
ndk = { version = "0.7", features = ["api-level-23"] }
|
||||||
|
ndk-context = "0.1.1"
|
||||||
|
android_logger = "0.11.0"
|
||||||
|
android-activity = { version = "0.4", features = ["native-activity"] }
|
||||||
|
|
||||||
|
[[package.metadata.android.permission]]
|
||||||
|
name = "android.permission.READ_EXTERNAL_STORAGE"
|
||||||
|
max_sdk_version = 18
|
||||||
|
|
||||||
|
[[package.metadata.android.permission]]
|
||||||
|
name = "android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
|
max_sdk_version = 18
|
||||||
|
|
||||||
|
|
10
assets/models/Kirche.mtl
Normal file
10
assets/models/Kirche.mtl
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Blender MTL File: 'Kirche.blend'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl None
|
||||||
|
Ns 500
|
||||||
|
Ka 0.8 0.8 0.8
|
||||||
|
Kd 0.8 0.8 0.8
|
||||||
|
Ks 0.8 0.8 0.8
|
||||||
|
d 1
|
||||||
|
illum 2
|
File diff suppressed because it is too large
Load diff
|
@ -4,19 +4,25 @@ precision mediump float;
|
||||||
varying vec2 texcoord;
|
varying vec2 texcoord;
|
||||||
varying vec3 v_normal;
|
varying vec3 v_normal;
|
||||||
varying float v_position;
|
varying float v_position;
|
||||||
|
varying vec3 v_cam_normal;
|
||||||
uniform sampler2D u_image0;
|
uniform sampler2D u_image0;
|
||||||
uniform vec2 fog;
|
uniform vec2 fog;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
|
vec3 N = normalize(v_cam_normal);
|
||||||
|
vec3 L = vec3(0.0, 0.0, 1.0);
|
||||||
|
float NdotL = dot(N, L)/ 3.0 + 1.0 + (1.0/3.0);
|
||||||
|
|
||||||
float fogAmount = smoothstep(fog.x, fog.y, v_position);
|
float fogAmount = smoothstep(fog.x, fog.y, v_position);
|
||||||
|
|
||||||
float light = -dot(vec3(0.0, -1.0, 0.0), v_normal) / 3.0 + 1.0 + (1.0/3.0);
|
float light = -dot(vec3(0.1, -1.0, 0.3), v_normal) / 3.0 + 1.0;
|
||||||
|
|
||||||
gl_FragColor =
|
gl_FragColor =
|
||||||
texture2D(u_image0, texcoord)
|
texture2D(u_image0, texcoord)
|
||||||
* vec4(1.0 - fogAmount, 1.0 - fogAmount, 1.0 - fogAmount, 1.0 - fogAmount)
|
* vec4(1.0 - fogAmount, 1.0 - fogAmount, 1.0 - fogAmount, 1.0 - fogAmount)
|
||||||
* vec4(light, light, light, 1.0);
|
* vec4(light, light, light, 1.0)
|
||||||
|
* vec4(NdotL, NdotL, NdotL, 1.0);
|
||||||
if(gl_FragColor.a < 0.0000001)
|
if(gl_FragColor.a < 0.0000001)
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ uniform vec3 wpos;
|
||||||
varying vec2 texcoord;
|
varying vec2 texcoord;
|
||||||
varying vec3 v_normal;
|
varying vec3 v_normal;
|
||||||
varying float v_position;
|
varying float v_position;
|
||||||
|
varying vec3 v_cam_normal;
|
||||||
|
|
||||||
uniform mat4 view;
|
uniform mat4 view;
|
||||||
uniform mat4 proj;
|
uniform mat4 proj;
|
||||||
|
@ -23,8 +24,12 @@ void main() {
|
||||||
texcoord = uv;
|
texcoord = uv;
|
||||||
|
|
||||||
v_normal = normal;
|
v_normal = normal;
|
||||||
|
|
||||||
|
|
||||||
gl_Position = proj * view * drawProj * vec4(pos, 1.0);
|
vec4 space_pos = view * drawProj * vec4(pos, 1.0);
|
||||||
|
|
||||||
v_position = length((view * drawProj * vec4(pos, 1.0)).xyz);
|
gl_Position = proj * space_pos;//* view * drawProj * vec4(pos, 1.0);
|
||||||
|
|
||||||
|
v_position = length(space_pos.xyz);
|
||||||
|
v_cam_normal = mat3(view * drawProj) * normal;
|
||||||
}
|
}
|
BIN
jassets/javaState.jar
Normal file
BIN
jassets/javaState.jar
Normal file
Binary file not shown.
49
src/game.rs
49
src/game.rs
|
@ -1,6 +1,10 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
|
||||||
|
use j4rs::errors::J4RsError;
|
||||||
|
use j4rs::JvmBuilder;
|
||||||
|
use log::warn;
|
||||||
|
|
||||||
use self::bots::*;
|
use self::bots::*;
|
||||||
use self::player::Player;
|
use self::player::Player;
|
||||||
|
|
||||||
|
@ -10,7 +14,7 @@ mod player;
|
||||||
pub struct Game {
|
pub struct Game {
|
||||||
bots: Vec<Bot>,
|
bots: Vec<Bot>,
|
||||||
bot_names: HashMap<String, usize>,
|
bot_names: HashMap<String, usize>,
|
||||||
pub players: Vec<Player>
|
pub players: Vec<Player>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Game {
|
impl Game {
|
||||||
|
@ -18,16 +22,27 @@ impl Game {
|
||||||
let mut out = Self {
|
let mut out = Self {
|
||||||
bots: vec![],
|
bots: vec![],
|
||||||
players: vec![],
|
players: vec![],
|
||||||
bot_names: HashMap::new()
|
bot_names: HashMap::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
out.load_bots(".".to_string());
|
let mut path: String = ".".to_string();
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
{
|
||||||
|
|
||||||
|
path = get_android_path().unwrap();
|
||||||
|
/*if let Ok(p) = get_android_path() {
|
||||||
|
path = p;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//out.load_bots(path);
|
||||||
|
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_bots(&mut self, classpath: String) {
|
pub fn load_bots(&mut self, classpath: String) {
|
||||||
for cl in list_bot_classes() {
|
for cl in list_bot_classes(&classpath) {
|
||||||
let bot = Bot::new(&cl, &classpath);
|
let bot = Bot::new(&cl, &classpath);
|
||||||
if bot.is_ok() {
|
if bot.is_ok() {
|
||||||
let mut bot: Bot = bot.unwrap();
|
let mut bot: Bot = bot.unwrap();
|
||||||
|
@ -36,7 +51,6 @@ impl Game {
|
||||||
println!("Loaded Bot: „{}”", name);
|
println!("Loaded Bot: „{}”", name);
|
||||||
self.bot_names.insert(name, self.bots.len());
|
self.bot_names.insert(name, self.bots.len());
|
||||||
self.bots.push(bot);
|
self.bots.push(bot);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,9 +60,9 @@ impl Game {
|
||||||
self.players.push(Player::new(bot));
|
self.players.push(Player::new(bot));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tick(&mut self){
|
pub fn tick(&mut self) {
|
||||||
for p in self.players.iter_mut(){
|
for p in self.players.iter_mut() {
|
||||||
let state = GameState{
|
let state = GameState {
|
||||||
posX: p.x,
|
posX: p.x,
|
||||||
posY: p.y,
|
posY: p.y,
|
||||||
};
|
};
|
||||||
|
@ -59,3 +73,22 @@ impl Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
fn get_android_path() -> Result<String, J4RsError> {
|
||||||
|
use log::error;
|
||||||
|
|
||||||
|
error!("launch jvm");
|
||||||
|
let jvm = JvmBuilder::new().build()?;
|
||||||
|
/*println!("invoke get getExternalStorageDirectory");
|
||||||
|
let j_file = jvm.invoke_static(
|
||||||
|
"android.os.Environment",
|
||||||
|
"getExternalStorageDirectory",
|
||||||
|
&[],
|
||||||
|
)?;
|
||||||
|
println!("invoke getPath");
|
||||||
|
let j_path = jvm.invoke(&j_file, "getPath", &[])?;
|
||||||
|
println!("to rust");
|
||||||
|
Ok(jvm.to_rust(j_path)?)*/
|
||||||
|
Ok("Some".to_string())
|
||||||
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ impl Bot {
|
||||||
self.jvm.to_rust(result).unwrap()
|
self.jvm.to_rust(result).unwrap()
|
||||||
}
|
}
|
||||||
pub fn tick(&mut self, state: &GameState) -> Controller {
|
pub fn tick(&mut self, state: &GameState) -> Controller {
|
||||||
|
|
||||||
let controller = Controller {
|
let controller = Controller {
|
||||||
dirX: 1.0,
|
dirX: 1.0,
|
||||||
dirY: 0.0,
|
dirY: 0.0,
|
||||||
|
@ -47,7 +46,8 @@ impl Bot {
|
||||||
let j_controller = InvocationArg::new(&controller, "javaState.Controller");
|
let j_controller = InvocationArg::new(&controller, "javaState.Controller");
|
||||||
let j_gamestate = InvocationArg::new(state, "javaState.GameState");
|
let j_gamestate = InvocationArg::new(state, "javaState.GameState");
|
||||||
|
|
||||||
let j_ret_controller = self.jvm
|
let j_ret_controller = self
|
||||||
|
.jvm
|
||||||
.invoke(&self.bot, "executeTurn", &[j_gamestate, j_controller])
|
.invoke(&self.bot, "executeTurn", &[j_gamestate, j_controller])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let controller2: Controller = self.jvm.to_rust(j_ret_controller).unwrap();
|
let controller2: Controller = self.jvm.to_rust(j_ret_controller).unwrap();
|
||||||
|
@ -55,10 +55,10 @@ impl Bot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_bot_classes() -> Vec<String> {
|
pub fn list_bot_classes(base: &String) -> Vec<String> {
|
||||||
let mut out: Vec<String> = vec![];
|
let mut out: Vec<String> = vec![];
|
||||||
|
|
||||||
if let Ok(paths) = fs::read_dir("./bots") {
|
if let Ok(paths) = fs::read_dir(String::from(base) + "/bots") {
|
||||||
for path in paths {
|
for path in paths {
|
||||||
if let Ok(p) = path {
|
if let Ok(p) = path {
|
||||||
if p.path().is_file() {
|
if p.path().is_file() {
|
||||||
|
|
31
src/main.rs
31
src/main.rs
|
@ -10,39 +10,56 @@ use no_stage::NoStage;
|
||||||
use stage::Stage;
|
use stage::Stage;
|
||||||
use tools::parse_arg;
|
use tools::parse_arg;
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
extern crate android_logger;
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
use log::LevelFilter;
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
use android_logger::Config;
|
||||||
|
|
||||||
mod game;
|
mod game;
|
||||||
mod no_stage;
|
mod no_stage;
|
||||||
|
mod render_tools;
|
||||||
mod stage;
|
mod stage;
|
||||||
mod tools;
|
mod tools;
|
||||||
mod render_tools;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
android_logger::init_once(
|
||||||
|
Config::default()
|
||||||
|
.with_tag("rust.j_game"));
|
||||||
let args = parse_arg(env::args().collect());
|
let args = parse_arg(env::args().collect());
|
||||||
let mut game = Game::new();
|
|
||||||
|
|
||||||
game.add_player(0);
|
|
||||||
|
|
||||||
if args.contains_key("n") {
|
if args.contains_key("n") {
|
||||||
|
let mut game = Game::new();
|
||||||
|
//game.add_player(0);
|
||||||
let mut no_stage = NoStage::new(game);
|
let mut no_stage = NoStage::new(game);
|
||||||
no_stage.run();
|
no_stage.run();
|
||||||
} else {
|
} else {
|
||||||
start(
|
start(
|
||||||
conf::Conf {
|
conf::Conf {
|
||||||
window_title: "Jucraft".to_string(),
|
window_title: "jGame".to_string(),
|
||||||
window_height: 900,
|
window_height: 900,
|
||||||
window_width: 900 * 16 / 9,
|
window_width: 900 * 16 / 9,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
move |mut ctx| Box::new(Stage::new(&mut ctx, game)),
|
move || Box::new(Stage::new()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const JNI_VERSION_1_6: jint = 0x00010006;
|
|
||||||
|
/*const JNI_VERSION_1_6: jint = 0x00010006;
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn jni_onload(env: *mut JavaVM, _reserved: jobject) -> jint {
|
pub extern "C" fn jni_onload(env: *mut JavaVM, _reserved: jobject) -> jint {
|
||||||
j4rs::set_java_vm(env);
|
j4rs::set_java_vm(env);
|
||||||
JNI_VERSION_1_6
|
JNI_VERSION_1_6
|
||||||
}
|
}*/
|
|
@ -7,9 +7,9 @@ use super::Vertex;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Graphics {
|
pub struct Graphics {
|
||||||
pub textures: HashMap<String, Texture>,
|
pub textures: HashMap<String, TextureId>,
|
||||||
pub pipelines: HashMap<String, Pipeline>,
|
pub pipelines: HashMap<String, Pipeline>,
|
||||||
pub models: HashMap<String, (Buffer, Buffer, usize)>,
|
pub models: HashMap<String, (BufferId, BufferId, usize)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Graphics {
|
impl Graphics {
|
||||||
|
@ -20,14 +20,18 @@ impl Graphics {
|
||||||
models: HashMap::new(),
|
models: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn load_texture(&mut self, ctx: &mut Context, bytes: &[u8], id: String) -> Texture {
|
pub fn load_texture(
|
||||||
|
&mut self,
|
||||||
|
ctx: &mut Box<dyn RenderingBackend>,
|
||||||
|
bytes: &[u8],
|
||||||
|
id: String,
|
||||||
|
) -> TextureId {
|
||||||
let decoder = png::Decoder::new(bytes);
|
let decoder = png::Decoder::new(bytes);
|
||||||
let mut reader = decoder.read_info().unwrap();
|
let mut reader = decoder.read_info().unwrap();
|
||||||
let mut buf = vec![0; reader.output_buffer_size()];
|
let mut buf = vec![0; reader.output_buffer_size()];
|
||||||
let info = reader.next_frame(&mut buf).unwrap();
|
let info = reader.next_frame(&mut buf).unwrap();
|
||||||
let bytes = &buf[..info.buffer_size()];
|
let bytes = &buf[..info.buffer_size()];
|
||||||
let text = Texture::from_data_and_format(
|
let text = ctx.new_texture_from_data_and_format(
|
||||||
ctx,
|
|
||||||
bytes,
|
bytes,
|
||||||
TextureParams {
|
TextureParams {
|
||||||
format: TextureFormat::RGBA8,
|
format: TextureFormat::RGBA8,
|
||||||
|
@ -49,18 +53,26 @@ impl Graphics {
|
||||||
}
|
}
|
||||||
pub fn add_model(
|
pub fn add_model(
|
||||||
&mut self,
|
&mut self,
|
||||||
ctx: &mut Context,
|
ctx: &mut Box<dyn RenderingBackend>,
|
||||||
vertices: Vec<Vertex>,
|
vertices: Vec<Vertex>,
|
||||||
indices: Vec<i32>,
|
indices: Vec<i32>,
|
||||||
id: String,
|
id: String,
|
||||||
) {
|
) {
|
||||||
let vertex_buffer = Buffer::immutable(ctx, BufferType::VertexBuffer, &vertices);
|
let vertex_buffer = ctx.new_buffer(
|
||||||
let index_buffer = Buffer::immutable(ctx, BufferType::IndexBuffer, &indices);
|
BufferType::VertexBuffer,
|
||||||
|
BufferUsage::Immutable,
|
||||||
|
BufferSource::slice(&vertices),
|
||||||
|
);
|
||||||
|
let index_buffer = ctx.new_buffer(
|
||||||
|
BufferType::IndexBuffer,
|
||||||
|
BufferUsage::Immutable,
|
||||||
|
BufferSource::slice(&indices),
|
||||||
|
);
|
||||||
self.models
|
self.models
|
||||||
.insert(id, (vertex_buffer, index_buffer, indices.len()));
|
.insert(id, (vertex_buffer, index_buffer, indices.len()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_model_obj(&mut self, ctx: &mut Context, txt: String, id: String) {
|
pub fn add_model_obj(&mut self, ctx: &mut Box<dyn RenderingBackend>, txt: String, id: String) {
|
||||||
let mut vertices: Vec<Vertex> = vec![];
|
let mut vertices: Vec<Vertex> = vec![];
|
||||||
let mut indices: Vec<i32> = vec![];
|
let mut indices: Vec<i32> = vec![];
|
||||||
let mut verts: Vec<Vec3> = vec![];
|
let mut verts: Vec<Vec3> = vec![];
|
||||||
|
@ -102,12 +114,7 @@ impl Graphics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//println!("verts: {:?}", vertices);
|
self.add_model(ctx, vertices, indices, id);
|
||||||
//println!("indecies: {:?}", indices);
|
|
||||||
let vertex_buffer = Buffer::immutable(ctx, BufferType::VertexBuffer, &vertices);
|
|
||||||
let index_buffer = Buffer::immutable(ctx, BufferType::IndexBuffer, &indices);
|
|
||||||
self.models
|
|
||||||
.insert(id, (vertex_buffer, index_buffer, indices.len()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
168
src/stage.rs
168
src/stage.rs
|
@ -1,9 +1,14 @@
|
||||||
use gl_matrix::common::{Vec2, Vec3, PI};
|
use gl_matrix::common::{Vec2, Vec3, PI};
|
||||||
use gl_matrix::mat4;
|
use gl_matrix::mat4;
|
||||||
|
use miniquad::window::{
|
||||||
|
screen_size, set_cursor_grab, set_fullscreen, set_window_size, show_keyboard, show_mouse,
|
||||||
|
};
|
||||||
use miniquad::*;
|
use miniquad::*;
|
||||||
|
|
||||||
use crate::game::Game;
|
use crate::game::Game;
|
||||||
|
|
||||||
|
use j4rs::jni_sys::{jint, JavaVM};
|
||||||
|
|
||||||
use crate::render_tools::default_solid_shader;
|
use crate::render_tools::default_solid_shader;
|
||||||
use crate::render_tools::graphics::Graphics;
|
use crate::render_tools::graphics::Graphics;
|
||||||
use crate::tools::Sides;
|
use crate::tools::Sides;
|
||||||
|
@ -14,6 +19,7 @@ pub struct Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Stage {
|
pub struct Stage {
|
||||||
|
ctx: Box<dyn RenderingBackend>,
|
||||||
game: Game,
|
game: Game,
|
||||||
graphics: Graphics,
|
graphics: Graphics,
|
||||||
pipeline: Pipeline,
|
pipeline: Pipeline,
|
||||||
|
@ -21,34 +27,39 @@ pub struct Stage {
|
||||||
mouse_grab: bool,
|
mouse_grab: bool,
|
||||||
fullscreen: bool,
|
fullscreen: bool,
|
||||||
s_move: Sides<bool>,
|
s_move: Sides<bool>,
|
||||||
|
begin_x: f32,
|
||||||
|
begin_y: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stage {
|
impl Stage {
|
||||||
pub fn new(ctx: &mut Context, game: Game) -> Self {
|
pub fn new() -> Self {
|
||||||
|
let mut ctx: Box<dyn RenderingBackend> = window::new_rendering_backend();
|
||||||
let mut graphics = Graphics::new();
|
let mut graphics = Graphics::new();
|
||||||
|
|
||||||
graphics.add_model_obj(
|
graphics.add_model_obj(
|
||||||
ctx,
|
&mut ctx,
|
||||||
String::from(include_str!(concat!("../assets/models/Kirche.obj"))),
|
String::from(include_str!(concat!("../assets/models/Kirche.obj"))),
|
||||||
"test".to_string(),
|
"test".to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
graphics.load_texture(
|
graphics.load_texture(
|
||||||
ctx,
|
&mut ctx,
|
||||||
include_bytes!(concat!("../assets/images/avatar.png")),
|
include_bytes!(concat!("../assets/images/avatar.png")),
|
||||||
"avatar".to_string(),
|
"avatar".to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let shader = Shader::new(
|
let shader = ctx
|
||||||
ctx,
|
.new_shader(
|
||||||
default_solid_shader::VERTEX,
|
ShaderSource {
|
||||||
default_solid_shader::FRAGMENT,
|
glsl_vertex: Some(default_solid_shader::VERTEX),
|
||||||
default_solid_shader::meta(),
|
glsl_fragment: Some(default_solid_shader::FRAGMENT),
|
||||||
)
|
metal_shader: None,
|
||||||
.unwrap();
|
},
|
||||||
|
default_solid_shader::meta(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let pipeline = Pipeline::with_params(
|
let pipeline = ctx.new_pipeline_with_params(
|
||||||
ctx,
|
|
||||||
&[BufferLayout::default()],
|
&[BufferLayout::default()],
|
||||||
&[
|
&[
|
||||||
VertexAttribute::with_buffer("pos", VertexFormat::Float3, 0),
|
VertexAttribute::with_buffer("pos", VertexFormat::Float3, 0),
|
||||||
|
@ -76,6 +87,16 @@ impl Stage {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
{
|
||||||
|
show_keyboard(true);
|
||||||
|
unsafe {
|
||||||
|
j4rs::set_java_vm(miniquad::native::android::VM as *mut JavaVM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut game = Game::new();
|
||||||
|
//game.add_player(0);
|
||||||
Self {
|
Self {
|
||||||
game,
|
game,
|
||||||
graphics,
|
graphics,
|
||||||
|
@ -87,12 +108,15 @@ impl Stage {
|
||||||
s_move: Sides::all(false),
|
s_move: Sides::all(false),
|
||||||
mouse_grab: false,
|
mouse_grab: false,
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
|
ctx,
|
||||||
|
begin_x: 0.,
|
||||||
|
begin_y: 0.,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventHandler for Stage {
|
impl EventHandler for Stage {
|
||||||
fn update(&mut self, ctx: &mut Context) {
|
fn update(&mut self) {
|
||||||
let delta_s = 1. / 60.;
|
let delta_s = 1. / 60.;
|
||||||
|
|
||||||
if self.s_move.top {
|
if self.s_move.top {
|
||||||
|
@ -120,12 +144,13 @@ impl EventHandler for Stage {
|
||||||
self.game.tick();
|
self.game.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(&mut self, ctx: &mut Context) {
|
fn draw(&mut self) {
|
||||||
ctx.begin_default_pass(PassAction::clear_color(0.75, 0.85, 0.8, 1.0));
|
self.ctx
|
||||||
|
.begin_default_pass(PassAction::clear_color(0.75, 0.85, 0.8, 1.0));
|
||||||
|
|
||||||
//render
|
//render
|
||||||
ctx.apply_pipeline(&self.pipeline);
|
self.ctx.apply_pipeline(&self.pipeline);
|
||||||
let (w, h) = ctx.screen_size();
|
let (w, h) = screen_size();
|
||||||
let mut proj_matrix = mat4::create();
|
let mut proj_matrix = mat4::create();
|
||||||
mat4::perspective(
|
mat4::perspective(
|
||||||
&mut proj_matrix,
|
&mut proj_matrix,
|
||||||
|
@ -160,35 +185,46 @@ impl EventHandler for Stage {
|
||||||
);
|
);
|
||||||
mat4::multiply(&mut cammat, &cammat1, &view_matrix);
|
mat4::multiply(&mut cammat, &cammat1, &view_matrix);
|
||||||
|
|
||||||
ctx.apply_uniforms(&default_solid_shader::Uniforms {
|
self.ctx
|
||||||
proj: proj_matrix,
|
.apply_uniforms(UniformsSource::table(&default_solid_shader::Uniforms {
|
||||||
view: cammat,
|
proj: proj_matrix,
|
||||||
fog: [140.0, 160.0],
|
view: cammat,
|
||||||
wpos: [
|
fog: [140.0, 160.0],
|
||||||
self.game.players[0].x as f32,
|
wpos: [
|
||||||
0.,
|
0., //self.game.players[0].x as f32,
|
||||||
self.game.players[0].y as f32,
|
0., 0., //self.game.players[0].y as f32,
|
||||||
],
|
],
|
||||||
});
|
}));
|
||||||
|
|
||||||
ctx.apply_bindings(&Bindings {
|
self.ctx.apply_bindings(&Bindings {
|
||||||
vertex_buffers: vec![self.graphics.models["test"].0].clone(),
|
vertex_buffers: vec![self.graphics.models["test"].0].clone(),
|
||||||
index_buffer: self.graphics.models["test"].1,
|
index_buffer: self.graphics.models["test"].1,
|
||||||
images: vec![self.graphics.textures["avatar"]],
|
images: vec![self.graphics.textures["avatar"]],
|
||||||
});
|
});
|
||||||
ctx.draw(0, self.graphics.models["test"].2 as i32, 1);
|
self.ctx.draw(0, self.graphics.models["test"].2 as i32, 1);
|
||||||
|
|
||||||
ctx.end_render_pass();
|
self.ctx.end_render_pass();
|
||||||
ctx.commit_frame();
|
self.ctx.commit_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn key_down_event(
|
fn char_event(&mut self, _character: char, _keymods: KeyMods, _repeat: bool) {
|
||||||
&mut self,
|
if _character == 'h' {
|
||||||
_ctx: &mut Context,
|
self.s_move.top = !self.s_move.top;
|
||||||
keycode: KeyCode,
|
} else if _character == 'n' {
|
||||||
_keymods: KeyMods,
|
self.s_move.bottom = !self.s_move.bottom;
|
||||||
_repeatt: bool,
|
} else if _character == 'w' {
|
||||||
) {
|
self.s_move.front = !self.s_move.front;
|
||||||
|
} else if _character == 'a' {
|
||||||
|
self.s_move.left = !self.s_move.left;
|
||||||
|
} else if _character == 's' {
|
||||||
|
self.s_move.back = !self.s_move.back;
|
||||||
|
} else if _character == 'd' {
|
||||||
|
self.s_move.right = !self.s_move.right;
|
||||||
|
} else if _character == 'k' {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn key_down_event(&mut self, keycode: KeyCode, _keymods: KeyMods, _repeatt: bool) {
|
||||||
if keycode == KeyCode::Space {
|
if keycode == KeyCode::Space {
|
||||||
self.s_move.top = true;
|
self.s_move.top = true;
|
||||||
} else if keycode == KeyCode::LeftShift {
|
} else if keycode == KeyCode::LeftShift {
|
||||||
|
@ -205,25 +241,25 @@ impl EventHandler for Stage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn key_up_event(&mut self, ctx: &mut Context, keycode: KeyCode, _keymods: KeyMods) {
|
fn key_up_event(&mut self, keycode: KeyCode, _keymods: KeyMods) {
|
||||||
if keycode == KeyCode::F11 {
|
if keycode == KeyCode::F11 {
|
||||||
if self.fullscreen {
|
if self.fullscreen {
|
||||||
ctx.set_fullscreen(false);
|
set_fullscreen(false);
|
||||||
ctx.set_window_size(1000, 800);
|
set_window_size(1000, 800);
|
||||||
self.fullscreen = false;
|
self.fullscreen = false;
|
||||||
} else {
|
} else {
|
||||||
ctx.set_fullscreen(true);
|
set_fullscreen(true);
|
||||||
self.fullscreen = true;
|
self.fullscreen = true;
|
||||||
}
|
}
|
||||||
if self.mouse_grab {
|
if self.mouse_grab {
|
||||||
//println!("reloc");
|
//println!("reloc");
|
||||||
ctx.set_cursor_grab(false);
|
set_cursor_grab(false);
|
||||||
ctx.show_mouse(true);
|
show_mouse(true);
|
||||||
self.mouse_grab = false;
|
self.mouse_grab = false;
|
||||||
}
|
}
|
||||||
} else if keycode == KeyCode::Escape {
|
} else if keycode == KeyCode::Escape {
|
||||||
ctx.set_cursor_grab(false);
|
set_cursor_grab(false);
|
||||||
ctx.show_mouse(true);
|
show_mouse(true);
|
||||||
self.mouse_grab = false;
|
self.mouse_grab = false;
|
||||||
} else if keycode == KeyCode::Space {
|
} else if keycode == KeyCode::Space {
|
||||||
self.s_move.top = false;
|
self.s_move.top = false;
|
||||||
|
@ -240,29 +276,23 @@ impl EventHandler for Stage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window_minimized_event(&mut self, ctx: &mut Context) {
|
fn window_minimized_event(&mut self) {
|
||||||
ctx.set_cursor_grab(false);
|
set_cursor_grab(false);
|
||||||
ctx.show_mouse(true);
|
show_mouse(true);
|
||||||
self.mouse_grab = false;
|
self.mouse_grab = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mouse_button_down_event(
|
fn mouse_button_down_event(&mut self, button: MouseButton, _x: f32, _y: f32) {
|
||||||
&mut self,
|
|
||||||
ctx: &mut Context,
|
|
||||||
button: MouseButton,
|
|
||||||
_x: f32,
|
|
||||||
_y: f32,
|
|
||||||
) {
|
|
||||||
if button == MouseButton::Left {
|
if button == MouseButton::Left {
|
||||||
if !self.mouse_grab {
|
if !self.mouse_grab {
|
||||||
ctx.set_cursor_grab(true);
|
set_cursor_grab(true);
|
||||||
ctx.show_mouse(false);
|
show_mouse(false);
|
||||||
self.mouse_grab = true;
|
self.mouse_grab = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn raw_mouse_motion(&mut self, _ctx: &mut Context, x: f32, y: f32) {
|
fn raw_mouse_motion(&mut self, x: f32, y: f32) {
|
||||||
if self.mouse_grab {
|
if self.mouse_grab {
|
||||||
self.player.rot[0] -= y / 10.0;
|
self.player.rot[0] -= y / 10.0;
|
||||||
self.player.rot[1] += x / 10.0;
|
self.player.rot[1] += x / 10.0;
|
||||||
|
@ -280,4 +310,24 @@ impl EventHandler for Stage {
|
||||||
self.player.rot[1] += 360.;
|
self.player.rot[1] += 360.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn touch_event(&mut self, phase: TouchPhase, _id: u64, x: f32, y: f32) {
|
||||||
|
if phase == TouchPhase::Started {
|
||||||
|
if !self.mouse_grab {
|
||||||
|
self.mouse_grab = true;
|
||||||
|
self.begin_x = x;
|
||||||
|
self.begin_y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if phase == TouchPhase::Ended {
|
||||||
|
self.mouse_grab = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if phase == TouchPhase::Moved {
|
||||||
|
self.raw_mouse_motion(self.begin_x - x, self.begin_y - y);
|
||||||
|
self.begin_x = x;
|
||||||
|
self.begin_y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue