townengine/src/textures/internal_api.h

43 lines
1023 B
C
Raw Normal View History

#ifndef TEXTURES_INTERNAL_API_H
#define TEXTURES_INTERNAL_API_H
#include "../util.h"
#include "../textures/modes.h"
#include <SDL2/SDL.h>
#include <stb_rect_pack.h>
#include <glad/glad.h>
#include <stdbool.h>
struct texture {
2024-07-30 15:09:21 +00:00
t_frect 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 */
enum texture_mode mode;
};
struct texture_cache_item {
char *key;
struct texture value;
};
struct texture_cache {
SDL_Window *window; /* from context */
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; /* atlas that is currently being built */
bool is_dirty; /* current atlas needs to be recreated */
};
#endif