townengine/src/private/textures.h

43 lines
912 B
C
Raw Normal View History

#ifndef PRIVATE_TEXTURES_H
#define PRIVATE_TEXTURES_H
#include "../util.h"
#include <SDL2/SDL.h>
#include <stb_rect_pack.h>
#include <glad/glad.h>
#include <stdbool.h>
struct texture {
t_rect srcrect; /* position in atlas */
SDL_Surface *data; /* original image data */
int atlas_index;
GLuint loner_texture; /* stored directly for loners, == 0 means atlas_index should be used*/
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;
stbrp_node *node_buffer; /* used internally by stb_rect_pack */
SDL_Surface **atlas_surfaces;
GLuint *atlas_textures; /* shared by atlas textures */
int atlas_index;
bool is_dirty; /* current atlas needs to be recreated */
};
#endif