Fix textures/font lifetimes
This commit is contained in:
@@ -80,10 +80,6 @@ int Window::load_image(const char *path, float alpha, bool pixel_art) {
|
||||
return id;
|
||||
}
|
||||
|
||||
void Window::use_image(int image_id) {
|
||||
image_pool.use(image_id);
|
||||
}
|
||||
|
||||
Vec2<float> Window::get_image_size(int image_id) {
|
||||
if (!image_pool.is_valid(image_id)) {
|
||||
fprintf(stderr, "Invalid image ID: %d\n", image_id);
|
||||
@@ -92,16 +88,6 @@ Vec2<float> Window::get_image_size(int image_id) {
|
||||
return image_pool[image_id]->size;
|
||||
}
|
||||
|
||||
void Window::unload_image(int image_id) {
|
||||
if (!image_pool.is_valid(image_id)) {
|
||||
fprintf(stderr, "Invalid image ID: %d\n", image_id);
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_DestroyTexture(image_pool[image_id]->texture);
|
||||
image_pool.release(image_id);
|
||||
}
|
||||
|
||||
int Window::load_font(const char *path, int font_size, bool bold, bool italic, bool underline, bool pixel_art) {
|
||||
TTF_Font *font = TTF_OpenFont(path, font_size);
|
||||
|
||||
@@ -127,20 +113,6 @@ int Window::load_font(const char *path, int font_size, bool bold, bool italic, b
|
||||
return id;
|
||||
}
|
||||
|
||||
void Window::use_font(int font_id) {
|
||||
font_pool.use(font_id);
|
||||
}
|
||||
|
||||
void Window::unload_font(int font_id) {
|
||||
if (!font_pool.is_valid(font_id)) {
|
||||
fprintf(stderr, "Invalid font ID: %d\n", font_id);
|
||||
return;
|
||||
}
|
||||
|
||||
TTF_CloseFont(font_pool[font_id]->font);
|
||||
font_pool.release(font_id);
|
||||
}
|
||||
|
||||
int Window::create_text(int font_id, const char *text, uint32_t length, Color color) {
|
||||
if (!font_pool.is_valid(font_id)) {
|
||||
fprintf(stderr, "Invalid font ID: %d\n", font_id);
|
||||
@@ -184,16 +156,6 @@ Vec2<float> Window::get_text_size(int text_id) {
|
||||
return text_pool[text_id]->size;
|
||||
}
|
||||
|
||||
void Window::unload_text(int text_id) {
|
||||
if (!text_pool.is_valid(text_id)) {
|
||||
fprintf(stderr, "Invalid text ID: %d\n", text_id);
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_DestroyTexture(text_pool[text_id]->texture);
|
||||
text_pool.release(text_id);
|
||||
}
|
||||
|
||||
bool Window::write(int text_id, Vec2<float> position, float z, float angle, Vec2<float> scale) {
|
||||
if (!text_pool.is_valid(text_id)) {
|
||||
fprintf(stderr, "Invalid text ID: %d\n", text_id);
|
||||
|
||||
Reference in New Issue
Block a user