From 175c72557b21f356e295a6f8a4acd91b7e744bef Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Fri, 24 Oct 2025 15:40:40 -0700 Subject: Consolidate LLR into a single file. --- include/gfx/llr/light.h | 30 -------------------- include/gfx/llr/llr.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++ include/gfx/llr/material.h | 26 ------------------ include/gfx/llr/mesh.h | 23 ---------------- 4 files changed, 68 insertions(+), 79 deletions(-) delete mode 100644 include/gfx/llr/light.h delete mode 100644 include/gfx/llr/material.h delete mode 100644 include/gfx/llr/mesh.h (limited to 'include') 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 @@ -#pragma once - -typedef struct Texture Texture; - -typedef struct Light Light; - -/// Light type. -typedef enum LightType { EnvironmentLightType } LightType; - -/// Describes an environment light. -typedef struct EnvironmentLightDesc { - const Texture* environment_map; -} EnvironmentLightDesc; - -/// Describes a light. -typedef struct LightDesc { - LightType type; - union { - EnvironmentLightDesc environment; - } light; -} LightDesc; - -/// Create a light. -Light* gfx_make_light(const LightDesc*); - -/// Destroy the light. -/// -/// The light is conveniently removed from the scene graph and its parent scene -/// node is destroyed. -void 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 @@ #pragma once +#include +#include + #include #include #include @@ -11,9 +14,74 @@ typedef struct Material Material; typedef struct Mesh Mesh; typedef struct ShaderProgram ShaderProgram; typedef struct Skeleton Skeleton; +typedef struct Texture Texture; typedef struct LLR LLR; +// ----------------------------------------------------------------------------- +// Data structures. + +/// Light type. +typedef enum LightType { EnvironmentLightType } LightType; + +/// Describes an environment light. +typedef struct EnvironmentLightDesc { + const Texture* environment_map; +} EnvironmentLightDesc; + +/// Describes a light. +typedef struct LightDesc { + LightType type; + union { + EnvironmentLightDesc environment; + } light; +} LightDesc; + +/// Describes a material. +/// +/// TODO: It doesn't hold the shader program anymore...It's in the Mesh. +/// A material holds a shader program and a set of shader-specific uniform +/// variables. Two materials can share the same shader, but shader parameters +/// generally give two materials a different appearance. +typedef struct MaterialDesc { + ShaderUniform uniforms[GFX_MAX_UNIFORMS_PER_MATERIAL]; + int num_uniforms; +} MaterialDesc; + +/// Describes a mesh. +typedef struct MeshDesc { + const Geometry* geometry; + const Material* material; + ShaderProgram* shader; +} MeshDesc; + +/// Create a light. +Light* gfx_make_light(const LightDesc*); + +/// Destroy the light. +/// +/// The light is conveniently removed from the scene graph and its parent scene +/// node is destroyed. +void gfx_destroy_light(Light**); + +/// Create a material. +Material* gfx_make_material(const MaterialDesc*); + +/// Destroy the material. +/// +/// The caller must make sure that no Mesh points to the given Material. +/// For a safe purge of unused resources, see scene_purge(). +void gfx_destroy_material(Material**); + +/// Create a mesh. +Mesh* gfx_make_mesh(const MeshDesc*); + +/// Destroy the mesh. +/// +/// The caller must make sure that no SceneObject points to the given Mesh. +/// For a safe purge of unused resources, see scene_purge(). +void gfx_destroy_mesh(Mesh**); + // ----------------------------------------------------------------------------- // Low-level rendering. 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 @@ -#pragma once - -#include -#include - -typedef struct Material Material; - -/// Describes a material. -/// -/// TODO: It doesn't hold the shader program anymore...It's in the Mesh. -/// A material holds a shader program and a set of shader-specific uniform -/// variables. Two materials can share the same shader, but shader parameters -/// generally give two materials a different appearance. -typedef struct MaterialDesc { - ShaderUniform uniforms[GFX_MAX_UNIFORMS_PER_MATERIAL]; - int num_uniforms; -} MaterialDesc; - -/// Create a material. -Material* gfx_make_material(const MaterialDesc*); - -/// Destroy the material. -/// -/// The caller must make sure that no Mesh points to the given Material. -/// For a safe purge of unused resources, see scene_purge(). -void 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 @@ -#pragma once - -typedef struct Geometry Geometry; -typedef struct Material Material; -typedef struct ShaderProgram ShaderProgram; - -typedef struct Mesh Mesh; - -/// Describes a mesh. -typedef struct MeshDesc { - const Geometry* geometry; - const Material* material; - ShaderProgram* shader; -} MeshDesc; - -/// Create a mesh. -Mesh* gfx_make_mesh(const MeshDesc*); - -/// Destroy the mesh. -/// -/// The caller must make sure that no SceneObject points to the given Mesh. -/// For a safe purge of unused resources, see scene_purge(). -void gfx_destroy_mesh(Mesh**); -- cgit v1.2.3