make SetFramebufferAsTarget work also for the loading gamestate

This commit is contained in:
Sebastian Krzyszkowiak 2018-11-22 03:40:41 +01:00
parent a6abd01ec2
commit 7f7c522b3c
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
4 changed files with 19 additions and 10 deletions

View file

@ -279,6 +279,8 @@ SYMBOL_INTERNAL void GamestateProgress(struct Game* game) {
#else #else
al_convert_memory_bitmaps(); al_convert_memory_bitmaps();
DrawGamestates(game); DrawGamestates(game);
SetFramebufferAsTarget(game);
al_clear_to_color(al_map_rgb(0, 0, 0));
double delta = al_get_time() - game->_priv.loading.time; double delta = al_get_time() - game->_priv.loading.time;
if (game->_priv.loading.current->showLoading) { if (game->_priv.loading.current->showLoading) {
game->_priv.loading.gamestate->api->Gamestate_Logic(game, game->_priv.loading.gamestate->data, delta); game->_priv.loading.gamestate->api->Gamestate_Logic(game, game->_priv.loading.gamestate->data, delta);

View file

@ -251,7 +251,8 @@ static inline bool MainloopTick(struct Game* game) {
al_run_detached_thread(GamestateLoadingThread, &data); al_run_detached_thread(GamestateLoadingThread, &data);
while (game->_priv.loading.inProgress) { while (game->_priv.loading.inProgress) {
DrawGamestates(game); DrawGamestates(game);
al_set_target_backbuffer(game->display); SetFramebufferAsTarget(game);
al_clear_to_color(al_map_rgb(0, 0, 0));
double delta = al_get_time() - game->_priv.loading.time; double delta = al_get_time() - game->_priv.loading.time;
if (tmp->showLoading) { if (tmp->showLoading) {
(*game->_priv.loading.gamestate->api->Gamestate_Logic)(game, game->_priv.loading.gamestate->data, delta); (*game->_priv.loading.gamestate->api->Gamestate_Logic)(game, game->_priv.loading.gamestate->data, delta);

View file

@ -486,18 +486,24 @@ SYMBOL_EXPORT void WindowCoordsToViewport(struct Game* game, int* x, int* y) {
} }
SYMBOL_EXPORT ALLEGRO_BITMAP* GetFramebuffer(struct Game* game) { SYMBOL_EXPORT ALLEGRO_BITMAP* GetFramebuffer(struct Game* game) {
if (game->_priv.loading.inProgress) {
return al_get_backbuffer(game->display);
}
return game->_priv.current_gamestate->fb; return game->_priv.current_gamestate->fb;
} }
SYMBOL_EXPORT void SetFramebufferAsTarget(struct Game* game) { SYMBOL_EXPORT void SetFramebufferAsTarget(struct Game* game) {
al_set_target_bitmap(GetFramebuffer(game)); ALLEGRO_BITMAP* framebuffer = GetFramebuffer(game);
double x = al_get_bitmap_width(GetFramebuffer(game)) / (double)game->viewport.width; al_set_target_bitmap(framebuffer);
double y = al_get_bitmap_height(GetFramebuffer(game)) / (double)game->viewport.height; if (framebuffer != al_get_backbuffer(game->display)) {
double x = al_get_bitmap_width(framebuffer) / (double)game->viewport.width;
double y = al_get_bitmap_height(framebuffer) / (double)game->viewport.height;
ALLEGRO_TRANSFORM t; ALLEGRO_TRANSFORM t;
al_identity_transform(&t); al_identity_transform(&t);
al_scale_transform(&t, x, y); al_scale_transform(&t, x, y);
al_use_transform(&t); al_use_transform(&t);
} }
}
SYMBOL_EXPORT ALLEGRO_BITMAP* CreateNotPreservedBitmap(int width, int height) { SYMBOL_EXPORT ALLEGRO_BITMAP* CreateNotPreservedBitmap(int width, int height) {
int flags = al_get_new_bitmap_flags(); int flags = al_get_new_bitmap_flags();