aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gfx/core.h24
-rw-r--r--include/gfx/render/llr.h11
-rw-r--r--include/gfx/render/renderer.h13
-rw-r--r--include/gfx/scene.h1
4 files changed, 36 insertions, 13 deletions
diff --git a/include/gfx/core.h b/include/gfx/core.h
index dc0b015..5a05cda 100644
--- a/include/gfx/core.h
+++ b/include/gfx/core.h
@@ -183,11 +183,12 @@ typedef struct ShaderProgramDesc {
183 183
184/// Shader uniform type. 184/// Shader uniform type.
185typedef enum { 185typedef enum {
186 UniformInt,
186 UniformFloat, 187 UniformFloat,
187 UniformMat4, 188 UniformMat4,
188 UniformTexture,
189 UniformVec3, 189 UniformVec3,
190 UniformVec4, 190 UniformVec4,
191 UniformTexture,
191 UniformMat4Array 192 UniformMat4Array
192} UniformType; 193} UniformType;
193 194
@@ -200,10 +201,11 @@ typedef struct ShaderUniform {
200 UniformType type; 201 UniformType type;
201 union { 202 union {
202 const Texture* texture; 203 const Texture* texture;
203 mat4 mat4; 204 int uniform_int;
204 vec3 vec3; 205 float uniform_float;
205 vec4 vec4; 206 mat4 uniform_mat4;
206 float scalar; 207 vec3 uniform_vec3;
208 vec4 uniform_vec4;
207 struct { 209 struct {
208 size_t count; 210 size_t count;
209 union { 211 union {
@@ -479,9 +481,13 @@ void gfx_deactivate_shader_program(const ShaderProgram*);
479/// gfx_activate_shader_program(). 481/// gfx_activate_shader_program().
480void gfx_apply_uniforms(const ShaderProgram*); 482void gfx_apply_uniforms(const ShaderProgram*);
481 483
482/// Set the texture uniform. 484/// Set the int uniform.
483/// Has no effect if the shader does not contain the given uniform. 485/// Has no effect if the shader does not contain the given uniform.
484void gfx_set_texture_uniform(ShaderProgram*, const char* name, const Texture*); 486void gfx_set_int_uniform(ShaderProgram*, const char* name, int value);
487
488/// Set the float uniform.
489/// Has no effect if the shader does not contain the given uniform.
490void gfx_set_float_uniform(ShaderProgram*, const char* name, float value);
485 491
486/// Set the matrix uniform. 492/// Set the matrix uniform.
487/// Has no effect if the shader does not contain the given uniform. 493/// Has no effect if the shader does not contain the given uniform.
@@ -495,9 +501,9 @@ void gfx_set_vec3_uniform(ShaderProgram*, const char* name, vec3);
495/// Has no effect if the shader does not contain the given uniform. 501/// Has no effect if the shader does not contain the given uniform.
496void gfx_set_vec4_uniform(ShaderProgram*, const char* name, vec4); 502void gfx_set_vec4_uniform(ShaderProgram*, const char* name, vec4);
497 503
498/// Set the float uniform. 504/// Set the texture uniform.
499/// Has no effect if the shader does not contain the given uniform. 505/// Has no effect if the shader does not contain the given uniform.
500void gfx_set_float_uniform(ShaderProgram*, const char* name, float value); 506void gfx_set_texture_uniform(ShaderProgram*, const char* name, const Texture*);
501 507
502/// Set the matrix array uniform. 508/// Set the matrix array uniform.
503/// Has no effect if the shader does not contain the given uniform. 509/// Has no effect if the shader does not contain the given uniform.
diff --git a/include/gfx/render/llr.h b/include/gfx/render/llr.h
index 785f9cd..b30b11e 100644
--- a/include/gfx/render/llr.h
+++ b/include/gfx/render/llr.h
@@ -18,8 +18,10 @@ typedef struct Texture Texture;
18 18
19typedef struct LLR LLR; 19typedef struct LLR LLR;
20 20
21// TODO: Move data structures to scene.h?
21// ----------------------------------------------------------------------------- 22// -----------------------------------------------------------------------------
22// Data structures. 23// Data structures.
24// -----------------------------------------------------------------------------
23 25
24/// Light type. 26/// Light type.
25typedef enum LightType { EnvironmentLightType } LightType; 27typedef enum LightType { EnvironmentLightType } LightType;
@@ -37,6 +39,9 @@ typedef struct LightDesc {
37 } light; 39 } light;
38} LightDesc; 40} LightDesc;
39 41
42/// Alpha mode.
43typedef enum AlphaMode { Opaque = 0, Mask = 1, Blend = 2 } AlphaMode;
44
40/// Describes a material. 45/// Describes a material.
41/// 46///
42/// TODO: It doesn't hold the shader program anymore...It's in the Mesh. 47/// TODO: It doesn't hold the shader program anymore...It's in the Mesh.
@@ -44,8 +49,10 @@ typedef struct LightDesc {
44/// variables. Two materials can share the same shader, but shader parameters 49/// variables. Two materials can share the same shader, but shader parameters
45/// generally give two materials a different appearance. 50/// generally give two materials a different appearance.
46typedef struct MaterialDesc { 51typedef struct MaterialDesc {
47 ShaderUniform uniforms[GFX_MAX_UNIFORMS_PER_MATERIAL]; 52 AlphaMode alpha_mode;
53 float alpha_cutoff;
48 int num_uniforms; 54 int num_uniforms;
55 ShaderUniform uniforms[GFX_MAX_UNIFORMS_PER_MATERIAL];
49} MaterialDesc; 56} MaterialDesc;
50 57
51/// Describes a mesh. 58/// Describes a mesh.
@@ -85,6 +92,7 @@ void gfx_destroy_mesh(Mesh**);
85 92
86// ----------------------------------------------------------------------------- 93// -----------------------------------------------------------------------------
87// Low-level rendering. 94// Low-level rendering.
95// -----------------------------------------------------------------------------
88 96
89/// Set the shader to be used for subsequent draw calls. 97/// Set the shader to be used for subsequent draw calls.
90/// The shader is not yet activated at this point. 98/// The shader is not yet activated at this point.
@@ -130,6 +138,7 @@ void gfx_llr_render_mesh(LLR*, const Mesh*);
130 138
131// ----------------------------------------------------------------------------- 139// -----------------------------------------------------------------------------
132// Matrix stack manipulation. 140// Matrix stack manipulation.
141// -----------------------------------------------------------------------------
133 142
134/// Load an identity model matrix. Clears the matrix stack. 143/// Load an identity model matrix. Clears the matrix stack.
135void gfx_llr_load_identity(LLR* renderer); 144void gfx_llr_load_identity(LLR* renderer);
diff --git a/include/gfx/render/renderer.h b/include/gfx/render/renderer.h
index 6cebe50..9f3231b 100644
--- a/include/gfx/render/renderer.h
+++ b/include/gfx/render/renderer.h
@@ -8,6 +8,7 @@ typedef struct Scene Scene;
8 8
9typedef struct Renderer Renderer; 9typedef struct Renderer Renderer;
10 10
11// TODO: Add RenderDepth.
11typedef enum RenderSceneMode { 12typedef enum RenderSceneMode {
12 RenderDefault, 13 RenderDefault,
13 RenderDebug, 14 RenderDebug,
@@ -16,10 +17,16 @@ typedef enum RenderSceneMode {
16 RenderTangents 17 RenderTangents
17} RenderSceneMode; 18} RenderSceneMode;
18 19
20typedef enum RenderSceneFilter {
21 RenderOpaqueAndAlphaMasked,
22 RenderTransparent
23} RenderSceneFilter;
24
19typedef struct RenderSceneParams { 25typedef struct RenderSceneParams {
20 RenderSceneMode mode; 26 RenderSceneMode mode;
21 const Scene* scene; 27 RenderSceneFilter filter;
22 const Camera* camera; 28 const Scene* scene;
29 const Camera* camera;
23} RenderSceneParams; 30} RenderSceneParams;
24 31
25/// Render the scene. 32/// Render the scene.
diff --git a/include/gfx/scene.h b/include/gfx/scene.h
index 740a948..9747da7 100644
--- a/include/gfx/scene.h
+++ b/include/gfx/scene.h
@@ -82,6 +82,7 @@ const Skeleton* gfx_get_object_skeleton(const SceneObject*);
82/// The object's bounding box is the bounding box of its mesh geometries. 82/// The object's bounding box is the bounding box of its mesh geometries.
83aabb3 gfx_get_object_aabb(const SceneObject*); 83aabb3 gfx_get_object_aabb(const SceneObject*);
84 84
85// TODO: Remove the scene object? It only contains the root node.
85// ----------------------------------------------------------------------------- 86// -----------------------------------------------------------------------------
86// Scene. 87// Scene.
87// ----------------------------------------------------------------------------- 88// -----------------------------------------------------------------------------