61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
#define WIN32_LEAN_AND_MEAN
|
|
#include <Windows.h>
|
|
|
|
#define SDL_MAIN_USE_CALLBACKS
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL_main.h>
|
|
|
|
#include <IAEngine/EngineInterface.hpp>
|
|
|
|
SDL_AppResult SDL_AppIterate(void *appstate)
|
|
{
|
|
IAEngine_OnIterate();
|
|
return SDL_APP_CONTINUE;
|
|
}
|
|
|
|
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
|
{
|
|
switch (event->type) {
|
|
case SDL_EVENT_QUIT:
|
|
return SDL_APP_SUCCESS;
|
|
}
|
|
IAEngine_OnEvent(event);
|
|
return SDL_APP_CONTINUE;
|
|
}
|
|
|
|
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
|
{
|
|
GameFunctionTable gameFunctionTable{};
|
|
|
|
const auto gameLib = LoadLibrary("Game.dll");
|
|
if(!gameLib)
|
|
{
|
|
IAE_LOG_ERROR("Failed to load the dynamic library \"Game.dll\". Please make sure it exists.");
|
|
return SDL_APP_FAILURE;
|
|
}
|
|
|
|
gameFunctionTable.OnInitialize = (VOID(*)())GetProcAddress(gameLib, "Game_OnInitialize");
|
|
gameFunctionTable.OnTerminate = (VOID(*)())GetProcAddress(gameLib, "Game_OnTerminate");
|
|
gameFunctionTable.OnDebugDraw = (VOID(*)())GetProcAddress(gameLib, "Game_OnDebugDraw");
|
|
gameFunctionTable.OnFixedUpdate = (VOID(*)())GetProcAddress(gameLib, "Game_OnFixedUpdate");
|
|
gameFunctionTable.OnUpdate = (VOID(*)(IN FLOAT32 deltaTime))GetProcAddress(gameLib, "Game_OnUpdate");
|
|
gameFunctionTable.OnResize = (VOID(*)(IN INT32 newWidth, IN INT32 newHeight))GetProcAddress(gameLib, "Game_OnResize");
|
|
|
|
gameFunctionTable.GetName = (PCCHAR(*)())GetProcAddress(gameLib, "Game_GetName");
|
|
gameFunctionTable.GetVersion = (UINT64(*)())GetProcAddress(gameLib, "Game_GetVersion");
|
|
gameFunctionTable.GetPackageName = (PCCHAR(*)())GetProcAddress(gameLib, "Game_GetPackageName");
|
|
gameFunctionTable.GetDeveloperName = (PCCHAR(*)())GetProcAddress(gameLib, "Game_GetDeveloperName");
|
|
gameFunctionTable.GetPublisherName = (PCCHAR(*)())GetProcAddress(gameLib, "Game_GetPublisherName");
|
|
|
|
if(!IAEngine_OnInitialize(gameFunctionTable))
|
|
return SDL_APP_FAILURE;
|
|
|
|
return SDL_APP_CONTINUE;
|
|
}
|
|
|
|
void SDL_AppQuit(void *appstate, SDL_AppResult result)
|
|
{
|
|
IAEngine_OnTerminate();
|
|
SDL_Quit();
|
|
} |