prosperon/source/engine/texture.h

80 lines
2 KiB
C
Raw Normal View History

2021-11-30 21:29:18 -06:00
#ifndef TEXTURE_H
#define TEXTURE_H
2022-02-06 10:14:57 -06:00
#include "timer.h"
#define TEX_SPEC 0
#define TEX_NORM 1
#define TEX_HEIGHT 2
#define TEX_DIFF 3
2021-11-30 21:29:18 -06:00
struct Rect {
float x;
float y;
float w;
float h;
};
struct TexAnimation {
int frame;
int playing;
int pausetime;
2022-02-06 10:14:57 -06:00
struct timer *timer;
2021-11-30 21:29:18 -06:00
struct Rect uv;
struct Texture *tex;
};
struct TexAnim {
int frames;
int dimensions[2];
int ms;
int loop;
};
struct TextureOptions {
int sprite;
unsigned int gamma:1;
int animation;
};
struct Texture {
2022-02-06 10:14:57 -06:00
int type;
2021-11-30 21:29:18 -06:00
unsigned int id;
2022-01-19 16:43:21 -06:00
int width;
int height;
2021-11-30 21:29:18 -06:00
short flipy;
2022-08-24 12:24:21 -05:00
unsigned char *data; // Pixel data of the texture, loaded in at runtime
2021-11-30 21:29:18 -06:00
struct TextureOptions opts;
struct TexAnim anim;
};
2022-08-25 15:48:15 -05:00
struct Texture *texture_pullfromfile(const char *path); // Create texture from image
struct Texture *texture_loadfromfile(const char *path); // Create texture & load to gpu
void tex_gpu_load(struct Texture *tex); // Send texture data to gpu
void tex_gpu_reload(struct Texture *tex); // gpu_free then gpu_load
void tex_gpu_free(struct Texture *tex); // Remove texture data from gpu
void tex_free(struct Texture *tex); // Delete struct
void tex_flush(struct Texture *tex); // Remove pixel data from struct
void tex_pull(struct Texture *tex); // Pull pixel data from image
void tex_bind(struct Texture *tex); // Bind to gl context
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
2021-11-30 21:29:18 -06:00
void anim_play(struct TexAnimation *anim);
2022-08-25 15:48:15 -05:00
void anim_setframe(struct TexAnimation *anim, int frame);
2021-11-30 21:29:18 -06:00
void anim_stop(struct TexAnimation *anim);
void anim_pause(struct TexAnimation *anim);
void anim_fwd(struct TexAnimation *anim);
void anim_bkwd(struct TexAnimation *anim);
void anim_incr(struct TexAnimation *anim);
void anim_decr(struct TexAnimation *anim);
2022-08-22 08:55:54 -05:00
void tex_incr_anim(struct TexAnimation *tex_anim);
2021-11-30 21:29:18 -06:00
void tex_anim_calc_uv(struct TexAnimation *anim);
void tex_anim_set(struct TexAnimation *anim);
#endif