mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 09:11:27 +01:00
convert bitmaps to video textures on every progress() when loading gamestate in threaded mode
This commit is contained in:
parent
81488f9390
commit
016c482154
3 changed files with 24 additions and 1 deletions
|
@ -249,6 +249,14 @@ SYMBOL_INTERNAL void GamestateProgress(struct Game* game) {
|
||||||
if (game->config.debug) {
|
if (game->config.debug) {
|
||||||
PrintConsole(game, "[%s] Progress: %d%% (%d/%d)", tmp->name, (int)(progress * 100), game->_priv.loading.progress, *(tmp->api->Gamestate_ProgressCount));
|
PrintConsole(game, "[%s] Progress: %d%% (%d/%d)", tmp->name, (int)(progress * 100), game->_priv.loading.progress, *(tmp->api->Gamestate_ProgressCount));
|
||||||
}
|
}
|
||||||
|
#ifndef LIBSUPERDERPY_SINGLE_THREAD
|
||||||
|
al_lock_mutex(game->_priv.texture_sync_mutex);
|
||||||
|
game->_priv.texture_sync = true;
|
||||||
|
while (game->_priv.texture_sync) {
|
||||||
|
al_wait_cond(game->_priv.texture_sync_cond, game->_priv.texture_sync_mutex);
|
||||||
|
}
|
||||||
|
al_unlock_mutex(game->_priv.texture_sync_mutex);
|
||||||
|
#endif
|
||||||
#ifdef LIBSUPERDERPY_SINGLE_THREAD
|
#ifdef LIBSUPERDERPY_SINGLE_THREAD
|
||||||
DrawGamestates(game);
|
DrawGamestates(game);
|
||||||
double delta = al_get_time() - game->_priv.loading.time;
|
double delta = al_get_time() - game->_priv.loading.time;
|
||||||
|
|
|
@ -85,6 +85,10 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
||||||
game->handlers.predraw = NULL;
|
game->handlers.predraw = NULL;
|
||||||
game->handlers.postdraw = NULL;
|
game->handlers.postdraw = NULL;
|
||||||
|
|
||||||
|
game->_priv.texture_sync = false;
|
||||||
|
game->_priv.texture_sync_cond = al_create_cond();
|
||||||
|
game->_priv.texture_sync_mutex = al_create_mutex();
|
||||||
|
|
||||||
game->config.fullscreen = strtol(GetConfigOptionDefault(game, "SuperDerpy", "fullscreen", "1"), NULL, 10);
|
game->config.fullscreen = strtol(GetConfigOptionDefault(game, "SuperDerpy", "fullscreen", "1"), NULL, 10);
|
||||||
game->config.music = strtol(GetConfigOptionDefault(game, "SuperDerpy", "music", "10"), NULL, 10);
|
game->config.music = strtol(GetConfigOptionDefault(game, "SuperDerpy", "music", "10"), NULL, 10);
|
||||||
game->config.voice = strtol(GetConfigOptionDefault(game, "SuperDerpy", "voice", "10"), NULL, 10);
|
game->config.voice = strtol(GetConfigOptionDefault(game, "SuperDerpy", "voice", "10"), NULL, 10);
|
||||||
|
@ -412,15 +416,20 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) {
|
||||||
(*game->_priv.loading.gamestate->api->Gamestate_Draw)(game, game->_priv.loading.gamestate->data);
|
(*game->_priv.loading.gamestate->api->Gamestate_Draw)(game, game->_priv.loading.gamestate->data);
|
||||||
}
|
}
|
||||||
game->_priv.loading.time += delta;
|
game->_priv.loading.time += delta;
|
||||||
|
if (game->_priv.texture_sync) {
|
||||||
|
al_convert_memory_bitmaps();
|
||||||
|
game->_priv.texture_sync = false;
|
||||||
|
al_signal_cond(game->_priv.texture_sync_cond);
|
||||||
|
}
|
||||||
DrawConsole(game);
|
DrawConsole(game);
|
||||||
al_flip_display();
|
al_flip_display();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
GamestateLoadingThread(&data);
|
GamestateLoadingThread(&data);
|
||||||
|
al_convert_memory_bitmaps();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
al_set_new_bitmap_flags(data.bitmap_flags);
|
al_set_new_bitmap_flags(data.bitmap_flags);
|
||||||
al_convert_memory_bitmaps();
|
|
||||||
ReloadShaders(game, false);
|
ReloadShaders(game, false);
|
||||||
game->_priv.loading.loaded++;
|
game->_priv.loading.loaded++;
|
||||||
|
|
||||||
|
@ -666,6 +675,8 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) {
|
||||||
al_destroy_mixer(game->audio.music);
|
al_destroy_mixer(game->audio.music);
|
||||||
al_destroy_mixer(game->audio.mixer);
|
al_destroy_mixer(game->audio.mixer);
|
||||||
al_destroy_voice(game->audio.v);
|
al_destroy_voice(game->audio.v);
|
||||||
|
al_destroy_cond(game->_priv.texture_sync_cond);
|
||||||
|
al_destroy_mutex(game->_priv.texture_sync_mutex);
|
||||||
al_uninstall_audio();
|
al_uninstall_audio();
|
||||||
DeinitConfig(game);
|
DeinitConfig(game);
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
|
|
|
@ -137,6 +137,10 @@ struct Game {
|
||||||
|
|
||||||
bool paused;
|
bool paused;
|
||||||
|
|
||||||
|
volatile bool texture_sync;
|
||||||
|
ALLEGRO_MUTEX* texture_sync_mutex;
|
||||||
|
ALLEGRO_COND* texture_sync_cond;
|
||||||
|
|
||||||
#ifdef ALLEGRO_MACOSX
|
#ifdef ALLEGRO_MACOSX
|
||||||
char cwd[MAXPATHLEN];
|
char cwd[MAXPATHLEN];
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue