mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-08 06:06:43 +01:00
gamestate: add optional PostLoad hook for stuff that needs to be done on GPU thread
This commit is contained in:
parent
a314ad2d6d
commit
521e6bf431
4 changed files with 8 additions and 0 deletions
|
@ -28,6 +28,7 @@ struct Gamestate_API {
|
|||
void (*Gamestate_Logic)(struct Game* game, void* data, double delta);
|
||||
|
||||
void* (*Gamestate_Load)(struct Game* game, void (*progress)(struct Game* game));
|
||||
void (*Gamestate_PostLoad)(struct Game* game, void* data);
|
||||
void (*Gamestate_Start)(struct Game* game, void* data);
|
||||
void (*Gamestate_Pause)(struct Game* game, void* data);
|
||||
void (*Gamestate_Resume)(struct Game* game, void* data);
|
||||
|
|
|
@ -319,6 +319,7 @@ SYMBOL_INTERNAL bool LinkGamestate(struct Game* game, struct Gamestate* gamestat
|
|||
if (!(gamestate->api->Gamestate_ProcessEvent = dlsym(gamestate->handle, "Gamestate_ProcessEvent"))) { GS_ERROR; }
|
||||
|
||||
// optional
|
||||
gamestate->api->Gamestate_PostLoad = dlsym(gamestate->handle, "Gamestate_PostLoad");
|
||||
gamestate->api->Gamestate_Pause = dlsym(gamestate->handle, "Gamestate_Pause");
|
||||
gamestate->api->Gamestate_Resume = dlsym(gamestate->handle, "Gamestate_Resume");
|
||||
gamestate->api->Gamestate_Reload = dlsym(gamestate->handle, "Gamestate_Reload");
|
||||
|
|
|
@ -444,6 +444,11 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) {
|
|||
|
||||
al_set_new_bitmap_flags(data.bitmap_flags);
|
||||
|
||||
if (tmp->api->Gamestate_PostLoad) {
|
||||
PrintConsole(game, "[%s] Post-loading...", tmp->name);
|
||||
tmp->api->Gamestate_PostLoad(game, tmp->data);
|
||||
}
|
||||
|
||||
game->_priv.loading.progress++;
|
||||
CalculateProgress(game);
|
||||
PrintConsole(game, "Gamestate \"%s\" loaded successfully.", tmp->name);
|
||||
|
|
|
@ -184,6 +184,7 @@ void Gamestate_ProcessEvent(struct Game* game, struct GamestateResources* data,
|
|||
void Gamestate_Logic(struct Game* game, struct GamestateResources* data, double delta);
|
||||
void Gamestate_Draw(struct Game* game, struct GamestateResources* data);
|
||||
void* Gamestate_Load(struct Game* game, void (*progress)(struct Game*));
|
||||
void Gamestate_PostLoad(struct Game* game, struct GamestateResources* data);
|
||||
void Gamestate_Unload(struct Game* game, struct GamestateResources* data);
|
||||
void Gamestate_Start(struct Game* game, struct GamestateResources* data);
|
||||
void Gamestate_Stop(struct Game* game, struct GamestateResources* data);
|
||||
|
|
Loading…
Reference in a new issue