When exploring physics models, signal processing algorithms, or custom graphics techniques, full-scale game engines (Unreal, Unity) introduce unnecessary friction, while raw OpenGL or Vulkan requires excessive boilerplate just to draw a cube with a UI overlay.

GFX was created as a lightweight, clean C++ application harness combining Raylib, Dear ImGui, and miniaudio. It provides a rapid sandbox for interactive 3D simulations, real-time plotting, and audio generation.


Framework Design

The core of the library is gfx::App, which wraps window initialization, input polling, multi-sampling (4X MSAA), camera management, audio engine lifecycle, and ImGui integration into an intuitive subclassing interface:

#include "gfx/app.hpp"

class SimulationApp : public gfx::App {
public:
    SimulationApp() : gfx::App(1280, 720, 60, "Physics Sandbox") {}

    int update() override {
        // Step physics, update particle positions
        physics.step(GetFrameTime());
        return 0;
    }

    int draw() override {
        // 3D rendering with Raylib
        BeginMode3D(camera);
        DrawGrid(20, 1.0f);
        DrawModel(rocketModel, position, 1.0f, WHITE);
        EndMode3D();
        return 0;
    }

    int ui() override {
        // Immediate mode UI and telemetry plots
        ImGui::Begin("Telemetry");
        if (ImPlot::BeginPlot("Altitude vs Time")) {
            ImPlot::PlotLine("Altitude (m)", timeData.data(), altData.data(), altData.size());
            ImPlot::EndPlot();
        }
        ImGui::End();
        return 0;
    }
};

int main() {
    SimulationApp app;
    return app.run();
}

Example Implementations

1. 6-DOF Toy Rocket Simulation & Telemetry

A multi-stage model rocket simulation evaluating:

  • Variable mass burn curves and solid motor thrust profiles.
  • Aerodynamic drag calculations based on altitude and atmospheric density.
  • Real-time flight instrumentation: pitching/yawing orientation, acceleration, velocity, and apogee detection plotted via ImPlot.

2. Heightmap Terrain Generation

  • Loads grayscale heightmaps and procedural noise functions to generate 3D polygonal terrain meshes.
  • Configurable vertex normals, diffuse shading, and terrain contouring.

3. N-Body Gravitational Dynamics (bodies)

  • Multi-body orbital simulation calculating pairwise Newtonian gravitational interactions.
  • Trajectory trail rendering with dynamic point light sources illuminating neighboring celestial bodies.

Stepping Stone to WebGPU

Building and using GFX highlighted the value of lightweight, focused graphics tooling. The lessons learned regarding reactive event loops, compute-heavy algorithms (such as FFTs and phased arrays), and decoupled pipeline architecture directly inspired the creation of WGFX, my subsequent WebGPU (Dawn) engine.