aboutsummaryrefslogtreecommitdiff
path: root/examples/render-bsp/src
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:20 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:20 +0100
commit51168c753286eeee64410ab19dc9f78a4ea479e4 (patch)
treed384093c6fd11b36b189013b663f3500b18ec2a4 /examples/render-bsp/src
parentd076d3a6fd484e298915cd85609ba9706abacc87 (diff)
refactor(all): use new traits-based levels everywhere else.
unfortunately this also starts using an unstable feature - generic_associated_types see rust-lang/rust#44265
Diffstat (limited to 'examples/render-bsp/src')
-rw-r--r--examples/render-bsp/src/main.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/examples/render-bsp/src/main.rs b/examples/render-bsp/src/main.rs
index 7477567..f2310e6 100644
--- a/examples/render-bsp/src/main.rs
+++ b/examples/render-bsp/src/main.rs
@@ -16,7 +16,7 @@
//! Renders ./example.bsp
extern crate stockton_types;
-extern crate stockton_bsp;
+extern crate stockton_levels;
extern crate stockton_render;
extern crate winit;
extern crate simple_logger;
@@ -25,7 +25,7 @@ extern crate image;
use image::load_from_memory;
use std::time::SystemTime;
-use stockton_bsp::BSPFile;
+use stockton_levels::q3::Q3BSPFile;
use stockton_types::{World, Vector3};
use stockton_render::Renderer;
@@ -35,7 +35,7 @@ use winit::{
window::WindowBuilder
};
-const SPEED: f32 = 25.0;
+const SPEED: f32 = 100.0;
#[derive(Debug)]
struct KeyState {
@@ -91,21 +91,22 @@ fn main() {
let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();
let data = include_bytes!("../data/test.bsp").to_vec().into_boxed_slice();
- let bsp = BSPFile::from_buffer(data).unwrap();
+ let bsp = Q3BSPFile::new(&data).unwrap();
- let world = World::new(bsp).unwrap();
+ let world = World::new(bsp);
let mut renderer = Renderer::new(world, &window).unwrap();
+ {
+ renderer.context.add_texture(
+ load_from_memory(include_bytes!("../../render-quad/data/test1.png"))
+ .expect("Couldn't load test texture 1")
+ .into_rgba()).unwrap();
- renderer.context.add_texture(
- load_from_memory(include_bytes!("../../render-quad/data/test1.png"))
- .expect("Couldn't load test texture 1")
- .into_rgba()).unwrap();
-
- renderer.context.add_texture(
- load_from_memory(include_bytes!("../../render-quad/data/test2.png"))
- .expect("Couldn't load test texture 2")
- .into_rgba()).unwrap();
+ renderer.context.add_texture(
+ load_from_memory(include_bytes!("../../render-quad/data/test2.png"))
+ .expect("Couldn't load test texture 2")
+ .into_rgba()).unwrap();
+ }
let mut last_update = SystemTime::now();
let mut key_state = KeyState::new();
@@ -113,7 +114,6 @@ fn main() {
// Keep rendering the world
event_loop.run(move |event, _, flow| {
*flow = ControlFlow::Poll;
-
match event {
Event::WindowEvent {
event,