#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include <SDL3/SDL.h>

#include <IAEngine/EngineLibraryInterface.hpp>

int main(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.GetConfigRequest = (GameRequestedConfig (*)()) GetProcAddress(gameLib, "Game_GetConfigRequest");
    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");

    return IAEngine_Run(gameFunctionTable);
}