1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# GFX - 3D Rendering Library
A portable 3D rendering library with minimal dependencies written for
educational purposes.
## Guiding Principles
- Provide a minimal set of functionality necessary for indie games and graphics
applications.
- Provide a minimal interface; physically hide the implementation.
- Allow for additional future rendering backends (e.g. Vulkan).
- Strive for a minimal set of dependencies.
- All dependencies but system libraries should be compiled with the graphics
library for portability and ease of use.
- Rely on dynamic allocation as little as possible. Isolate dynamic allocation
to where it is strictly needed.
## Design
### Gfx
The `Gfx` object represents the graphics subsystem and provides a high-level API
to render graphics. The `Gfx` object exposes a `Render` backend and a `Renderer`
, and allows the caller to create `Scene` objects.
### Render Backend
The `Render Backend` is a thin abstraction layer over low-level graphics APIs
(OpenGL, etc). It presents an immediate mode style of rendering, whereby callers
directly submit draw commands to the `Render Backend`.
The `Render Backend` holds GPU resources such as geometry, textures, shaders,
etc.
Currently there is only one implementation of the `Render Backend` based on
OpenGL for simplicity and portability.
#### Ownership
The `Render Backend` owns all rendering resources: buffers, geometries,
textures, shaders, etc. Even resources that point to other resources do not own
those other resources (geometries and buffers).
There is no sophisticated resource sharing on the renderer side, like reference
counting or resource naming. Instead, it is up to the user to make appropriate
use of allocated resources and share them where appropriate.
### Scene
A `Scene` is the top-level object of a scene graph. A scene graph is a
description of the scene and holds all of the elements that make up a scene:
nodes, cameras, lights, objects, etc.
### Renderer
The `Renderer` takes a `Render` backend and a `Scene` and renders the scene.
Currently, only a forward renderer is provided, but additional renderers can be
implemented in the future.
## Future Work
- Ideally, some way to customize the rendering pipeline to allow for custom
multi-pass rendering algorithms.
## Build (Ubuntu)
```
sudo apt install libbsd-dev libgl-dev libglfw3-dev zlib1g-dev
```
TODO: Add GLFW and zlib to `contrib/`.
|