2021-11-30 21:29:18 -06:00
|
|
|
#ifndef TEXTURE_H
|
|
|
|
#define TEXTURE_H
|
|
|
|
|
2023-05-04 17:07:00 -05:00
|
|
|
#include "sokol/sokol_gfx.h"
|
2023-11-14 09:20:09 -06:00
|
|
|
#include "HandmadeMath.h"
|
2023-12-22 11:50:03 -06:00
|
|
|
#include "render.h"
|
2022-02-06 10:14:57 -06:00
|
|
|
|
|
|
|
#define TEX_SPEC 0
|
|
|
|
#define TEX_NORM 1
|
|
|
|
#define TEX_HEIGHT 2
|
|
|
|
#define TEX_DIFF 3
|
|
|
|
|
2022-12-30 13:31:06 -06:00
|
|
|
float st_s_w(struct glrect st);
|
|
|
|
float st_s_h(struct glrect st);
|
|
|
|
|
2023-01-18 14:43:07 -06:00
|
|
|
extern struct glrect ST_UNIT;
|
2021-11-30 21:29:18 -06:00
|
|
|
|
|
|
|
struct TextureOptions {
|
|
|
|
int sprite;
|
2023-01-13 22:08:39 -06:00
|
|
|
int mips;
|
2021-11-30 21:29:18 -06:00
|
|
|
unsigned int gamma:1;
|
2023-06-06 15:49:55 -05:00
|
|
|
int wrapx;
|
|
|
|
int wrapy;
|
2021-11-30 21:29:18 -06:00
|
|
|
};
|
|
|
|
|
2023-01-18 14:43:07 -06:00
|
|
|
/* Represents an actual texture on the GPU */
|
2021-11-30 21:29:18 -06:00
|
|
|
struct Texture {
|
2023-05-04 17:07:00 -05:00
|
|
|
sg_image id; /* ID reference for the GPU memory location of the texture */
|
2023-12-21 17:21:01 -06:00
|
|
|
int width;
|
|
|
|
int height;
|
2023-03-24 14:01:01 -05:00
|
|
|
unsigned char *data;
|
2021-11-30 21:29:18 -06:00
|
|
|
struct TextureOptions opts;
|
2023-12-29 19:08:53 -06:00
|
|
|
int frames;
|
|
|
|
int *delays;
|
2021-11-30 21:29:18 -06:00
|
|
|
};
|
|
|
|
|
2023-12-29 19:08:53 -06:00
|
|
|
typedef struct Texture texture;
|
|
|
|
|
2023-05-24 20:45:50 -05:00
|
|
|
struct Image {
|
|
|
|
struct Texture *tex;
|
|
|
|
struct glrect frame;
|
|
|
|
};
|
|
|
|
|
2022-08-25 15:48:15 -05:00
|
|
|
struct Texture *texture_pullfromfile(const char *path); // Create texture from image
|
2023-11-03 22:01:30 -05:00
|
|
|
struct Texture *texture_fromdata(void *raw, long size);
|
2023-12-18 17:12:05 -06:00
|
|
|
|
|
|
|
/* Hot reloads a texture, if needed */
|
2023-05-01 20:58:10 -05:00
|
|
|
void texture_sync(const char *path);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-08-25 15:48:15 -05:00
|
|
|
char * tex_get_path(struct Texture *tex); // Get image path for texture
|
2022-08-24 12:24:21 -05:00
|
|
|
|
2023-09-24 11:26:44 -05:00
|
|
|
int gif_nframes(const char *path);
|
2023-12-29 19:08:53 -06:00
|
|
|
int *gif_delays(const char *path);
|
2023-09-24 11:26:44 -05:00
|
|
|
|
2022-12-29 11:27:41 -06:00
|
|
|
struct glrect tex_get_rect(struct Texture *tex);
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 tex_get_dimensions(struct Texture *tex);
|
2022-12-24 13:18:06 -06:00
|
|
|
|
2024-01-02 07:55:22 -06:00
|
|
|
double perlin(double x, double y, double z);
|
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
#endif
|