aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-10-24 15:40:40 -0700
committer3gg <3gg@shellblade.net>2025-10-24 15:40:40 -0700
commit175c72557b21f356e295a6f8a4acd91b7e744bef (patch)
tree3d2a77481bc112e58a7618ef3b8de20a9e415811 /include
parentc2cbe2ef1cb0237efd14fbe87469ee991ad3daa1 (diff)
Consolidate LLR into a single file.
Diffstat (limited to 'include')
-rw-r--r--include/gfx/llr/light.h30
-rw-r--r--include/gfx/llr/llr.h68
-rw-r--r--include/gfx/llr/material.h26
-rw-r--r--include/gfx/llr/mesh.h23
4 files changed, 68 insertions, 79 deletions
diff --git a/include/gfx/llr/light.h b/include/gfx/llr/light.h
deleted file mode 100644
index 132e344..0000000
--- a/include/gfx/llr/light.h
+++ /dev/null
@@ -1,30 +0,0 @@
1#pragma once
2
3typedef struct Texture Texture;
4
5typedef struct Light Light;
6
7/// Light type.
8typedef enum LightType { EnvironmentLightType } LightType;
9
10/// Describes an environment light.
11typedef struct EnvironmentLightDesc {
12 const Texture* environment_map;
13} EnvironmentLightDesc;
14
15/// Describes a light.
16typedef struct LightDesc {
17 LightType type;
18 union {
19 EnvironmentLightDesc environment;
20 } light;
21} LightDesc;
22
23/// Create a light.
24Light* gfx_make_light(const LightDesc*);
25
26/// Destroy the light.
27///
28/// The light is conveniently removed from the scene graph and its parent scene
29/// node is destroyed.
30void gfx_destroy_light(Light**);
diff --git a/include/gfx/llr/llr.h b/include/gfx/llr/llr.h
index f84b3fb..6d78a50 100644
--- a/include/gfx/llr/llr.h
+++ b/include/gfx/llr/llr.h
@@ -1,5 +1,8 @@
1#pragma once 1#pragma once
2 2
3#include <gfx/core.h>
4#include <gfx/sizes.h>
5
3#include <math/camera.h> 6#include <math/camera.h>
4#include <math/mat4.h> 7#include <math/mat4.h>
5#include <math/vec3.h> 8#include <math/vec3.h>
@@ -11,10 +14,75 @@ typedef struct Material Material;
11typedef struct Mesh Mesh; 14typedef struct Mesh Mesh;
12typedef struct ShaderProgram ShaderProgram; 15typedef struct ShaderProgram ShaderProgram;
13typedef struct Skeleton Skeleton; 16typedef struct Skeleton Skeleton;
17typedef struct Texture Texture;
14 18
15typedef struct LLR LLR; 19typedef struct LLR LLR;
16 20
17// ----------------------------------------------------------------------------- 21// -----------------------------------------------------------------------------
22// Data structures.
23
24/// Light type.
25typedef enum LightType { EnvironmentLightType } LightType;
26
27/// Describes an environment light.
28typedef struct EnvironmentLightDesc {
29 const Texture* environment_map;
30} EnvironmentLightDesc;
31
32/// Describes a light.
33typedef struct LightDesc {
34 LightType type;
35 union {
36 EnvironmentLightDesc environment;
37 } light;
38} LightDesc;
39
40/// Describes a material.
41///
42/// TODO: It doesn't hold the shader program anymore...It's in the Mesh.
43/// A material holds a shader program and a set of shader-specific uniform
44/// variables. Two materials can share the same shader, but shader parameters
45/// generally give two materials a different appearance.
46typedef struct MaterialDesc {
47 ShaderUniform uniforms[GFX_MAX_UNIFORMS_PER_MATERIAL];
48 int num_uniforms;
49} MaterialDesc;
50
51/// Describes a mesh.
52typedef struct MeshDesc {
53 const Geometry* geometry;
54 const Material* material;
55 ShaderProgram* shader;
56} MeshDesc;
57
58/// Create a light.
59Light* gfx_make_light(const LightDesc*);
60
61/// Destroy the light.
62///
63/// The light is conveniently removed from the scene graph and its parent scene
64/// node is destroyed.
65void gfx_destroy_light(Light**);
66
67/// Create a material.
68Material* gfx_make_material(const MaterialDesc*);
69
70/// Destroy the material.
71///
72/// The caller must make sure that no Mesh points to the given Material.
73/// For a safe purge of unused resources, see scene_purge().
74void gfx_destroy_material(Material**);
75
76/// Create a mesh.
77Mesh* gfx_make_mesh(const MeshDesc*);
78
79/// Destroy the mesh.
80///
81/// The caller must make sure that no SceneObject points to the given Mesh.
82/// For a safe purge of unused resources, see scene_purge().
83void gfx_destroy_mesh(Mesh**);
84
85// -----------------------------------------------------------------------------
18// Low-level rendering. 86// Low-level rendering.
19 87
20/// Set the shader to be used for subsequent draw calls. 88/// Set the shader to be used for subsequent draw calls.
diff --git a/include/gfx/llr/material.h b/include/gfx/llr/material.h
deleted file mode 100644
index 9ebf9b3..0000000
--- a/include/gfx/llr/material.h
+++ /dev/null
@@ -1,26 +0,0 @@
1#pragma once
2
3#include <gfx/core.h>
4#include <gfx/sizes.h>
5
6typedef struct Material Material;
7
8/// Describes a material.
9///
10/// TODO: It doesn't hold the shader program anymore...It's in the Mesh.
11/// A material holds a shader program and a set of shader-specific uniform
12/// variables. Two materials can share the same shader, but shader parameters
13/// generally give two materials a different appearance.
14typedef struct MaterialDesc {
15 ShaderUniform uniforms[GFX_MAX_UNIFORMS_PER_MATERIAL];
16 int num_uniforms;
17} MaterialDesc;
18
19/// Create a material.
20Material* gfx_make_material(const MaterialDesc*);
21
22/// Destroy the material.
23///
24/// The caller must make sure that no Mesh points to the given Material.
25/// For a safe purge of unused resources, see scene_purge().
26void gfx_destroy_material(Material**);
diff --git a/include/gfx/llr/mesh.h b/include/gfx/llr/mesh.h
deleted file mode 100644
index 0d3b4d4..0000000
--- a/include/gfx/llr/mesh.h
+++ /dev/null
@@ -1,23 +0,0 @@
1#pragma once
2
3typedef struct Geometry Geometry;
4typedef struct Material Material;
5typedef struct ShaderProgram ShaderProgram;
6
7typedef struct Mesh Mesh;
8
9/// Describes a mesh.
10typedef struct MeshDesc {
11 const Geometry* geometry;
12 const Material* material;
13 ShaderProgram* shader;
14} MeshDesc;
15
16/// Create a mesh.
17Mesh* gfx_make_mesh(const MeshDesc*);
18
19/// Destroy the mesh.
20///
21/// The caller must make sure that no SceneObject points to the given Mesh.
22/// For a safe purge of unused resources, see scene_purge().
23void gfx_destroy_mesh(Mesh**);