Cristian Gora a36ed3a902 Make GL state changes predictable and clean up main.cpp
Engine:
- Create, resize and update functions now restore the bindings they
  touch instead of leaving their own objects bound or resetting to 0
  (Texture, FrameBuffer, Mesh, UniformBuffer)
- Texture::bind/unbind switch back to texture unit 0 afterwards, so
  later texture binds can't replace a material's specular map
- Add gl_get_binding() helper to read the current binding
- Renderer remembers the wireframe mode (new is_wireframe());
  draw_debug_wireframes restores it instead of always disabling it,
  which fixes H having no effect while debug wireframes are shown

main.cpp (same behavior and UI):
- main() only sets up the window and renderer; all GL resources live
  in run() and are released before Renderer::shutdown()
- One function per scene and a shared create_textured_material()
- Split app state into AppState, CameraInput and PerformanceStats;
  drop the duplicate delta_time and static toggle variables
- Move the scene pass to render_scene() and the overlay to
  draw_overlay(); name the light box and overlay constants
- Clear the mouse callback before AppState is destroyed
2026-10-28 21:42:08 +01:00
2026-09-27 01:53:32 +02:00
2026-09-27 01:33:35 +02:00
2026-09-27 01:53:32 +02:00
2026-09-27 01:33:35 +02:00

Fan Engine

A minimal 3D renderer written in C++ and OpenGL 3.3 Core.

NOTE: The engine is still in development. Expect breaking changes.

Building

The only tested platform at the moment is GNU/Linux (x86_64).

To build the project you'll need to have GLFW already installed system-wide, the rest of the dependencies are already included.

After that, building comes down to just running the included Makefile.

$ make # optionally pass -j$(nproc)

Features

This is the current state of the engine architecture:

flowchart TB
    subgraph Infrastructure["Infrastructure"]
        direction LR

        subgraph Platform
            direction TB
            Window --> GLFW
            Window --> glad
            Window --> ImGui["Dear ImGui"]
        end

        subgraph Loading
            direction TB
            Loader --> tinyobjloader
            Loader --> stb_image
        end
    end

    subgraph Application
        direction LR
        Framebuffer
        Renderer --> Camera
        Renderer --> Scene
        Renderer -->|Updates| UniformBuffer
        Renderer -->|Owns| ResourceCache
    end

    subgraph World
        direction LR

        subgraph SceneGraph["Scene Graph"]
            direction TB
            Scene --> Entity
            Entity --> Transform
            Entity --> Mesh
            Entity -.->|Optional override| Material
            Mesh -->|Partitions| SubMesh
            SubMesh -->|Owns| Material
        end

        subgraph Lighting
            direction TB
            Scene --> LightEnvironment
            LightEnvironment --> DirectionalLight
            LightEnvironment --> PointLight
            LightEnvironment --> SpotLight
        end
    end

    subgraph SceneData["Scene Data"]
        direction LR

        subgraph Geometry
            direction TB
            Mesh --> Vertices
            Mesh --> Indices
        end

        subgraph Resources
            direction TB
            Material --> Shader
            Material --> Texture
            UniformBuffer -->|Global data| Shader
            ResourceCache -.->|Caches, falls back| Texture
            ResourceCache -.->|Caches, falls back| Shader
        end
    end

    tinyobjloader -->|Generates| Entity
    Texture -.->|Decodes via| stb_image

    classDef application fill:#7c3aed,stroke:#4c1d95,color:#fff
    classDef world fill:#2563eb,stroke:#1e3a8a,color:#fff
    classDef data fill:#0f766e,stroke:#134e4a,color:#fff
    classDef loading fill:#d97706,stroke:#92400e,color:#fff
    classDef platform fill:#64748b,stroke:#334155,color:#fff

    class Renderer,Scene,Camera,Framebuffer,ResourceCache application
    class Entity,Transform,Mesh,SubMesh,Material,LightEnvironment world
    class UniformBuffer,Shader,Texture,Vertices,Indices,DirectionalLight,PointLight,SpotLight data
    class Loader,tinyobjloader,stb_image loading
    class Window,GLFW,glad,ImGui platform
Description
A minimal 3D renderer written in C++ and OpenGL 3.3 Core
Readme MIT 168 MiB
Languages
C++ 90.2%
GLSL 5.1%
Python 2.8%
Makefile 1.9%