mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-12 12:08:00 +01:00
Use al_store_state and al_restore_state when dealing with threads
This lets the active Allegro file interface to be used by the new thread.
This commit is contained in:
parent
5f7c0ff18f
commit
2e15e4d8dc
3 changed files with 7 additions and 5 deletions
|
@ -283,7 +283,7 @@ SYMBOL_INTERNAL void Console_Unload(struct Game* game) {
|
|||
SYMBOL_INTERNAL void* GamestateLoadingThread(void* arg) {
|
||||
struct GamestateLoadingThreadData* data = arg;
|
||||
data->game->_priv.loading.in_progress = true;
|
||||
al_set_new_bitmap_flags(data->bitmap_flags);
|
||||
al_restore_state(&data->state);
|
||||
data->gamestate->data = data->gamestate->api->load(data->game, &GamestateProgress);
|
||||
if (data->game->_priv.loading.progress != data->gamestate->progress_count) {
|
||||
PrintConsole(data->game, "[%s] WARNING: Gamestate_ProgressCount does not match the number of progress invokations (%d)!", data->gamestate->name, data->game->_priv.loading.progress);
|
||||
|
@ -295,7 +295,8 @@ SYMBOL_INTERNAL void* GamestateLoadingThread(void* arg) {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
data->bitmap_flags = al_get_new_bitmap_flags();
|
||||
al_store_state(&data->state, ALLEGRO_STATE_NEW_FILE_INTERFACE | ALLEGRO_STATE_NEW_BITMAP_PARAMETERS | ALLEGRO_STATE_BLENDER);
|
||||
|
||||
data->game->_priv.loading.in_progress = false;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ struct List {
|
|||
struct GamestateLoadingThreadData {
|
||||
struct Game* game;
|
||||
struct Gamestate* gamestate;
|
||||
int bitmap_flags;
|
||||
ALLEGRO_STATE state;
|
||||
};
|
||||
|
||||
struct ScreenshotThreadData {
|
||||
|
|
|
@ -349,7 +349,8 @@ static inline bool MainloopTick(struct Game* game) {
|
|||
game->_priv.loading.current = tmp;
|
||||
game->_priv.current_gamestate = tmp;
|
||||
|
||||
struct GamestateLoadingThreadData data = {.game = game, .gamestate = tmp, .bitmap_flags = al_get_new_bitmap_flags()};
|
||||
struct GamestateLoadingThreadData data = {.game = game, .gamestate = tmp};
|
||||
al_store_state(&data.state, ALLEGRO_STATE_NEW_FILE_INTERFACE | ALLEGRO_STATE_NEW_BITMAP_PARAMETERS | ALLEGRO_STATE_BLENDER);
|
||||
game->_priv.loading.in_progress = true;
|
||||
double time = al_get_time();
|
||||
game->_priv.loading.time = time;
|
||||
|
@ -406,7 +407,7 @@ static inline bool MainloopTick(struct Game* game) {
|
|||
#endif
|
||||
al_convert_memory_bitmaps();
|
||||
|
||||
al_set_new_bitmap_flags(data.bitmap_flags);
|
||||
al_restore_state(&data.state);
|
||||
|
||||
ReloadShaders(game, false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue