diff --git a/diagram.drawio b/diagram.drawio
deleted file mode 100644
index e2b9f148..00000000
--- a/diagram.drawio
+++ /dev/null
@@ -1 +0,0 @@
-7Vtbc5s4FP41ntl9SMdC4MtjbafdTtOZzHhnmz4qIGM1gDxCxHZ//R7ZAgwyDmkdC3fXL0FHAsH3nZt0lB6expuPgqyWX3hAo57TDzY9POs5DvLcPvxRkq2W4PFoLwkFC7SsFMzZD6qF+sYwYwFNKwMl55Fkq6rQ50lCfVmRESH4ujpswaPqrCsS6hn7pWDuk4gaw76yQC7zt4Nf2fMXZeFSGl0xycdrQbokAV8fiPBtD08F53J/FW+mNFIA5tDs7/vQ0Fu8m6CJbHODM4nZEGfjLERPaXj3/e7jbHODvP1jnkmU6Y+eZIsFFSCb8kQSllCR9pxBBHNMHkE8CNXV7yLZESO3OeGCZ0lAFWB96F4vmaTzFfFV7xp0HGRLGUfQQnAZkUca3fOUScYTkPlABACHJ89USAZadFcbELMgUDNNSMTCo3e81x3FSM0OdNNNI++o0CYwRcpjKsUWhugb8EgroLbCG6zb61KlnbGWLQ+U2clVmWgzCotnl2oGF1rTXqN1yNC6KUmeSfo33chM0F/j5RyYjauYOSZkyDkC2eDNEHMaEPsUKx/WNbxQ3zpg+ISKTYm/tA9aER87o2TuCcy6Ypp11DqgaoMG2OYQ8VUkrYedP3wer1gEmY3KZ9TXsxWNINL+aR1dI1gg61rpmJb8hSTg9VIDLRpA+qabXMglD3lCottSOqniWY6543ylUfxOpdzqXJRkwA+eAHhi+6D7d41v6gnvvLw52+gn7ltb3TK4US94mhn4Hp4Jn7bI2SQRIZWnBg6Pcy1oRCR7rr7J+XlzL8bPAc50w+RDTgZcHxAFrZIn1dgekvZQZfRbhdDj9J6T08FVcIqHrW0RfJCsUiNoyn6Qx90ABd+Ks0Tu3tCb9LzZq/LiXe49If5TuNOYKY+42M2LF7vfKW+oV4v6TXoHi7+StxMa3eg7b0B9+iPtrVrzoR93r8A4GMIXixQUoU5YMevPc5jHzyuyy5rbdV7yu+c0zGFLw8Rjm4aJTMPc5yDWMwrkvrz8PJpQoPGbZRSOVQsotL6IMa+OTOiCBjC6isiUv6ZhAB8Eie2vWupWUKTL9tJqcw/GhlWcU1PHbTV1ZDWHMjX1ve9ncQaT/0fyqNO2AgEe5TuE28qM3U2qct07IHUmyFphYz8Eu51zPtjczjxlA1eWn14wPc1Zezk97R9XkQvtBfTN6MzjVSY7YiC17eshsm4gZl3u0pteZzOOd31IDasG4rovmMiudU8FAzhVBDu73bTdQ8PYqt38X5797cuzw6rvcYem77lwedZpKmh0pQZUr1J49osUTfsvHanP1gAbWC+aOU3r9Q7VZ3HntMxcZXSwQIu7pmt4cHVJk739Ptx6RWE1M8INK4pubPc5XucWFEeOXCm8PlORqGOb13RGoZYxFcHNHrjmwZlrXa3ZK4HnGtpxx+Oiq+MUVuCQblVW4K5newWOcVu6rRZW8ZFzhMpvziWR9uMMqsUZt60rRKM384VmjvrP073gPk1TLqwjdoPqR1XbhmZv4L0aMmiWB/z3tYbyXyXw7b8=
\ No newline at end of file
diff --git a/notes b/notes
deleted file mode 100644
index a23a0f15..00000000
--- a/notes
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-StorageImage
- General-purpose image in device memory.
-AttachmentImage
- ImageAccess whose purpose is to be used as a framebuffer attachment
-
-
-
-
-Hello!
-
-Any of you guys use the Vulkano library? There is this PersistentDescriptorSetBuilder struct
-which uses this fun chaining dynamic
-
-```
-PersistentDescriptorSet::start(layout, 0)
- .add_sampled_image(sampled_image1).unwrap()
- .add_sampled_image(sampled_image2).unwrap()
- .add_sampled_image(sampled_image3).unwrap()
- .build().unwrap();
-```
-
-But it modifies the return values template values so I can't store it between loops
-
-```
-let mut set_builder = PersistentDescriptorSet::start(layout, 0);
-for image in images {
- set_builder = set_builder.add_sampled_image(image);
-}
-let descriptor_set = set_builder.build().unwrap();
-```
-
-The gist of the error that I get is something like:
-
-```
-expected:
-PersistentDescriptorSetBuilder, ()>
-got:
-PersistentDescriptorSetBuilder, ((), PersistentDescriptorSetImg>>)>
-```
-
-So it's adding tuples of tuples of tuples of tuples of tuples each time I chain a
-.add_sampled_image() call. I really really want to be able to do this dynamically in
-a loop; I've tried this neat iter().fold() thinking that if I didn't explicitly
-overwrite the previous returned value, rust would figure it out. It didn't
-
-```
-let descriptor_set = images.iter().fold(
- PersistentDescriptorSet::start(layout, 0)
- ,|a, &b| a.add_image(b))
- .unwrap()).build().unwrap();
-```
-
-How do I do this dynamically?
\ No newline at end of file
diff --git a/src/canvas/canvas_buffer.rs b/src/canvas/canvas_buffer.rs
index 1dd2b410..0ba14a9b 100644
--- a/src/canvas/canvas_buffer.rs
+++ b/src/canvas/canvas_buffer.rs
@@ -5,9 +5,10 @@ use vulkano::format::{Format, R8Unorm};
use vulkano::sampler::Sampler;
use vulkano::descriptor::DescriptorSet;
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
-use vulkano::buffer::CpuAccessibleBuffer;
+use vulkano::buffer::{CpuAccessibleBuffer, BufferAccess};
use vulkano::pipeline::GraphicsPipelineAbstract;
use crate::canvas::canvas_text::CanvasFontHandle;
+use rusttype::Font;
#[derive(Clone)]
pub struct CanvasTexture {
@@ -52,10 +53,15 @@ impl CanvasImage {
}
#[derive(Clone)]
-pub struct CanvasText {
+pub struct CanvasFont {
+ pub(crate) handle: Arc,
+ pub(crate) buffer: Arc<(dyn BufferAccess + Send + Sync)>, // Font atlas
+ pub(crate) font: Font<'static>,
+ pub(crate) name: String,
+
}
-impl CanvasText {
+impl CanvasFont {
pub fn get_descriptor_set(pipeline: Arc)
-> Box {
let o: Box = Box::new(
diff --git a/src/canvas/canvas_state.rs b/src/canvas/canvas_state.rs
index e240fdb3..997f34d2 100644
--- a/src/canvas/canvas_state.rs
+++ b/src/canvas/canvas_state.rs
@@ -36,6 +36,13 @@ use crate::canvas::shader::text_shader::GlyphInstance;
/// Provides Image and Texture handles for drawing
/// Split out to two drawables?
///
+
+//
+pub trait DrawableTest {
+ fn get_vertices(&self) -> Vec;
+ fn get_handle(&self) -> Vec;
+}
+
pub trait Drawable {
fn get_vertices(&self) -> Vec<(f32, f32, f32)>;
fn get_color(&self) -> (f32, f32, f32, f32);
@@ -68,6 +75,12 @@ pub struct CanvasImageHandle {
pub handle: u32
}
+/// Typed wrapper for a u32 font handle (index id)
+#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
+pub struct CanvasFontHandle {
+ pub handle: u32
+}
+
/// Canvas state is used for storage of texture and image buffers in addition to vertex buffers
/// Canvas state also contains logic for writing the stored buffers to the command_buffer
#[derive(Clone)]
@@ -77,14 +90,13 @@ pub struct CanvasState {
/// Generated during new()
sampler: Arc,
- // hold the image, texture, and shader buffers the same was as we do CompuState
+ // hold the image, texture, and Fonts the same was as we do CompuState
image_buffers: Vec>,
texture_buffers: Vec>,
- shader_buffers: Vec>>,
-
- // Individually hold onto the Fonts
font_buffers: Vec>,
+ shader_buffers: Vec>>,
+
// Hold onto the vertices we get from the Compu and Canvas Frames
// When the run comes around, push the vertices to the GPU
colored_vertex_buffer: Vec>,
diff --git a/src/canvas/canvas_text.rs b/src/canvas/canvas_text.rs
index 492f7b06..6afed02f 100644
--- a/src/canvas/canvas_text.rs
+++ b/src/canvas/canvas_text.rs
@@ -98,140 +98,4 @@ impl CanvasFont {
return self.allocated_font_atlas.clone();
}
- /// postpone this until caching
- pub fn queue_text(&mut self,
- x: f32, y: f32,
- size: f32, color: [f32; 4],
- text: &str) {
- let glyphs: Vec = self.font.layout(text, Scale::uniform(size), point(x, y)).map(|x| x.standalone()).collect();
-// for glyph in &glyphs {
-// self.cache.queue_glyph(0, glyph.clone());
-// }
-// self.texts.push(TextData {
-// glyphs: glyphs.clone(),
-// color: color,
-// });
- }
-
- pub fn draw_text(&mut self,
- command_buffer: AutoCommandBufferBuilder,
- image_num: usize,
- ) -> AutoCommandBufferBuilder {
-
-// let screen_width = 0;
-// let screen_height = 0;
-//
-// let cache_pixel_buffer = &mut self.cache_pixel_buffer;
-// let cache = &mut self.cache;
-//
-// // update texture cache
-// cache.cache_queued(
-// |rect, src_data| {
-// let width = (rect.max.x - rect.min.x) as usize;
-// let height = (rect.max.y - rect.min.y) as usize;
-// let mut dst_index = rect.min.y as usize * CACHE_WIDTH + rect.min.x as usize;
-// let mut src_index = 0;
-//
-// for _ in 0..height {
-// let dst_slice = &mut cache_pixel_buffer[dst_index..dst_index+width];
-// let src_slice = &src_data[src_index..src_index+width];
-// dst_slice.copy_from_slice(src_slice);
-//
-// dst_index += CACHE_WIDTH;
-// src_index += width;
-// }
-// }
-// ).unwrap();
-//
-// // need to get a hold of the cache buffer handle after I create it
-// // will then get swapped into this texture buffer
-// // Hmmm so this uninit call returns the texture and then a handle for whatever fills it up
-// let (cache_texture, cache_texture_write) = ImmutableImage::uninitialized(
-// self.device.clone(),
-// Dimensions::Dim2d { width: CACHE_WIDTH as u32, height: CACHE_HEIGHT as u32 },
-// R8Unorm,
-// 1,
-// ImageUsage {
-// sampled: true,
-// transfer_destination: true,
-// .. ImageUsage::none()
-// },
-// ImageLayout::General,
-// Some(self.queue.family())
-// ).unwrap();
-//
-//
-//
-// let set = Arc::new(
-// PersistentDescriptorSet::start(self.pipeline.clone(), 0)
-// .add_sampled_image(cache_texture.clone(), sampler).unwrap()
-// .build().unwrap()
-// );
-//
-// let mut command_buffer = command_buffer
-// .copy_buffer_to_image(
-// buffer.clone(),
-// cache_texture_write,
-// ).unwrap()
-// .begin_render_pass(self.framebuffers[image_num].clone(), false, vec!(ClearValue::None)).unwrap();
-//
-// // draw
-// for text in &mut self.texts.drain(..) {
-// let vertices: Vec = text.glyphs.iter().flat_map(|g| {
-// if let Ok(Some((uv_rect, screen_rect))) = cache.rect_for(0, g) {
-// let gl_rect = Rect {
-// min: point(
-// (screen_rect.min.x as f32 / screen_width as f32 - 0.5) * 2.0,
-// (screen_rect.min.y as f32 / screen_height as f32 - 0.5) * 2.0
-// ),
-// max: point(
-// (screen_rect.max.x as f32 / screen_width as f32 - 0.5) * 2.0,
-// (screen_rect.max.y as f32 / screen_height as f32 - 0.5) * 2.0
-// )
-// };
-// vec!(
-//// Vertex {
-//// position: [gl_rect.min.x, gl_rect.max.y],
-//// tex_position: [uv_rect.min.x, uv_rect.max.y],
-//// color: text.color,
-//// },
-//// Vertex {
-//// position: [gl_rect.min.x, gl_rect.min.y],
-//// tex_position: [uv_rect.min.x, uv_rect.min.y],
-//// color: text.color,
-//// },
-//// Vertex {
-//// position: [gl_rect.max.x, gl_rect.min.y],
-//// tex_position: [uv_rect.max.x, uv_rect.min.y],
-//// color: text.color,
-//// },
-////
-//// Vertex {
-//// position: [gl_rect.max.x, gl_rect.min.y],
-//// tex_position: [uv_rect.max.x, uv_rect.min.y],
-//// color: text.color,
-//// },
-//// Vertex {
-//// position: [gl_rect.max.x, gl_rect.max.y],
-//// tex_position: [uv_rect.max.x, uv_rect.max.y],
-//// color: text.color,
-//// },
-//// Vertex {
-//// position: [gl_rect.min.x, gl_rect.max.y],
-//// tex_position: [uv_rect.min.x, uv_rect.max.y],
-//// color: text.color,
-//// },
-// ).into_iter()
-// }
-// else {
-// vec!().into_iter()
-// }
-// }).collect();
-//
-// let vertex_buffer = CpuAccessibleBuffer::from_iter(self.device.clone(), BufferUsage::all(), vertices.into_iter()).unwrap();
-// command_buffer = command_buffer.draw(self.pipeline.clone(), &DynamicState::none(), vertex_buffer.clone(), set.clone(), ()).unwrap();
-// }
-
- command_buffer//.end_render_pass().unwrap()
- }
}
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index 6731f090..1a9c15c1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -97,6 +97,13 @@ pub fn main() {
let funky_sprite = Sprite::new_with_texture((0.0, -0.5), (0.5, 0.5), 0, funky_handle.clone());
let sfml_sprite = Sprite::new_with_texture((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone());
+
+ // ========================
+ // Creating a new text... This is just something to interface with the
+ // canvas_frame. So it can be mutable
+ let text_sprite = TextSprite::new();
+
+
let test_polygon = Poly::new_with_color((-0.5, -0.5), (0.5, 0.5), 1, (1.0,0.0,0.0,0.0));
drop(q2);
@@ -156,16 +163,18 @@ pub fn main() {
compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
- if elapsed_time > (count) as f32 {
- count += 1;
- compu_frame.add_chained(compute_buffer.clone(), compute_buffer.clone(), compute_kernel.clone());
- }
+// if elapsed_time > (count) as f32 {
+// count += 1;
+// compu_frame.add_chained(compute_buffer.clone(), compute_buffer.clone(), compute_kernel.clone());
+// }
let mut canvas = CanvasFrame::new();
-
canvas.draw(&funky_sprite);
canvas.draw(&test_polygon);
+
+
+
{
let g = hprof::enter("Run");
processor.run(&surface,
diff --git a/src/sprite.rs b/src/sprite.rs
index 2cc0c1b0..57d7d856 100644
--- a/src/sprite.rs
+++ b/src/sprite.rs
@@ -1,5 +1,6 @@
-use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle};
+use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle, DrawableTest};
use std::sync::Arc;
+use crate::canvas::shader::text_shader::GlyphInstance;
#[derive(Debug, Clone)]
pub struct Sprite {
@@ -14,6 +15,7 @@ pub struct Sprite {
textured: bool,
texture_handle: Option>,
+ value: GlyphInstance,
}
/// Container class which implements drawable.
@@ -52,7 +54,13 @@ impl Sprite {
size: size,
color: color,
textured: false,
- texture_handle: None
+ texture_handle: None,
+ value: GlyphInstance {
+ screen_position: (0.0, 0.0),
+ atlas_position: (0.0, 0.0),
+ atlas_size: (0.0, 0.0),
+ scale: 0.0
+ }
}
}
@@ -93,6 +101,16 @@ impl Sprite {
}
+impl DrawableTest for Sprite {
+ fn get_vertices(&self) -> Vec {
+
+ }
+
+ fn get_handle(&self) -> Vec {
+ unimplemented!()
+ }
+}
+
impl Drawable for Sprite {
fn get_vertices(&self) -> Vec<(f32,f32,f32)> {
@@ -135,6 +153,9 @@ pub struct Poly {
textured: bool,
texture_handle: Option>,
+ // ==================================
+
+
}
/// Container class which implements drawable.
@@ -248,3 +269,77 @@ impl Drawable for Poly {
None
}
}
+
+
+#[derive(Debug, Clone)]
+pub struct Poly {
+
+ pub vertices: Vec<(f32, f32, f32)>,
+ pub ti_position: Vec<(f32, f32)>,
+
+ position: (f32, f32),
+ size: (f32, f32),
+ color: (f32, f32, f32, f32),
+
+ textured: bool,
+ texture_handle: Option>,
+
+ // ==================================
+
+
+}
+
+/// Container class which implements drawable.
+impl Poly {
+
+ pub fn new(position: (f32, f32), size: (f32, f32)) -> Poly {
+ Poly::new_with_color(position, size, 0, (0.,0.,0.,0.))
+ }
+
+ pub fn new_with_color(position: (f32, f32),
+ size: (f32, f32),
+ depth: u32,
+ color: (f32, f32, f32, f32)) -> Poly {
+
+ let normalized_depth = (depth as f32 / 255.0);
+
+ Poly {
+ vertices: vec![],
+
+ position: position,
+ ti_position: vec![],
+ size: size,
+ color: color,
+ textured: false,
+ texture_handle: None
+ }
+ }
+}
+
+impl Drawable for Poly {
+
+ fn get_vertices(&self) -> Vec<(f32,f32,f32)> {
+ self.vertices.to_vec()
+ }
+
+ fn get_color(&self) -> (f32, f32, f32, f32) {
+ self.color.clone()
+ }
+
+ fn get_ti_coords(&self) -> Vec<(f32, f32)> {
+ self.ti_position.to_vec()
+ }
+
+ fn get_texture_handle(&self) -> Option> {
+ match self.textured {
+ true => {
+ self.texture_handle.clone()
+ },
+ false => None,
+ }
+ }
+
+ fn get_image_handle(&self) -> Option> {
+ None
+ }
+}