How nicofgr/engine-grafica works
1. Top-level shape
- This repo is a two-process client/server application written mostly in C, with a small shared C++ networking layer.
- The build is split into two executables:
- src/server/* for the headless server
- src/client/* for the interactive client
- The src/shared/* directory holds the contract between them: common constants, types, and networking code.
2. Server subsystem
- src/server/main.c is the server entry point.
- src/server/server.c/.h contains the server runtime and likely the authoritative application logic.
- The server side appears intentionally minimal compared to the client: no rendering code, just state, simulation, and network servicing.
3. Client subsystem
- src/client/main.c is the client entry point.
- src/client/client.c/.h is the client runtime and top-level orchestration layer.
- The client is responsible for connection setup, receiving state from the server, and driving the local render/update loop.
4. Shared protocol and data model
- src/shared/types.c/.h and src/shared/constants.c/.h define the data model used by both sides.
- This is the main architectural boundary: anything that must be understood by both client and server is centralized here to keep the network protocol and game/application state consistent.
- src/shared/network.cpp/.h suggests the networking transport abstraction is implemented in C++ and shared by both executables.
5. Networking layer
- The README explicitly calls out GameNetworkingSockets as a dependency, so the client/server communication is built on that library rather than raw sockets.
- The presence of network.cpp indicates this layer likely wraps the external transport and exposes a simpler API to the C client/server code.
- For the architecture diagram, treat this as the transport boundary between the client process and server process.
6. Rendering pipeline on the client
- Rendering is isolated under src/client/renderer/.
- Main renderer components:
- renderer.c/.h — core render loop and graphics setup
- shader.c/.h — shader compilation/program management
- mesh.c/.h — geometry buffers and draw-ready mesh data
- model.c/.h — higher-level model composition
- gui.c/.h — on-screen UI rendering
- text.c/.h — font/text rendering
- This is a fairly standard layered rendering stack: asset/data preparation at the bottom, scene/model abstraction in the middle, and UI/text overlays at the top.
7. Graphics and asset dependencies
- include/glad and src/client/glad.c show the project uses GLAD for OpenGL function loading.
- include/cglm is vendored, so the client uses cglm for matrix/vector math in rendering and camera transforms.
- assets/shaders/* contains GLSL programs for points, simple geometry, text, and post-processing; these are runtime assets loaded by the client renderer.
8. Text and font path
- src/client/renderer/text.c/.h plus the FreeType dependency in the README indicate text is rendered via font rasterization rather than bitmap-only UI assets.
- This is a separate client-side rendering concern from the main scene pipeline, likely used by GUI overlays and debug/status text.
9. Client platform/runtime boundary
- The README lists SDL2 as a dependency, which strongly suggests the client uses SDL2 for window creation, input, timing, and the OpenGL context.
- That makes the client a platformed interactive app, while the server remains a non-graphical process.
10. Asset organization
- Runtime shader sources live under assets/shaders/.
- There are no obvious large content pipelines or editor subprojects in the tree, so assets seem lightweight and directly consumed at runtime by the client.
11. Build and vendored dependencies
- Makefile is the main repo build entry point.
- Third-party headers are vendored under include/, especially cglm and glad.
- This suggests the repo is designed for self-contained compilation, with only a few external system/runtime dependencies: SDL2, FreeType, and GameNetworkingSockets.
12. Likely architecture diagram boundaries
- Best diagram split:
- Client process: SDL2 window/input + OpenGL renderer + GUI/text/model/mesh + local networking client
- Network transport: GameNetworkingSockets wrapper in src/shared/network.cpp
- Server process: authoritative runtime and state management
- Shared contract: constants/types used by both sides
- External assets: GLSL shader files
- The key interaction is server-authoritative state flowing to the client, with the client handling presentation and user interaction.
Main entry points: client.c Client core · renderer.c Renderer · server.c Server core · shader.c Shaders
Components 20
Client process
Interactive SDL/OpenGL client that receives server state and renders the local view.
- Main · Client executable entry point.
src/client/main.c - Client core · Top-level client orchestration for connection, update, and render flow.
src/client/client.c - SDL2 runtime · Windowing, input, timing, and OpenGL context boundary implied by the client build.
- Net client · Client-side networking path built on the shared transport wrapper.
src/shared/network.cpp - Renderer · Client render loop and graphics setup.
src/client/renderer/renderer.c - Shaders · Shader compilation, linking, and program handling.
src/client/renderer/shader.c - Mesh model · Geometry buffers and higher-level model composition for rendering.
src/client/mesh.c - UI text · On-screen GUI and font/text rendering for overlays and status output.
src/client/renderer/gui.c - Client API · Client-facing orchestration and state access contract.
src/client/client.h
Server process
Headless authoritative runtime that simulates state and services network traffic.
- Main · Server executable entry point.
src/server/main.c - Server core · Authoritative server runtime and application logic.
src/server/server.c - Server API · Server-facing orchestration and state access contract.
src/server/server.h
Shared contract
Common protocol, types, and transport wrapper used by both executables.
Runtime assets
Shader sources loaded by the client renderer at runtime.
- Point shader · Runtime shader for point rendering.
assets/shaders/point_shader.vert - Simple shader · Runtime shader for simple geometry rendering.
assets/shaders/simple_shader.vert - Text shader · Runtime shader for font/text rendering.
assets/shaders/text.vert
Connections 23
- Main → Client core: starts · Client entry initializes the runtime.
- Main → Server core: starts · Server entry initializes the authoritative runtime.
- Client core → SDL2 runtime: uses · Client runtime depends on platform window/input/timing services.
- Client core → Net client: connects · Client runtime communicates with the server through the shared transport.
- Client core → Renderer: drives · Client runtime runs the local presentation loop.
- Renderer → Shaders: binds · Renderer manages GPU programs and shader setup.
- Renderer → Mesh model: draws · Renderer consumes scene geometry and model data.
- Renderer → UI text: overlays · Renderer draws GUI and text on top of the scene.
- Renderer → GLAD: loads GL · Renderer relies on GLAD for OpenGL function access.
- Renderer → cglm: math · Renderer uses cglm for transforms and camera math.
- Shaders → Point shader: loads · Shader system consumes runtime GLSL assets.
- Shaders → Simple shader: loads · Shader system consumes runtime GLSL assets.
- Shaders → Text shader: loads · Shader system consumes runtime GLSL assets.
- Server core → Server API: exposes · Server implementation is organized behind its local interface.
- Client core → Client API: exposes · Client implementation is organized behind its local interface.
- Client core → Types: reads/writes · Client uses shared state definitions for protocol handling.
- Server core → Types: reads/writes · Server uses shared state definitions for protocol handling.
- Client core → Constants: uses · Client relies on shared constants to stay protocol-compatible.
- Server core → Constants: uses · Server relies on shared constants to stay protocol-compatible.
- Client core → Transport: uses · Client uses the shared networking wrapper for transport.
- Server core → Transport: uses · Server uses the shared networking wrapper for transport.
- Transport → Net client: client side · Transport wrapper forms the client connection boundary.
- Transport → Server core: server side · Transport wrapper forms the server communication boundary.