diff options
author | Omniscient <omniscient.oce@gmail.com> | 2024-03-05 20:50:20 +1100 |
---|---|---|
committer | Omniscient <omniscient.oce@gmail.com> | 2024-03-05 20:50:20 +1100 |
commit | cd1f6de2fda8b29a55d9ca9abb7b31e774d8d165 (patch) | |
tree | 3d9dbd54b05ed1eb99b8eec55a78733f2bdefead | |
parent | 90dd96cbc9b09cdc75977b115a9b61fa7547baef (diff) |
add render types for material and texture
-rw-r--r-- | src/core.h | 3 | ||||
-rw-r--r-- | src/renderer/render_types.h | 44 |
2 files changed, 44 insertions, 3 deletions
@@ -13,10 +13,11 @@ typedef struct core { input_state input; text_system_state text; screenspace_state screenspace; + model_darray* models; } core; // --- Lifecycle core* core_bringup(); void core_shutdown(core* core); -void core_input_update(core* core);
\ No newline at end of file +void core_input_update(core* core); diff --git a/src/renderer/render_types.h b/src/renderer/render_types.h index f63f3f8..45851fe 100644 --- a/src/renderer/render_types.h +++ b/src/renderer/render_types.h @@ -13,7 +13,11 @@ struct GLFWwindow; +#define MAX_MATERIAL_NAME_LEN 256 +#define MAX_TEXTURE_NAME_LEN 256 + #ifndef RESOURCE_HANDLE_DEFS +CORE_DEFINE_HANDLE(model_handle); CORE_DEFINE_HANDLE(texture_handle); #define RESOURCE_HANDLE_DEFS #endif @@ -36,6 +40,42 @@ typedef struct renderer { renderer_config config; } renderer; +// --- Lighting & Materials + +typedef struct texture { + u32 texture_id; + char name[MAX_TEXTURE_NAME_LEN]; + void *image_data; + u32 width; + u32 height; + u8 channel_count; + u32 channel_type; +} texture; + +typedef struct blinn_phong_material { + char name[MAX_MATERIAL_NAME_LEN]; + texture diffuse_texture; + char diffuse_tex_path[256]; + texture specular_texture; + char specular_tex_path[256]; + vec3 ambient_colour; + vec3 diffuse; + vec3 specular; + f32 spec_exponent; + bool is_loaded; + bool is_uploaded; +} blinn_phong_material; +typedef blinn_phong_material material; // when we start using PBR, this will no longer be the case + +// the default blinn-phong material. MUST be initialised with the function below +extern material DEFAULT_MATERIAL; +void default_material_init(); + +#ifndef TYPED_MATERIAL_ARRAY +KITC_DECL_TYPED_ARRAY(material) // creates "material_darray" +#define TYPED_MATERIAL_ARRAY +#endif + /** @brief Vertex format for a static mesh */ typedef struct vertex { vec3 position; @@ -69,7 +109,7 @@ typedef struct model { str8 name; mesh_darray meshes; aabb_3d bbox; - // TODO: materials + material_darray *materials; bool is_loaded; bool is_uploaded; } model; @@ -102,4 +142,4 @@ typedef enum gpu_texture_format { TEXTURE_FORMAT_8_8_8_8_RGBA_UNORM, TEXTURE_FORMAT_DEPTH_DEFAULT, TEXTURE_FORMAT_COUNT -} gpu_texture_format;
\ No newline at end of file +} gpu_texture_format; |