diff options
Diffstat (limited to 'src/new_render/skybox.h')
-rw-r--r-- | src/new_render/skybox.h | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/new_render/skybox.h b/src/new_render/skybox.h index 9bdc2ec..ec06658 100644 --- a/src/new_render/skybox.h +++ b/src/new_render/skybox.h @@ -7,20 +7,6 @@ #include "defines.h" #include "ral_types.h" -typedef struct CubeMapData { - void* top_image_data; - void* bottom_image_data; - void* left_image_data; - void* right_image_data; - void* front_image_data; - void* back_image_data; - u32 width, height, num_channels; -} CubeMapData; - -PUB void CubeMapData_Load(const char** face_paths, int n); // should always pass n = 6 for now -PUB void CubeMapData_Free(CubeMapData* cubemap); // Frees all the image data for a cubemap -PUB TextureHandle CubeMapData_Upload(CubeMapData* cubemap); - typedef struct Skybox { BufferHandle vertex_buffer; TextureHandle texture; @@ -30,3 +16,35 @@ typedef struct Skybox { PUB Skybox Skybox_Create(const char** face_paths, int n); // should always pass n = 6 for now PUB void Skybox_Draw(Skybox* skybox); + +typedef struct SkyboxUniforms { + Vec3 in_pos; + TextureHandle cubemap; +} SkyboxUniforms; + +static ShaderDataLayout Skybox_GetLayout(void* data) { + SkyboxUniforms* d = (SkyboxUniforms*)data; // cold cast + bool has_data = data != NULL; + + ShaderBinding b1 = { + .label = "In", + .vis = VISIBILITY_VERTEX, + .kind = BINDING_BYTES, + .data = {.bytes = {.size = sizeof(Vec3)}} + }; + + ShaderBinding b2 = { + .label = "cubemap", + .vis = VISIBILITY_FRAGMENT, + .kind = BINDING_SAMPLER, + }; + + if (has_data) { + b1.data.bytes.data = &d->in_pos; + b2.data.texture.handle = d->cubemap; + } + return (ShaderDataLayout) { + .bindings = { b1, b2}, + .binding_count = 2 + }; +}
\ No newline at end of file |