diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/gfx/core.h | 3 | ||||
| -rw-r--r-- | include/gfx/llr/light.h (renamed from include/gfx/scene/light.h) | 0 | ||||
| -rw-r--r-- | include/gfx/llr/llr.h | 117 | ||||
| -rw-r--r-- | include/gfx/llr/material.h (renamed from include/gfx/scene/material.h) | 0 | ||||
| -rw-r--r-- | include/gfx/llr/mesh.h (renamed from include/gfx/scene/mesh.h) | 0 |
5 files changed, 120 insertions, 0 deletions
diff --git a/include/gfx/core.h b/include/gfx/core.h index 2a29003..0cf4465 100644 --- a/include/gfx/core.h +++ b/include/gfx/core.h | |||
| @@ -474,6 +474,9 @@ void gfx_deactivate_shader_program(const ShaderProgram*); | |||
| 474 | /// | 474 | /// |
| 475 | /// This function should be called after setting all of the uniform variables | 475 | /// This function should be called after setting all of the uniform variables |
| 476 | /// and prior to issuing a draw call. | 476 | /// and prior to issuing a draw call. |
| 477 | /// | ||
| 478 | /// The given program must have been activated prior to this call with | ||
| 479 | /// gfx_activate_shader_program(). | ||
| 477 | void gfx_apply_uniforms(const ShaderProgram*); | 480 | void gfx_apply_uniforms(const ShaderProgram*); |
| 478 | 481 | ||
| 479 | /// Set the texture uniform. | 482 | /// Set the texture uniform. |
diff --git a/include/gfx/scene/light.h b/include/gfx/llr/light.h index 132e344..132e344 100644 --- a/include/gfx/scene/light.h +++ b/include/gfx/llr/light.h | |||
diff --git a/include/gfx/llr/llr.h b/include/gfx/llr/llr.h new file mode 100644 index 0000000..49b7706 --- /dev/null +++ b/include/gfx/llr/llr.h | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <math/aabb2.h> | ||
| 4 | #include <math/aabb3.h> | ||
| 5 | #include <math/camera.h> | ||
| 6 | #include <math/mat4.h> | ||
| 7 | #include <math/vec3.h> | ||
| 8 | #include <math/vec4.h> | ||
| 9 | |||
| 10 | typedef struct Anima Anima; | ||
| 11 | typedef struct Light Light; | ||
| 12 | typedef struct Mesh Mesh; | ||
| 13 | typedef struct Skeleton Skeleton; | ||
| 14 | |||
| 15 | typedef struct ImmRenderer ImmRenderer; | ||
| 16 | |||
| 17 | /// Prepare the graphics systems for immediate-mode rendering. | ||
| 18 | /// | ||
| 19 | /// Call this before issuing any immediate-mode rendering draws. | ||
| 20 | void gfx_imm_start(ImmRenderer*); | ||
| 21 | |||
| 22 | /// End immediate mode rendering. | ||
| 23 | /// | ||
| 24 | /// Call this after issuing immediate-mode rendering draws and before swapping | ||
| 25 | /// buffers. | ||
| 26 | void gfx_imm_end(ImmRenderer*); | ||
| 27 | |||
| 28 | // ----------------------------------------------------------------------------- | ||
| 29 | // Immediate-mode rendering of scene elements. | ||
| 30 | // | ||
| 31 | // This renders models and meshes under lighting. It is up to the client to | ||
| 32 | // determine visibility, sort the calls optimally, etc. | ||
| 33 | |||
| 34 | /// Push a light into the lights stack. | ||
| 35 | void gfx_imm_push_light(ImmRenderer*, Light*); | ||
| 36 | |||
| 37 | /// Pop the last light from the lights stack. | ||
| 38 | void gfx_imm_pop_light(ImmRenderer*); | ||
| 39 | |||
| 40 | /// Load a skeleton. | ||
| 41 | /// | ||
| 42 | /// If a skeleton is loaded, subsequent meshes are rendered with joint data | ||
| 43 | /// passed to the shader. This has a cost, so if subsequent meshes are not | ||
| 44 | /// animated, unload the skeleton prior to rendering them. | ||
| 45 | void gfx_imm_set_skeleton(ImmRenderer*, const Anima*, const Skeleton*); | ||
| 46 | |||
| 47 | /// Unload the loaded skeleton. | ||
| 48 | void gfx_imm_unset_skeleton(ImmRenderer*); | ||
| 49 | |||
| 50 | /// Render the mesh. | ||
| 51 | void gfx_imm_render_mesh(ImmRenderer*, const Mesh*); | ||
| 52 | |||
| 53 | // ----------------------------------------------------------------------------- | ||
| 54 | // Immediate-mode rendering of primitives. | ||
| 55 | // | ||
| 56 | // This is rather inefficient and should be reserved for debug rendering. It | ||
| 57 | // also does not support lighting; the primitives are rendered with a constant | ||
| 58 | // colour. | ||
| 59 | |||
| 60 | /// Draw a set of triangles. | ||
| 61 | void gfx_imm_draw_triangles(ImmRenderer*, const vec3[], size_t num_triangles); | ||
| 62 | |||
| 63 | /// Draw a triangle. | ||
| 64 | void gfx_imm_draw_triangle(ImmRenderer*, const vec3[3]); | ||
| 65 | |||
| 66 | /// Draw a bounding box. | ||
| 67 | void gfx_imm_draw_aabb2(ImmRenderer*, aabb2); | ||
| 68 | |||
| 69 | /// Draw a bounding box. | ||
| 70 | void gfx_imm_draw_aabb3(ImmRenderer*, aabb3); | ||
| 71 | |||
| 72 | /// Draw a box. | ||
| 73 | /// | ||
| 74 | /// The vertices must be given in the following order: | ||
| 75 | /// | ||
| 76 | /// 7 ----- 6 | ||
| 77 | /// / /| | ||
| 78 | /// 3 ----- 2 | | ||
| 79 | /// | | | | ||
| 80 | /// | 4 ----- 5 | ||
| 81 | /// |/ |/ | ||
| 82 | /// 0 ----- 1 | ||
| 83 | void gfx_imm_draw_box3(ImmRenderer* renderer, const vec3 vertices[8]); | ||
| 84 | |||
| 85 | /// Set the render colour. | ||
| 86 | void gfx_imm_set_colour(ImmRenderer*, vec4 colour); | ||
| 87 | |||
| 88 | // ----------------------------------------------------------------------------- | ||
| 89 | // Matrix stack manipulation. | ||
| 90 | // | ||
| 91 | // Common to both scene and and primitive rendering. | ||
| 92 | |||
| 93 | /// Load an identity model matrix. Clears the matrix stack. | ||
| 94 | void gfx_imm_load_identity(ImmRenderer* renderer); | ||
| 95 | |||
| 96 | /// Push the given matrix to the matrix stack. | ||
| 97 | void gfx_imm_push_matrix(ImmRenderer* renderer, const mat4* matrix); | ||
| 98 | |||
| 99 | /// Pop the top of the matrix stack. | ||
| 100 | void gfx_imm_pop_matrix(ImmRenderer* renderer); | ||
| 101 | |||
| 102 | /// Push a translation matrix to the matrix stack. | ||
| 103 | void gfx_imm_translate(ImmRenderer* renderer, vec3 offset); | ||
| 104 | |||
| 105 | /// Set the model matrix. Clears the matrix stack. | ||
| 106 | void gfx_imm_set_model_matrix(ImmRenderer*, const mat4*); | ||
| 107 | |||
| 108 | // ----------------------------------------------------------------------------- | ||
| 109 | // Camera | ||
| 110 | // | ||
| 111 | // Common to both scene and and primitive rendering. | ||
| 112 | |||
| 113 | /// Set the camera. | ||
| 114 | void gfx_imm_set_camera(ImmRenderer*, const Camera*); | ||
| 115 | |||
| 116 | /// Set the view-projection matrix. | ||
| 117 | // void gfx_imm_set_view_projection_matrix(ImmRenderer*, const mat4*); | ||
diff --git a/include/gfx/scene/material.h b/include/gfx/llr/material.h index bca664e..bca664e 100644 --- a/include/gfx/scene/material.h +++ b/include/gfx/llr/material.h | |||
diff --git a/include/gfx/scene/mesh.h b/include/gfx/llr/mesh.h index 0d3b4d4..0d3b4d4 100644 --- a/include/gfx/scene/mesh.h +++ b/include/gfx/llr/mesh.h | |||
