Page:
Code Architecture
No results
2
Code Architecture
wriverson edited this page 2026-09-18 19:21:07 +02:00
Table of Contents
Overview
| File | Responsibility |
|---|---|
main.cpp |
Startup, input handling, state management, render loop |
axisWidget.hpp/.cpp |
Corner orientation widget (mini axes + labels) |
vortexLoader.hpp |
.surf parsing, colour palette, geometry construction |
shader.hpp |
Shader compilation and program linking |
vectorMath.hpp |
4D vector/matrix math and rotation generators |
uniforms.hpp |
Cached uniform locations, per-frame upload |
objects.hpp |
Vertex, Triangle, lattice extent globals |
stateLog.hpp |
Binary shared-state read/write for window sync |
Rendering
Two shader programs share a vertex stage:
- Vertex stage (
vertex.glsl): folds each vertex into the periodic image nearest the selection centre, applies the combined 4D rotation, and projects 4D to 3D with a perspective divide on the rotated w coordinate. - Geometry stages (
geometryLines.glsl,geometryTriangles.glsl): cull primitives outside the focus radius or time slab, re-wrap vertices, and reject wrap-around edges longer than 1.5 lattice units. - Fragment stages: distance-based alpha fade (smoothstep-like easing) and green highlight for the selected primitive ID. The line variant discards fragments below 0.3 alpha.
Geometry is built CPU-side by vortexLoader.hpp: each surface element becomes four vertices, two triangles, and eight line endpoints (four outline edges). The timeslice cones are rebuilt dynamically into a separate buffer whenever t0 changes.
State flow per frame
input (keyboard/mouse)
-> update angles, R_spatial, selection centre, t0
-> combine R = R_spatial * XW * YW * ZW rotations
-> write SharedState file (if focused)
-> upload uniforms, draw passes:
1. translucent triangle faces (depth writes off)
2. line outlines (depth writes on)
3. timeslice cones (mode 3)
4. axis widget (own viewport, orthographic)
5. SFML overlay: widget labels + HUD text