OVERVIEW
Monorepo/Foundation Libraries/libs/render
v0.1.0 • ActiveSource Code
libs/render/

libs/render

2D Batched GPU Graphics & Font Atlas Engine

The foundational 2D graphics engine powering all Kale native GUIs. Implements high-throughput CPU-to-GPU dynamic batching capable of drawing hundreds of thousands of textured and colored quads in a single draw call. Fully integrated with stb_truetype for real-time font glyph caching.

Batch Capacity65,536 Vertices/Batch
Draw Calls1-3 Per Frame
SDF RenderingAntialiased Corners
MilestoneM5 Validated
libs/render
Protocol & Wire Format Architecture
Zero-Heap Allocation Primitives
Deterministic Memory
Buffer allocations are bound to caller lifecycle with zero heap fragmentation
RFC Wire Conformance
Strict binary packet layout and protocol compliance written in pure Kale
Monorepo Integration
Instantly consumable by Compiler, Editor, and Bare-Metal targets
Architecture Contract

High-Throughput Systems Foundation

Engineered to maximize CPU instruction pipelining and data cache locality. Every algorithm avoids heap pointer indirection wherever contiguous stack or arena buffers can be employed.

Verification: 138/138 Regression Suite Pass
Signed commit governance • Strict type safety
Systems Foundation
render_demo.kl
kale
import "libs/render/batch.kl" as batch;
import "libs/render/font.kl" as font;

fn draw_card(b: *batch.RenderBatch, f: *font.FontAtlas, x: f32, y: f32, w: f32, h: f32) -> void {
    // Drop shadow
    batch.draw_rect_rounded(b, x + 4.0, y + 4.0, w, h, 8.0, 0x00000088);
    // Card background
    batch.draw_rect_rounded(b, x, y, w, h, 8.0, 0x0e1838ff);
    // Border
    batch.draw_rect_outline(b, x, y, w, h, 8.0, 1.5, 0xb91c1cff);
    // Header text
    font.draw_string(b, f, "Kale Architecture", x + 16.0, y + 24.0, 0xf8fafcff);
}
Compilation & Linker Directives

Deterministic command-line invocations to build, link native dynamic dependencies, and run automated regression tests:

$kale build tests/test_render_batch.kl -o bin/test_render.exe -lglfw3 -lopengl32 -Llibs/stb/vendor
$./bin/test_render.exe
Monorepo Governance

GPG Key 1B917D4779A6102E • Continuous integration with automated symbol verification.

Architectural Capabilities
Dynamic Batch Aggregator

Batches rects, borders, drop shadows, and textured glyphs, auto-flushing only upon texture or blend mode changes.

Dynamic Font Atlas

Rasterizes TrueType glyphs into a 1024x1024 alpha texture atlas with pixel-accurate UV coordinate mapping.

Scissor Rect Clipping

Hardware-accelerated hierarchical scissor clipping for scrollable viewports and nested UI panels.