diff --git a/notes/CanvasFrame.txt b/notes/CanvasFrame.txt index 2faef1f0..f1ae4c3c 100644 --- a/notes/CanvasFrame.txt +++ b/notes/CanvasFrame.txt @@ -8,8 +8,30 @@ Creation-Date: 2020-02-03T23:57:15-08:00 ===== Details ===== -Canvas frame -**** +Canvas frame is at it's core, an accumulator of meta data to draw to the screen. + +At the moment it is split up into these groups: + +* Colored items like non-textured sprites are just a list of triangles, simple vertices. +@todo +* Textured are grouped by their texture handle. Currently implemented as a list of lists of vertices. I don't think the vertices need to be grouped by sprite as long as they are triangle lists with texture coords included in the definition +* Images are just the same as Textured +* Text is a simple Font->Glyph lookup. XY coords of the font and the ASCII code + +{{{code: lang="rust" linenumbers="True" +colored_drawables: Vec +textured_drawables: HashMap, Vec>> +image_drawables: HashMap, Vec>> +text_drawables: HashMap, Vec> +}}} + + +===== Future ===== + +I like this immediate interface for this simple style of UI and drawing. + +@todo finish this + -------------------- diff --git a/notes/Dynamic_Vertex.txt b/notes/DynamicVertex.txt similarity index 76% rename from notes/Dynamic_Vertex.txt rename to notes/DynamicVertex.txt index ec7580d9..9651ba3a 100644 --- a/notes/Dynamic_Vertex.txt +++ b/notes/DynamicVertex.txt @@ -1,8 +1,28 @@ Content-Type: text/x-zim-wiki Wiki-Format: zim 0.4 -Creation-Date: 2020-01-22T18:39:43-08:00 +Creation-Date: 2020-02-04T23:22:14-08:00 + +====== DynamicVertex ====== + +[[/doc/sfml_rust/canvas/managed/shader/dynamic_vertex/index.html|Documentation]] + +[[https://vulkan-tutorial.com/Vertex_buffers/Vertex_input_description|Vulkan C++ binding equivilent]] + +===== Details ===== + +So, the **pipeline** we create over in the **shader** needs to know about the vertex data it will be using. This lines up pretty well because the Shader is precisely the mechanism which would know about this data. + + +-------------------- + +===== Data ===== + +**Borrowed:** + +**Owns:** + +-------------------- -====== Dynamic Vertex ====== {{{code: lang="rust" linenumbers="True" #[derive(Default, Debug, Clone)] @@ -46,8 +66,7 @@ unsafe impl VertexDefinition for RuntimeVertexDef } } -/// I don't know what the fuck is going on here... It just repackages the buffs -/// Needs the num vertices + unsafe impl VertexSource>> for RuntimeVertexDef { fn decode(&self, bufs: Vec>) -> (Vec>, usize, usize) @@ -63,3 +82,15 @@ unsafe impl VertexSource>> for RuntimeVe }}} + + + + + + + + + + + + diff --git a/notes/Home.txt b/notes/Home.txt index 187e224d..f8797b25 100644 --- a/notes/Home.txt +++ b/notes/Home.txt @@ -7,17 +7,49 @@ Creation-Date: 2020-02-03T22:11:42-08:00 [[~/source/Trac3r-rust/doc/sfml_rust/index.html|Documentation Root]] Main Systems: - [[~/source/Trac3r-rust/doc/sfml_rust/sprite/index.html|Sprite]] - - - - - - - Docs + [[~/source/Trac3r-rust/doc/sfml_rust/sprite/index.html|Spri]][[~/source/Trac3r-rust/doc/sfml_rust/sprite/index.html|te]] + [[CanvasContainerClasses]] + + Docs [[VkProcessor]] [[~/source/Trac3r-rust/doc/sfml_rust/vkprocessor/struct.VkProcessor.html|===========]] [[CanvasState]] [[~/source/Trac3r-rust/doc/sfml_rust/canvas/canvas_state/index.html|===========]] + [[DynamicVertex]] [[CompuState]] [[~/source/Trac3r-rust/doc/sfml_rust/compute/compu_state/struct.CompuState.html|===========]] +├── canvas +│   ├── canvas_frame.rs +│   ├── canvas_state.rs +│   ├── managed +│   │   ├── canvas_text.rs +│   │   ├── gpu_buffers.rs +│   │   ├── handles.rs +│   │   ├── mod.rs +│   │   └── shader +│   │   ├── dynamic_vertex.rs +│   │   ├── generic_shader.rs +│   │   ├── mod.rs +│   │   ├── shader_common.rs +│   │   └── text_shader.rs +│   └── mod.rs +├── compute +│   ├── compu_frame.rs +│   ├── compu_state.rs +│   ├── managed +│   │   ├── compu_buffer.rs +│   │   ├── compu_kernel.rs +│   │   ├── compu_sprite.rs +│   │   ├── handles.rs +│   │   └── mod.rs +│   └── mod.rs +├── main.rs +├── sprite.rs +├── util +│   ├── mod.rs +│   ├── timer.rs +│   ├── vertex_2d.rs +│   └── vertex_3d.rs +└── vkprocessor.rs + + diff --git a/src/canvas/canvas_frame.rs b/src/canvas/canvas_frame.rs index 4b2575ab..fbcb720c 100644 --- a/src/canvas/canvas_frame.rs +++ b/src/canvas/canvas_frame.rs @@ -8,8 +8,7 @@ use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef; use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle}; use crate::canvas::managed::shader::text_shader::GlyphInstance; -/// I dont know why this isnt working -/// fqowiejf + pub struct CanvasFrame { pub colored_drawables: Vec, pub textured_drawables: HashMap, Vec>>, diff --git a/src/canvas/canvas_state.rs b/src/canvas/canvas_state.rs index 9a204633..c1239b1d 100644 --- a/src/canvas/canvas_state.rs +++ b/src/canvas/canvas_state.rs @@ -26,7 +26,7 @@ use vulkano::memory::pool::PotentialDedicatedAllocation::Generic; use std::borrow::Borrow; use std::fs::File; use std::io::Read; -use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId}; +use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId, Line, Curve, Segment}; use vulkano::pipeline::vertex::VertexDefinition; use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef; use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledGraphicsPipelineHandle, Handle}; @@ -344,15 +344,29 @@ impl CanvasState { let mut accumulator = Vec::new(); - for i in (0..255) { - let glyph = font.glyph(GlyphId { 0: 40 }); - - let glyph_data = glyph.get_data().unwrap(); - for vertex in glyph_data.clone().shape.clone().unwrap() { - accumulator.push(TextVertex3D { - position: [vertex.x as f32, vertex.y as f32, 0.0], - }); + for i in (0..255) { + let glyph = font.glyph('d'); + + let s = glyph.scaled(Scale{ x: 1.0, y: 1.0 }); + + let shape = s.shape().unwrap(); + + for contour in shape { + for segment in contour.segments { + match segment { + Segment::Line(l) => { + accumulator.push(TextVertex3D { + position: [l.p[0].x as f32, l.p[0].y as f32, 0.0], + }); + }, + Segment::Curve(c) => { + accumulator.push(TextVertex3D { + position: [c.p[0].x as f32, c.p[0].y as f32, 0.0], + }); + } + } + } } }