townengine/src/textures.h

40 lines
1.5 KiB
C
Raw Normal View History

2024-07-08 00:44:20 +00:00
#ifndef TEXTURES_H
#define TEXTURES_H
#include "private/textures.h"
2024-07-08 00:44:20 +00:00
#include <SDL2/SDL.h>
#include <glad/glad.h>
2024-07-08 00:44:20 +00:00
void textures_cache_init(struct texture_cache *cache, SDL_Window *window);
void textures_cache_deinit(struct texture_cache *cache);
/* for debugging */
void textures_dump_atlases(struct texture_cache *cache);
/* loads an image if it isn't in the cache, otherwise a no-op. */
/* can be called from anywhere at any time after init, useful if you want to */
/* preload textures you know will definitely be used */
void textures_load(struct texture_cache *cache, const char *path);
2024-07-08 00:44:20 +00:00
/* repacks the current texture atlas based on the texture cache */
void textures_update_current_atlas(struct texture_cache *cache);
/* returns a rect in a texture cache atlas based on a path, for drawing */
/* if the texture is not found, returns a zero-filled rect (so check w or h) */
SDL_Rect textures_get_srcrect(struct texture_cache *cache, const char *path);
2024-07-08 00:44:20 +00:00
/* returns which atlas the texture in the path is in, starting from 0 */
/* if the texture is not found, returns INT_MIN */
int textures_get_atlas_index(struct texture_cache *cache, const char *path);
2024-07-08 00:44:20 +00:00
/* binds atlas texture in opengl state */
void textures_bind_atlas(struct texture_cache *cache, int index, GLenum target);
2024-07-08 00:44:20 +00:00
void textures_bind_loner(struct texture_cache *cache, const char *path, GLenum target);
2024-07-08 00:44:20 +00:00
/* returns the number of atlases in the cache */
size_t textures_get_num_atlases(struct texture_cache *cache);
#endif