aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gfx/core.h3
-rw-r--r--include/gfx/render/llr.h79
-rw-r--r--include/gfx/scene.h101
3 files changed, 97 insertions, 86 deletions
diff --git a/include/gfx/core.h b/include/gfx/core.h
index 25b8779..8f01081 100644
--- a/include/gfx/core.h
+++ b/include/gfx/core.h
@@ -482,6 +482,9 @@ void gfx_deactivate_shader_program(const ShaderProgram*);
482/// gfx_activate_shader_program(). 482/// gfx_activate_shader_program().
483void gfx_apply_uniforms(const ShaderProgram*); 483void gfx_apply_uniforms(const ShaderProgram*);
484 484
485/// Set the uniform.
486void gfx_set_uniform(ShaderProgram* prog, const ShaderUniform* uniform);
487
485/// Set the int uniform. 488/// Set the int uniform.
486/// Has no effect if the shader does not contain the given uniform. 489/// Has no effect if the shader does not contain the given uniform.
487void gfx_set_int_uniform(ShaderProgram*, const char* name, int value); 490void gfx_set_int_uniform(ShaderProgram*, const char* name, int value);
diff --git a/include/gfx/render/llr.h b/include/gfx/render/llr.h
index b30b11e..6f635b6 100644
--- a/include/gfx/render/llr.h
+++ b/include/gfx/render/llr.h
@@ -1,13 +1,10 @@
1#pragma once 1#pragma once
2 2
3#include <gfx/core.h> 3#include <math/fwd.h>
4#include <gfx/sizes.h>
5
6#include <math/camera.h>
7#include <math/mat4.h>
8#include <math/vec3.h> 4#include <math/vec3.h>
9 5
10typedef struct Anima Anima; 6typedef struct Anima Anima;
7typedef struct Camera Camera;
11typedef struct Geometry Geometry; 8typedef struct Geometry Geometry;
12typedef struct Light Light; 9typedef struct Light Light;
13typedef struct Material Material; 10typedef struct Material Material;
@@ -18,78 +15,6 @@ typedef struct Texture Texture;
18 15
19typedef struct LLR LLR; 16typedef struct LLR LLR;
20 17
21// TODO: Move data structures to scene.h?
22// -----------------------------------------------------------------------------
23// Data structures.
24// -----------------------------------------------------------------------------
25
26/// Light type.
27typedef enum LightType { EnvironmentLightType } LightType;
28
29/// Describes an environment light.
30typedef struct EnvironmentLightDesc {
31 const Texture* environment_map;
32} EnvironmentLightDesc;
33
34/// Describes a light.
35typedef struct LightDesc {
36 LightType type;
37 union {
38 EnvironmentLightDesc environment;
39 } light;
40} LightDesc;
41
42/// Alpha mode.
43typedef enum AlphaMode { Opaque = 0, Mask = 1, Blend = 2 } AlphaMode;
44
45/// Describes a material.
46///
47/// TODO: It doesn't hold the shader program anymore...It's in the Mesh.
48/// A material holds a shader program and a set of shader-specific uniform
49/// variables. Two materials can share the same shader, but shader parameters
50/// generally give two materials a different appearance.
51typedef struct MaterialDesc {
52 AlphaMode alpha_mode;
53 float alpha_cutoff;
54 int num_uniforms;
55 ShaderUniform uniforms[GFX_MAX_UNIFORMS_PER_MATERIAL];
56} MaterialDesc;
57
58/// Describes a mesh.
59typedef struct MeshDesc {
60 const Geometry* geometry;
61 const Material* material;
62 ShaderProgram* shader;
63} MeshDesc;
64
65/// Create a light.
66Light* gfx_make_light(const LightDesc*);
67
68/// Destroy the light.
69///
70/// TODO: Remove this comment. Inline node payload as described in node_impl.h
71/// The light is conveniently removed from the scene graph and its parent scene
72/// node is destroyed.
73void gfx_destroy_light(Light**);
74
75/// Create a material.
76Material* gfx_make_material(const MaterialDesc*);
77
78/// Destroy the material.
79///
80/// The caller must make sure that no Mesh points to the given Material.
81/// For a safe purge of unused resources, see scene_purge().
82void gfx_destroy_material(Material**);
83
84/// Create a mesh.
85Mesh* gfx_make_mesh(const MeshDesc*);
86
87/// Destroy the mesh.
88///
89/// The caller must make sure that no SceneObject points to the given Mesh.
90/// For a safe purge of unused resources, see scene_purge().
91void gfx_destroy_mesh(Mesh**);
92
93// ----------------------------------------------------------------------------- 18// -----------------------------------------------------------------------------
94// Low-level rendering. 19// Low-level rendering.
95// ----------------------------------------------------------------------------- 20// -----------------------------------------------------------------------------
diff --git a/include/gfx/scene.h b/include/gfx/scene.h
index 9747da7..3aa6e0e 100644
--- a/include/gfx/scene.h
+++ b/include/gfx/scene.h
@@ -1,18 +1,19 @@
1#pragma once 1#pragma once
2 2
3#include <gfx/scene.h> 3#include <gfx/core.h>
4#include <gfx/sizes.h> 4#include <gfx/sizes.h>
5 5
6#include <math/aabb3.h> 6#include <math/aabb3.h>
7#include <math/fwd.h> 7#include <math/fwd.h>
8#include <math/mat4.h> 8#include <math/mat4.h>
9 9
10typedef struct Anima Anima; 10typedef struct Anima Anima;
11typedef struct Camera Camera; 11typedef struct Camera Camera;
12typedef struct Light Light; 12typedef struct Light Light;
13typedef struct Mesh Mesh; 13typedef struct Material Material;
14typedef struct Model Model; 14typedef struct Mesh Mesh;
15typedef struct Scene Scene; 15typedef struct Model Model;
16typedef struct Scene Scene;
16/// A node in the scene graph. 17/// A node in the scene graph.
17/// 18///
18/// Scene nodes take ownership of the object they are associated with (Camera, 19/// Scene nodes take ownership of the object they are associated with (Camera,
@@ -20,6 +21,46 @@ typedef struct Scene Scene;
20typedef struct SceneNode SceneNode; 21typedef struct SceneNode SceneNode;
21typedef struct SceneObject SceneObject; 22typedef struct SceneObject SceneObject;
22typedef struct Skeleton Skeleton; 23typedef struct Skeleton Skeleton;
24typedef struct Texture Texture;
25
26/// Light type.
27typedef enum LightType { EnvironmentLightType } LightType;
28
29/// Describes an environment light.
30typedef struct EnvironmentLightDesc {
31 const Texture* environment_map;
32} EnvironmentLightDesc;
33
34/// Describes a light.
35typedef struct LightDesc {
36 LightType type;
37 union {
38 EnvironmentLightDesc environment;
39 } light;
40} LightDesc;
41
42/// Alpha mode.
43typedef enum AlphaMode { Opaque = 0, Mask = 1, Blend = 2 } AlphaMode;
44
45/// Describes a material.
46///
47/// TODO: It doesn't hold the shader program anymore...It's in the Mesh.
48/// A material holds a shader program and a set of shader-specific uniform
49/// variables. Two materials can share the same shader, but shader parameters
50/// generally give two materials a different appearance.
51typedef struct MaterialDesc {
52 AlphaMode alpha_mode;
53 float alpha_cutoff;
54 int num_uniforms;
55 ShaderUniform uniforms[GFX_MAX_UNIFORMS_PER_MATERIAL];
56} MaterialDesc;
57
58/// Describes a mesh.
59typedef struct MeshDesc {
60 const Geometry* geometry;
61 const Material* material;
62 ShaderProgram* shader;
63} MeshDesc;
23 64
24typedef struct ObjectDesc { 65typedef struct ObjectDesc {
25 size_t num_meshes; 66 size_t num_meshes;
@@ -44,9 +85,51 @@ typedef enum NodeType {
44Camera* gfx_make_camera(void); 85Camera* gfx_make_camera(void);
45 86
46/// Destroy the camera. 87/// Destroy the camera.
88///
89/// The caller must make sure that no Node owns the given Camera.
90/// For a safe purge of unused resources, see scene_purge().
47void gfx_destroy_camera(Camera**); 91void gfx_destroy_camera(Camera**);
48 92
49// ----------------------------------------------------------------------------- 93// -----------------------------------------------------------------------------
94// Light.
95// -----------------------------------------------------------------------------
96
97/// Create a light.
98Light* gfx_make_light(const LightDesc*);
99
100/// Destroy the light.
101///
102/// The caller must make sure that no Node owns the given Light.
103/// For a safe purge of unused resources, see scene_purge().
104void gfx_destroy_light(Light**);
105
106// -----------------------------------------------------------------------------
107// Material.
108// -----------------------------------------------------------------------------
109
110/// Create a material.
111Material* gfx_make_material(const MaterialDesc*);
112
113/// Destroy the material.
114///
115/// The caller must make sure that no Mesh points to the given Material.
116/// For a safe purge of unused resources, see scene_purge().
117void gfx_destroy_material(Material**);
118
119// -----------------------------------------------------------------------------
120// Mesh.
121// -----------------------------------------------------------------------------
122
123/// Create a mesh.
124Mesh* gfx_make_mesh(const MeshDesc*);
125
126/// Destroy the mesh.
127///
128/// The caller must make sure that no SceneObject points to the given Mesh.
129/// For a safe purge of unused resources, see scene_purge().
130void gfx_destroy_mesh(Mesh**);
131
132// -----------------------------------------------------------------------------
50// Model. 133// Model.
51// ----------------------------------------------------------------------------- 134// -----------------------------------------------------------------------------
52 135
@@ -66,8 +149,8 @@ SceneObject* gfx_make_object(const ObjectDesc*);
66 149
67/// Destroy the object. 150/// Destroy the object.
68/// 151///
69/// The object is conveniently removed from the scene graph and its parent scene 152/// The caller must make sure that no Node owns the given SceneObject.
70/// node is destroyed. 153/// For a safe purge of unused resources, see scene_purge().
71void gfx_destroy_object(SceneObject**); 154void gfx_destroy_object(SceneObject**);
72 155
73/// Set the object's skeleton. 156/// Set the object's skeleton.