Engine & Game Library Interface Update
This commit is contained in:
29
Engine/Src/Imp/CPP/AudioManager.cpp
Normal file
29
Engine/Src/Imp/CPP/AudioManager.cpp
Normal 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()
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
66
Engine/Src/Imp/CPP/EventManager.cpp
Normal file
66
Engine/Src/Imp/CPP/EventManager.cpp
Normal 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
|
||||
108
Engine/Src/Imp/CPP/InputManager.cpp
Normal file
108
Engine/Src/Imp/CPP/InputManager.cpp
Normal 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
|
||||
159
Engine/Src/Imp/CPP/InternalEngine.cpp
Normal file
159
Engine/Src/Imp/CPP/InternalEngine.cpp
Normal 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;
|
||||
}
|
||||
@ -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()
|
||||
{
|
||||
}
|
||||
}
|
||||
110
Engine/Src/Imp/CPP/Renderer/DebugDraw.cpp
Normal file
110
Engine/Src/Imp/CPP/Renderer/DebugDraw.cpp
Normal 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
|
||||
148
Engine/Src/Imp/CPP/Renderer/GPUResourceManager.cpp
Normal file
148
Engine/Src/Imp/CPP/Renderer/GPUResourceManager.cpp
Normal 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, ®ion, 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
|
||||
108
Engine/Src/Imp/CPP/Renderer/Pipeline.cpp
Normal file
108
Engine/Src/Imp/CPP/Renderer/Pipeline.cpp
Normal 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
|
||||
257
Engine/Src/Imp/CPP/Renderer/Renderer.cpp
Normal file
257
Engine/Src/Imp/CPP/Renderer/Renderer.cpp
Normal 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
|
||||
24
Engine/Src/Imp/CPP/Renderer/UIRenderer.cpp
Normal file
24
Engine/Src/Imp/CPP/Renderer/UIRenderer.cpp
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
4
Engine/Src/Imp/CPP/Renderer/imgui.ini
Normal file
4
Engine/Src/Imp/CPP/Renderer/imgui.ini
Normal file
@ -0,0 +1,4 @@
|
||||
[Window][Debug##Default]
|
||||
Pos=60,60
|
||||
Size=400,400
|
||||
|
||||
65
Engine/Src/Imp/CPP/ResourceManager.cpp
Normal file
65
Engine/Src/Imp/CPP/ResourceManager.cpp
Normal 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
|
||||
@ -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
|
||||
92
Engine/Src/Imp/CPP/WorldManager.cpp
Normal file
92
Engine/Src/Imp/CPP/WorldManager.cpp
Normal 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
|
||||
4
Engine/Src/Imp/CPP/imgui.ini
Normal file
4
Engine/Src/Imp/CPP/imgui.ini
Normal file
@ -0,0 +1,4 @@
|
||||
[Window][Debug##Default]
|
||||
Pos=60,60
|
||||
Size=400,400
|
||||
|
||||
31
Engine/Src/Imp/HPP/AudioManager.hpp
Normal file
31
Engine/Src/Imp/HPP/AudioManager.hpp
Normal 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();
|
||||
};
|
||||
}
|
||||
33
Engine/Src/Imp/HPP/EventManager.hpp
Normal file
33
Engine/Src/Imp/HPP/EventManager.hpp
Normal 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);
|
||||
};
|
||||
}
|
||||
33
Engine/Src/Imp/HPP/InputManager.hpp
Normal file
33
Engine/Src/Imp/HPP/InputManager.hpp
Normal 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);
|
||||
};
|
||||
}
|
||||
@ -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();
|
||||
};
|
||||
}
|
||||
32
Engine/Src/Imp/HPP/Renderer/DebugDraw.hpp
Normal file
32
Engine/Src/Imp/HPP/Renderer/DebugDraw.hpp
Normal 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();
|
||||
};
|
||||
}
|
||||
154
Engine/Src/Imp/HPP/Renderer/EmbeddedShader.hpp
Normal file
154
Engine/Src/Imp/HPP/Renderer/EmbeddedShader.hpp
Normal file
File diff suppressed because one or more lines are too long
38
Engine/Src/Imp/HPP/Renderer/GPUResourceManager.hpp
Normal file
38
Engine/Src/Imp/HPP/Renderer/GPUResourceManager.hpp
Normal 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
|
||||
48
Engine/Src/Imp/HPP/Renderer/Pipeline.hpp
Normal file
48
Engine/Src/Imp/HPP/Renderer/Pipeline.hpp
Normal 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
|
||||
86
Engine/Src/Imp/HPP/Renderer/Renderer.hpp
Normal file
86
Engine/Src/Imp/HPP/Renderer/Renderer.hpp
Normal 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
|
||||
24
Engine/Src/Imp/HPP/Renderer/UIRenderer.hpp
Normal file
24
Engine/Src/Imp/HPP/Renderer/UIRenderer.hpp
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
31
Engine/Src/Imp/HPP/ResourceManager.hpp
Normal file
31
Engine/Src/Imp/HPP/ResourceManager.hpp
Normal 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();
|
||||
};
|
||||
}
|
||||
@ -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();
|
||||
};
|
||||
}
|
||||
36
Engine/Src/Imp/HPP/WorldManager.hpp
Normal file
36
Engine/Src/Imp/HPP/WorldManager.hpp
Normal 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();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user