34 lines
733 B
C++
34 lines
733 B
C++
#ifndef RESOURCES_H
|
|
#define RESOURCES_H
|
|
|
|
#include "SDL3/SDL_render.h"
|
|
#include <SDL3_image/SDL_image.h>
|
|
#include <SDL3_ttf/SDL_ttf.h>
|
|
|
|
namespace cera {
|
|
enum Font {
|
|
FONT_REGULAR = 0,
|
|
FONT_BOLD = 1,
|
|
FONT_MAX
|
|
};
|
|
|
|
extern TTF_TextEngine *textEngine;
|
|
extern TTF_Font *defaultFont[FONT_MAX];
|
|
|
|
typedef void (*DestructorFn)(void* data);
|
|
|
|
void SetDefaultFont(char const *path);
|
|
void StoreResource(void *data, DestructorFn destructor);
|
|
void CleanupResources();
|
|
|
|
static inline SDL_Texture *LoadAndStoreTexture(SDL_Renderer *renderer, char const *path) {
|
|
if(SDL_Texture *texture{IMG_LoadTexture(renderer, path)}) {
|
|
StoreResource(texture, (DestructorFn)&SDL_DestroyTexture);
|
|
return texture;
|
|
}
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
#endif // !RESOURCES_H
|