aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--README.md9
-rw-r--r--examples/render-quad/src/main.rs25
-rwxr-xr-xexamples/render-quad/textures/example_texturebin0 -> 128311 bytes
-rw-r--r--stockton-render/src/draw/draw_passes/level.rs18
-rw-r--r--stockton-render/src/draw/draw_passes/mod.rs2
-rw-r--r--stockton-render/src/draw/mod.rs2
7 files changed, 35 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index 273cfc3..a7533cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,9 +55,6 @@ GitHub.sublime-settings
# End of https://www.gitignore.io/api/rust,sublimetext,visualstudiocode
-# Game data. Used for testing, but not sure about license yet
-textures/
-
# Intermediate BSP files.
*.srf
*.prt
diff --git a/README.md b/README.md
index d0580db..db2b09b 100644
--- a/README.md
+++ b/README.md
@@ -2,11 +2,7 @@
[![Build Status](https://travis-ci.org/tcmal/stockton.svg?branch=master)](https://travis-ci.org/tcmal/stockton)
-A WIP Quake engine using Vulkan and Rust.
-
-## State
-
-Currently, it can render a BSP file with textures on the filesystem using however many texture arrays are needed. It doesn't properly cull/sort the faces of the BSP file though.
+A WIP Game engine using Vulkan and Rust.
## License
@@ -15,5 +11,4 @@ Code & Assets (including from `rust-bsp`) are licensed under the GNU GPL v3.0, a
Exceptions:
- `rendy-memory` and `rendy-descriptor` are both modified from [here](https://github.com/amethyst/rendy) and are licensed under MIT.
- - `examples/render-quad/data/test1.png` - [Photo by Lisa Fotios from Pexels](https://www.pexels.com/photo/white-petaled-flowers-painting-2224220/)
- - `examples/render-quad/data/test2.png` - [Photo by Elina Sazonova from Pexels](https://www.pexels.com/photo/brown-tabby-cat-on-pink-textile-3971972/) \ No newline at end of file
+ - `textures/example_texture` is from [OpenArena](http://www.openarena.ws/smfnews.php) and is licensed under the GNU GPLv2. \ No newline at end of file
diff --git a/examples/render-quad/src/main.rs b/examples/render-quad/src/main.rs
index 681c2a1..9c3748d 100644
--- a/examples/render-quad/src/main.rs
+++ b/examples/render-quad/src/main.rs
@@ -10,10 +10,13 @@ use anyhow::{Context, Result};
use log::warn;
use std::collections::BTreeMap;
+use std::path::Path;
use std::sync::{Arc, RwLock};
use stockton_levels::parts::data::{Geometry, Vertex};
use stockton_levels::types::Rgba;
-use stockton_render::draw::{ConsDrawPass, LevelDrawPass, UiDrawPass};
+use stockton_render::draw::{
+ texture::resolver::FsResolver, ConsDrawPass, LevelDrawPass, LevelDrawPassConfig, UiDrawPass,
+};
use winit::{event::Event, event_loop::EventLoop, window::WindowBuilder};
use egui::{containers::CentralPanel, Frame};
@@ -150,8 +153,8 @@ fn try_main<'a>() -> Result<()> {
// Load everything into the session
let mut session = Session::new(
- move |resources| {
- resources.insert(map);
+ |resources| {
+ resources.insert(map.clone());
resources.insert(manager);
resources.insert(Timing::default());
resources.insert(Mouse::default());
@@ -188,8 +191,20 @@ fn try_main<'a>() -> Result<()> {
));
// Create the renderer
- let (renderer, tx): (Renderer<Dp<'static>>, _) =
- Renderer::new(&window, &session, (player, ()))?;
+ let (renderer, tx): (Renderer<Dp<'static>>, _) = Renderer::new(
+ &window,
+ &session,
+ (
+ LevelDrawPassConfig {
+ active_camera: player,
+ tex_resolver: FsResolver::new(
+ Path::new("./examples/render-quad/textures"),
+ map.clone(),
+ ),
+ },
+ (),
+ ),
+ )?;
let new_control_flow = renderer.update_control_flow.clone();
// Populate the initial UI state
diff --git a/examples/render-quad/textures/example_texture b/examples/render-quad/textures/example_texture
new file mode 100755
index 0000000..eb4e502
--- /dev/null
+++ b/examples/render-quad/textures/example_texture
Binary files differ
diff --git a/stockton-render/src/draw/draw_passes/level.rs b/stockton-render/src/draw/draw_passes/level.rs
index 9872b8c..682c775 100644
--- a/stockton-render/src/draw/draw_passes/level.rs
+++ b/stockton-render/src/draw/draw_passes/level.rs
@@ -17,7 +17,7 @@ use crate::{
},
queue_negotiator::QueueNegotiator,
target::SwapchainProperties,
- texture::{resolver::FsResolver, TexLoadQueue, TextureLoadConfig, TextureRepo},
+ texture::{resolver::TextureResolver, TexLoadQueue, TextureLoadConfig, TextureRepo},
},
error::{EnvironmentError, LevelError, LockPoisoned},
types::*,
@@ -52,7 +52,6 @@ use std::{
convert::TryInto,
iter::{empty, once},
marker::PhantomData,
- path::Path,
sync::{Arc, RwLock},
};
@@ -264,13 +263,19 @@ where
}
}
-impl<'a, M> IntoDrawPass<LevelDrawPass<'a, M>> for Entity
+pub struct LevelDrawPassConfig<R> {
+ pub active_camera: Entity,
+ pub tex_resolver: R,
+}
+
+impl<'a, M, R> IntoDrawPass<LevelDrawPass<'a, M>> for LevelDrawPassConfig<R>
where
M: for<'b> MinRenderFeatures<'b> + 'static,
+ R: TextureResolver + Send + Sync + 'static,
{
fn init(
self,
- session: &Session,
+ _session: &Session,
adapter: &Adapter,
device_lock: Arc<RwLock<DeviceT>>,
queue_negotiator: &mut QueueNegotiator,
@@ -356,7 +361,6 @@ where
.build()
.context("Error building pipeline")?;
- let map_lock: Arc<RwLock<M>> = session.resources.get::<Arc<RwLock<M>>>().unwrap().clone();
let repo = TextureRepo::new(
device_lock.clone(),
queue_negotiator
@@ -369,7 +373,7 @@ where
.context("Error finding texture queue")?,
adapter,
TextureLoadConfig {
- resolver: FsResolver::new(Path::new("textures"), map_lock),
+ resolver: self.tex_resolver,
filter: Filter::Linear,
wrap_mode: WrapMode::Tile,
},
@@ -434,7 +438,7 @@ where
pipeline,
repo,
draw_buffers,
- active_camera: self,
+ active_camera: self.active_camera,
_d: PhantomData,
framebuffers,
depth_buffers,
diff --git a/stockton-render/src/draw/draw_passes/mod.rs b/stockton-render/src/draw/draw_passes/mod.rs
index b18d50e..8d1d59b 100644
--- a/stockton-render/src/draw/draw_passes/mod.rs
+++ b/stockton-render/src/draw/draw_passes/mod.rs
@@ -13,7 +13,7 @@ mod ui;
pub mod util;
pub use cons::ConsDrawPass;
-pub use level::LevelDrawPass;
+pub use level::{LevelDrawPass, LevelDrawPassConfig};
pub use ui::UiDrawPass;
/// One of several 'passes' that draw on each frame.
diff --git a/stockton-render/src/draw/mod.rs b/stockton-render/src/draw/mod.rs
index b570b12..4ba38cd 100644
--- a/stockton-render/src/draw/mod.rs
+++ b/stockton-render/src/draw/mod.rs
@@ -8,7 +8,7 @@ pub mod camera;
mod context;
pub mod draw_passes;
mod queue_negotiator;
-mod texture;
+pub mod texture;
mod ui;
mod utils;