Updated examples

This commit is contained in:
Joshua Barretto 2020-04-23 17:52:26 +01:00
parent 7a11da1540
commit 0a892e488a
8 changed files with 138 additions and 43 deletions

134
Cargo.lock generated
View File

@ -2589,17 +2589,23 @@ dependencies = [
[[package]]
name = "minifb"
version = "0.14.0"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799c20458eb0dd69f48cea5014afe736b363818c86d7ca61dbb56e1c0585014c"
checksum = "b18d2987dac6afdd7f6d81101a3b422b7da3e6799d7f11863ad006d8ccd562b2"
dependencies = [
"cast",
"cc",
"orbclient",
"raw-window-handle",
"tempfile",
"time",
"wayland-client 0.25.0",
"wayland-cursor",
"wayland-protocols 0.25.0",
"winapi 0.3.8",
"x11-dl",
"xkb",
"xkbcommon-sys",
]
[[package]]
@ -2728,6 +2734,19 @@ dependencies = [
"void",
]
[[package]]
name = "nix"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
dependencies = [
"bitflags",
"cc",
"cfg-if",
"libc",
"void",
]
[[package]]
name = "nodrop"
version = "0.1.14"
@ -3947,6 +3966,12 @@ dependencies = [
"winapi 0.3.8",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "scoped_threadpool"
version = "0.1.9"
@ -4406,6 +4431,20 @@ dependencies = [
"remove_dir_all",
]
[[package]]
name = "tempfile"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [
"cfg-if",
"libc",
"rand 0.7.3",
"redox_syscall",
"remove_dir_all",
"winapi 0.3.8",
]
[[package]]
name = "term"
version = "0.5.2"
@ -5217,6 +5256,22 @@ dependencies = [
"wayland-sys 0.23.6",
]
[[package]]
name = "wayland-client"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a42cb608953ec8e132c7f53fde722cca9bfbf8b2071d685dbbb8df2b567fee8b"
dependencies = [
"bitflags",
"downcast-rs",
"libc",
"nix 0.17.0",
"scoped-tls",
"wayland-commons 0.25.0",
"wayland-scanner 0.25.0",
"wayland-sys 0.25.0",
]
[[package]]
name = "wayland-commons"
version = "0.21.13"
@ -5237,6 +5292,28 @@ dependencies = [
"wayland-sys 0.23.6",
]
[[package]]
name = "wayland-commons"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8caa2f106138cf71358c6a9e84468e4406069cec93cbd6dbfce92225fc175932"
dependencies = [
"nix 0.17.0",
"once_cell",
"smallvec 1.2.0",
"wayland-sys 0.25.0",
]
[[package]]
name = "wayland-cursor"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d774f69a6a4a9eac6d1a29cea45a4750ee7f997520421b2068f099a11b4cbba"
dependencies = [
"wayland-client 0.25.0",
"wayland-sys 0.25.0",
]
[[package]]
name = "wayland-protocols"
version = "0.21.13"
@ -5262,6 +5339,18 @@ dependencies = [
"wayland-scanner 0.23.6",
]
[[package]]
name = "wayland-protocols"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f784a990d5fa6d846fa93eb8d3bb744ff1e6ec60c7f785b0a0ee2f1a1f20bee9"
dependencies = [
"bitflags",
"wayland-client 0.25.0",
"wayland-commons 0.25.0",
"wayland-scanner 0.25.0",
]
[[package]]
name = "wayland-scanner"
version = "0.21.13"
@ -5284,6 +5373,17 @@ dependencies = [
"xml-rs",
]
[[package]]
name = "wayland-scanner"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f45ddc08a8078f3efa96b5f413268cc9c53b30712891de081fbc1d5846fbc736"
dependencies = [
"proc-macro2 1.0.9",
"quote 1.0.3",
"xml-rs",
]
[[package]]
name = "wayland-sys"
version = "0.21.13"
@ -5304,6 +5404,15 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "wayland-sys"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80f9fc64f9045ad5ff491886a9460437655353e8be73c1b3f29f569342553319"
dependencies = [
"dlib",
]
[[package]]
name = "web-sys"
version = "0.3.36"
@ -5467,6 +5576,27 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
[[package]]
name = "xkb"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aec02bc5de902aa579f3d2f2c522edaf40fa42963cbaffe645b058ddcc68fdb2"
dependencies = [
"bitflags",
"libc",
"xkbcommon-sys",
]
[[package]]
name = "xkbcommon-sys"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa434980dca02ebf28795d71e570dbb78316d095a228707efd6117bf8246d78b"
dependencies = [
"libc",
"pkg-config",
]
[[package]]
name = "xml-rs"
version = "0.8.0"

View File

@ -56,7 +56,7 @@ fn main() {
};
scene.camera_mut().set_focus_pos(Vec3::unit_z() * 0.8);
scene.camera_mut().set_distance(1.5);
scene.camera_mut().update(0.0);
scene.camera_mut().update(0.0, 1.0 / 60.0);
scene.maintain(&mut renderer, scene_data);
// Render

View File

@ -29,4 +29,4 @@ ron = "0.5.1"
[dev-dependencies]
pretty_env_logger = "0.3.0"
minifb = "0.14.0"
minifb = "0.16.0"

View File

@ -1,35 +0,0 @@
use rand::thread_rng;
use vek::*;
use veloren_world::sim::Settlement;
const W: usize = 640;
const H: usize = 480;
fn main() {
let mut win =
minifb::Window::new("City Viewer", W, H, minifb::WindowOptions::default()).unwrap();
let settlement = Settlement::generate(&mut thread_rng());
while win.is_open() {
let mut buf = vec![0; W * H];
for i in 0..W {
for j in 0..H {
let pos = Vec2::new(i as f32, j as f32) * 0.002;
let seed = settlement.get_at(pos).map(|b| b.seed).unwrap_or(0);
buf[j * W + i] = u32::from_le_bytes([
(seed >> 0) as u8,
(seed >> 8) as u8,
(seed >> 16) as u8,
(seed >> 24) as u8,
]);
}
}
win.update_with_buffer(&buf).unwrap();
}
}

View File

@ -52,6 +52,6 @@ fn main() {
zoom /= 1.05;
}
win.update_with_buffer(&buf).unwrap();
win.update_with_buffer_size(&buf, W, H).unwrap();
}
}

View File

@ -34,7 +34,7 @@ fn main() {
}
}
win.update_with_buffer(&buf).unwrap();
win.update_with_buffer(&buf, W, H).unwrap();
_time += 1.0 / 60.0;
}

View File

@ -71,6 +71,6 @@ fn main() {
scale -= 6;
}
win.update_with_buffer(&buf).unwrap();
win.update_with_buffer(&buf, W, H).unwrap();
}
}

View File

@ -252,6 +252,6 @@ fn main() {
}
}
win.update_with_buffer(&buf).unwrap();
win.update_with_buffer(&buf, W, H).unwrap();
}
}