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

22
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,22 @@
{
"files.associations": {
"*.rml": "html",
"format": "cpp",
"random": "cpp",
"chrono": "cpp",
"functional": "cpp",
"optional": "cpp",
"regex": "cpp",
"system_error": "cpp",
"type_traits": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xtr1common": "cpp",
"xutility": "cpp",
"filesystem": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xstring": "cpp",
"any": "cpp"
}
}

View File

@ -1,5 +1,20 @@
set(SRC_FILES
"Src/Imp/CPP/Time.cpp"
"Src/Imp/CPP/Random.cpp"
"Src/Imp/CPP/Engine.cpp"
"Src/Imp/CPP/InternalEngine.cpp"
"Src/Imp/CPP/InputManager.cpp"
"Src/Imp/CPP/ResourceManager.cpp"
"Src/Imp/CPP/EventManager.cpp"
"Src/Imp/CPP/WorldManager.cpp"
"Src/Imp/CPP/AudioManager.cpp"
"Src/Imp/CPP/Renderer/DebugDraw.cpp"
"Src/Imp/CPP/Renderer/Pipeline.cpp"
"Src/Imp/CPP/Renderer/Renderer.cpp"
"Src/Imp/CPP/Renderer/UIRenderer.cpp"
"Src/Imp/CPP/Renderer/GPUResourceManager.cpp"
)
add_library(IAEngine SHARED ${SRC_FILES})

View File

@ -0,0 +1,29 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <AudioManager.hpp>
#include <IAEngine/Engine.hpp>
namespace ia::iae
{
VOID AudioManager::Initialize()
{
}
VOID AudioManager::Terminate()
{
}
}

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);
}

View File

@ -0,0 +1,66 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <EventManager.hpp>
#include <IAEngine/Engine.hpp>
namespace ia::iae
{
VOID EventManager::Initialize()
{
}
VOID EventManager::Terminate()
{
}
VOID EventManager::OnSDLEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae
namespace ia::iae
{
Handle Engine::CreateEvent(IN CONST String &name)
{
return INVALID_HANDLE;
}
VOID Engine::DestroyEvent(IN Handle event)
{
}
Handle Engine::GetEventByName(IN CONST String &name)
{
return INVALID_HANDLE;
}
VOID Engine::AddEventListener(IN Handle event, IN std::function<VOID()> callback)
{
}
VOID Engine::AddEventListener(IN CONST String &eventName, IN std::function<VOID()> callback)
{
}
VOID Engine::BroadcastEvent(IN Handle event)
{
}
VOID Engine::BroadcastEvent(IN CONST String &eventName)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,108 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <InputManager.hpp>
#include <IAEngine/Engine.hpp>
namespace ia::iae
{
VOID InputManager::Initialize()
{
}
VOID InputManager::Terminate()
{
}
VOID InputManager::OnSDLEvent(IN SDL_Event *event)
{
}
}
namespace ia::iae
{
Vec2 Engine::GetInputAxis()
{
return {};
}
VOID Engine::SwitchInputModeToText()
{
}
VOID Engine::SwitchInputModeToAction()
{
}
Vec2 Engine::GetInputPointerPosition()
{
return {};
}
BOOL Engine::IsInputKeyDown(IN InputKey key)
{
return false;
}
BOOL Engine::WasInputKeyPressed(IN InputKey key)
{
return false;
}
BOOL Engine::WasInputKeyReleased(IN InputKey key)
{
return false;
}
BOOL Engine::IsInputActionDown(IN Handle action)
{
return false;
}
BOOL Engine::WasInputActionPressed(IN Handle action)
{
return false;
}
BOOL Engine::WasInputActionReleased(IN Handle action)
{
return false;
}
BOOL Engine::IsInputActionDown(IN PCCHAR action)
{
return false;
}
BOOL Engine::WasInputActionPressed(IN PCCHAR action)
{
return false;
}
BOOL Engine::WasInputActionReleased(IN PCCHAR action)
{
return false;
}
Handle Engine::BindInputAction(IN CONST String &name, IN InputKey key)
{
return INVALID_HANDLE;
}
VOID Engine::BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,159 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <AudioManager.hpp>
#include <EventManager.hpp>
#include <InputManager.hpp>
#include <InternalEngine.hpp>
#include <Random.hpp>
#include <Renderer/Renderer.hpp>
#include <ResourceManager.hpp>
#include <Time.hpp>
#include <WorldManager.hpp>
#include <IAEngine/Engine.hpp>
#include <IAEngine/EngineLibraryInterface.hpp>
#include <backends/imgui_impl_sdl3.h>
#include <backends/imgui_impl_sdlgpu3.h>
GameFunctionTable g_gameFunctions{};
namespace ia::iae
{
SDL_Window *g_windowHandle;
VOID __Internal_Engine::Initialize()
{
IAE_LOG_INFO("Booting IAEngine for ", g_gameFunctions.GetName());
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMEPAD))
THROW_UNKNOWN("Failed to intialize SDL: ", SDL_GetError());
if (!(g_windowHandle = SDL_CreateWindow(g_gameFunctions.GetName(), 800, 600, SDL_WINDOW_RESIZABLE)))
THROW_UNKNOWN("Failed to create the SDL window: ", SDL_GetError());
SDL_SetWindowResizable(g_windowHandle, false);
const auto gameVersion = g_gameFunctions.GetVersion();
SDL_SetAppMetadata(g_gameFunctions.GetName(), BuildString(gameVersion).c_str(),
g_gameFunctions.GetPackageName());
Time::Initialize();
Random::Initialize();
Renderer::Initialize();
AudioManager::Initialize();
EventManager::Initialize();
InputManager::Initialize();
ResourceManager::Initialize();
WorldManager::Initialize();
g_gameFunctions.OnInitialize();
}
VOID __Internal_Engine::Terminate()
{
g_gameFunctions.OnTerminate();
WorldManager::Terminate();
ResourceManager::Terminate();
InputManager::Terminate();
EventManager::Terminate();
AudioManager::Terminate();
Renderer::Terminate();
Random::Terminate();
Time::Terminate();
SDL_DestroyWindow(g_windowHandle);
IAE_LOG_INFO("Shutting down IAEngine");
}
VOID __Internal_Engine::Iterate()
{
WorldManager::Update();
Renderer::BeginFrame();
WorldManager::Draw();
Renderer::EndFrame();
}
VOID __Internal_Engine::ProcessEvent(IN SDL_Event *event)
{
switch (event->type)
{
case SDL_EVENT_WINDOW_RESIZED:
Engine::ResizeDisplay(event->window.data1, event->window.data2);
break;
}
InputManager::OnSDLEvent(event);
EventManager::OnSDLEvent(event);
ImGui_ImplSDL3_ProcessEvent(event);
}
} // 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 INT32 IAEngine_Run(IN GameFunctionTable gameFunctionTable))
{
if (!ValidateGameFunctionTable(gameFunctionTable))
{
IAE_LOG_ERROR("Invalid game function table was passed to the engine. Exiting..");
return -1;
}
g_gameFunctions = gameFunctionTable;
__Internal_Engine::Initialize();
SDL_Event event{};
while(true)
{
SDL_PollEvent(&event);
if (event.type == SDL_EVENT_QUIT)
break;
__Internal_Engine::ProcessEvent(&event);
__Internal_Engine::Iterate();
}
__Internal_Engine::Terminate();
return 0;
}

View File

@ -0,0 +1,29 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <Random.hpp>
#include <IAEngine/Engine.hpp>
namespace ia::iae
{
VOID Random::Initialize()
{
}
VOID Random::Terminate()
{
}
}

View File

@ -0,0 +1,110 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <IAEngine/Engine.hpp>
#include <Renderer/Renderer.hpp>
#include <Renderer/DebugDraw.hpp>
#include <WorldManager.hpp>
#include <backends/imgui_impl_sdl3.h>
#include <backends/imgui_impl_sdlgpu3.h>
namespace ia::iae
{
EXTERN SDL_Window *g_windowHandle;
ImGuiIO g_imGUIIO{};
VOID DebugDraw::Initialize()
{
const auto mainScale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
IMGUI_CHECKVERSION();
ImGui::CreateContext();
g_imGUIIO = ImGui::GetIO();
g_imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
g_imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
ImGui::StyleColorsClassic();
ImGuiStyle &style = ImGui::GetStyle();
style.ScaleAllSizes(mainScale);
style.FontScaleDpi = mainScale;
ImGui_ImplSDLGPU3_InitInfo initInfo{.Device = Renderer::GetDevice(),
.ColorTargetFormat =
Renderer::GetRenderTargetFormat(),
.PresentMode = SDL_GPU_PRESENTMODE_VSYNC};
ImGui_ImplSDL3_InitForSDLGPU(g_windowHandle);
ImGui_ImplSDLGPU3_Init(&initInfo);
}
VOID DebugDraw::Terminate()
{
ImGui_ImplSDL3_Shutdown();
ImGui_ImplSDLGPU3_Shutdown();
ImGui::DestroyContext();
}
VOID DebugDraw::Render()
{
ImGui_ImplSDLGPU3_NewFrame();
ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame();
WorldManager::DebugDraw();
ImGui::Render();
}
} // namespace ia::iae
namespace ia::iae
{
struct State
{
ImU32 ActiveColor{0xFFFFFFFF};
FLOAT32 ActiveStrokeWidth{1.0f};
} g_debugDrawState{};
VOID Engine::DebugDraw_SetColor(IN Color color)
{
g_debugDrawState.ActiveColor = IM_COL32(color.R, color.G, color.B, color.A);
}
VOID Engine::DebugDraw_StrokeWidth(IN FLOAT32 width)
{
g_debugDrawState.ActiveStrokeWidth = width;
}
VOID Engine::DebugDraw_Line(IN Vec2 from, IN Vec2 to)
{
const auto drawList = ImGui::GetForegroundDrawList();
drawList->AddLine(ImVec2(from.x, from.y), ImVec2(to.x, to.y), g_debugDrawState.ActiveColor, g_debugDrawState.ActiveStrokeWidth);
}
VOID Engine::DebugDraw_FillRect(IN Vec2 position, IN Vec2 size)
{
const auto drawList = ImGui::GetForegroundDrawList();
drawList->AddRectFilled(ImVec2(position.x, position.y), ImVec2(position.x + size.x, position.y + size.y), g_debugDrawState.ActiveColor);
}
VOID Engine::DebugDraw_StrokeRect(IN Vec2 position, IN Vec2 size)
{
const auto drawList = ImGui::GetForegroundDrawList();
drawList->AddRect(ImVec2(position.x, position.y), ImVec2(position.x + size.x, position.y + size.y), g_debugDrawState.ActiveColor, g_debugDrawState.ActiveStrokeWidth);
}
} // namespace ia::iae

View File

@ -0,0 +1,148 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <IAEngine/Engine.hpp>
#include <Renderer/GPUResourceManager.hpp>
#include <Renderer/Renderer.hpp>
namespace ia::iae
{
SDL_GPUSampler *g_linearClampSampler{};
SDL_GPUSampler *g_linearRepeatSampler{};
VOID GPUResourceManager::Initialize()
{
{ // Create Samplers
SDL_GPUSamplerCreateInfo createInfo{.min_filter = SDL_GPU_FILTER_LINEAR,
.mag_filter = SDL_GPU_FILTER_LINEAR,
.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR,
.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_REPEAT,
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_REPEAT,
.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_REPEAT,
.enable_anisotropy = false};
g_linearClampSampler = SDL_CreateGPUSampler(Renderer::GetDevice(), &createInfo);
createInfo.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_REPEAT,
createInfo.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_REPEAT,
createInfo.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_REPEAT,
g_linearRepeatSampler = SDL_CreateGPUSampler(Renderer::GetDevice(), &createInfo);
}
}
VOID GPUResourceManager::Terminate()
{
SDL_ReleaseGPUSampler(Renderer::GetDevice(), g_linearClampSampler);
SDL_ReleaseGPUSampler(Renderer::GetDevice(), g_linearRepeatSampler);
}
SDL_GPUSampler *GPUResourceManager::GetSampler_LinearClamp()
{
return g_linearClampSampler;
}
SDL_GPUSampler *GPUResourceManager::GetSampler_LinearRepeat()
{
return g_linearRepeatSampler;
}
SDL_GPUTexture *GPUResourceManager::CreateTexture(IN SDL_GPUTextureUsageFlags usage, IN INT32 width,
IN INT32 height, IN PCUINT8 rgbaData,
IN SDL_GPUTextureFormat format)
{
SDL_GPUTextureCreateInfo createInfo{.type = SDL_GPU_TEXTURETYPE_2D,
.format = format,
.usage = usage,
.width = (UINT32) width,
.height = (UINT32) height,
.layer_count_or_depth = 1,
.num_levels = 1,
.sample_count = SDL_GPU_SAMPLECOUNT_1};
const auto result = SDL_CreateGPUTexture(Renderer::GetDevice(), &createInfo);
if (!result)
{
THROW_UNKNOWN("Failed to create a SDL GPU Texture: ", SDL_GetError());
return nullptr;
}
if (rgbaData)
{
SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
.size = (UINT32) width * (UINT32) height * 4};
const auto stagingBuffer = SDL_CreateGPUTransferBuffer(Renderer::GetDevice(), &stagingBufferCreateInfo);
const auto mappedPtr = SDL_MapGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer, false);
SDL_memcpy(mappedPtr, rgbaData, width * height * 4);
SDL_UnmapGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer);
const auto cmdBuffer = SDL_AcquireGPUCommandBuffer(Renderer::GetDevice());
const auto copyPass = SDL_BeginGPUCopyPass(cmdBuffer);
SDL_GPUTextureTransferInfo transferInfo{.transfer_buffer = stagingBuffer, .offset = 0};
SDL_GPUTextureRegion region{.texture = result, .w = (UINT32) width, .h = (UINT32) height, .d = 1};
SDL_UploadToGPUTexture(copyPass, &transferInfo, &region, false);
SDL_EndGPUCopyPass(copyPass);
SDL_SubmitGPUCommandBuffer(cmdBuffer);
SDL_WaitForGPUIdle(Renderer::GetDevice());
SDL_ReleaseGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer);
}
return result;
}
SDL_GPUBuffer *GPUResourceManager::CreateDeviceLocalBuffer(IN SDL_GPUBufferUsageFlags usage, IN PCVOID data,
IN UINT32 dataSize)
{
SDL_GPUBufferCreateInfo createInfo{.usage = usage, .size = dataSize};
const auto result = SDL_CreateGPUBuffer(Renderer::GetDevice(), &createInfo);
if (!result)
{
THROW_UNKNOWN("Failed to create a SDL GPU Buffer: ", SDL_GetError());
return nullptr;
}
if(dataSize && dataSize)
{
SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
.size = dataSize};
const auto stagingBuffer = SDL_CreateGPUTransferBuffer(Renderer::GetDevice(), &stagingBufferCreateInfo);
const auto mappedPtr = SDL_MapGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer, false);
SDL_memcpy(mappedPtr, data, dataSize);
SDL_UnmapGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer);
const auto cmdBuffer = SDL_AcquireGPUCommandBuffer(Renderer::GetDevice());
const auto copyPass = SDL_BeginGPUCopyPass(cmdBuffer);
SDL_GPUTransferBufferLocation src{.transfer_buffer = stagingBuffer, .offset = 0};
SDL_GPUBufferRegion dst{.buffer = result, .offset = 0, .size = dataSize};
SDL_UploadToGPUBuffer(copyPass, &src, &dst, false);
SDL_EndGPUCopyPass(copyPass);
SDL_SubmitGPUCommandBuffer(cmdBuffer);
SDL_WaitForGPUIdle(Renderer::GetDevice());
SDL_ReleaseGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer);
}
return result;
}
VOID GPUResourceManager::DestroyTexture(IN SDL_GPUTexture *handle)
{
SDL_ReleaseGPUTexture(Renderer::GetDevice(), handle);
}
VOID GPUResourceManager::DestroyBuffer(IN SDL_GPUBuffer *handle)
{
SDL_ReleaseGPUBuffer(Renderer::GetDevice(), handle);
}
} // namespace ia::iae

View File

@ -0,0 +1,108 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <IAEngine/Engine.hpp>
#include <Renderer/Pipeline.hpp>
#include <Renderer/Renderer.hpp>
namespace ia::iae
{
Pipeline::Pipeline(IN CONST StageDesc &vertexStageDesc, IN CONST StageDesc &pixelStageDesc,
IN BOOL enableVertexBuffer, IN BOOL enableDepthTest)
{
SDL_GPUShader *vertexShader{};
SDL_GPUShader *pixelShader{};
SDL_GPUShaderCreateInfo shaderCreateInfo = {
.entrypoint = "main",
.format = SDL_GPU_SHADERFORMAT_SPIRV,
.num_storage_textures = 0,
.num_storage_buffers = 0,
};
shaderCreateInfo.stage = SDL_GPU_SHADERSTAGE_VERTEX;
shaderCreateInfo.code = vertexStageDesc.SourceData;
shaderCreateInfo.code_size = vertexStageDesc.SourceLength;
shaderCreateInfo.num_samplers = vertexStageDesc.SamplerCount;
shaderCreateInfo.num_uniform_buffers = vertexStageDesc.UniformBufferCount;
if (!(vertexShader = SDL_CreateGPUShader(Renderer::GetDevice(), &shaderCreateInfo)))
THROW_UNKNOWN("Failed to create a SDL shader: ", SDL_GetError());
shaderCreateInfo.stage = SDL_GPU_SHADERSTAGE_FRAGMENT;
shaderCreateInfo.code = pixelStageDesc.SourceData;
shaderCreateInfo.code_size = pixelStageDesc.SourceLength;
shaderCreateInfo.num_samplers = pixelStageDesc.SamplerCount;
shaderCreateInfo.num_uniform_buffers = pixelStageDesc.UniformBufferCount;
if (!(pixelShader = SDL_CreateGPUShader(Renderer::GetDevice(), &shaderCreateInfo)))
THROW_UNKNOWN("Failed to create a SDL shader: ", SDL_GetError());
SDL_GPUColorTargetDescription colorTargetDesc = {
.format = Renderer::GetRenderTargetFormat(),
};
SDL_GPUVertexBufferDescription vertexBufferDesc = {
.slot = 0,
.pitch = sizeof(GeometryVertex),
.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX,
.instance_step_rate = 0,
};
SDL_GPUVertexAttribute vertexAttributes[] = {
{.location = 0, .buffer_slot = 0, .format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2, .offset = 0},
{.location = 1,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
.offset = sizeof(glm::vec2)},
{.location = 2,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4,
.offset = sizeof(glm::vec4)},
};
SDL_GPUGraphicsPipelineCreateInfo createInfo = {
.vertex_shader = vertexShader,
.fragment_shader = pixelShader,
.vertex_input_state = SDL_GPUVertexInputState{.vertex_buffer_descriptions = &vertexBufferDesc,
.num_vertex_buffers = enableVertexBuffer ? (UINT32) 1 : 0,
.vertex_attributes = vertexAttributes,
.num_vertex_attributes = enableVertexBuffer ? (UINT32) 3 : 0},
.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
.rasterizer_state = SDL_GPURasterizerState{.fill_mode = SDL_GPU_FILLMODE_FILL,
.cull_mode = SDL_GPU_CULLMODE_NONE,
.front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE},
.depth_stencil_state = SDL_GPUDepthStencilState{.compare_op = SDL_GPU_COMPAREOP_GREATER_OR_EQUAL,
.write_mask = 0xFF,
.enable_depth_test = enableDepthTest,
.enable_depth_write = enableDepthTest,
.enable_stencil_test = false},
.target_info = {.color_target_descriptions = &colorTargetDesc,
.num_color_targets = 1,
.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D16_UNORM,
.has_depth_stencil_target = enableDepthTest},
};
if(!(m_handle = SDL_CreateGPUGraphicsPipeline(Renderer::GetDevice(), &createInfo)))
THROW_UNKNOWN("Failed to create a SDL graphics pipeline: ", SDL_GetError());
SDL_ReleaseGPUShader(Renderer::GetDevice(), pixelShader);
SDL_ReleaseGPUShader(Renderer::GetDevice(), vertexShader);
}
Pipeline::~Pipeline()
{
SDL_ReleaseGPUGraphicsPipeline(Renderer::GetDevice(), m_handle);
}
} // namespace ia::iae

View File

@ -0,0 +1,257 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <IAEngine/Engine.hpp>
#include <Renderer/DebugDraw.hpp>
#include <Renderer/EmbeddedShader.hpp>
#include <Renderer/Renderer.hpp>
#include <backends/imgui_impl_sdl3.h>
#include <backends/imgui_impl_sdlgpu3.h>
namespace ia::iae
{
EXTERN SDL_Window *g_windowHandle;
INT32 Renderer::s_screenWidth{};
INT32 Renderer::s_screenHeight{};
Renderer::State Renderer::s_state{};
SDL_GPUDevice *Renderer::s_gpuDevice{};
SDL_GPUTexture *Renderer::s_renderTargetSceneColor{};
SDL_GPUTexture *Renderer::s_renderTargetSceneDepth{};
SDL_GPUTexture *Renderer::s_renderTargetDebugDrawColor{};
Pipeline *Renderer::s_geometryPipeline{};
Pipeline *Renderer::s_postprocessPipeline{};
VOID Renderer::Initialize()
{
SDL_GetWindowSizeInPixels(g_windowHandle, &s_screenWidth, &s_screenHeight);
if (!(s_gpuDevice = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_SPIRV, Engine::IsDebugMode(), nullptr)))
THROW_UNKNOWN("Failed to create the SDL GPU Device: ", SDL_GetError());
if (!SDL_ClaimWindowForGPUDevice(s_gpuDevice, g_windowHandle))
THROW_UNKNOWN("Failed to initialize SDL GPU for the window: ", SDL_GetError());
SDL_SetGPUSwapchainParameters(s_gpuDevice, g_windowHandle, SDL_GPU_SWAPCHAINCOMPOSITION_SDR,
SDL_GPU_PRESENTMODE_VSYNC);
GPUResourceManager::Initialize();
// Initialize Render Targets
s_renderTargetSceneDepth =
GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, s_screenWidth, s_screenHeight,
nullptr, SDL_GPU_TEXTUREFORMAT_D16_UNORM);
s_renderTargetSceneColor = GPUResourceManager::CreateTexture(
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER, s_screenWidth, s_screenHeight, nullptr,
SDL_GetGPUSwapchainTextureFormat(s_gpuDevice, g_windowHandle));
s_renderTargetDebugDrawColor = GPUResourceManager::CreateTexture(
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER, s_screenWidth, s_screenHeight, nullptr,
SDL_GetGPUSwapchainTextureFormat(s_gpuDevice, g_windowHandle));
// Initialize Pipelines
s_geometryPipeline = new Pipeline(
Pipeline::StageDesc{
.SourceData = SHADER_SOURCE_GEOMETRY_VERT,
.SourceLength = sizeof(SHADER_SOURCE_GEOMETRY_VERT),
.SamplerCount = 0,
.UniformBufferCount = 3,
},
Pipeline::StageDesc{
.SourceData = SHADER_SOURCE_GEOMETRY_FRAG,
.SourceLength = sizeof(SHADER_SOURCE_GEOMETRY_FRAG),
.SamplerCount = 1,
.UniformBufferCount = 1,
},
true, true);
s_postprocessPipeline = new Pipeline(
Pipeline::StageDesc{
.SourceData = SHADER_SOURCE_POSTPROCESS_VERT,
.SourceLength = sizeof(SHADER_SOURCE_POSTPROCESS_VERT),
.SamplerCount = 0,
.UniformBufferCount = 0,
},
Pipeline::StageDesc{
.SourceData = SHADER_SOURCE_POSTPROCESS_FRAG,
.SourceLength = sizeof(SHADER_SOURCE_POSTPROCESS_FRAG),
.SamplerCount = 2,
.UniformBufferCount = 0,
},
false, false);
DebugDraw::Initialize();
s_state.ProjectionMatrix =
glm::orthoLH(0.0f, (FLOAT32) s_screenWidth, (FLOAT32) s_screenHeight, 0.0f, -2097152.0f, 2097152.0f);
s_state.ColorTargetInfo.clear_color = SDL_FColor{0.33f, 0.33f, 0.33f, 1.0f};
s_state.ColorTargetInfo.load_op = SDL_GPU_LOADOP_CLEAR;
s_state.ColorTargetInfo.store_op = SDL_GPU_STOREOP_STORE;
s_state.DepthStencilTargetInfo.cycle = true;
s_state.DepthStencilTargetInfo.clear_depth = 0;
s_state.DepthStencilTargetInfo.clear_stencil = 0;
s_state.DepthStencilTargetInfo.load_op = SDL_GPU_LOADOP_CLEAR;
s_state.DepthStencilTargetInfo.store_op = SDL_GPU_STOREOP_STORE;
s_state.DepthStencilTargetInfo.stencil_load_op = SDL_GPU_LOADOP_CLEAR;
s_state.DepthStencilTargetInfo.stencil_store_op = SDL_GPU_STOREOP_STORE;
}
VOID Renderer::Terminate()
{
SDL_WaitForGPUIdle(s_gpuDevice);
DebugDraw::Terminate();
delete s_geometryPipeline;
delete s_postprocessPipeline;
GPUResourceManager::DestroyTexture(s_renderTargetSceneDepth);
GPUResourceManager::DestroyTexture(s_renderTargetSceneColor);
GPUResourceManager::DestroyTexture(s_renderTargetDebugDrawColor);
GPUResourceManager::Terminate();
SDL_ReleaseWindowFromGPUDevice(s_gpuDevice, g_windowHandle);
SDL_DestroyGPUDevice(s_gpuDevice);
}
VOID Renderer::BeginFrame()
{
if (!(s_state.ActiveCommandBuffer = SDL_AcquireGPUCommandBuffer(s_gpuDevice)))
THROW_UNKNOWN("Failed to acquire SDL GPU command buffer: ", SDL_GetError());
s_state.ColorTargetInfo.texture = s_renderTargetSceneColor;
s_state.DepthStencilTargetInfo.texture = s_renderTargetSceneDepth;
s_state.ActiveRenderPass = SDL_BeginGPURenderPass(s_state.ActiveCommandBuffer, &s_state.ColorTargetInfo, 1,
&s_state.DepthStencilTargetInfo);
SDL_BindGPUGraphicsPipeline(s_state.ActiveRenderPass, s_geometryPipeline->GetHandle());
SDL_PushGPUVertexUniformData(s_state.ActiveCommandBuffer, 0, &s_state.ProjectionMatrix, sizeof(Mat4));
//SDL_PushGPUVertexUniformData(s_state.ActiveCommandBuffer, 1, s_state.ActiveCamera->GetMatrix(), sizeof(Mat4));
}
VOID Renderer::EndFrame()
{
SDL_EndGPURenderPass(s_state.ActiveRenderPass);
DebugDraw::Render();
const auto imDrawData = ImGui::GetDrawData();
ImGui_ImplSDLGPU3_PrepareDrawData(imDrawData, s_state.ActiveCommandBuffer);
s_state.ColorTargetInfo.texture = s_renderTargetDebugDrawColor;
s_state.ActiveRenderPass =
SDL_BeginGPURenderPass(s_state.ActiveCommandBuffer, &s_state.ColorTargetInfo, 1, nullptr);
ImGui_ImplSDLGPU3_RenderDrawData(imDrawData, s_state.ActiveCommandBuffer, s_state.ActiveRenderPass);
SDL_EndGPURenderPass(s_state.ActiveRenderPass);
SDL_GPUTexture *swapChainTexture{};
if (!SDL_WaitAndAcquireGPUSwapchainTexture(s_state.ActiveCommandBuffer, g_windowHandle, &swapChainTexture,
(PUINT32) &s_screenWidth, (PUINT32) &s_screenHeight))
THROW_UNKNOWN("Failed to acquire SDL GPU Swapchain texture: ", SDL_GetError());
if (!swapChainTexture)
return;
s_state.ColorTargetInfo.texture = swapChainTexture;
s_state.ActiveRenderPass =
SDL_BeginGPURenderPass(s_state.ActiveCommandBuffer, &s_state.ColorTargetInfo, 1, nullptr);
SDL_BindGPUGraphicsPipeline(s_state.ActiveRenderPass, s_postprocessPipeline->GetHandle());
SDL_GPUTextureSamplerBinding textureBindings[2] = {
{.texture = s_renderTargetSceneColor, .sampler = GPUResourceManager::GetSampler_LinearRepeat()},
{.texture = s_renderTargetDebugDrawColor, .sampler = GPUResourceManager::GetSampler_LinearRepeat()},
};
SDL_BindGPUFragmentSamplers(s_state.ActiveRenderPass, 0, textureBindings, 2);
SDL_DrawGPUPrimitives(s_state.ActiveRenderPass, 6, 1, 0, 0);
SDL_EndGPURenderPass(s_state.ActiveRenderPass);
SDL_SubmitGPUCommandBuffer(s_state.ActiveCommandBuffer);
}
VOID Renderer::OnScreenResize(IN INT32 newWidth, IN INT32 newHeight)
{
}
SDL_GPUTextureFormat Renderer::GetRenderTargetFormat()
{
return SDL_GetGPUSwapchainTextureFormat(s_gpuDevice, g_windowHandle);
}
} // namespace ia::iae
namespace ia::iae
{
VOID Engine::SetActiveCamera(IN ICameraComponent *cameraComponent)
{
Renderer::s_state.ActiveCamera = cameraComponent;
}
Handle Engine::CreateGeometry(IN CONST Vector<GeometryVertex> &vertices, IN CONST Vector<INT32> &indices)
{
return INVALID_HANDLE;
}
VOID Engine::DestroyGeometry(IN Handle geometry)
{
}
VOID Engine::DrawGeometry(IN Handle handle)
{
}
VOID Engine::SetRenderState_Scissor(IN IVec4 rect)
{
Renderer::s_state.Scissor = rect.z ? SDL_Rect{0, 0, Renderer::s_screenWidth, Renderer::s_screenHeight}
: SDL_Rect{rect.x, rect.y, rect.z, rect.w};
}
VOID Engine::SetRenderState_FlippedH(IN BOOL value)
{
Renderer::s_state.FlippedH = value;
}
VOID Engine::SetRenderState_FlippedV(IN BOOL value)
{
Renderer::s_state.FlippedV = value;
}
VOID Engine::SetRenderState_TextureOffset(IN Vec2 off)
{
Renderer::s_state.TextureOffset = off;
}
VOID Engine::SetRenderState_ColorOverlay(IN Color color)
{
Renderer::s_state.ColorOverlay = color;
}
VOID Engine::SetRenderState_CameraRelative(IN BOOL value)
{
Renderer::s_state.CameraRelative = value;
}
VOID Engine::SetRenderState_Texture(IN Handle image)
{
Renderer::s_state.ActiveTexture = image;
}
VOID Engine::SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer,
IN INT16 sortIndex)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,24 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <IAEngine/Engine.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
}

View File

@ -0,0 +1,4 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400

View File

@ -0,0 +1,65 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <ResourceManager.hpp>
#include <IAEngine/Engine.hpp>
namespace ia::iae
{
VOID ResourceManager::Initialize()
{
}
VOID ResourceManager::Terminate()
{
}
}
namespace ia::iae
{
Handle Engine::CreateImage()
{
return INVALID_HANDLE;
}
Handle Engine::CreateSound()
{
return INVALID_HANDLE;
}
VOID Engine::DestroyImage(IN Handle image)
{
}
VOID Engine::DestroySound(IN Handle sound)
{
}
Vec2 Engine::GetImageExtent(IN Handle image)
{
return {};
}
VOID Engine::RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight)
{
}
Handle Engine::CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY)
{
return INVALID_HANDLE;
}
} // namespace ia::iae

View File

@ -0,0 +1,29 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <IAEngine/Engine.hpp>
#include <Time.hpp>
namespace ia::iae
{
VOID Time::Initialize()
{
}
VOID Time::Terminate()
{
}
} // namespace ia::iae

View File

@ -0,0 +1,92 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 <IAEngine/Engine.hpp>
#include <WorldManager.hpp>
namespace ia::iae
{
VOID WorldManager::Initialize()
{
}
VOID WorldManager::Terminate()
{
}
VOID WorldManager::Draw()
{
}
VOID WorldManager::DebugDraw()
{
Engine::DebugDraw_FillRect({0.0f, 0.0f}, {100.0f, 100.0f});
}
VOID WorldManager::Update()
{
}
} // namespace ia::iae
namespace ia::iae
{
Handle Engine::CreatePhysicsBody()
{
return INVALID_HANDLE;
}
VOID Engine::DestroyPhysicsBody(IN Handle body)
{
}
VOID Engine::SetTimeScale(IN FLOAT32 scale)
{
}
Handle Engine::CreateScene()
{
return INVALID_HANDLE;
}
VOID Engine::DestroyScene(IN Handle handle)
{
}
VOID Engine::ChangeActiveScene(IN Handle scene)
{
}
VOID Engine::AddNodeToActiveScene(IN RefPtr<INode> node)
{
}
INode *Engine::GetNodeFromActiveScene(IN CONST String &name)
{
return nullptr;
}
VOID Engine::RemoveNodeFromActiveScene(IN CONST String &name)
{
}
VOID Engine::AddNodeToScene(IN Handle scene, IN RefPtr<INode> node)
{
}
VOID Engine::RemoveNodeFromScene(IN Handle scene, IN CONST String &name)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,4 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400

View File

@ -0,0 +1,31 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class AudioManager
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
};
}

View File

@ -0,0 +1,33 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class EventManager
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC VOID OnSDLEvent(IN SDL_Event* event);
};
}

View File

@ -0,0 +1,33 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class InputManager
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC VOID OnSDLEvent(IN SDL_Event* event);
};
}

View File

@ -0,0 +1,31 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class Random
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
};
}

View File

@ -0,0 +1,32 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class DebugDraw
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC VOID Render();
};
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,38 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class GPUResourceManager
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC SDL_GPUSampler *GetSampler_LinearClamp();
STATIC SDL_GPUSampler *GetSampler_LinearRepeat();
STATIC SDL_GPUTexture *CreateTexture(IN SDL_GPUTextureUsageFlags usage, IN INT32 width, IN INT32 height, IN PCUINT8 rgbaData = nullptr, IN SDL_GPUTextureFormat format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM);
STATIC SDL_GPUBuffer *CreateDeviceLocalBuffer(IN SDL_GPUBufferUsageFlags usage, IN PCVOID data, IN UINT32 dataSize);
STATIC VOID DestroyTexture(IN SDL_GPUTexture *handle);
STATIC VOID DestroyBuffer(IN SDL_GPUBuffer *handle);
};
} // namespace ia::iae

View File

@ -0,0 +1,48 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class Pipeline
{
public:
struct StageDesc
{
PCUINT8 SourceData{};
UINT64 SourceLength{};
UINT32 SamplerCount{};
UINT32 UniformBufferCount{};
};
public:
Pipeline(IN CONST StageDesc &vertexStageDesc, IN CONST StageDesc &pixelStageDesc, IN BOOL enableVertexBuffer, IN BOOL enableDepthTest);
~Pipeline();
SDL_GPUGraphicsPipeline *GetHandle() CONST
{
return m_handle;
}
private:
SDL_GPUGraphicsPipeline *m_handle{};
};
} // namespace ia::iae

View File

@ -0,0 +1,86 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <Renderer/Pipeline.hpp>
#include <Renderer/GPUResourceManager.hpp>
namespace ia::iae
{
class Renderer
{
public:
struct Mesh
{
INT32 IndexCount{};
SDL_GPUBuffer *IndexBuffer;
SDL_GPUBuffer *VertexBuffer;
};
struct State
{
BOOL FlippedH{false};
BOOL FlippedV{false};
BOOL CameraRelative{true};
BOOL ScissorEnabled{false};
Color ColorOverlay{};
Vec2 TextureOffset{0.0f, 0.0f};
SDL_Rect Scissor{0, 0, 0, 0};
Handle ActiveTexture{INVALID_HANDLE};
Mat4 ModelMatrix{1.0f};
Mat4 ProjectionMatrix{1.0f};
SDL_GPURenderPass* ActiveRenderPass{};
SDL_GPUCommandBuffer* ActiveCommandBuffer{};
SDL_GPUColorTargetInfo ColorTargetInfo{};
SDL_GPUDepthStencilTargetInfo DepthStencilTargetInfo{};
class ICameraComponent *ActiveCamera{};
};
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC VOID BeginFrame();
STATIC VOID EndFrame();
STATIC VOID OnScreenResize(IN INT32 newWidth, IN INT32 newHeight);
public:
STATIC SDL_GPUTextureFormat GetRenderTargetFormat();
STATIC SDL_GPUDevice *GetDevice()
{
return s_gpuDevice;
}
private:
STATIC State s_state;
STATIC INT32 s_screenWidth;
STATIC INT32 s_screenHeight;
STATIC SDL_GPUDevice *s_gpuDevice;
STATIC SDL_GPUTexture *s_renderTargetSceneColor;
STATIC SDL_GPUTexture *s_renderTargetSceneDepth;
STATIC SDL_GPUTexture *s_renderTargetDebugDrawColor;
STATIC Pipeline* s_geometryPipeline;
STATIC Pipeline* s_postprocessPipeline;
friend class Engine;
};
} // namespace ia::iae

View File

@ -0,0 +1,24 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
namespace ia::iae
{
}

View File

@ -0,0 +1,31 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class ResourceManager
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
};
}

View File

@ -0,0 +1,31 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class Time
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
};
}

View File

@ -0,0 +1,36 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class WorldManager
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC VOID Draw();
STATIC VOID DebugDraw();
STATIC VOID Update();
};
}

View File

@ -16,24 +16,24 @@
#pragma once
#include <IACore/Exception.hpp>
#include <IACore/Logger.hpp>
#include <IACore/Vector.hpp>
#include <IACore/Memory.hpp>
#include <IACore/String.hpp>
#include <IACore/Exception.hpp>
#include <IACore/Vector.hpp>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/ext/scalar_constants.hpp>
#include <glm/mat4x4.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/scalar_constants.hpp>
#define IAE_LOG_TAG "[IAE]: "
#define IAE_LOG_INFO(...) ia::Logger::Info(IAE_LOG_TAG, __VA_ARGS__)
#define IAE_LOG_WARN(...) ia::Logger::Warn(IAE_LOG_TAG, __VA_ARGS__)
#define IAE_LOG_INFO(...) ia::Logger::Info(IAE_LOG_TAG, __VA_ARGS__)
#define IAE_LOG_WARN(...) ia::Logger::Warn(IAE_LOG_TAG, __VA_ARGS__)
#define IAE_LOG_ERROR(...) ia::Logger::Error(IAE_LOG_TAG, __VA_ARGS__)
namespace ia::iae
@ -44,6 +44,34 @@ namespace ia::iae
using Vec2 = glm::vec2;
using Vec3 = glm::vec3;
using Vec4 = glm::vec4;
using IVec2 = glm::ivec2;
using IVec3 = glm::ivec3;
using IVec4 = glm::ivec4;
using Mat4 = glm::mat4;
struct TimePeriod
{
};
struct ImageView
{
Handle Image{};
Vec4 Scissor{};
};
struct SoundView
{
Handle Sound{};
INT32 LoopTimes{};
TimePeriod LoopDelay{};
};
struct GeometryVertex
{
Vec2 Position{};
Vec2 TexCoord{};
Vec4 Color{};
};
struct Color
{
@ -51,7 +79,235 @@ namespace ia::iae
UINT8 G{0xFF};
UINT8 B{0xFF};
UINT8 A{0xFF};
};
/* Adopted from SDL3 */
enum class InputKey : UINT8
{
UNKNOWN = 0,
A = 4,
B = 5,
C = 6,
D = 7,
E = 8,
F = 9,
G = 10,
H = 11,
I = 12,
J = 13,
K = 14,
L = 15,
M = 16,
N = 17,
O = 18,
P = 19,
Q = 20,
R = 21,
S = 22,
T = 23,
U = 24,
V = 25,
W = 26,
X = 27,
Y = 28,
Z = 29,
N1 = 30,
N2 = 31,
N3 = 32,
N4 = 33,
N5 = 34,
N6 = 35,
N7 = 36,
N8 = 37,
N9 = 38,
N0 = 39,
RETURN = 40,
ESCAPE = 41,
BACKSPACE = 42,
TAB = 43,
SPACE = 44,
MINUS = 45,
EQUALS = 46,
LEFTBRACKET = 47,
RIGHTBRACKET = 48,
BACKSLASH = 49,
NONUSHASH = 50,
SEMICOLON = 51,
APOSTROPHE = 52,
GRAVE = 53,
COMMA = 54,
PERIOD = 55,
SLASH = 56,
CAPSLOCK = 57,
F1 = 58,
F2 = 59,
F3 = 60,
F4 = 61,
F5 = 62,
F6 = 63,
F7 = 64,
F8 = 65,
F9 = 66,
F10 = 67,
F11 = 68,
F12 = 69,
K_PRINTSCREEN = 70,
K_SCROLLLOCK = 71,
K_PAUSE = 72,
K_INSERT = 73,
K_HOME = 74,
K_PAGEUP = 75,
K_DELETE = 76,
K_END = 77,
K_PAGEDOWN = 78,
K_RIGHT = 79,
K_LEFT = 80,
K_DOWN = 81,
K_UP = 82,
NUMLOCKCLEAR = 83,
KP_DIVIDE = 84,
KP_MULTIPLY = 85,
KP_MINUS = 86,
KP_PLUS = 87,
KP_ENTER = 88,
KP_1 = 89,
KP_2 = 90,
KP_3 = 91,
KP_4 = 92,
KP_5 = 93,
KP_6 = 94,
KP_7 = 95,
KP_8 = 96,
KP_9 = 97,
KP_0 = 98,
KP_PERIOD = 99,
NONUSBACKSLASH = 100,
APPLICATION = 101,
POWER = 102,
KP_EQUALS = 103,
F13 = 104,
F14 = 105,
F15 = 106,
F16 = 107,
F17 = 108,
F18 = 109,
F19 = 110,
F20 = 111,
F21 = 112,
F22 = 113,
F23 = 114,
F24 = 115,
EXECUTE = 116,
HELP = 117,
MENU = 118,
SELECT = 119,
STOP = 120,
AGAIN = 121,
UNDO = 122,
CUT = 123,
COPY = 124,
PASTE = 125,
FIND = 126,
MUTE = 127,
VOLUMEUP = 128,
VOLUMEDOWN = 129,
KP_COMMA = 133,
KP_EQUALSAS400 = 134,
INTERNATIONAL1 = 135,
INTERNATIONAL2 = 136,
INTERNATIONAL3 = 137,
INTERNATIONAL4 = 138,
INTERNATIONAL5 = 139,
INTERNATIONAL6 = 140,
INTERNATIONAL7 = 141,
INTERNATIONAL8 = 142,
INTERNATIONAL9 = 143,
LANG1 = 144,
LANG2 = 145,
LANG3 = 146,
LANG4 = 147,
LANG5 = 148,
LANG6 = 149,
LANG7 = 150,
LANG8 = 151,
LANG9 = 152,
ALTERASE = 153,
SYSREQ = 154,
CANCEL = 155,
CLEAR = 156,
PRIOR = 157,
RETURN2 = 158,
SEPARATOR = 159,
OPER = 161,
CLEARAGAIN = 162,
CRSEL = 163,
EXSEL = 164,
KP_00 = 176,
KP_000 = 177,
THOUSANDSSEPARATOR = 178,
DECIMALSEPARATOR = 179,
CURRENCYUNIT = 180,
CURRENCYSUBUNIT = 181,
KP_LEFTPAREN = 182,
KP_RIGHTPAREN = 183,
KP_LEFTBRACE = 184,
KP_RIGHTBRACE = 185,
KP_TAB = 186,
KP_BACKSPACE = 187,
KP_A = 188,
KP_B = 189,
KP_C = 190,
KP_D = 191,
KP_E = 192,
KP_F = 193,
KP_XOR = 194,
KP_POWER = 195,
KP_PERCENT = 196,
KP_LESS = 197,
KP_GREATER = 198,
KP_AMPERSAND = 199,
KP_DBLAMPERSAND = 200,
KP_VERTICALBAR = 201,
KP_DBLVERTICALBAR = 202,
KP_COLON = 203,
KP_HASH = 204,
KP_SPACE = 205,
KP_AT = 206,
KP_EXCLAM = 207,
KP_MEMSTORE = 208,
KP_MEMRECALL = 209,
KP_MEMCLEAR = 210,
KP_MEMADD = 211,
KP_MEMSUBTRACT = 212,
KP_MEMMULTIPLY = 213,
KP_MEMDIVIDE = 214,
KP_PLUSMINUS = 215,
KP_CLEAR = 216,
KP_CLEARENTRY = 217,
KP_BINARY = 218,
KP_OCTAL = 219,
KP_DECIMAL = 220,
KP_HEXADECIMAL = 221,
LCTRL = 224,
LSHIFT = 225,
LALT = 226,
LGUI = 227,
RCTRL = 228,
RSHIFT = 229,
RALT = 230,
RGUI = 231,
};
} // namespace ia::iae

View File

@ -0,0 +1,27 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Components/IComponent.hpp>
namespace ia::iae
{
struct ICameraComponent: public IComponent
{
PURE_VIRTUAL(Mat4* GetMatrix() CONST);
};
}

View File

@ -0,0 +1,29 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
namespace ia::iae
{
class INode;
struct IComponent
{
INode* Node{};
};
}

View File

@ -16,52 +16,11 @@
#pragma once
#include <IAEngine/Base.hpp>
#include <IAEngine/Nodes/INode.hpp>
#include <IAEngine/Components/CameraComponent.hpp>
namespace ia::iae
{
using InputKey = UINT8;
struct TimePeriod
{
};
struct INode
{
String Name{};
};
struct IComponent
{
};
struct ICameraComponent: public IComponent
{
};
struct ImageView
{
Handle Image{};
Vec4 Scissor{};
};
struct SoundView
{
Handle Sound{};
INT32 LoopTimes{};
TimePeriod LoopDelay{};
};
struct GeometryVertex
{
Vec2 Position{};
Vec2 TexCoord{};
Vec4 Color{};
};
class Engine
{
public:
@ -85,13 +44,12 @@ namespace ia::iae
STATIC VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
// Renderer State Functions
STATIC VOID SetRenderState_Scissor(IN Vec4 rect);
STATIC VOID SetRenderState_Scissor(IN IVec4 rect);
STATIC VOID SetRenderState_FlippedH(IN BOOL value);
STATIC VOID SetRenderState_FlippedV(IN BOOL value);
STATIC VOID SetRenderState_TextureOffset(IN Vec2 off);
STATIC VOID SetRenderState_ColorOverlay(IN Color color);
STATIC VOID SetRenderState_CameraRelative(IN BOOL value);
STATIC VOID SetRenderState_ScissorEnabled(IN BOOL value);
STATIC VOID SetRenderState_Texture(IN Handle image);
STATIC VOID SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN INT16 sortIndex);
@ -151,5 +109,8 @@ namespace ia::iae
STATIC INT64 GetUnixSecond();
STATIC INT64 GetUnixMillisecond();
STATIC FLOAT32 GetFrameDeltaTime();
// Engine Functions
STATIC BOOL IsDebugMode();
};
}

View File

@ -16,7 +16,7 @@
#pragma once
#include <IAEngine/GameInterface.hpp>
#include <IAEngine/GameLibraryInterface.hpp>
#if defined(__BUILDING_IAENGINE) && (__BUILDING_IAENGINE)
#define IAE_DLL_API IA_DLL_EXPORT
@ -24,7 +24,4 @@
#define IAE_DLL_API IA_DLL_IMPORT
#endif
C_DECL(IAE_DLL_API ia::BOOL IAEngine_OnInitialize(IN GameFunctionTable gameFunctionTable));
C_DECL(IAE_DLL_API ia::VOID IAEngine_OnTerminate());
C_DECL(IAE_DLL_API ia::BOOL IAEngine_OnIterate());
C_DECL(IAE_DLL_API ia::VOID IAEngine_OnEvent(IN PVOID event));
C_DECL(IAE_DLL_API INT32 IAEngine_Run(IN GameFunctionTable gameFunctionTable));

View File

@ -0,0 +1,27 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
namespace ia::iae
{
struct INode
{
String Name{};
};
}

View File

@ -0,0 +1,24 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Nodes/INode.hpp>
namespace ia::iae
{
}

View File

@ -0,0 +1,24 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Nodes/INode.hpp>
namespace ia::iae
{
}

View File

@ -0,0 +1,24 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Nodes/INode.hpp>
namespace ia::iae
{
}

View File

@ -0,0 +1,24 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Nodes/INode.hpp>
namespace ia::iae
{
}

View File

@ -0,0 +1,24 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Nodes/INode.hpp>
namespace ia::iae
{
}

View File

@ -0,0 +1,24 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Nodes/INode.hpp>
namespace ia::iae
{
}

View File

@ -1,61 +1,34 @@
#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>
#include <IAEngine/EngineLibraryInterface.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[])
int main(int argc, char* argv[])
{
GameFunctionTable gameFunctionTable{};
const auto gameLib = LoadLibrary("Game.dll");
if(!gameLib)
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.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");
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();
return IAEngine_Run(gameFunctionTable);
}

View File

@ -16,5 +16,5 @@
#pragma once
#include <IAEngine/GameInterface.hpp>
#include <IAEngine/GameLibraryInterface.hpp>

2
Vendor/IACore vendored