Engine & Game Library Interface Update

This commit is contained in:
Isuru Samarathunga
2025-10-05 01:51:48 +05:30
parent 5408f07e97
commit f8b41a0d61
48 changed files with 2423 additions and 193 deletions

View File

@ -14,114 +14,53 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Engine.hpp>
#include <IAEngine/Engine.hpp>
#include <Renderer/Renderer.hpp>
#include <SDL3/SDL.h>
#include <IAEngine/EngineLibraryInterface.hpp>
#include <IAEngine/EngineInterface.hpp>
GameFunctionTable g_gameFunctions{};
EXTERN GameFunctionTable g_gameFunctions;
namespace ia::iae
{
String GetStringVersion(IN UINT64 version)
BOOL Engine::IsDebugMode()
{
return "";
return true;
}
VOID __Internal_Engine::Initialize()
VOID Engine::ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight)
{
IAE_LOG_INFO("Booting IAEngine for ", g_gameFunctions.GetName());
SDL_SetAppMetadata(g_gameFunctions.GetName(), GetStringVersion(g_gameFunctions.GetVersion()).c_str(),
g_gameFunctions.GetPackageName());
g_gameFunctions.OnInitialize();
Renderer::OnScreenResize(newWidth, newHeight);
g_gameFunctions.OnResize(newWidth, newHeight);
}
VOID __Internal_Engine::Terminate()
FLOAT32 Engine::GetRandomFloat()
{
g_gameFunctions.OnTerminate();
IAE_LOG_INFO("Shutting down IAEngine");
return 0.0f;
}
VOID __Internal_Engine::Iterate()
INT32 Engine::GetRandomInRange(IN INT32 min, IN INT32 max)
{
return 0;
}
VOID __Internal_Engine::ProcessEvent(IN SDL_Event *event)
INT64 Engine::GetTickCount()
{
switch (event->type)
{
case SDL_EVENT_WINDOW_RESIZED:
break;
return 0;
}
INT64 Engine::GetUnixSecond()
{
return 0;
}
}
INT64 Engine::GetUnixMillisecond()
{
return 0;
}
FLOAT32 Engine::GetFrameDeltaTime()
{
return 0.0f;
}
} // namespace ia::iae
namespace ia::iae
{
}
BOOL ValidateGameFunctionTable(IN GameFunctionTable gameFunctionTable)
{
if (!gameFunctionTable.OnInitialize)
return false;
if (!gameFunctionTable.OnTerminate)
return false;
if (!gameFunctionTable.OnDebugDraw)
return false;
if (!gameFunctionTable.OnFixedUpdate)
return false;
if (!gameFunctionTable.OnUpdate)
return false;
if (!gameFunctionTable.OnResize)
return false;
if (!gameFunctionTable.GetName)
return false;
if (!gameFunctionTable.GetVersion)
return false;
if (!gameFunctionTable.GetPackageName)
return false;
if (!gameFunctionTable.GetDeveloperName)
return false;
if (!gameFunctionTable.GetPublisherName)
return false;
return true;
}
C_DECL(IAE_DLL_API ia::BOOL IAEngine_OnInitialize(IN GameFunctionTable gameFunctionTable))
{
if (!ValidateGameFunctionTable(gameFunctionTable))
{
IAE_LOG_ERROR("Invalid game function table was passed to the engine. Exiting..");
return false;
}
g_gameFunctions = gameFunctionTable;
__Internal_Engine::Initialize();
return true;
}
C_DECL(IAE_DLL_API ia::VOID IAEngine_OnTerminate())
{
__Internal_Engine::Terminate();
}
C_DECL(IAE_DLL_API ia::BOOL IAEngine_OnIterate())
{
__Internal_Engine::Iterate();
return true;
}
C_DECL(IAE_DLL_API ia::VOID IAEngine_OnEvent(IN PVOID event))
{
__Internal_Engine::ProcessEvent((SDL_Event *) event);
}