Fix textures/font lifetimes
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
namespace definitions {
|
||||
DEF_RB(
|
||||
Font,
|
||||
({ window.unload_font(id); }),
|
||||
({ font_pool.release(id); }),
|
||||
({
|
||||
char *path;
|
||||
mrb_int size;
|
||||
@@ -29,7 +29,7 @@ DEF_RB(
|
||||
|
||||
DEF_RB(
|
||||
Image,
|
||||
({ window.unload_image(id); }),
|
||||
({ image_pool.release(id); }),
|
||||
({
|
||||
char *path;
|
||||
mrb_value kwargs;
|
||||
@@ -43,7 +43,6 @@ DEF_RB(
|
||||
}
|
||||
|
||||
s->id = window.load_image(path, alpha, pixel_art);
|
||||
#warning "Fix lifetimes for images/fonts right now they'll always exist"
|
||||
})
|
||||
)
|
||||
|
||||
@@ -70,7 +69,7 @@ DEF_RB(
|
||||
return mrb_nil_value();
|
||||
}
|
||||
int frame_id = get_id_Image(mrb, frame_val);
|
||||
window.use_image(frame_id);
|
||||
image_pool.use(frame_id);
|
||||
frame_ids.push_back(frame_id);
|
||||
}
|
||||
|
||||
@@ -114,7 +113,7 @@ DEF_RB(
|
||||
Vec2<float> position = {x, y};
|
||||
|
||||
int id = get_id_Font(mrb, font_val);
|
||||
window.use_font(id);
|
||||
font_pool.use(id);
|
||||
|
||||
app::EText *element = new app::EText(key_id, id, {255, 255, 255, 255});
|
||||
element->position = position;
|
||||
@@ -238,9 +237,8 @@ DEF_RB(
|
||||
}
|
||||
|
||||
int id = get_id_Animation(mrb, animation_val);
|
||||
Animation *animation = animation_pool[id];
|
||||
|
||||
app::EImage *element = new app::EImage(*animation);
|
||||
app::EImage *element = new app::EImage(id);
|
||||
element->position = {x, y};
|
||||
element->z = z;
|
||||
element->click_through = click_through;
|
||||
@@ -363,7 +361,10 @@ static mrb_value app_run(mrb_state *mrb, mrb_value) {
|
||||
.loop = false
|
||||
};
|
||||
|
||||
app_ = new app::App({(float)width, (float)height}, title, loading_animation);
|
||||
int loading_animation_id = animation_pool.acquire(new Animation(loading_animation));
|
||||
animation_pool.use(loading_animation_id);
|
||||
|
||||
app_ = new app::App({(float)width, (float)height}, title, loading_animation_id);
|
||||
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user