Code cleanup, use examples folder

This commit is contained in:
Piotr Siuszko 2021-09-12 00:29:20 +02:00
parent 35befda242
commit 9320ed97b6
48 changed files with 34467 additions and 8013 deletions

155
Cargo.lock generated
View File

@ -38,9 +38,9 @@ dependencies = [
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.0.0" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
@ -66,9 +66,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.58" version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -329,13 +329,6 @@ dependencies = [
"tobj", "tobj",
] ]
[[package]]
name = "doppler_example"
version = "0.1.0"
dependencies = [
"doppler",
]
[[package]] [[package]]
name = "downcast-rs" name = "downcast-rs"
version = "1.2.0" version = "1.2.0"
@ -491,11 +484,10 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]] [[package]]
name = "image2" name = "image2"
version = "0.11.3" version = "0.11.4"
source = "git+https://github.com/Leinnan/image2-rs?branch=legacy#e5d4de2a6e8647fb0cb444e09851c125f950e7ff" source = "git+https://github.com/Leinnan/image2-rs?branch=legacy#ed21bc2a18f2e0ec5c7a5d9f9b4fc52e4c7d7d7e"
dependencies = [ dependencies = [
"cc", "cc",
"lazy_static",
"num", "num",
] ]
@ -554,9 +546,9 @@ dependencies = [
[[package]] [[package]]
name = "imgui-winit-support" name = "imgui-winit-support"
version = "0.7.0" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d632440e05c964e8a7f00f2659c4f71c97897d8c38a77a0c2dc1f3fe8d632208" checksum = "22ae881a42852470216c77fba5835b9701815adac24dfaa8d4ebf3a368376756"
dependencies = [ dependencies = [
"imgui", "imgui",
"winit", "winit",
@ -583,11 +575,11 @@ dependencies = [
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.7" version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63312a18f7ea8760cdd0a7c5aac1a619752a246b833545e3e36d1f81f7cd9e66" checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -601,9 +593,9 @@ dependencies = [
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "0.4.7" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]] [[package]]
name = "jni-sys" name = "jni-sys"
@ -641,9 +633,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.94" version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -673,9 +665,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.3" version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176" checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
dependencies = [ dependencies = [
"scopeguard", "scopeguard",
] ]
@ -706,9 +698,9 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.3.4" version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]] [[package]]
name = "memmap2" name = "memmap2"
@ -719,6 +711,21 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "memoffset"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
dependencies = [
"autocfg",
]
[[package]]
name = "minimal-lexical"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c835948974f68e0bd58636fc6c5b1fbff7b297e3046f11b3b3c18bbac012c6d"
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.6.22" version = "0.6.22"
@ -832,23 +839,25 @@ dependencies = [
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.20.0" version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a" checksum = "df8e5e343312e7fbeb2a52139114e9e702991ef9c2aea6817ff2440b35647d56"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cc", "cc",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
"memoffset",
] ]
[[package]] [[package]]
name = "nom" name = "nom"
version = "6.1.2" version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" checksum = "7ffd9d26838a953b4af82cbeb9f1592c6798916983959be223a7124e992742c1"
dependencies = [ dependencies = [
"memchr", "memchr",
"minimal-lexical",
"version_check", "version_check",
] ]
@ -961,9 +970,9 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.7.2" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]] [[package]]
name = "osmesa-sys" name = "osmesa-sys"
@ -985,9 +994,9 @@ dependencies = [
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.11.1" version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [ dependencies = [
"instant", "instant",
"lock_api", "lock_api",
@ -996,14 +1005,14 @@ dependencies = [
[[package]] [[package]]
name = "parking_lot_core" name = "parking_lot_core"
version = "0.8.3" version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"instant", "instant",
"libc", "libc",
"redox_syscall 0.2.7", "redox_syscall 0.2.10",
"smallvec", "smallvec",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -1031,9 +1040,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.26" version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" checksum = "51ef7cd2518ead700af67bf9d1a658d90b6037d77110fd9c0445429d0ba1c6c9"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid",
] ]
@ -1064,9 +1073,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.2.7" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85dd92e586f7355c633911e11f77f3d12f04b1b1bd76a198bd34ae3af8341ef2" checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
dependencies = [ dependencies = [
"bitflags", "bitflags",
] ]
@ -1110,18 +1119,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.125" version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.125" version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1130,9 +1139,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.64" version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" checksum = "a7f9e390c27c3c0ce8bc5d725f6e4d30a29d26659494aa4b17535f7522c5c950"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -1211,9 +1220,9 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.71" version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373" checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1222,18 +1231,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.24" version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.24" version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1297,14 +1306,14 @@ dependencies = [
[[package]] [[package]]
name = "wayland-client" name = "wayland-client"
version = "0.28.5" version = "0.28.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ca44d86554b85cf449f1557edc6cc7da935cc748c8e4bf1c507cbd43bae02c" checksum = "e3ab332350e502f159382201394a78e3cc12d0f04db863429260164ea40e0355"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"downcast-rs", "downcast-rs",
"libc", "libc",
"nix 0.20.0", "nix 0.20.1",
"scoped-tls", "scoped-tls",
"wayland-commons", "wayland-commons",
"wayland-scanner", "wayland-scanner",
@ -1313,11 +1322,11 @@ dependencies = [
[[package]] [[package]]
name = "wayland-commons" name = "wayland-commons"
version = "0.28.5" version = "0.28.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bd75ae380325dbcff2707f0cd9869827ea1d2d6d534cff076858d3f0460fd5a" checksum = "a21817947c7011bbd0a27e11b17b337bfd022e8544b071a2641232047966fbda"
dependencies = [ dependencies = [
"nix 0.20.0", "nix 0.20.1",
"once_cell", "once_cell",
"smallvec", "smallvec",
"wayland-sys", "wayland-sys",
@ -1325,20 +1334,20 @@ dependencies = [
[[package]] [[package]]
name = "wayland-cursor" name = "wayland-cursor"
version = "0.28.5" version = "0.28.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b37e5455ec72f5de555ec39b5c3704036ac07c2ecd50d0bffe02d5fe2d4e65ab" checksum = "be610084edd1586d45e7bdd275fe345c7c1873598caa464c4fb835dee70fa65a"
dependencies = [ dependencies = [
"nix 0.20.0", "nix 0.20.1",
"wayland-client", "wayland-client",
"xcursor", "xcursor",
] ]
[[package]] [[package]]
name = "wayland-egl" name = "wayland-egl"
version = "0.28.5" version = "0.28.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9461a67930ec16da7a4fd8b50e9ffa23f4417240b43ec84008bd1b2c94421c94" checksum = "99ba1ab1e18756b23982d36f08856d521d7df45015f404a2d7c4f0b2d2f66956"
dependencies = [ dependencies = [
"wayland-client", "wayland-client",
"wayland-sys", "wayland-sys",
@ -1346,9 +1355,9 @@ dependencies = [
[[package]] [[package]]
name = "wayland-protocols" name = "wayland-protocols"
version = "0.28.5" version = "0.28.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95df3317872bcf9eec096c864b69aa4769a1d5d6291a5b513f8ba0af0efbd52c" checksum = "286620ea4d803bacf61fa087a4242ee316693099ee5a140796aaba02b29f861f"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"wayland-client", "wayland-client",
@ -1358,9 +1367,9 @@ dependencies = [
[[package]] [[package]]
name = "wayland-scanner" name = "wayland-scanner"
version = "0.28.5" version = "0.28.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "389d680d7bd67512dc9c37f39560224327038deb0f0e8d33f870900441b68720" checksum = "ce923eb2deb61de332d1f356ec7b6bf37094dc5573952e1c8936db03b54c03f1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1369,9 +1378,9 @@ dependencies = [
[[package]] [[package]]
name = "wayland-sys" name = "wayland-sys"
version = "0.28.5" version = "0.28.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2907bd297eef464a95ba9349ea771611771aa285b932526c633dc94d5400a8e2" checksum = "d841fca9aed7febf9bed2e9796c49bf58d4152ceda8ac949ebe00868d8f0feb8"
dependencies = [ dependencies = [
"dlib 0.5.0", "dlib 0.5.0",
"lazy_static", "lazy_static",
@ -1476,9 +1485,9 @@ dependencies = [
[[package]] [[package]]
name = "xcursor" name = "xcursor"
version = "0.3.3" version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a9a231574ae78801646617cefd13bfe94be907c0e4fa979cfd8b770aa3c5d08" checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7"
dependencies = [ dependencies = [
"nom", "nom",
] ]

View File

@ -1,16 +1,28 @@
[package] [package]
name = "doppler_example" name = "doppler"
version = "0.1.0" version = "0.1.0"
authors = ["Piotr <siuszko@zoho.com>"] authors = ["Piotr <mev_lyshkin@protonmail.com>"]
edition = "2018" edition = "2018"
[profile.release]
opt-level = 'z'
panic = 'abort'
lto = true
[profile.dev.package."*"]
opt-level = 2
[dependencies] [dependencies]
doppler = {path="doppler"} gl = "0.14.0"
imgui={version="0.7.0", optional=true}
imgui-winit-support = {version="0.7.0", optional=true}
imgui-opengl-renderer = {version="0.11.0", optional = true}
cgmath = {version="0.18.0", features=["serde"]}
imgui-inspect = {version="0.8.0", optional = true}
imgui-inspect-derive = {version="0.8.0", optional= true}
tobj = "2.0.2"
inline_tweak = "1.0.8"
log = "0.4.11"
simple-logging = "2.0.2"
image2 = { git = "https://github.com/Leinnan/image2-rs", branch="legacy", default-features = false, features=["io"] }
glutin = "0.26.0"
serde = { version = "1.0.117", features = ["derive"] }
serde_json = "1.0.59"
serde_yaml = "0.8"
[features]
default = ["imgui_inspect"]
imgui_inspect = ["imgui","imgui-inspect-derive","imgui-opengl-renderer", "imgui-inspect", "imgui-winit-support"]

1514
doppler/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
[package]
name = "doppler"
version = "0.1.0"
authors = ["Piotr <mev_lyshkin@protonmail.com>"]
edition = "2018"
[dependencies]
gl = "0.14.0"
imgui={version="0.7.0", optional=true}
imgui-winit-support = {version="0.7.0", optional=true}
imgui-opengl-renderer = {version="0.11.0", optional = true}
cgmath = {version="0.18.0", features=["serde"]}
imgui-inspect = {version="0.8.0", optional = true}
imgui-inspect-derive = {version="0.8.0", optional= true}
tobj = "2.0.2"
inline_tweak = "1.0.8"
log = "0.4.11"
simple-logging = "2.0.2"
image2 = { git = "https://github.com/Leinnan/image2-rs", branch="legacy", default-features = false, features=["io"] }
glutin = "0.26.0"
serde = { version = "1.0.117", features = ["derive"] }
serde_json = "1.0.59"
serde_yaml = "0.8"
[features]
default = ["imgui_inspect"]
imgui_inspect = ["imgui","imgui-inspect-derive","imgui-opengl-renderer", "imgui-inspect", "imgui-winit-support"]

View File

@ -1,29 +0,0 @@
#version 330 core
out vec4 FragColor;
in vec2 TexCoords;
uniform float screen_width;
uniform float screen_height;
uniform sampler2D screenTexture;
uniform float pixelWidth = 3.0;
uniform float pixelHeight = 3.0;
void main()
{
vec2 uv = TexCoords.xy;
uv *= 1.0 - uv.yx;
float vig = uv.x*uv.y * 15.0;
vig = pow(vig, 0.3);
float dx = pixelWidth*(1.0/screen_width);
float dy = pixelHeight*(1.0/screen_height);
vec2 coord = vec2(dx*floor(TexCoords.x/dx), dy*floor(TexCoords.y/dy));
vec3 tc = texture(screenTexture, coord).rgb;
float gamma = 2.2;
FragColor = vec4(pow(tc, vec3(1.0/gamma)),1.0) * vig;
}

View File

@ -1,11 +0,0 @@
#version 330 core
layout (location = 0) in vec2 aPos;
layout (location = 1) in vec2 aTexCoords;
out vec2 TexCoords;
void main()
{
TexCoords = aTexCoords;
gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0);
}

View File

@ -1,7 +0,0 @@
#version 330 core
out vec4 FragColor;
void main()
{
FragColor = vec4(1.0); // set alle 4 vector values to 1.0
}

View File

@ -1,11 +0,0 @@
#version 330 core
layout (location = 0) in vec3 aPos;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
}

View File

@ -1,14 +0,0 @@
#version 330 core
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D texture_diffuse1;
void main()
{
vec4 texColor = texture(texture_diffuse1, TexCoords);
if(texColor.a < 0.1)
discard;
FragColor = texColor;
}

View File

@ -1,16 +0,0 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
out vec2 TexCoords;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
TexCoords = aTexCoords;
gl_Position = projection * view * model * vec4(aPos, 1.0);
}

View File

@ -1,150 +0,0 @@
#version 330 core
out vec4 FragColor;
struct Material {
sampler2D diffuse;
sampler2D specular;
float shininess;
};
struct DirLight {
vec3 direction;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
struct PointLight {
vec3 position;
float constant;
float linear;
float quadratic;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
struct SpotLight {
vec3 position;
vec3 direction;
float cutOff;
float outerCutOff;
float constant;
float linear;
float quadratic;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
#define NR_POINT_LIGHTS 4
in vec3 FragPos;
in vec3 Normal;
in vec2 TexCoords;
uniform vec3 viewPos;
uniform DirLight dirLight;
uniform PointLight pointLights[NR_POINT_LIGHTS];
uniform SpotLight spotLight;
uniform Material material;
// function prototypes
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir);
vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
void main()
{
vec4 texColor = texture(material.diffuse, TexCoords);
if(texColor.a < 0.1)
discard;
// properties
vec3 norm = normalize(Normal);
vec3 viewDir = normalize(viewPos - FragPos);
// == =====================================================
// Our lighting is set up in 3 phases: directional, point lights and an optional flashlight
// For each phase, a calculate function is defined that calculates the corresponding color
// per lamp. In the main() function we take all the calculated colors and sum them up for
// this fragment's final color.
// == =====================================================
// phase 1: directional lighting
vec3 result = CalcDirLight(dirLight, norm, viewDir);
// phase 2: point lights
for(int i = 0; i < NR_POINT_LIGHTS; i++)
result += CalcPointLight(pointLights[i], norm, FragPos, viewDir);
// phase 3: spot light
//result += CalcSpotLight(spotLight, norm, FragPos, viewDir);
FragColor = vec4(result, 1.0);
}
// calculates the color when using a directional light.
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir)
{
vec3 lightDir = normalize(-light.direction);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// combine results
vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords));
vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords));
vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords));
return (ambient + diffuse + specular);
}
// calculates the color when using a point light.
vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir)
{
vec3 lightDir = normalize(light.position - fragPos);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// attenuation
float distance = length(light.position - fragPos);
float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
// combine results
vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords));
vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords));
vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords));
ambient *= attenuation;
diffuse *= attenuation;
specular *= attenuation;
return (ambient + diffuse + specular);
}
// calculates the color when using a spot light.
vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir)
{
vec3 lightDir = normalize(light.position - fragPos);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// attenuation
float distance = length(light.position - fragPos);
float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
// spotlight intensity
float theta = dot(lightDir, normalize(-light.direction));
float epsilon = light.cutOff - light.outerCutOff;
float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0, 1.0);
// combine results
vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords));
vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords));
vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords));
ambient *= attenuation * intensity;
diffuse *= attenuation * intensity;
specular *= attenuation * intensity;
return (ambient + diffuse + specular);
}

View File

@ -1,30 +0,0 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
#define PRECISION 0.01
#define MIN_DIST 20.0
out vec3 FragPos;
out vec3 Normal;
out vec2 TexCoords;
uniform mat4 model;
uniform mat4 view;
uniform vec3 viewPos;
uniform mat4 projection;
void main()
{
FragPos = vec3(model * vec4(aPos, 1.0));
Normal = mat3(transpose(inverse(model))) * aNormal;
TexCoords = aTexCoords;
gl_Position = projection * view * vec4(FragPos, 1.0);
if(distance(viewPos, gl_Position.xyz) > MIN_DIST){
gl_Position.xyz = gl_Position.xyz - mod(gl_Position.xyz, PRECISION);
}
}

View File

@ -1,11 +0,0 @@
#version 330 core
out vec4 FragColor;
in vec3 TexCoords;
uniform samplerCube skybox;
void main()
{
FragColor = texture(skybox, TexCoords);
}

View File

@ -1,14 +0,0 @@
#version 330 core
layout (location = 0) in vec3 aPos;
out vec3 TexCoords;
uniform mat4 projection;
uniform mat4 view;
void main()
{
TexCoords = aPos;
vec4 pos = projection * view * vec4(aPos, 1.0);
gl_Position = pos.xyww;
}

View File

@ -1,15 +1,11 @@
use doppler::assets_cache::AssetsCache; use doppler::assets_cache::AssetsCache;
use doppler::camera::*; use doppler::camera::*;
use doppler::client::Client; use doppler::client::Client;
use doppler::components::{ModelComponent, Transform}; use doppler::components::Transform;
use doppler::consts;
use doppler::glutin::event::{ElementState, VirtualKeyCode}; use doppler::glutin::event::{ElementState, VirtualKeyCode};
use doppler::imgui::*; use doppler::imgui::*;
use doppler::light::*; use doppler::light::*;
use doppler::map::*; use doppler::map::*;
use doppler::math::prelude::*;
use doppler::math::{perspective, vec3, Deg, Matrix4, Point3};
use doppler::sky::Sky;
pub struct ExampleClient { pub struct ExampleClient {
map: Map, map: Map,
@ -65,7 +61,6 @@ impl Client for ExampleClient {
fn load_assets(&mut self, cache: &mut AssetsCache) { fn load_assets(&mut self, cache: &mut AssetsCache) {
cache.load_all_from_file("resources/test_objects.txt"); cache.load_all_from_file("resources/test_objects.txt");
self.map = MapSave::load("resources/test_map.yaml", cache); self.map = MapSave::load("resources/test_map.yaml", cache);
MapSave::save(&self.map, "test");
} }
unsafe fn draw(&mut self) { unsafe fn draw(&mut self) {
@ -102,8 +97,6 @@ impl Client for ExampleClient {
} }
{ {
use doppler::imgui_inspect;
if self.show_camera_info { if self.show_camera_info {
Window::new(im_str!("CameraInfo")) Window::new(im_str!("CameraInfo"))
.size([260.0, 430.0], Condition::Always) .size([260.0, 430.0], Condition::Always)
@ -205,3 +198,7 @@ impl Client for ExampleClient {
self.map.camera.process_mouse_movement(x, y, true); self.map.camera.process_mouse_movement(x, y, true);
} }
} }
pub fn main() {
doppler::engine::Engine::default().run::<ExampleClient>();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Default_OBJ
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd foliage.png

View File

@ -0,0 +1,762 @@
# Blender v2.83.0 OBJ File: ''
# www.blender.org
mtllib grass.mtl
o grass
v 1.666654 1.745757 0.000055
v -1.666686 1.745757 0.000055
v -1.666686 -0.254243 0.000055
v 1.666654 -0.254243 0.000055
v 4.999994 1.745757 0.000055
v 4.999994 -0.254243 0.000055
v -5.000006 -0.254243 0.000055
v -5.000006 1.745757 0.000055
v 1.666654 1.745757 0.000055
v -1.666686 1.745757 0.000055
v -1.666686 -0.254243 0.000055
v 1.666654 -0.254243 0.000055
v 4.999994 1.745757 0.000055
v 4.999994 -0.254243 0.000055
v -5.000006 -0.254243 0.000055
v -5.000006 1.745757 0.000055
v 1.666654 1.745757 0.000055
v -1.666686 1.745757 0.000055
v -1.666686 -0.254243 0.000055
v 1.666654 -0.254243 0.000055
v 4.999994 1.745757 0.000055
v 4.999994 -0.254243 0.000055
v -5.000006 -0.254243 0.000055
v -5.000006 1.745757 0.000055
v 0.999994 -0.254243 0.000035
v 0.999994 1.745757 0.000035
v -1.000006 1.745757 0.000035
v -1.000006 -0.254243 0.000035
v 0.999994 -0.254243 0.000035
v 0.999994 1.745757 0.000035
v -1.000006 1.745757 0.000035
v -1.000006 -0.254243 0.000035
v 0.999994 -0.254243 0.000035
v 0.999994 1.745757 0.000035
v -1.000006 1.745757 0.000035
v -1.000006 -0.254243 0.000035
v 0.999994 -0.254243 0.000035
v 0.999994 1.745757 0.000035
v -1.000006 1.745757 0.000035
v -1.000006 -0.254243 0.000035
v -0.499638 1.745757 0.486116
v -3.246300 1.745757 -1.402534
v -3.246300 -0.254243 -1.402535
v -0.499638 -0.254243 0.486116
v 2.247024 1.745757 2.374767
v 2.247024 -0.254243 2.374767
v -5.992946 -0.254242 -3.291174
v -5.992946 1.745757 -3.291174
v -0.499638 1.745757 0.486116
v -3.246300 1.745757 -1.402534
v -3.246300 -0.254243 -1.402535
v -0.499638 -0.254243 0.486116
v 2.247024 1.745757 2.374767
v 2.247024 -0.254243 2.374767
v -5.992946 -0.254242 -3.291174
v -5.992946 1.745757 -3.291174
v -0.499638 1.745757 0.486116
v -3.246300 1.745757 -1.402534
v -3.246300 -0.254243 -1.402535
v -0.499638 -0.254243 0.486116
v 2.247024 1.745757 2.374767
v 2.247024 -0.254243 2.374767
v -5.992946 -0.254242 -3.291174
v -5.992946 1.745757 -3.291174
v -1.048952 -0.254243 0.108374
v -1.048953 1.745757 0.108374
v -2.696947 1.745757 -1.024814
v -2.696947 -0.254243 -1.024814
v -1.048952 -0.254243 0.108374
v -1.048953 1.745757 0.108374
v -2.696947 1.745757 -1.024814
v -2.696947 -0.254243 -1.024814
v -1.048952 -0.254243 0.108374
v -1.048953 1.745757 0.108374
v -2.696947 1.745757 -1.024814
v -2.696947 -0.254243 -1.024814
v -1.048952 -0.254243 0.108374
v -1.048953 1.745757 0.108374
v -2.696947 1.745757 -1.024814
v -2.696947 -0.254243 -1.024814
v 1.491788 1.745757 1.192182
v 0.700645 1.745757 -2.045912
v 0.700645 -0.254243 -2.045911
v 1.491789 -0.254243 1.192182
v 2.282932 1.745756 4.430275
v 2.282932 -0.254244 4.430275
v -0.090494 -0.254242 -5.283986
v -0.090494 1.745758 -5.283985
v 1.491788 1.745757 1.192182
v 0.700645 1.745757 -2.045912
v 0.700645 -0.254243 -2.045911
v 1.491789 -0.254243 1.192182
v 2.282932 1.745756 4.430275
v 2.282932 -0.254244 4.430275
v -0.090494 -0.254242 -5.283986
v -0.090494 1.745758 -5.283985
v 1.491788 1.745757 1.192182
v 0.700645 1.745757 -2.045912
v 0.700645 -0.254243 -2.045911
v 1.491789 -0.254243 1.192182
v 2.282932 1.745756 4.430275
v 2.282932 -0.254244 4.430275
v -0.090494 -0.254242 -5.283986
v -0.090494 1.745758 -5.283985
v 1.333582 -0.254243 0.544566
v 1.333581 1.745757 0.544566
v 0.858896 1.745757 -1.398286
v 0.858896 -0.254243 -1.398286
v 1.333582 -0.254243 0.544566
v 1.333581 1.745757 0.544566
v 0.858896 1.745757 -1.398286
v 0.858896 -0.254243 -1.398286
v 1.333582 -0.254243 0.544566
v 1.333581 1.745757 0.544566
v 0.858896 1.745757 -1.398286
v 0.858896 -0.254243 -1.398286
v 1.333582 -0.254243 0.544566
v 1.333581 1.745757 0.544566
v 0.858896 1.745757 -1.398286
v 0.858896 -0.254243 -1.398286
v -0.493205 1.675185 -2.800463
v -3.210898 1.549805 -0.874435
v -2.582099 -0.183660 -0.100023
v 0.135593 -0.058280 -2.026051
v 2.224487 1.800565 -4.726490
v 2.853286 0.067102 -3.952078
v -5.299776 -0.309039 1.825994
v -5.928575 1.424425 1.051581
v -0.493205 1.675185 -2.800463
v -3.210898 1.549805 -0.874435
v -2.582099 -0.183660 -0.100023
v 0.135593 -0.058280 -2.026051
v 2.224487 1.800565 -4.726490
v 2.853286 0.067102 -3.952078
v -5.299776 -0.309039 1.825994
v -5.928575 1.424425 1.051581
v -0.493205 1.675185 -2.800463
v -3.210898 1.549805 -0.874435
v -2.582099 -0.183660 -0.100023
v 0.135593 -0.058280 -2.026051
v 2.224487 1.800565 -4.726490
v 2.853286 0.067102 -3.952078
v -5.299776 -0.309039 1.825994
v -5.928575 1.424425 1.051581
v -0.407948 -0.083365 -1.640864
v -1.036747 1.650099 -2.415277
v -2.667359 1.574871 -1.259662
v -2.038561 -0.158593 -0.485250
v -0.407948 -0.083365 -1.640864
v -1.036747 1.650099 -2.415277
v -2.667359 1.574871 -1.259662
v -2.038561 -0.158593 -0.485250
v -0.407948 -0.083365 -1.640864
v -1.036747 1.650099 -2.415277
v -2.667359 1.574871 -1.259662
v -2.038561 -0.158593 -0.485250
v -0.407948 -0.083365 -1.640864
v -1.036747 1.650099 -2.415277
v -2.667359 1.574871 -1.259662
v -2.038561 -0.158593 -0.485250
v -0.514581 1.409819 -2.577216
v 0.117084 1.440839 0.200420
v 0.111239 -0.559012 0.224084
v -0.520425 -0.590034 -2.553552
v -1.146245 1.378797 -5.354854
v -1.152091 -0.621054 -5.331190
v 0.742900 -0.527991 3.001705
v 0.748746 1.471861 2.978041
v -0.514581 1.409819 -2.577216
v 0.117084 1.440839 0.200420
v 0.111239 -0.559012 0.224084
v -0.520425 -0.590034 -2.553552
v -1.146245 1.378797 -5.354854
v -1.152091 -0.621054 -5.331190
v 0.742900 -0.527991 3.001705
v 0.748746 1.471861 2.978041
v -0.514581 1.409819 -2.577216
v 0.117084 1.440839 0.200420
v 0.111239 -0.559012 0.224084
v -0.520425 -0.590034 -2.553552
v -1.146245 1.378797 -5.354854
v -1.152091 -0.621054 -5.331190
v 0.742900 -0.527991 3.001705
v 0.748746 1.471861 2.978041
v -0.394111 -0.583829 -1.998028
v -0.388266 1.416022 -2.021692
v -0.009268 1.434635 -0.355113
v -0.015112 -0.565216 -0.331449
v -0.394111 -0.583829 -1.998028
v -0.388266 1.416022 -2.021692
v -0.009268 1.434635 -0.355113
v -0.015112 -0.565216 -0.331449
v -0.394111 -0.583829 -1.998028
v -0.388266 1.416022 -2.021692
v -0.009268 1.434635 -0.355113
v -0.015112 -0.565216 -0.331449
v -0.394111 -0.583829 -1.998028
v -0.388266 1.416022 -2.021692
v -0.009268 1.434635 -0.355113
v -0.015112 -0.565216 -0.331449
v 0.300983 1.427704 -0.864156
v -0.752411 1.462100 1.782428
v -0.758256 -0.537751 1.806092
v 0.295138 -0.572147 -0.840492
v 1.354377 1.393310 -3.510741
v 1.348532 -0.606541 -3.487076
v -1.811643 -0.503357 4.452661
v -1.805799 1.496494 4.428998
v 0.300983 1.427704 -0.864156
v -0.752411 1.462100 1.782428
v -0.758256 -0.537751 1.806092
v 0.295138 -0.572147 -0.840492
v 1.354377 1.393310 -3.510741
v 1.348532 -0.606541 -3.487076
v -1.811643 -0.503357 4.452661
v -1.805799 1.496494 4.428998
v 0.300983 1.427704 -0.864156
v -0.752411 1.462100 1.782428
v -0.758256 -0.537751 1.806092
v 0.295138 -0.572147 -0.840492
v 1.354377 1.393310 -3.510741
v 1.348532 -0.606541 -3.487076
v -1.811643 -0.503357 4.452661
v -1.805799 1.496494 4.428998
v 0.084446 -0.565268 -0.311188
v 0.090291 1.434584 -0.334852
v -0.541744 1.455221 1.253095
v -0.547589 -0.544630 1.276760
v 0.084446 -0.565268 -0.311188
v 0.090291 1.434584 -0.334852
v -0.541744 1.455221 1.253095
v -0.547589 -0.544630 1.276760
v 0.084446 -0.565268 -0.311188
v 0.090291 1.434584 -0.334852
v -0.541744 1.455221 1.253095
v -0.547589 -0.544630 1.276760
v 0.084446 -0.565268 -0.311188
v 0.090291 1.434584 -0.334852
v -0.541744 1.455221 1.253095
v -0.547589 -0.544630 1.276760
v 0.512000 1.405869 -2.657360
v -2.036504 1.428377 -1.384627
v -2.042348 -0.571474 -1.360963
v 0.506155 -0.593982 -2.633697
v 3.060504 1.383362 -3.930094
v 3.054659 -0.616489 -3.906430
v -4.590837 -0.548966 -0.088237
v -4.584992 1.450886 -0.111901
v 0.512000 1.405869 -2.657360
v -2.036504 1.428377 -1.384627
v -2.042348 -0.571474 -1.360963
v 0.506155 -0.593982 -2.633697
v 3.060504 1.383362 -3.930094
v 3.054659 -0.616489 -3.906430
v -4.590837 -0.548966 -0.088237
v -4.584992 1.450886 -0.111901
v 0.512000 1.405869 -2.657360
v -2.036504 1.428377 -1.384627
v -2.042348 -0.571474 -1.360963
v 0.506155 -0.593982 -2.633697
v 3.060504 1.383362 -3.930094
v 3.054659 -0.616489 -3.906430
v -4.590837 -0.548966 -0.088237
v -4.584992 1.450886 -0.111901
v -0.003547 -0.589481 -2.379169
v 0.002298 1.410371 -2.402833
v -1.526801 1.423875 -1.639194
v -1.532646 -0.575976 -1.615530
v -0.003547 -0.589481 -2.379169
v 0.002298 1.410371 -2.402833
v -1.526801 1.423875 -1.639194
v -1.532646 -0.575976 -1.615530
v -0.003547 -0.589481 -2.379169
v 0.002298 1.410371 -2.402833
v -1.526801 1.423875 -1.639194
v -1.532646 -0.575976 -1.615530
v -0.003547 -0.589481 -2.379169
v 0.002298 1.410371 -2.402833
v -1.526801 1.423875 -1.639194
v -1.532646 -0.575976 -1.615530
v -2.439273 1.372450 -0.246013
v -0.319607 1.263363 1.655193
v 0.201517 -0.479447 1.005014
v -1.918148 -0.370360 -0.896192
v -4.558938 1.481537 -2.147220
v -4.037813 -0.261272 -2.797400
v 2.321170 -0.588533 2.906209
v 1.800045 1.154275 3.556390
v -2.439273 1.372450 -0.246013
v -0.319607 1.263363 1.655193
v 0.201517 -0.479447 1.005014
v -1.918148 -0.370360 -0.896192
v -4.558938 1.481537 -2.147220
v -4.037813 -0.261272 -2.797400
v 2.321170 -0.588533 2.906209
v 1.800045 1.154275 3.556390
v -2.439273 1.372450 -0.246013
v -0.319607 1.263363 1.655193
v 0.201517 -0.479447 1.005014
v -1.918148 -0.370360 -0.896192
v -4.558938 1.481537 -2.147220
v -4.037813 -0.261272 -2.797400
v 2.321170 -0.588533 2.906209
v 1.800045 1.154275 3.556390
v -1.494231 -0.392187 -0.515945
v -2.015355 1.350623 0.134234
v -0.743558 1.285171 1.274956
v -0.222434 -0.457639 0.624777
v -1.494231 -0.392187 -0.515945
v -2.015355 1.350623 0.134234
v -0.743558 1.285171 1.274956
v -0.222434 -0.457639 0.624777
v -1.494231 -0.392187 -0.515945
v -2.015355 1.350623 0.134234
v -0.743558 1.285171 1.274956
v -0.222434 -0.457639 0.624777
v -1.494231 -0.392187 -0.515945
v -2.015355 1.350623 0.134234
v -0.743558 1.285171 1.274956
v -0.222434 -0.457639 0.624777
vt 0.666700 0.499800
vt 0.333300 0.499800
vt 0.333300 0.748400
vt 0.666700 0.748400
vt 1.000000 0.499800
vt 1.000000 0.748400
vt 0.000000 0.748400
vt 0.000000 0.499800
vt 0.666700 0.750300
vt 0.333300 0.750300
vt 0.333300 0.998900
vt 0.666700 0.998900
vt 1.000000 0.750300
vt 1.000000 0.998900
vt 0.000000 0.998900
vt 0.000000 0.750300
vt 0.666700 0.249900
vt 0.333300 0.249900
vt 0.333300 0.498500
vt 0.666700 0.498500
vt 1.000000 0.249900
vt 1.000000 0.498500
vt 0.000000 0.498500
vt 0.000000 0.249900
vt 0.250700 0.248100
vt 0.250700 0.000000
vt 0.000800 0.000000
vt 0.000800 0.248100
vt 0.496300 0.248100
vt 0.496300 0.000000
vt 0.246400 0.000000
vt 0.246400 0.248100
vt 0.747800 0.248100
vt 0.747800 0.000000
vt 0.497900 0.000000
vt 0.497900 0.248100
vt 0.999600 0.248100
vt 0.999600 0.000000
vt 0.749700 0.000000
vt 0.749700 0.248100
vt 0.666700 0.499800
vt 0.333300 0.499800
vt 0.333300 0.748400
vt 0.666700 0.748400
vt 1.000000 0.499800
vt 1.000000 0.748400
vt 0.000000 0.748400
vt 0.000000 0.499800
vt 0.666700 0.750300
vt 0.333300 0.750300
vt 0.333300 0.998900
vt 0.666700 0.998900
vt 1.000000 0.750300
vt 1.000000 0.998900
vt 0.000000 0.998900
vt 0.000000 0.750300
vt 0.666700 0.249900
vt 0.333300 0.249900
vt 0.333300 0.498500
vt 0.666700 0.498500
vt 1.000000 0.249900
vt 1.000000 0.498500
vt 0.000000 0.498500
vt 0.000000 0.249900
vt 0.250700 0.248100
vt 0.250700 0.000000
vt 0.000800 0.000000
vt 0.000800 0.248100
vt 0.496300 0.248100
vt 0.496300 0.000000
vt 0.246400 0.000000
vt 0.246400 0.248100
vt 0.747800 0.248100
vt 0.747800 0.000000
vt 0.497900 0.000000
vt 0.497900 0.248100
vt 0.999600 0.248100
vt 0.999600 0.000000
vt 0.749700 0.000000
vt 0.749700 0.248100
vt 0.666700 0.499800
vt 0.333300 0.499800
vt 0.333300 0.748400
vt 0.666700 0.748400
vt 1.000000 0.499800
vt 1.000000 0.748400
vt 0.000000 0.748400
vt 0.000000 0.499800
vt 0.666700 0.750300
vt 0.333300 0.750300
vt 0.333300 0.998900
vt 0.666700 0.998900
vt 1.000000 0.750300
vt 1.000000 0.998900
vt 0.000000 0.998900
vt 0.000000 0.750300
vt 0.666700 0.249900
vt 0.333300 0.249900
vt 0.333300 0.498500
vt 0.666700 0.498500
vt 1.000000 0.249900
vt 1.000000 0.498500
vt 0.000000 0.498500
vt 0.000000 0.249900
vt 0.250700 0.248100
vt 0.250700 0.000000
vt 0.000800 0.000000
vt 0.000800 0.248100
vt 0.496300 0.248100
vt 0.496300 0.000000
vt 0.246400 0.000000
vt 0.246400 0.248100
vt 0.747800 0.248100
vt 0.747800 0.000000
vt 0.497900 0.000000
vt 0.497900 0.248100
vt 0.999600 0.248100
vt 0.999600 0.000000
vt 0.749700 0.000000
vt 0.749700 0.248100
vt 0.666700 0.499800
vt 0.333300 0.499800
vt 0.333300 0.748400
vt 0.666700 0.748400
vt 1.000000 0.499800
vt 1.000000 0.748400
vt 0.000000 0.748400
vt 0.000000 0.499800
vt 0.666700 0.750300
vt 0.333300 0.750300
vt 0.333300 0.998900
vt 0.666700 0.998900
vt 1.000000 0.750300
vt 1.000000 0.998900
vt 0.000000 0.998900
vt 0.000000 0.750300
vt 0.666700 0.249900
vt 0.333300 0.249900
vt 0.333300 0.498500
vt 0.666700 0.498500
vt 1.000000 0.249900
vt 1.000000 0.498500
vt 0.000000 0.498500
vt 0.000000 0.249900
vt 0.250700 0.248100
vt 0.250700 0.000000
vt 0.000800 0.000000
vt 0.000800 0.248100
vt 0.496300 0.248100
vt 0.496300 0.000000
vt 0.246400 0.000000
vt 0.246400 0.248100
vt 0.747800 0.248100
vt 0.747800 0.000000
vt 0.497900 0.000000
vt 0.497900 0.248100
vt 0.999600 0.248100
vt 0.999600 0.000000
vt 0.749700 0.000000
vt 0.749700 0.248100
vt 0.666700 0.499800
vt 0.333300 0.499800
vt 0.333300 0.748400
vt 0.666700 0.748400
vt 1.000000 0.499800
vt 1.000000 0.748400
vt 0.000000 0.748400
vt 0.000000 0.499800
vt 0.666700 0.750300
vt 0.333300 0.750300
vt 0.333300 0.998900
vt 0.666700 0.998900
vt 1.000000 0.750300
vt 1.000000 0.998900
vt 0.000000 0.998900
vt 0.000000 0.750300
vt 0.666700 0.249900
vt 0.333300 0.249900
vt 0.333300 0.498500
vt 0.666700 0.498500
vt 1.000000 0.249900
vt 1.000000 0.498500
vt 0.000000 0.498500
vt 0.000000 0.249900
vt 0.250700 0.248100
vt 0.250700 0.000000
vt 0.000800 0.000000
vt 0.000800 0.248100
vt 0.496300 0.248100
vt 0.496300 0.000000
vt 0.246400 0.000000
vt 0.246400 0.248100
vt 0.747800 0.248100
vt 0.747800 0.000000
vt 0.497900 0.000000
vt 0.497900 0.248100
vt 0.999600 0.248100
vt 0.999600 0.000000
vt 0.749700 0.000000
vt 0.749700 0.248100
vt 0.666700 0.499800
vt 0.333300 0.499800
vt 0.333300 0.748400
vt 0.666700 0.748400
vt 1.000000 0.499800
vt 1.000000 0.748400
vt 0.000000 0.748400
vt 0.000000 0.499800
vt 0.666700 0.750300
vt 0.333300 0.750300
vt 0.333300 0.998900
vt 0.666700 0.998900
vt 1.000000 0.750300
vt 1.000000 0.998900
vt 0.000000 0.998900
vt 0.000000 0.750300
vt 0.666700 0.249900
vt 0.333300 0.249900
vt 0.333300 0.498500
vt 0.666700 0.498500
vt 1.000000 0.249900
vt 1.000000 0.498500
vt 0.000000 0.498500
vt 0.000000 0.249900
vt 0.250700 0.248100
vt 0.250700 0.000000
vt 0.000800 0.000000
vt 0.000800 0.248100
vt 0.496300 0.248100
vt 0.496300 0.000000
vt 0.246400 0.000000
vt 0.246400 0.248100
vt 0.747800 0.248100
vt 0.747800 0.000000
vt 0.497900 0.000000
vt 0.497900 0.248100
vt 0.999600 0.248100
vt 0.999600 0.000000
vt 0.749700 0.000000
vt 0.749700 0.248100
vt 0.666700 0.499800
vt 0.333300 0.499800
vt 0.333300 0.748400
vt 0.666700 0.748400
vt 1.000000 0.499800
vt 1.000000 0.748400
vt 0.000000 0.748400
vt 0.000000 0.499800
vt 0.666700 0.750300
vt 0.333300 0.750300
vt 0.333300 0.998900
vt 0.666700 0.998900
vt 1.000000 0.750300
vt 1.000000 0.998900
vt 0.000000 0.998900
vt 0.000000 0.750300
vt 0.666700 0.249900
vt 0.333300 0.249900
vt 0.333300 0.498500
vt 0.666700 0.498500
vt 1.000000 0.249900
vt 1.000000 0.498500
vt 0.000000 0.498500
vt 0.000000 0.249900
vt 0.250700 0.248100
vt 0.250700 0.000000
vt 0.000800 0.000000
vt 0.000800 0.248100
vt 0.496300 0.248100
vt 0.496300 0.000000
vt 0.246400 0.000000
vt 0.246400 0.248100
vt 0.747800 0.248100
vt 0.747800 0.000000
vt 0.497900 0.000000
vt 0.497900 0.248100
vt 0.999600 0.248100
vt 0.999600 0.000000
vt 0.749700 0.000000
vt 0.749700 0.248100
vt 0.666700 0.499800
vt 0.333300 0.499800
vt 0.333300 0.748400
vt 0.666700 0.748400
vt 1.000000 0.499800
vt 1.000000 0.748400
vt 0.000000 0.748400
vt 0.000000 0.499800
vt 0.666700 0.750300
vt 0.333300 0.750300
vt 0.333300 0.998900
vt 0.666700 0.998900
vt 1.000000 0.750300
vt 1.000000 0.998900
vt 0.000000 0.998900
vt 0.000000 0.750300
vt 0.666700 0.249900
vt 0.333300 0.249900
vt 0.333300 0.498500
vt 0.666700 0.498500
vt 1.000000 0.249900
vt 1.000000 0.498500
vt 0.000000 0.498500
vt 0.000000 0.249900
vt 0.250700 0.248100
vt 0.250700 0.000000
vt 0.000800 0.000000
vt 0.000800 0.248100
vt 0.496300 0.248100
vt 0.496300 0.000000
vt 0.246400 0.000000
vt 0.246400 0.248100
vt 0.747800 0.248100
vt 0.747800 0.000000
vt 0.497900 0.000000
vt 0.497900 0.248100
vt 0.999600 0.248100
vt 0.999600 0.000000
vt 0.749700 0.000000
vt 0.749700 0.248100
vn 0.0000 1.0000 0.0000
vn -0.3144 0.8667 -0.3872
vn -0.3145 0.8667 -0.3871
vn 0.0029 0.9999 -0.0119
vn 0.0029 0.9999 -0.0118
vn 0.0031 0.9999 -0.0119
vn 0.0030 0.9999 -0.0119
vn -0.2619 0.9018 0.3437
vn -0.2618 0.9018 0.3437
vn -0.2645 0.9020 0.3414
vn -0.2698 0.9022 0.3366
vn -0.2645 0.9020 0.3413
usemtl Default_OBJ
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/5/1 1/1/1 4/4/1 6/6/1
f 7/7/1 3/3/1 2/2/1 8/8/1
f 9/9/1 10/10/1 11/11/1 12/12/1
f 13/13/1 9/9/1 12/12/1 14/14/1
f 15/15/1 11/11/1 10/10/1 16/16/1
f 17/17/1 18/18/1 19/19/1 20/20/1
f 21/21/1 17/17/1 20/20/1 22/22/1
f 23/23/1 19/19/1 18/18/1 24/24/1
f 25/25/1 26/26/1 27/27/1 28/28/1
f 29/29/1 30/30/1 31/31/1 32/32/1
f 33/33/1 34/34/1 35/35/1 36/36/1
f 37/37/1 38/38/1 39/39/1 40/40/1
f 41/41/1 42/42/1 43/43/1 44/44/1
f 45/45/1 41/41/1 44/44/1 46/46/1
f 47/47/1 43/43/1 42/42/1 48/48/1
f 49/49/1 50/50/1 51/51/1 52/52/1
f 53/53/1 49/49/1 52/52/1 54/54/1
f 55/55/1 51/51/1 50/50/1 56/56/1
f 57/57/1 58/58/1 59/59/1 60/60/1
f 61/61/1 57/57/1 60/60/1 62/62/1
f 63/63/1 59/59/1 58/58/1 64/64/1
f 65/65/1 66/66/1 67/67/1 68/68/1
f 69/69/1 70/70/1 71/71/1 72/72/1
f 73/73/1 74/74/1 75/75/1 76/76/1
f 77/77/1 78/78/1 79/79/1 80/80/1
f 81/81/1 82/82/1 83/83/1 84/84/1
f 85/85/1 81/81/1 84/84/1 86/86/1
f 87/87/1 83/83/1 82/82/1 88/88/1
f 89/89/1 90/90/1 91/91/1 92/92/1
f 93/93/1 89/89/1 92/92/1 94/94/1
f 95/95/1 91/91/1 90/90/1 96/96/1
f 97/97/1 98/98/1 99/99/1 100/100/1
f 101/101/1 97/97/1 100/100/1 102/102/1
f 103/103/1 99/99/1 98/98/1 104/104/1
f 105/105/1 106/106/1 107/107/1 108/108/1
f 109/109/1 110/110/1 111/111/1 112/112/1
f 113/113/1 114/114/1 115/115/1 116/116/1
f 117/117/1 118/118/1 119/119/1 120/120/1
f 121/121/2 122/122/3 123/123/2 124/124/2
f 125/125/2 121/121/2 124/124/2 126/126/2
f 127/127/2 123/123/2 122/122/3 128/128/2
f 129/129/2 130/130/3 131/131/2 132/132/2
f 133/133/2 129/129/2 132/132/2 134/134/2
f 135/135/2 131/131/2 130/130/3 136/136/2
f 137/137/2 138/138/3 139/139/2 140/140/2
f 141/141/2 137/137/2 140/140/2 142/142/2
f 143/143/2 139/139/2 138/138/3 144/144/2
f 145/145/2 146/146/2 147/147/2 148/148/2
f 149/149/2 150/150/2 151/151/2 152/152/2
f 153/153/2 154/154/2 155/155/2 156/156/2
f 157/157/2 158/158/2 159/159/2 160/160/2
f 161/161/4 162/162/4 163/163/5 164/164/5
f 165/165/5 161/161/4 164/164/5 166/166/5
f 167/167/5 163/163/5 162/162/4 168/168/4
f 169/169/4 170/170/4 171/171/5 172/172/5
f 173/173/5 169/169/4 172/172/5 174/174/5
f 175/175/5 171/171/5 170/170/4 176/176/4
f 177/177/4 178/178/4 179/179/5 180/180/5
f 181/181/5 177/177/4 180/180/5 182/182/5
f 183/183/5 179/179/5 178/178/4 184/184/4
f 185/185/5 186/186/5 187/187/4 188/188/5
f 189/189/5 190/190/5 191/191/4 192/192/5
f 193/193/5 194/194/5 195/195/4 196/196/5
f 197/197/5 198/198/5 199/199/4 200/200/5
f 201/201/4 202/202/4 203/203/5 204/204/5
f 205/205/5 201/201/4 204/204/5 206/206/5
f 207/207/5 203/203/5 202/202/4 208/208/4
f 209/209/4 210/210/4 211/211/5 212/212/5
f 213/213/5 209/209/4 212/212/5 214/214/5
f 215/215/5 211/211/5 210/210/4 216/216/4
f 217/217/4 218/218/4 219/219/5 220/220/5
f 221/221/5 217/217/4 220/220/5 222/222/5
f 223/223/5 219/219/5 218/218/4 224/224/4
f 225/225/5 226/226/5 227/227/4 228/228/5
f 229/229/5 230/230/5 231/231/4 232/232/5
f 233/233/5 234/234/5 235/235/4 236/236/5
f 237/237/5 238/238/5 239/239/4 240/240/5
f 241/241/6 242/242/6 243/243/5 244/244/5
f 245/245/5 241/241/6 244/244/5 246/246/5
f 247/247/5 243/243/5 242/242/6 248/248/7
f 249/249/6 250/250/6 251/251/5 252/252/5
f 253/253/5 249/249/6 252/252/5 254/254/5
f 255/255/5 251/251/5 250/250/6 256/256/7
f 257/257/6 258/258/6 259/259/5 260/260/5
f 261/261/5 257/257/6 260/260/5 262/262/5
f 263/263/5 259/259/5 258/258/6 264/264/7
f 265/265/5 266/266/5 267/267/7 268/268/5
f 269/269/5 270/270/5 271/271/7 272/272/5
f 273/273/5 274/274/5 275/275/7 276/276/5
f 277/277/5 278/278/5 279/279/7 280/280/5
f 281/281/8 282/282/8 283/283/9 284/284/9
f 285/285/10 281/281/8 284/284/9 286/286/11
f 287/287/11 283/283/9 282/282/8 288/288/12
f 289/289/8 290/290/8 291/291/9 292/292/9
f 293/293/10 289/289/8 292/292/9 294/294/11
f 295/295/11 291/291/9 290/290/8 296/296/12
f 297/297/8 298/298/8 299/299/9 300/300/9
f 301/301/10 297/297/8 300/300/9 302/302/11
f 303/303/11 299/299/9 298/298/8 304/304/12
f 305/305/11 306/306/10 307/307/12 308/308/11
f 309/309/11 310/310/10 311/311/12 312/312/11
f 313/313/11 314/314/10 315/315/12 316/316/11
f 317/317/11 318/318/10 319/319/12 320/320/11

View File

@ -0,0 +1,13 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl ground_mat
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd ground.png

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl lambert7SG
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.087302 0.087302 0.087302
Ni 1.000000
d 1.000000
illum 2
map_Kd ruins.jpg

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl tree_e
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd tree_e.dds

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,15 +1,15 @@
use crate::mesh::Texture; use crate::mesh::Texture;
use crate::model::Model; use crate::model::Model;
use crate::utils::load_texture_from_dir; use crate::utils::load_texture_from_dir;
use log::{info, error}; use log::{error, info};
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap; use std::collections::HashMap;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
#[derive(Default)] #[derive(Default)]
pub struct AssetsCache { pub struct AssetsCache {
textures: HashMap<u64, Texture>, textures: HashMap<u64, Texture>,
models: HashMap<u64, Model> models: HashMap<u64, Model>,
} }
impl AssetsCache { impl AssetsCache {
@ -55,7 +55,7 @@ impl AssetsCache {
Some(model) => model.clone(), Some(model) => model.clone(),
None => { None => {
self.load_model_ext(path, diff_texture); self.load_model_ext(path, diff_texture);
self.get_model_ext(path,diff_texture) self.get_model_ext(path, diff_texture)
} }
} }
} }
@ -63,7 +63,7 @@ impl AssetsCache {
pub fn get_model_by_hash(&mut self, hash: &u64) -> Option<Model> { pub fn get_model_by_hash(&mut self, hash: &u64) -> Option<Model> {
match self.models.get(hash) { match self.models.get(hash) {
Some(model) => Some(model.clone()), Some(model) => Some(model.clone()),
None => None None => None,
} }
} }

View File

@ -3,13 +3,13 @@
#[cfg(feature = "imgui_inspect")] #[cfg(feature = "imgui_inspect")]
use crate::imgui_helper::*; use crate::imgui_helper::*;
use cgmath; use cgmath;
use serde::{Deserialize, Serialize};
use cgmath::prelude::*; use cgmath::prelude::*;
use cgmath::vec3; use cgmath::vec3;
#[cfg(feature = "imgui_inspect")] #[cfg(feature = "imgui_inspect")]
use imgui; use imgui;
#[cfg(feature = "imgui_inspect")] #[cfg(feature = "imgui_inspect")]
use imgui_inspect_derive::Inspect; use imgui_inspect_derive::Inspect;
use serde::{Deserialize, Serialize};
type Point3 = cgmath::Point3<f32>; type Point3 = cgmath::Point3<f32>;
type Vector3 = cgmath::Vector3<f32>; type Vector3 = cgmath::Vector3<f32>;

View File

@ -9,7 +9,7 @@ use imgui;
use imgui_inspect_derive::Inspect; use imgui_inspect_derive::Inspect;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize,Clone, Copy, Debug)] #[derive(Deserialize, Serialize, Clone, Copy, Debug)]
#[cfg_attr(feature = "imgui_inspect", derive(Inspect))] #[cfg_attr(feature = "imgui_inspect", derive(Inspect))]
pub struct Transform { pub struct Transform {
#[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]

View File

@ -1,7 +1,7 @@
#![allow(dead_code)] #![allow(dead_code)]
// settings // settings
pub const FRAMES_STORED : usize = 30; pub const FRAMES_STORED: usize = 30;
pub const SCR_WIDTH: u32 = 1280; pub const SCR_WIDTH: u32 = 1280;
pub const SCR_HEIGHT: u32 = 720; pub const SCR_HEIGHT: u32 = 720;

View File

@ -7,10 +7,10 @@ use glutin::event::{Event, KeyboardInput, VirtualKeyCode, WindowEvent};
use imgui::Context; use imgui::Context;
#[cfg(feature = "imgui_inspect")] #[cfg(feature = "imgui_inspect")]
use imgui_winit_support::{HiDpiMode, WinitPlatform}; use imgui_winit_support::{HiDpiMode, WinitPlatform};
use std::time::Instant;
use log::info; use log::info;
use log::LevelFilter; use log::LevelFilter;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::time::Instant;
#[derive(Debug)] #[derive(Debug)]
pub struct TimeStep { pub struct TimeStep {
@ -111,7 +111,8 @@ impl Engine {
if utils::path_exists(std::path::Path::new("resources/icon.png")) { if utils::path_exists(std::path::Path::new("resources/icon.png")) {
use image2::image::Image; use image2::image::Image;
use image2::{io, ImagePtr, Rgba}; use image2::{io, ImagePtr, Rgba};
let img: ImagePtr<u8, Rgba> = io::read_u8(std::path::Path::new("resources/icon.png")).unwrap(); let img: ImagePtr<u8, Rgba> =
io::read_u8(std::path::Path::new("resources/icon.png")).unwrap();
let img_data = img.data().to_vec(); let img_data = img.data().to_vec();
let (x, y, _) = img.shape(); let (x, y, _) = img.shape();
let icon = glutin::window::Icon::from_rgba(img_data, x as u32, y as u32); let icon = glutin::window::Icon::from_rgba(img_data, x as u32, y as u32);
@ -334,7 +335,9 @@ impl Engine {
.bg_alpha(0.8) .bg_alpha(0.8)
.save_settings(false) .save_settings(false)
.build(&ui, || { .build(&ui, || {
ui.plot_histogram(im_str!("FPS"), &frames_vec).scale_min(0.0).build(); ui.plot_histogram(im_str!("FPS"), &frames_vec)
.scale_min(0.0)
.build();
ui.text(format!("Current FPS: {:.0}", fps)); ui.text(format!("Current FPS: {:.0}", fps));
ui.separator(); ui.separator();
ui.text(format!("Mouse position: ({:4.1},{:4.1})", last_x, last_y)); ui.text(format!("Mouse position: ({:4.1},{:4.1})", last_x, last_y));

View File

@ -3,10 +3,10 @@ pub extern crate imgui;
pub extern crate log; pub extern crate log;
pub extern crate simple_logging; pub extern crate simple_logging;
pub use serde;
pub use cgmath as math; pub use cgmath as math;
pub use glutin; pub use glutin;
pub use imgui_inspect; pub use imgui_inspect;
pub use serde;
pub mod macros; pub mod macros;
@ -20,9 +20,9 @@ pub mod framebuffer;
#[cfg(feature = "imgui_inspect")] #[cfg(feature = "imgui_inspect")]
pub mod imgui_helper; pub mod imgui_helper;
pub mod light; pub mod light;
pub mod map;
pub mod mesh; pub mod mesh;
pub mod model; pub mod model;
pub mod shader; pub mod shader;
pub mod sky; pub mod sky;
pub mod utils; pub mod utils;
pub mod map;

View File

@ -1,8 +0,0 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
extern crate doppler;
mod example_client;
use crate::example_client::ExampleClient;
pub fn main() {
doppler::engine::Engine::default().run::<ExampleClient>();
}

View File

@ -1,14 +1,12 @@
use crate::assets_cache::AssetsCache; use crate::assets_cache::AssetsCache;
use crate::model::Model;
use crate::components::*;
use crate::shader::Shader;
use crate::sky::Sky;
use crate::light::*;
use crate::consts;
use crate::camera::*; use crate::camera::*;
use serde::{Deserialize, Serialize}; use crate::components::*;
use crate::consts;
use crate::light::*;
use crate::math::{perspective, vec3, Deg, Matrix4, Point3}; use crate::math::{perspective, vec3, Deg, Matrix4, Point3};
use log::{info,error}; use crate::sky::Sky;
use log::{error, info};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct MapObject { pub struct MapObject {
@ -19,28 +17,28 @@ pub struct MapObject {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct MapSave { pub struct MapSave {
pub objects: Vec<MapObject>, pub objects: Vec<MapObject>,
pub camera: Camera pub camera: Camera,
} }
impl MapSave { impl MapSave {
pub fn save(map: &Map, _path: &str) { pub fn save(map: &Map, _path: &str) {
let mut objects = Vec::with_capacity(map.models.len()); let mut objects = Vec::with_capacity(map.models.len());
for m in &map.models { for m in &map.models {
objects.push(MapObject{ objects.push(MapObject {
model_hash: m.hash, model_hash: m.hash,
transform: m.transform transform: m.transform,
}); });
} }
let ms = MapSave { let ms = MapSave {
camera: map.camera.clone(), camera: map.camera.clone(),
objects: objects objects: objects,
}; };
match serde_yaml::to_string(&ms) { match serde_yaml::to_string(&ms) {
Ok(result) => Ok(result) => println!("{}", result),
println!("{}", result), Err(e) => println!("{:?}", e),
Err(e) => println!("{:?}", e)
} }
} }
pub fn load(path: &str, cache: &mut AssetsCache) -> Map { pub fn load(path: &str, cache: &mut AssetsCache) -> Map {
let mut map = Map::default(); let mut map = Map::default();
info!("Loading map from file: {}", path); info!("Loading map from file: {}", path);
@ -48,14 +46,14 @@ impl MapSave {
use std::fs; use std::fs;
let savefile = fs::read_to_string(path); let savefile = fs::read_to_string(path);
if savefile.is_err() { if savefile.is_err() {
error!("Cannot read file {}: {:?}",path, savefile); error!("Cannot read file {}: {:?}", path, savefile);
return map; return map;
} }
let save : Result<MapSave, serde_yaml::Error> = serde_yaml::from_str(&savefile.unwrap()); let save: Result<MapSave, serde_yaml::Error> = serde_yaml::from_str(&savefile.unwrap());
if save.is_err() { if save.is_err() {
error!("Cannot parse file {}: {:?}",path, save); error!("Cannot parse file {}: {:?}", path, save);
return map; return map;
} }

View File

@ -16,7 +16,7 @@ use crate::shader::Shader;
// Depending on how you pass the data to OpenGL, this may be bad. In this case it's not strictly // Depending on how you pass the data to OpenGL, this may be bad. In this case it's not strictly
// necessary though because of the `offset!` macro used below in setupMesh() // necessary though because of the `offset!` macro used below in setupMesh()
#[repr(C)] #[repr(C)]
#[derive(Clone,Debug)] #[derive(Clone, Debug)]
pub struct Vertex { pub struct Vertex {
// position // position
pub position: Vector3<f32>, pub position: Vector3<f32>,
@ -42,7 +42,7 @@ impl Default for Vertex {
} }
} }
#[derive(Clone,Debug)] #[derive(Clone, Debug)]
pub struct Texture { pub struct Texture {
pub id: u32, pub id: u32,
pub type_: String, pub type_: String,
@ -57,7 +57,7 @@ impl Drop for Texture {
} }
} }
#[derive(Clone,Debug)] #[derive(Clone, Debug)]
pub struct Mesh { pub struct Mesh {
/* Mesh Data */ /* Mesh Data */
pub vertices: Vec<Vertex>, pub vertices: Vec<Vertex>,
@ -129,7 +129,7 @@ impl Mesh {
// now set the sampler to the correct texture unit // now set the sampler to the correct texture unit
let sampler = CString::new(format!("{}{}", name, number)).unwrap(); let sampler = CString::new(format!("{}{}", name, number)).unwrap();
gl::Uniform1i( gl::Uniform1i(
gl::GetUniformLocation(shader.ID, sampler.as_ptr()), gl::GetUniformLocation(shader.id, sampler.as_ptr()),
i as i32, i as i32,
); );
// and finally bind the texture // and finally bind the texture

View File

@ -9,7 +9,7 @@ use log::{info, warn};
use std::path::Path; use std::path::Path;
use tobj; use tobj;
#[derive(Clone,Debug)] #[derive(Clone, Debug)]
pub struct Model { pub struct Model {
/* Model Data */ /* Model Data */
pub meshes: Vec<Mesh>, pub meshes: Vec<Mesh>,
@ -19,7 +19,11 @@ pub struct Model {
impl Default for Model { impl Default for Model {
fn default() -> Self { fn default() -> Self {
Model { meshes: Vec::new(), textures_loaded: Vec::new(), directory: "".to_string() } Model {
meshes: Vec::new(),
textures_loaded: Vec::new(),
directory: "".to_string(),
}
} }
} }

View File

@ -14,13 +14,13 @@ use cgmath::{Matrix, Matrix4, Vector2, Vector3};
#[derive(Debug)] #[derive(Debug)]
pub struct Shader { pub struct Shader {
pub ID: u32, pub id: u32,
} }
impl Drop for Shader { impl Drop for Shader {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
gl::DeleteShader(self.ID); gl::DeleteShader(self.id);
} }
} }
} }
@ -39,7 +39,7 @@ impl Default for Shader {
#[allow(dead_code)] #[allow(dead_code)]
impl Shader { impl Shader {
pub fn new(vShaderCode: CString, fShaderCode: CString) -> Shader { pub fn new(vShaderCode: CString, fShaderCode: CString) -> Shader {
let mut shader = Shader { ID: 0 }; let mut shader = Shader { id: 0 };
// 2. compile shaders // 2. compile shaders
unsafe { unsafe {
@ -62,7 +62,7 @@ impl Shader {
// delete the shaders as they're linked into our program now and no longer necessary // delete the shaders as they're linked into our program now and no longer necessary
gl::DeleteShader(vertex); gl::DeleteShader(vertex);
gl::DeleteShader(fragment); gl::DeleteShader(fragment);
shader.ID = ID; shader.id = ID;
} }
shader shader
@ -92,45 +92,45 @@ impl Shader {
/// activate the shader /// activate the shader
/// ------------------------------------------------------------------------ /// ------------------------------------------------------------------------
pub unsafe fn use_program(&self) { pub unsafe fn use_program(&self) {
gl::UseProgram(self.ID) gl::UseProgram(self.id)
} }
/// utility uniform functions /// utility uniform functions
/// ------------------------------------------------------------------------ /// ------------------------------------------------------------------------
pub unsafe fn setBool(&self, name: &CStr, value: bool) { pub unsafe fn setBool(&self, name: &CStr, value: bool) {
gl::Uniform1i(gl::GetUniformLocation(self.ID, name.as_ptr()), value as i32); gl::Uniform1i(gl::GetUniformLocation(self.id, name.as_ptr()), value as i32);
} }
/// ------------------------------------------------------------------------ /// ------------------------------------------------------------------------
pub unsafe fn setInt(&self, name: &CStr, value: i32) { pub unsafe fn setInt(&self, name: &CStr, value: i32) {
gl::Uniform1i(gl::GetUniformLocation(self.ID, name.as_ptr()), value); gl::Uniform1i(gl::GetUniformLocation(self.id, name.as_ptr()), value);
} }
/// ------------------------------------------------------------------------ /// ------------------------------------------------------------------------
pub unsafe fn setFloat(&self, name: &CStr, value: f32) { pub unsafe fn setFloat(&self, name: &CStr, value: f32) {
gl::Uniform1f(gl::GetUniformLocation(self.ID, name.as_ptr()), value); gl::Uniform1f(gl::GetUniformLocation(self.id, name.as_ptr()), value);
} }
/// ------------------------------------------------------------------------ /// ------------------------------------------------------------------------
pub unsafe fn set_vector3(&self, name: &CStr, value: &Vector3<f32>) { pub unsafe fn set_vector3(&self, name: &CStr, value: &Vector3<f32>) {
gl::Uniform3fv( gl::Uniform3fv(
gl::GetUniformLocation(self.ID, name.as_ptr()), gl::GetUniformLocation(self.id, name.as_ptr()),
1, 1,
value.as_ptr(), value.as_ptr(),
); );
} }
pub unsafe fn set_vector2(&self, name: &CStr, value: &Vector2<f32>) { pub unsafe fn set_vector2(&self, name: &CStr, value: &Vector2<f32>) {
gl::Uniform2fv( gl::Uniform2fv(
gl::GetUniformLocation(self.ID, name.as_ptr()), gl::GetUniformLocation(self.id, name.as_ptr()),
1, 1,
value.as_ptr(), value.as_ptr(),
); );
} }
/// ------------------------------------------------------------------------ /// ------------------------------------------------------------------------
pub unsafe fn set_vec3(&self, name: &CStr, x: f32, y: f32, z: f32) { pub unsafe fn set_vec3(&self, name: &CStr, x: f32, y: f32, z: f32) {
gl::Uniform3f(gl::GetUniformLocation(self.ID, name.as_ptr()), x, y, z); gl::Uniform3f(gl::GetUniformLocation(self.id, name.as_ptr()), x, y, z);
} }
/// ------------------------------------------------------------------------ /// ------------------------------------------------------------------------
pub unsafe fn set_mat4(&self, name: &CStr, mat: &Matrix4<f32>) { pub unsafe fn set_mat4(&self, name: &CStr, mat: &Matrix4<f32>) {
gl::UniformMatrix4fv( gl::UniformMatrix4fv(
gl::GetUniformLocation(self.ID, name.as_ptr()), gl::GetUniformLocation(self.id, name.as_ptr()),
1, 1,
gl::FALSE, gl::FALSE,
mat.as_ptr(), mat.as_ptr(),
@ -180,7 +180,7 @@ impl Shader {
/// Only used in 4.9 Geometry shaders - ignore until then (shader.h in original C++) /// Only used in 4.9 Geometry shaders - ignore until then (shader.h in original C++)
pub fn with_geometry_shader(vertexPath: &str, fragmentPath: &str, geometryPath: &str) -> Self { pub fn with_geometry_shader(vertexPath: &str, fragmentPath: &str, geometryPath: &str) -> Self {
let mut shader = Shader { ID: 0 }; let mut shader = Shader { id: 0 };
// 1. retrieve the vertex/fragment source code from filesystem // 1. retrieve the vertex/fragment source code from filesystem
let mut vShaderFile = let mut vShaderFile =
File::open(vertexPath).unwrap_or_else(|_| panic!("Failed to open {}", vertexPath)); File::open(vertexPath).unwrap_or_else(|_| panic!("Failed to open {}", vertexPath));
@ -234,7 +234,7 @@ impl Shader {
gl::DeleteShader(vertex); gl::DeleteShader(vertex);
gl::DeleteShader(fragment); gl::DeleteShader(fragment);
gl::DeleteShader(geometry); gl::DeleteShader(geometry);
shader.ID = ID; shader.id = ID;
} }
shader shader

View File

@ -1,7 +1,7 @@
use gl; use gl;
use image2::image::Image; use image2::image::Image;
use image2::{io, ImagePtr, Rgb, Rgba}; use image2::{io, ImagePtr, Rgb, Rgba};
use log::{info,error}; use log::{error, info};
use std::os::raw::c_void; use std::os::raw::c_void;
pub fn path_exists(path: &std::path::Path) -> bool { pub fn path_exists(path: &std::path::Path) -> bool {
@ -16,7 +16,7 @@ pub unsafe fn load_texture(path: &str, file_format: &str) -> u32 {
gl::GenTextures(1, &mut id); gl::GenTextures(1, &mut id);
let content = io::read_u8(path); let content = io::read_u8(path);
if content.is_err() { if content.is_err() {
error!("Error: {:?}",content.err()); error!("Error: {:?}", content.err());
panic!(); panic!();
} }
let (data, dim, format) = match file_format { let (data, dim, format) = match file_format {