fixed the glyph panic, this still is very wrong

master
mitchellhansen 5 years ago
parent f3f52becb4
commit 1fde36e42c

@ -8,8 +8,30 @@ Creation-Date: 2020-02-03T23:57:15-08:00
===== Details ===== ===== Details =====
Canvas frame Canvas frame is at it's core, an accumulator of meta data to draw to the screen.
**<notes>**
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<RuntimeVertexDef>
textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<RuntimeVertexDef>>>
image_drawables: HashMap<Arc<CanvasImageHandle>, Vec<Vec<RuntimeVertexDef>>>
text_drawables: HashMap<Arc<CanvasFontHandle>, Vec<GlyphInstance>>
}}}
===== Future =====
I like this immediate interface for this simple style of UI and drawing.
@todo finish this
-------------------- --------------------

@ -1,9 +1,29 @@
Content-Type: text/x-zim-wiki Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4 Wiki-Format: zim 0.4
Creation-Date: 2020-01-22T18:39:43-08:00 Creation-Date: 2020-02-04T23:22:14-08:00
====== DynamicVertex ====== ====== 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:**
--------------------
{{{code: lang="rust" linenumbers="True" {{{code: lang="rust" linenumbers="True"
#[derive(Default, Debug, Clone)] #[derive(Default, Debug, Clone)]
pub struct RuntimeVertexDef { pub struct RuntimeVertexDef {
@ -46,8 +66,7 @@ unsafe impl<I> VertexDefinition<I> 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<Vec<Arc<dyn BufferAccess + Send + Sync>>> for RuntimeVertexDef { unsafe impl VertexSource<Vec<Arc<dyn BufferAccess + Send + Sync>>> for RuntimeVertexDef {
fn decode(&self, bufs: Vec<Arc<dyn BufferAccess + Send + Sync>>) fn decode(&self, bufs: Vec<Arc<dyn BufferAccess + Send + Sync>>)
-> (Vec<Box<dyn BufferAccess + Send + Sync>>, usize, usize) -> (Vec<Box<dyn BufferAccess + Send + Sync>>, usize, usize)
@ -63,3 +82,15 @@ unsafe impl VertexSource<Vec<Arc<dyn BufferAccess + Send + Sync>>> for RuntimeVe
}}} }}}

@ -7,17 +7,49 @@ Creation-Date: 2020-02-03T22:11:42-08:00
[[~/source/Trac3r-rust/doc/sfml_rust/index.html|Documentation Root]] [[~/source/Trac3r-rust/doc/sfml_rust/index.html|Documentation Root]]
Main Systems: Main Systems:
[[~/source/Trac3r-rust/doc/sfml_rust/sprite/index.html|Sprite]] [[~/source/Trac3r-rust/doc/sfml_rust/sprite/index.html|Spri]][[~/source/Trac3r-rust/doc/sfml_rust/sprite/index.html|te]]
[[CanvasContainerClasses]]
Docs Docs
[[VkProcessor]] [[~/source/Trac3r-rust/doc/sfml_rust/vkprocessor/struct.VkProcessor.html|===========]] [[VkProcessor]] [[~/source/Trac3r-rust/doc/sfml_rust/vkprocessor/struct.VkProcessor.html|===========]]
[[CanvasState]] [[~/source/Trac3r-rust/doc/sfml_rust/canvas/canvas_state/index.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|===========]] [[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

@ -8,8 +8,7 @@ use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle}; use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
use crate::canvas::managed::shader::text_shader::GlyphInstance; use crate::canvas::managed::shader::text_shader::GlyphInstance;
/// I dont know why this isnt working
/// fqowiejf
pub struct CanvasFrame { pub struct CanvasFrame {
pub colored_drawables: Vec<RuntimeVertexDef>, pub colored_drawables: Vec<RuntimeVertexDef>,
pub textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<RuntimeVertexDef>>>, pub textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<RuntimeVertexDef>>>,

@ -26,7 +26,7 @@ use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
use std::borrow::Borrow; use std::borrow::Borrow;
use std::fs::File; use std::fs::File;
use std::io::Read; 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 vulkano::pipeline::vertex::VertexDefinition;
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef; use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledGraphicsPipelineHandle, Handle}; use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledGraphicsPipelineHandle, Handle};
@ -344,17 +344,31 @@ impl CanvasState {
let mut accumulator = Vec::new(); let mut accumulator = Vec::new();
for i in (0..255) { for i in (0..255) {
let glyph = font.glyph(GlyphId { 0: 40 }); let glyph = font.glyph('d');
let s = glyph.scaled(Scale{ x: 1.0, y: 1.0 });
let glyph_data = glyph.get_data().unwrap(); let shape = s.shape().unwrap();
for vertex in glyph_data.clone().shape.clone().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 { accumulator.push(TextVertex3D {
position: [vertex.x as f32, vertex.y as f32, 0.0], position: [c.p[0].x as f32, c.p[0].y as f32, 0.0],
}); });
} }
} }
}
}
}
CanvasFont { CanvasFont {
handle: handle.clone(), handle: handle.clone(),

Loading…
Cancel
Save