diff options
-rw-r--r-- | gfx/src/gfx.c | 1 | ||||
-rw-r--r-- | gfx/src/renderer/imm_renderer.c | 4 | ||||
-rw-r--r-- | gfx/src/renderer/imm_renderer_impl.h | 38 | ||||
-rw-r--r-- | gfx/src/renderer/renderer_impl.h | 36 |
4 files changed, 42 insertions, 37 deletions
diff --git a/gfx/src/gfx.c b/gfx/src/gfx.c index 27312b2..47f2187 100644 --- a/gfx/src/gfx.c +++ b/gfx/src/gfx.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <gfx/gfx.h> | 1 | #include <gfx/gfx.h> |
2 | 2 | ||
3 | #include "render/render_backend_impl.h" | 3 | #include "render/render_backend_impl.h" |
4 | #include "renderer/imm_renderer_impl.h" | ||
4 | #include "renderer/renderer_impl.h" | 5 | #include "renderer/renderer_impl.h" |
5 | #include "scene/scene_graph.h" | 6 | #include "scene/scene_graph.h" |
6 | #include "scene/scene_impl.h" | 7 | #include "scene/scene_impl.h" |
diff --git a/gfx/src/renderer/imm_renderer.c b/gfx/src/renderer/imm_renderer.c index e9f98f8..12b642c 100644 --- a/gfx/src/renderer/imm_renderer.c +++ b/gfx/src/renderer/imm_renderer.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #include "renderer_impl.h" | 1 | #include "imm_renderer_impl.h" |
2 | 2 | ||
3 | #include <gfx/render_backend.h> | 3 | #include <gfx/render_backend.h> |
4 | #include <gfx/util/shader.h> | 4 | #include <gfx/util/shader.h> |
@@ -8,8 +8,6 @@ | |||
8 | #include <assert.h> | 8 | #include <assert.h> |
9 | #include <string.h> // memcpy | 9 | #include <string.h> // memcpy |
10 | 10 | ||
11 | #include <log/log.h> // TODO: remove | ||
12 | |||
13 | bool imm_renderer_make(ImmRenderer* renderer, RenderBackend* render_backend) { | 11 | bool imm_renderer_make(ImmRenderer* renderer, RenderBackend* render_backend) { |
14 | assert(renderer); | 12 | assert(renderer); |
15 | assert(render_backend); | 13 | assert(render_backend); |
diff --git a/gfx/src/renderer/imm_renderer_impl.h b/gfx/src/renderer/imm_renderer_impl.h new file mode 100644 index 0000000..6f4b818 --- /dev/null +++ b/gfx/src/renderer/imm_renderer_impl.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <gfx/renderer.h> | ||
4 | #include <gfx/sizes.h> | ||
5 | |||
6 | #include <math/vec3.h> | ||
7 | |||
8 | #include <stdbool.h> | ||
9 | #include <stddef.h> | ||
10 | |||
11 | typedef struct Geometry Geometry; | ||
12 | typedef struct ShaderProgram ShaderProgram; | ||
13 | |||
14 | /// Immediate mode renderer. | ||
15 | /// | ||
16 | /// Currently, the immediate mode renderer can only draw up to a maximum number | ||
17 | /// of primitives per frame. It does not adjust this number dynamically. Keeps | ||
18 | /// things simple while the extra complexity is not needed. | ||
19 | typedef struct ImmRenderer { | ||
20 | RenderBackend* render_backend; | ||
21 | ShaderProgram* shader; | ||
22 | Geometry* triangles; | ||
23 | size_t num_triangle_verts; // Number of triangle verts this frame. | ||
24 | // TODO: wireframe rendering. | ||
25 | struct { | ||
26 | bool wireframe : 1; | ||
27 | } flags; | ||
28 | vec3 triangle_verts[IMM_MAX_NUM_TRIANGLES * 3]; | ||
29 | } ImmRenderer; | ||
30 | |||
31 | /// Create a new immediate mode renderer. | ||
32 | bool imm_renderer_make(ImmRenderer*, RenderBackend*); | ||
33 | |||
34 | /// Destroy the immediate mode renderer. | ||
35 | void imm_renderer_destroy(ImmRenderer*); | ||
36 | |||
37 | /// Flush draw commands. | ||
38 | void imm_renderer_flush(ImmRenderer*); | ||
diff --git a/gfx/src/renderer/renderer_impl.h b/gfx/src/renderer/renderer_impl.h index 833025a..b25d14c 100644 --- a/gfx/src/renderer/renderer_impl.h +++ b/gfx/src/renderer/renderer_impl.h | |||
@@ -1,22 +1,11 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | #include <gfx/renderer.h> | 3 | #include <gfx/renderer.h> |
4 | #include <gfx/sizes.h> | ||
5 | #include <gfx/util/ibl.h> | ||
6 | |||
7 | #include <math/vec3.h> | ||
8 | #include <math/vec4.h> | ||
9 | 4 | ||
10 | #include <stdbool.h> | 5 | #include <stdbool.h> |
11 | #include <stddef.h> | ||
12 | |||
13 | // Currently, the immediate mode renderer can only draw up to a maximum number | ||
14 | // of primitives per frame. It does not adjust this number dynamically. Keeps | ||
15 | // things simple while the extra complexity is not needed. | ||
16 | 6 | ||
17 | typedef struct Buffer Buffer; | 7 | typedef struct IBL IBL; |
18 | typedef struct Geometry Geometry; | 8 | typedef struct Texture Texture; |
19 | typedef struct ShaderProgram ShaderProgram; | ||
20 | 9 | ||
21 | typedef struct Renderer { | 10 | typedef struct Renderer { |
22 | RenderBackend* render_backend; | 11 | RenderBackend* render_backend; |
@@ -24,29 +13,8 @@ typedef struct Renderer { | |||
24 | Texture* brdf_integration_map; | 13 | Texture* brdf_integration_map; |
25 | } Renderer; | 14 | } Renderer; |
26 | 15 | ||
27 | typedef struct ImmRenderer { | ||
28 | RenderBackend* render_backend; | ||
29 | ShaderProgram* shader; | ||
30 | Geometry* triangles; | ||
31 | size_t num_triangle_verts; // Number of triangle verts this frame. | ||
32 | // TODO: wireframe rendering. | ||
33 | struct { | ||
34 | bool wireframe : 1; | ||
35 | } flags; | ||
36 | vec3 triangle_verts[IMM_MAX_NUM_TRIANGLES * 3]; | ||
37 | } ImmRenderer; | ||
38 | |||
39 | /// Create a new renderer. | 16 | /// Create a new renderer. |
40 | bool renderer_make(Renderer*, RenderBackend*); | 17 | bool renderer_make(Renderer*, RenderBackend*); |
41 | 18 | ||
42 | /// Destroy the renderer. | 19 | /// Destroy the renderer. |
43 | void renderer_destroy(Renderer*); | 20 | void renderer_destroy(Renderer*); |
44 | |||
45 | /// Create a new immediate mode renderer. | ||
46 | bool imm_renderer_make(ImmRenderer*, RenderBackend*); | ||
47 | |||
48 | /// Destroy the immediate mode renderer. | ||
49 | void imm_renderer_destroy(ImmRenderer*); | ||
50 | |||
51 | /// Flush draw commands. | ||
52 | void imm_renderer_flush(ImmRenderer*); | ||