How orangeduck/corange works
Project Type and Purpose
• This is Corange, a pure-C, cross-platform game engine library built on SDL2 and OpenGL (with optional OpenCL interop).
• It is not a standalone game but a framework providing core subsystems (asset loading, rendering, audio, physics, UI, entities, data structures) plus a set of demos that consume the library to showcase features.
File Structure Analysis
• Top‐level:
• / → Public headers for each subsystem (cengine, cgraphics, caudio, cphysics, cui, cnet, plus asset, entity, UI, data and rendering subfolders).
• src/ → Library implementation mirroring the include/ hierarchy.
• assets_core/ → Shared engine assets: fonts, shaders, textures, objects, UI skins, LUTs, water data.
• demos/ → Multiple demo executables (rendering, metaballs, noise, platformer, sea, scotland, tessellation, UI, physics, particles, parallax, teapot). Each has its own Makefile, source, assets.
• Makefile, README.md, LICENSE.md.
Key Insights from README
• Corange offers: deferred rendering, post‐effects, SSAO, shadows, skeletal animation, asset/entity/UI managers, terrain, OpenCL support, file loaders, math utilities.
• Demos illustrate how client code initializes Corange (corange_init), drives the main loop, sets up scenes, and renders with different techniques.
Components
a. External Dependencies
• SDL2 (window, input)
• SDL_Mixer (audio)
• SDL_Net (network)
• OpenGL (graphics API)
• OpenCL (compute kernels in some demos)
b. Core Engine Library (static or shared)
• Initialization & Shutdown (corange_init / corange_finish)
• Subsystems (each a module in include/ + src/):
• Asset Manager
• Entity Manager
• UI Manager
• Rendering Subsystem
– Deferred Renderer
– Shader Pipeline
– Sky, Water, Post-Effects
• Audio Subsystem
• Physics Subsystem
• Networking Subsystem
• Input / Joystick Subsystem
• Data Structures (lists, hashtables, splines, random)
c. Demos (clients)
• Each demo links against the engine core
• They supply their own assets and specialized initialization (e.g. load shaders, set up scene graph, dispatch OpenCL kernels)
d. Data Flow / Interactions
• Main Loop: Poll SDL events → UI Manager → Entity updates (physics, scripts) → Asset requests → Rendering → Audio updates → Networking
• Physics Subsystem updates Entity transforms (collision detection).
• Audio Subsystem mixes sound assets from Asset Manager and outputs via SDL_Mixer.
• Networking Subsystem uses SDL_Net to send/receive data, updating Entities or game state.
• Optional: OpenCL kernels (in metaballs demo) fetch entity data, compute volume or particles, return to GPU via OpenGL interop.
Architectural Patterns and Principles
• Layered Architecture:
• External APIs (SDL2, GL, CL) at the bottom
• Core Engine Modules in the middle
• Demos (applications) on top
• Manager/Facade Pattern: Asset, Entity, UI managers provide centralized access and lifecycle.
• Plugin‐like modularity: each subsystem lives in its own folder, clean separation via header files.
• Data‐driven: assets (shaders, textures, models) stored on disk under assets_core and per‐demo asset folders.