fixed the glyph panic, this still is very wrong
This commit is contained in:
@@ -8,8 +8,30 @@ Creation-Date: 2020-02-03T23:57:15-08:00
|
||||
|
||||
===== Details =====
|
||||
|
||||
Canvas frame
|
||||
**<notes>**
|
||||
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<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,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<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 {
|
||||
fn decode(&self, bufs: Vec<Arc<dyn BufferAccess + Send + Sync>>)
|
||||
-> (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]]
|
||||
|
||||
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
|
||||
[[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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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<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::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 = font.glyph('d');
|
||||
|
||||
let glyph_data = glyph.get_data().unwrap();
|
||||
let s = glyph.scaled(Scale{ x: 1.0, y: 1.0 });
|
||||
|
||||
for vertex in glyph_data.clone().shape.clone().unwrap() {
|
||||
let shape = s.shape().unwrap();
|
||||
|
||||
for contour in shape {
|
||||
for segment in contour.segments {
|
||||
match segment {
|
||||
Segment::Line(l) => {
|
||||
accumulator.push(TextVertex3D {
|
||||
position: [vertex.x as f32, vertex.y as f32, 0.0],
|
||||
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],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user