aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/draw/ui
diff options
context:
space:
mode:
Diffstat (limited to 'stockton-render/src/draw/ui')
-rw-r--r--stockton-render/src/draw/ui/mod.rs6
-rw-r--r--stockton-render/src/draw/ui/pipeline.rs6
-rw-r--r--stockton-render/src/draw/ui/render.rs30
-rwxr-xr-xstockton-render/src/draw/ui/texture.rs49
4 files changed, 52 insertions, 39 deletions
diff --git a/stockton-render/src/draw/ui/mod.rs b/stockton-render/src/draw/ui/mod.rs
index bcf5f38..4caec7a 100644
--- a/stockton-render/src/draw/ui/mod.rs
+++ b/stockton-render/src/draw/ui/mod.rs
@@ -21,10 +21,10 @@ pub mod pipeline;
pub mod render;
pub mod texture;
-pub use pipeline::UIPipeline;
+pub use pipeline::UiPipeline;
pub use render::do_render;
use stockton_types::Vector2;
-pub use texture::ensure_textures;
+pub use texture::{ensure_textures, UiTextures};
#[derive(Debug)]
-pub struct UIPoint(pub Vector2, pub Vector2, pub Srgba);
+pub struct UiPoint(pub Vector2, pub Vector2, pub Srgba);
diff --git a/stockton-render/src/draw/ui/pipeline.rs b/stockton-render/src/draw/ui/pipeline.rs
index f608173..1261ea7 100644
--- a/stockton-render/src/draw/ui/pipeline.rs
+++ b/stockton-render/src/draw/ui/pipeline.rs
@@ -37,7 +37,7 @@ use crate::error;
use crate::types::*;
/// A complete 2D graphics pipeline and associated resources
-pub struct UIPipeline {
+pub struct UiPipeline {
/// Our main render pass
pub(crate) renderpass: ManuallyDrop<RenderPass>,
@@ -54,7 +54,7 @@ pub struct UIPipeline {
pub(crate) fs_module: ManuallyDrop<ShaderModule>,
}
-impl UIPipeline {
+impl UiPipeline {
pub fn new<T>(
device: &mut Device,
extent: hal::image::Extent,
@@ -271,7 +271,7 @@ impl UIPipeline {
let pipeline = unsafe { device.create_graphics_pipeline(&pipeline_desc, None) }
.map_err(error::CreationError::PipelineError)?;
- Ok(UIPipeline {
+ Ok(UiPipeline {
renderpass: ManuallyDrop::new(renderpass),
pipeline_layout: ManuallyDrop::new(layout),
pipeline: ManuallyDrop::new(pipeline),
diff --git a/stockton-render/src/draw/ui/render.rs b/stockton-render/src/draw/ui/render.rs
index 02135e5..77231b0 100644
--- a/stockton-render/src/draw/ui/render.rs
+++ b/stockton-render/src/draw/ui/render.rs
@@ -15,24 +15,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use crate::draw::texture::TextureStore;
+use crate::draw::texture::TextureRepo;
use arrayvec::ArrayVec;
use hal::prelude::*;
use hal::pso::ShaderStageFlags;
-use super::UIPoint;
+use super::UiPoint;
use crate::draw::draw_buffers::DrawBuffers;
use crate::types::*;
-use crate::UIState;
+use crate::UiState;
use std::convert::TryInto;
use stockton_types::Vector2;
pub fn do_render(
cmd_buffer: &mut CommandBuffer,
pipeline_layout: &PipelineLayout,
- draw_buffers: &mut DrawBuffers<UIPoint>,
- texture_store: &mut TextureStore,
- ui: &mut UIState,
+ draw_buffers: &mut DrawBuffers<UiPoint>,
+ tex_repo: &mut TextureRepo,
+ ui: &mut UiState,
) {
// TODO: Actual UI Rendering
let (_out, paint) = ui.end_frame();
@@ -57,7 +57,7 @@ pub fn do_render(
);
}
for (i, vertex) in tris.vertices.iter().enumerate() {
- draw_buffers.vertex_buffer[i] = UIPoint(
+ draw_buffers.vertex_buffer[i] = UiPoint(
Vector2::new(vertex.pos.x, vertex.pos.y),
Vector2::new(vertex.uv.x, vertex.uv.y),
vertex.color,
@@ -65,13 +65,17 @@ pub fn do_render(
}
// TODO: *Properly* deal with textures
- let mut descriptor_sets: ArrayVec<[_; 1]> = ArrayVec::new();
- descriptor_sets.push(texture_store.get_chunk_descriptor_set(0));
+ if let Some(ds) = tex_repo.attempt_get_descriptor_set(0) {
+ let mut descriptor_sets: ArrayVec<[_; 1]> = ArrayVec::new();
+ descriptor_sets.push(ds);
- unsafe {
- cmd_buffer.bind_graphics_descriptor_sets(pipeline_layout, 0, descriptor_sets, &[]);
- // Call draw
- cmd_buffer.draw_indexed(0..tris.indices.len() as u32, 0, 0..1);
+ unsafe {
+ cmd_buffer.bind_graphics_descriptor_sets(pipeline_layout, 0, descriptor_sets, &[]);
+ // Call draw
+ cmd_buffer.draw_indexed(0..tris.indices.len() as u32, 0, 0..1);
+ }
+ } else {
+ // tex_repo.queue_load(0);
}
}
}
diff --git a/stockton-render/src/draw/ui/texture.rs b/stockton-render/src/draw/ui/texture.rs
index 98688de..439c3d7 100755
--- a/stockton-render/src/draw/ui/texture.rs
+++ b/stockton-render/src/draw/ui/texture.rs
@@ -14,10 +14,25 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use crate::draw::texture::{LoadableImage, TextureStore};
+use crate::draw::texture::{LoadableImage, TextureRepo};
use crate::types::*;
-use crate::UIState;
+use crate::UiState;
use egui::Texture;
+use stockton_levels::{prelude::HasTextures, traits::textures::Texture as LTexture};
+
+pub struct UiTextures;
+
+impl HasTextures for UiTextures {
+ type TexturesIter<'a> = std::slice::Iter<'a, LTexture>;
+
+ fn textures_iter(&self) -> Self::TexturesIter<'_> {
+ (&[]).iter()
+ }
+
+ fn get_texture(&self, _idx: u32) -> Option<&stockton_levels::prelude::textures::Texture> {
+ None
+ }
+}
impl LoadableImage for &Texture {
fn width(&self) -> u32 {
@@ -38,31 +53,25 @@ impl LoadableImage for &Texture {
}
}
}
+
+ unsafe fn copy_into(&self, _ptr: *mut u8, _row_size: usize) {
+ todo!()
+ }
}
pub fn ensure_textures(
- texture_store: &mut TextureStore,
- ui: &mut UIState,
- device: &mut Device,
- adapter: &mut Adapter,
- allocator: &mut DynamicAllocator,
- command_queue: &mut CommandQueue,
- command_pool: &mut CommandPool,
+ _tex_repo: &mut TextureRepo,
+ ui: &mut UiState,
+ _device: &mut Device,
+ _adapter: &mut Adapter,
+ _allocator: &mut DynamicAllocator,
+ _command_queue: &mut CommandQueue,
+ _command_pool: &mut CommandPool,
) {
let tex = ui.ctx.texture();
if tex.version != ui.last_tex_ver {
- texture_store
- .put_texture(
- 0,
- &*tex,
- device,
- adapter,
- allocator,
- command_queue,
- command_pool,
- )
- .unwrap(); // TODO
+ // tex_repo.force_queue_load(0).unwrap(); // TODO
ui.last_tex_ver = tex.version;
}
}