|
1 | 1 | # Design |
2 | 2 |
|
| 3 | +I could tell you that the Brenta engine was perfectly designed, with a |
| 4 | +clear vision from its inception, with a beautiful and powerful API |
| 5 | +that makes programming truly enjoyable. Except the fact that it would |
| 6 | +be a lie. It does not mean that I don't find the current design and |
| 7 | +API beautiful and fun - I think Brenta is a powerful engine - but its |
| 8 | +development has been more iterative than meticulously designed. I |
| 9 | +rewrote huge parts of the engine many many times, to the point where I |
| 10 | +am not scared to do big refactoring anymore - that is just routine - |
| 11 | +and I know I am deemed to repeat this process again. But through these |
| 12 | +many refactoring, the API reached a point where all objects work well |
| 13 | +together and you can reason about them through what I call the |
| 14 | +"architecture" or "design" of the engine. This is what I aim to |
| 15 | +describe in this documents. |
| 16 | + |
3 | 17 | Game engines are complex pieces of software. They provide an interface |
4 | 18 | to define logic, render graphics, and access system resources like |
5 | 19 | audio and input, as well as providing a cross-platform abstraction to |
6 | 20 | the developer. |
7 | 21 |
|
8 | | -Here is an high-level overview of the main objects Brenta provides: |
9 | | - |
10 | | - |
11 | | - |
12 | | -I wanted to write my own game engine primarily out of fascination and |
13 | | -curiosity to understand how these big systems are designed and |
14 | | -implemented. I found out that writing a game engine has a lot in |
15 | | -common with writing an operating system. You are working with audio, |
16 | | -files, video, network and the GPU. A game engine is essentially a |
17 | | -realtime system since you need to compute logic and render the frame |
18 | | -in under 16ms to run at 60 FPS, hence you have to understand how the |
19 | | -CPU and memory works in order to optimize it. Obviously game engines |
20 | | -and an operating system diverge in many other ways, for example an |
21 | | -operating system should manage virtualization and security, while a |
22 | | -game engine has to manage game logic and physics. Still, I think the |
23 | | -parallelism is clear: you need to interface and reason about many |
24 | | -types of systems and devices, which makes this project interesting to |
25 | | -me. |
| 22 | + |
| 23 | + |
| 24 | +I wanted to write my own graphics engine primarily because I was |
| 25 | +curious to understand how these big systems are designed and |
| 26 | +implemented, and as a programming exercise / learning experience. The |
| 27 | +more I learned about graphics the more I became fascinated and |
| 28 | +interested in the topic. |
| 29 | + |
| 30 | +When I began this project in july 2024 I was really confused with |
| 31 | +using OpenGL and C++, it took me a while to develop a decent mental |
| 32 | +model. I was at my second year of university and I did not have any |
| 33 | +major programming experience, but I pushed through it and hacked some |
| 34 | +things. I became obsessed with the project for the entire summer, |
| 35 | +which led to the release of Brenta v1.0.0. I did not fully understand |
| 36 | +what I was doing and its design is more of a hack (and the code |
| 37 | +clearly shows it). I moved on to other projects afterwards. |
| 38 | + |
| 39 | +I picked up the project in December 2025, I was a more experienced |
| 40 | +developer and I took up the challenge again. Here I fully rewrote |
| 41 | +every part of the engine, introducing most of the core abstractions |
| 42 | +that the engine uses. I found out that writing a game engine has a lot |
| 43 | +of overlap with writing an operating system (which is another area I |
| 44 | +am really interested in). You are working with audio, files, video, |
| 45 | +network and the GPU. A game engine is essentially a realtime system |
| 46 | +since you need to compute logic and render the frame in under 16ms to |
| 47 | +run at 60 FPS, hence you have to understand how the CPU and memory |
| 48 | +works in order to optimize it. |
26 | 49 |
|
27 | 50 |  |
28 | 51 |
|
| 52 | +## Subsystems |
29 | 53 |
|
30 | | -Brenta engine is divided in subsystems, each one has different |
31 | | -responsibilities and provides certain abstractions. The most important |
32 | | -subsystems are the Rendering, which manages things like the scene and |
33 | | -render commands, and the Entity Component System (ECS) which manages |
34 | | -game logic. |
| 54 | +One of the first architectural decision I made was the introduction of |
| 55 | +the `Sybsystem`. Brenta engine is divided in subsystems, each one has |
| 56 | +different responsibilities and provides certain abstractions. The most |
| 57 | +important subsystems are the Rendering, which manages things like the |
| 58 | +scene and render commands, and the Entity Component System (ECS) which |
| 59 | +manages game logic. |
35 | 60 |
|
36 | 61 |  |
37 | 62 |
|
| 63 | +We will talk about various subsystems now. |
| 64 | + |
38 | 65 | ## Renderer |
39 | 66 |
|
40 | 67 | The renderer provides a set of abstraction for working with geometry |
|
0 commit comments