2024-07-29 09:53:03 +00:00
|
|
|
#ifndef TEXTURES_INTERNAL_API_H
|
|
|
|
#define TEXTURES_INTERNAL_API_H
|
2024-07-12 18:10:25 +00:00
|
|
|
|
2024-07-14 13:04:12 +00:00
|
|
|
#include "../util.h"
|
2024-07-28 20:59:23 +00:00
|
|
|
#include "../textures/modes.h"
|
2024-07-14 13:04:12 +00:00
|
|
|
|
2024-07-12 18:10:25 +00:00
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
#include <stb_rect_pack.h>
|
|
|
|
#include <glad/glad.h>
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
struct texture {
|
2024-07-14 13:04:12 +00:00
|
|
|
t_rect srcrect; /* position in atlas */
|
2024-07-12 18:10:25 +00:00
|
|
|
SDL_Surface *data; /* original image data */
|
2024-07-14 13:04:12 +00:00
|
|
|
int atlas_index;
|
2024-07-28 20:59:23 +00:00
|
|
|
GLuint loner_texture; /* stored directly for loners, == 0 means atlas_index should be used */
|
|
|
|
enum texture_mode mode;
|
2024-07-12 18:10:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct texture_cache_item {
|
|
|
|
char *key;
|
|
|
|
struct texture value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct texture_cache {
|
2024-07-14 15:36:48 +00:00
|
|
|
SDL_Window *window; /* from context */
|
2024-07-12 18:10:25 +00:00
|
|
|
|
|
|
|
struct texture_cache_item *hash;
|
|
|
|
|
2024-07-14 13:04:12 +00:00
|
|
|
stbrp_node *node_buffer; /* used internally by stb_rect_pack */
|
2024-07-12 18:10:25 +00:00
|
|
|
|
|
|
|
SDL_Surface **atlas_surfaces;
|
2024-07-14 13:04:12 +00:00
|
|
|
GLuint *atlas_textures; /* shared by atlas textures */
|
2024-07-14 15:36:48 +00:00
|
|
|
int atlas_index; /* atlas that is currently being built */
|
2024-07-12 18:10:25 +00:00
|
|
|
|
2024-07-14 13:04:12 +00:00
|
|
|
bool is_dirty; /* current atlas needs to be recreated */
|
2024-07-12 18:10:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|