mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-05 14:42:42 -07:00
Completed initial draft for guide_backend.odin
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# VE Font Cache
|
||||
|
||||
|
||||
Vertex Engine GPU Font Cache: A text rendering libary.
|
||||
|
||||
This started off as a port of the [VEFontCache](https://github.com/hypernewbie/VEFontCache) library to the Odin programming language.
|
||||
Its original purpose was for use in game engines, however its rendeirng quality and performance is more than adequate for many other applications.
|
||||
|
@@ -548,7 +548,7 @@ render_text_layer :: proc( screen_extent : ve.Vec2, ve_ctx : ^ve.Context, ctx :
|
||||
samplers = { SMP_ve_blit_atlas_src_sampler = ctx.glyph_rt_sampler, },
|
||||
})
|
||||
|
||||
// 3. Use the atlas to then render the text.
|
||||
// 3. Use the atlas (.Target) or the glyph buffer (.Target_Unchached) to then render the text.
|
||||
case .None, .Target, .Target_Uncached:
|
||||
if num_indices == 0 && ! draw_call.clear_before_draw {
|
||||
continue
|
||||
|
@@ -4,4 +4,35 @@ The end-user needs adapt this library for hookup into their own codebase. As an
|
||||
|
||||
When rendering text, the two products the user has to deal with: The text to draw and their "layering". Similar to UIs text should be drawn in layer batches, where each layer can represent a pass on some arbitrary set of distictions between the other layers.
|
||||
|
||||
The following are generally needed:
|
||||
|
||||
* Vertex and Index Buffers for glyph meshes
|
||||
* Glyph shader for rendering the glyph to the glyph buffer
|
||||
* Atlas shader for blitting the upscaled glyph quads from the glyph buffer to an atlas region slot downsampled.
|
||||
* "Screen or Target" shader for blitting glyph quads from the atlas to a render target or swapchain
|
||||
* The glyph, atlas, and some "target" image buffers
|
||||
|
||||
Currently the library doesn't support sub-pixel AA so we're just rendering to R8 images.
|
||||
|
||||
## There are four passes that need to be handled when rendering a draw list
|
||||
|
||||
* Glyph: Rendering a glyph mesh to the glyph buffer
|
||||
* Atlas: Blitting a glyph quad from the glyph buffer to an atlas slot
|
||||
* Target: Blit from the atlas image to the target image
|
||||
* Target_Uncached: Blit from the glyph buffer image to the target image
|
||||
|
||||
The Target & Target_Uncached passes can technically be handled in the same case. The user just needs to swap out using the atlas image with the glyph buffer image. This is how the backend_soko.odin's `render_text_layer` has those passes setup.
|
||||
|
||||
## The vertex buffer will have the following alyout for all passes
|
||||
|
||||
`[2]f32` for positions
|
||||
`[2]f32` for texture coords (Offset is naturally `[2]f32`)
|
||||
With a total stride of `[4]f32`
|
||||
|
||||
---
|
||||
|
||||
The index buffer is just a u32 stream.
|
||||
|
||||
For how a quad mesh is laid out see `blit_quad` in [draw.odin](../vefontcache/draw.odin)
|
||||
|
||||
For how glyph shape triangulation meshes, the library currently only uses a triangle fanning technique so `fill_path_via_fan_triangulation` within [draw.odin](../vefontcache/draw.odin) is where that is being done. Eventually the libary will also support other modes on a per-font basis.
|
||||
|
Reference in New Issue
Block a user