Files
SimpleRayTracing/header/Rendering/Texture.h
Misaki 3de6b83d32 Set C standard to C11 and add new assets
Changed CMakeLists.txt to set the C standard to C11.
Added multiple binary image files for new visual assets.
Added several new image files to enhance rendering capabilities.
Changed stb_image.h to improve support for various image formats.
Changed ray tracing engine to enhance ray creation and intersection.
Changed triangle structure to use a vertex array for better attribute handling.
Changed scene initialization to accommodate new texture management.
2025-04-29 01:43:52 +09:00

54 lines
1.0 KiB
C

#ifndef TEXTURE_H
#define TEXTURE_H
#include "cglm/struct/vec4.h"
#include <stdint.h>
#include <stdbool.h>
#define INVALID_TEXTURE_ID UINT16_MAX
typedef enum
{
REPEAT,
CLAMP,
} wrap_mode_t;
typedef enum
{
NEAREST,
LINEAR,
} filter_mode_t;
typedef struct
{
uint32_t width;
uint32_t height;
wrap_mode_t wrap_mode;
filter_mode_t filter_mode;
uint8_t channel_count;
uint8_t* data;
} texture_t;
typedef struct
{
uint16_t count;
uint16_t size;
texture_t* buffer;
} texture_collection_t;
typedef struct
{
uint16_t id;
} texture_entity_t;
bool texture_collection_init(uint16_t size, texture_collection_t* textures);
void texture_collection_resize(texture_collection_t* textures, uint16_t size);
void texture_collection_free(texture_collection_t* textures);
texture_entity_t texture_load(const char* filename, bool srgb, texture_collection_t* textures);
vec4s texture_sample(const texture_t* texture, float u, float v);
void texture_free(texture_t* texture);
#endif // TEXTURE_H