mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 01:01:28 +01:00
make SetFramebufferAsTarget work also for the loading gamestate
This commit is contained in:
parent
a6abd01ec2
commit
7f7c522b3c
4 changed files with 19 additions and 10 deletions
|
@ -279,6 +279,8 @@ SYMBOL_INTERNAL void GamestateProgress(struct Game* game) {
|
|||
#else
|
||||
al_convert_memory_bitmaps();
|
||||
DrawGamestates(game);
|
||||
SetFramebufferAsTarget(game);
|
||||
al_clear_to_color(al_map_rgb(0, 0, 0));
|
||||
double delta = al_get_time() - game->_priv.loading.time;
|
||||
if (game->_priv.loading.current->showLoading) {
|
||||
game->_priv.loading.gamestate->api->Gamestate_Logic(game, game->_priv.loading.gamestate->data, delta);
|
||||
|
|
|
@ -251,7 +251,8 @@ static inline bool MainloopTick(struct Game* game) {
|
|||
al_run_detached_thread(GamestateLoadingThread, &data);
|
||||
while (game->_priv.loading.inProgress) {
|
||||
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;
|
||||
if (tmp->showLoading) {
|
||||
(*game->_priv.loading.gamestate->api->Gamestate_Logic)(game, game->_priv.loading.gamestate->data, delta);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "libsuperderpy.h"
|
||||
|
||||
ALLEGRO_SHADER *CreateShader(struct Game *game, const char* vertex, const char* fragment);
|
||||
void DestroyShader(struct Game *game, ALLEGRO_SHADER *shader);
|
||||
ALLEGRO_SHADER* CreateShader(struct Game* game, const char* vertex, const char* fragment);
|
||||
void DestroyShader(struct Game* game, ALLEGRO_SHADER* shader);
|
||||
|
||||
#endif
|
||||
|
|
20
src/utils.c
20
src/utils.c
|
@ -486,17 +486,23 @@ SYMBOL_EXPORT void WindowCoordsToViewport(struct Game* game, int* x, int* y) {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void SetFramebufferAsTarget(struct Game* game) {
|
||||
al_set_target_bitmap(GetFramebuffer(game));
|
||||
double x = al_get_bitmap_width(GetFramebuffer(game)) / (double)game->viewport.width;
|
||||
double y = al_get_bitmap_height(GetFramebuffer(game)) / (double)game->viewport.height;
|
||||
ALLEGRO_TRANSFORM t;
|
||||
al_identity_transform(&t);
|
||||
al_scale_transform(&t, x, y);
|
||||
al_use_transform(&t);
|
||||
ALLEGRO_BITMAP* framebuffer = GetFramebuffer(game);
|
||||
al_set_target_bitmap(framebuffer);
|
||||
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;
|
||||
al_identity_transform(&t);
|
||||
al_scale_transform(&t, x, y);
|
||||
al_use_transform(&t);
|
||||
}
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT ALLEGRO_BITMAP* CreateNotPreservedBitmap(int width, int height) {
|
||||
|
|
Loading…
Add table
Reference in a new issue