42 lines
915 B
C
42 lines
915 B
C
|
#ifndef PRIVATE_TEXTURES_H
|
||
|
#define PRIVATE_TEXTURES_H
|
||
|
|
||
|
#include <SDL2/SDL.h>
|
||
|
#include <stb_rect_pack.h>
|
||
|
#include <glad/glad.h>
|
||
|
|
||
|
#include <stdbool.h>
|
||
|
|
||
|
struct texture {
|
||
|
SDL_Rect srcrect; /* position in atlas */
|
||
|
SDL_Surface *data; /* original image data */
|
||
|
GLuint loner_data; /* loner textures store their data directly */
|
||
|
int atlas_index; /* which atlas the texture is in */
|
||
|
int8_t layer;
|
||
|
};
|
||
|
|
||
|
|
||
|
struct texture_cache_item {
|
||
|
char *key;
|
||
|
struct texture value;
|
||
|
};
|
||
|
|
||
|
|
||
|
struct texture_cache {
|
||
|
/* from context */
|
||
|
SDL_Window *window;
|
||
|
|
||
|
struct texture_cache_item *hash;
|
||
|
struct texture_cache_item *loner_hash;
|
||
|
|
||
|
stbrp_node *node_buffer; /* used internally by stb_rect_pack */
|
||
|
|
||
|
SDL_Surface **atlas_surfaces;
|
||
|
GLuint *atlas_textures;
|
||
|
int atlas_index;
|
||
|
|
||
|
bool is_dirty; /* current atlas needs to be recreated */
|
||
|
};
|
||
|
|
||
|
#endif
|