You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.9 KiB
70 lines
1.9 KiB
5 years ago
|
Content-Type: text/x-zim-wiki
|
||
|
Wiki-Format: zim 0.4
|
||
|
Creation-Date: 2020-02-03T23:57:15-08:00
|
||
|
|
||
|
====== CanvasFrame ======
|
||
|
|
||
5 years ago
|
[[/doc/sfml_rust/canvas/canvas_frame/struct.CanvasFrame.html|Documentation]]
|
||
5 years ago
|
|
||
|
===== Details =====
|
||
|
|
||
5 years ago
|
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
|
||
|
|
||
5 years ago
|
Now. The CanvasFrame is closely coupled with the Drawable trait, the object which allows CanvasFrame to ingest all drawable object on a single interface
|
||
5 years ago
|
|
||
5 years ago
|
Drawable needs a few things:
|
||
|
Handle to the Texture or Image it is using
|
||
|
Vertices describing it
|
||
|
(vertices will be character data for text)
|
||
|
Instances?
|
||
5 years ago
|
|
||
5 years ago
|
The handle is queiried and then turned into a descriptor set in the draw_commands.
|
||
|
|
||
5 years ago
|
* What if I pass using function params? But then how do I store???
|
||
5 years ago
|
|
||
5 years ago
|
==== Problem ====
|
||
|
I need to store vectors of multiple unequal types in a vec
|
||
|
|
||
|
vec<vec<T>>
|
||
|
|
||
|
Why can't I pass in
|
||
5 years ago
|
|
||
|
|
||
5 years ago
|
--------------------
|
||
|
|
||
|
===== Data =====
|
||
|
|
||
|
**Borrowed:**
|
||
|
|
||
|
**Owns:**
|
||
|
|
||
|
--------------------
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|