New design for graphics demo

Inspiration

I watched this which is a really good talk

I posted a couple of weeks ago about making a game but i’ve been thinking more about the code and how to structure it. First of all I’m going to be using C++23 but mostly a C-like non-oop style.

Nothing here is a firm plan, just ideas

Design

I will build a number of “libraries”. They might not build as libraries, but let’s call them that, and start by actually building them as libraries for now.

librender

This library can create a window, a texture, a shader, a mesh object. It can render a mesh. It will be the only library that uses OpenGL directly. It will not be responsible for loading textures or meshes etc , that will be done by libasset, instead it will take Texture_Data and Mesh_Data structs with the raw data as input

libasset

This library will be responsible for loading assets from disk. It will load textures, meshes, shaders and other assets. It will provide a simple interface to load these assets and return the data in Texture_Data, Mesh_Data, Shader_Data structs. It will also provide a way to unload these assets when they are no longer needed. It will not create GPU resources, that will be done by librender.

libgame

This library will be responsible for the game logic. It will handle the game state, the main render loop. It will use librender to render the game world and libinput to handle user input. It will not be responsible for loading assets, that will be done by libasset. It will also provide a simple interface to update the game state and render the game world. It will be the main entry point for the game.

libworld

This library will be responsible for the world state. It will know aboiut the entities in the world, their positions, velocities, and other properties. It will handle the physics and collision detection.

libinput

This library will be responsible for handling input from the user. It will provide a simple interface to get input events like key presses, mouse movements, and other input events. It will not be responsible for handling the input events, that will be done by libgame.

libaudio

This library will be responsible for handling audio. It will provide a simple interface to play sounds, load audio files, and manage audio resources. It will not be responsible for loading audio files, that will be done by libasset. It will also provide a way to unload audio resources when they are no longer needed.

libui

This library will be responsible for the user interface. It will provide a simple interface to create UI elements like buttons, text boxes, and other UI elements. It will not be responsible for handling the UI events, that will be done by libgame. It will also provide a way to unload UI resources when they are no longer needed.

libnetwork

This library will be responsible for handling network communication. It will provide a simple interface to send and receive data over the network. It will not be responsible for handling the network events, that will be done by libgame. It will also provide a way to unload network resources when they are no longer needed.

libphysics

This library will be responsible for handling physics simulations. It will provide a simple interface to simulate physics, handle collisions, and manage physics resources. It will not be responsible for loading physics resources, that will be done by libasset. It will also provide a way to unload physics resources when they are no longer needed.

libscript

This library will be responsible for handling scripting. It will provide a simple interface to run scripts, load script files, and manage script resources. It will not be responsible for loading script files, that will be done by libasset. It will also provide a way to unload script resources when they are no longer needed.

libdebug

This library will be responsible for debugging tools. It will provide a simple interface to log messages, debug information, and other debugging tools. It will not be responsible for handling the debug events, that will be done by libgame. It will also provide a way to unload debug resources when they are no longer needed.