Compare commits

...

5 Commits

Author SHA1 Message Date
57c4309cf2 Usable Engine 2025-10-07 17:11:20 +05:30
0ef29f4e5f Renderer 2025-10-06 17:23:17 +05:30
c23f5f4559 Input & Resource Managers 2025-10-06 01:23:54 +05:30
71c7499226 Clean 2025-10-05 16:17:27 +05:30
f8b41a0d61 Engine & Game Library Interface Update 2025-10-05 01:51:48 +05:30
103 changed files with 24327 additions and 282 deletions

7
.gitignore vendored
View File

@ -48,3 +48,10 @@
.cache/
build/
build-windows/
build-linux/
build-ios/
build-mac/
build-android/
imgui.ini

4
.vscode/launch.json vendored
View File

@ -8,10 +8,10 @@
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/Debug/IAEngineRuntimeWin.exe",
"program": "${workspaceFolder}/build/bin/Debug/IAERuntime.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"cwd": "${workspaceFolder}/Samples/SpaceInvaders",
"environment": [],
"console": "externalTerminal",
"preLaunchTask": "CMake: build"

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

@ -0,0 +1,26 @@
{
"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",
"array": "cpp",
"ranges": "cpp",
"span": "cpp",
"vector": "cpp"
}
}

View File

@ -1,5 +1,32 @@
set(SRC_FILES
"Src/Imp/CPP/Time.cpp"
"Src/Imp/CPP/Scene.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"
"Src/Imp/CPP/Nodes/Node2D.cpp"
"Src/Imp/CPP/Nodes/TextureNode.cpp"
"Src/Imp/CPP/Nodes/CameraNode.cpp"
"Src/Imp/CPP/Components/CameraComponent.cpp"
"Src/Imp/CPP/Components/PhysicsComponent.cpp"
"Src/Imp/CPP/Components/SpriteComponent.cpp"
"Src/Imp/CPP/Components/TextureComponent.cpp"
"Src/Imp/CPP/Components/TileMapComponent.cpp"
"Src/Imp/CPP/Components/SoundEmitterComponent.cpp"
)
add_library(IAEngine SHARED ${SRC_FILES})
@ -10,4 +37,4 @@ target_include_directories(IAEngine PUBLIC Src/Inc)
target_include_directories(IAEngine PRIVATE Src/Imp/HPP)
target_link_libraries(IAEngine PUBLIC IACore ImGui glm::glm)
target_link_libraries(IAEngine PRIVATE SDL3::SDL3 SDL3_mixer::SDL3_mixer RmlUi::RmlUi)
target_link_libraries(IAEngine PRIVATE SDL3::SDL3 SDL3_mixer::SDL3_mixer RmlUi::RmlUi STB)

View File

@ -0,0 +1,49 @@
// 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>
#include <SDL3/SDL_iostream.h>
namespace ia::iae
{
MIX_Mixer *AudioManager::s_mixer;
VOID AudioManager::Initialize()
{
if (!MIX_Init())
THROW_UNKNOWN("Failed to initialize SDL Mixer: ", SDL_GetError());
if (!(s_mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, NULL)))
THROW_UNKNOWN(BuildString("Failed to create the SDL mixer: ", SDL_GetError()));
}
VOID AudioManager::Terminate()
{
MIX_DestroyMixer(s_mixer);
}
Handle AudioManager::CreateAudio(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
{
return (Handle) MIX_LoadAudio_IO(s_mixer, SDL_IOFromConstMem(encodedData, encodedDataSize), false, true);
}
VOID AudioManager::DestoryAudio(IN Handle handle)
{
MIX_DestroyAudio((MIX_Audio*)handle);
}
} // namespace ia::iae

View File

@ -0,0 +1,53 @@
// 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/Components/CameraComponent.hpp>
#include <Renderer/Renderer.hpp>
namespace ia::iae
{
CameraComponent::CameraComponent(IN Node2D *node) : IComponent(node)
{
}
VOID CameraComponent::SetViewport(IN INT32 width, IN INT32 height)
{
m_viewport.x = 0;
m_viewport.y = 0;
m_viewport.z = width;
m_viewport.w = height;
m_projectionMatrix =
glm::orthoLH(0.0f, (FLOAT32) width, (FLOAT32) height, 0.0f, Renderer::MIN_DEPTH, Renderer::MAX_DEPTH);
}
VOID CameraComponent::Draw()
{
}
VOID CameraComponent::DebugDraw()
{
}
VOID CameraComponent::Update()
{
}
VOID CameraComponent::FixedUpdate()
{
}
} // namespace ia::iae

View File

@ -0,0 +1,60 @@
// 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/Components/TextureComponent.hpp>
#include <IAEngine/Engine.hpp>
namespace ia::iae
{
TextureComponent::TextureComponent(IN Node2D *node) : IComponent(node)
{
}
VOID TextureComponent::SetTexture(IN Handle image)
{
const auto t = Engine::GetImageExtent(image);
m_texture = image;
m_textureExtent = {t.x, t.y};
}
VOID TextureComponent::Draw()
{
m_drawnSize = m_node->GetScale() * m_textureExtent * m_scaleOffset;
Engine::SetRenderState_Texture(m_texture);
Engine::SetRenderState_FlippedH(m_isFlippedH);
Engine::SetRenderState_FlippedV(m_isFlippedV);
Engine::SetRenderState_ColorOverlay(m_colorOverlay);
Engine::SetRenderState_TextureOffset(m_textureOffset);
Engine::SetRenderState_CameraRelative(m_isCameraRelative);
Engine::SetRenderState_Transform(m_node->GetPosition() + m_positionOffset, m_drawnSize, m_node->GetRotation() + m_rotationOffset, m_node->Layer(), m_node->SortIndex());
Engine::DrawGeometry(Engine::GetGeometry_Quad());
}
VOID TextureComponent::DebugDraw()
{
}
VOID TextureComponent::Update()
{
}
VOID TextureComponent::FixedUpdate()
{
}
} // namespace ia::iae

View File

@ -14,114 +14,47 @@
// 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 <IACore/File.hpp>
#include <IAEngine/EngineInterface.hpp>
#include <IAEngine/EngineLibraryInterface.hpp>
GameFunctionTable g_gameFunctions{};
EXTERN GameFunctionTable g_gameFunctions;
namespace ia::iae
{
String GetStringVersion(IN UINT64 version)
BOOL Engine::IsDebugMode()
{
return "";
#if defined(__DEBUG_MODE__)
return true;
#else
return false;
#endif
}
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()
Handle Engine::CreateImageFromFile(IN CONST String &path)
{
g_gameFunctions.OnTerminate();
IAE_LOG_INFO("Shutting down IAEngine");
const auto data = File::ReadToVector(path.c_str());
return CreateImage(data.data(), data.size());
}
VOID __Internal_Engine::Iterate()
Handle Engine::CreateSoundFromFile(IN CONST String &path)
{
const auto data = File::ReadToVector(path.c_str());
return CreateSound(data.data(), data.size());
}
VOID __Internal_Engine::ProcessEvent(IN SDL_Event *event)
Handle Engine::CreateSceneFromFile(IN CONST String &path)
{
switch (event->type)
{
case SDL_EVENT_WINDOW_RESIZED:
break;
}
const auto data = File::ReadToString(path.c_str());
return CreateScene(data);
}
} // 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,236 @@
// 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 <InputManager.hpp>
namespace ia::iae
{
EXTERN SDL_Window *g_windowHandle;
BOOL InputManager::s_keys[256];
BOOL InputManager::s_prevKeys[256];
InputKey InputManager::s_axisInputs[4];
Vec2 InputManager::s_pointerPosition{};
Map<String, Handle> InputManager::s_actionNames;
Vector<Vector<InputKey>> InputManager::s_actions;
VOID InputManager::Initialize()
{
memset(s_keys, 0, sizeof(s_keys));
memset(s_prevKeys, 0, sizeof(s_prevKeys));
}
VOID InputManager::Terminate()
{
}
VOID InputManager::OnSDLEvent(IN SDL_Event *event)
{
memcpy(s_prevKeys, s_keys, sizeof(s_prevKeys));
switch (event->type)
{
case SDL_EVENT_KEY_DOWN:
s_keys[event->key.scancode] = true;
break;
case SDL_EVENT_KEY_UP:
s_keys[event->key.scancode] = false;
break;
case SDL_EVENT_MOUSE_MOTION:
s_pointerPosition = {event->motion.x, event->motion.y};
break;
default:
break;
}
}
Vec2 InputManager::GetAxis()
{
return Vec2{
IsKeyDown(s_axisInputs[1]) + IsKeyDown(s_axisInputs[0]) * -1,
IsKeyDown(s_axisInputs[3]) + IsKeyDown(s_axisInputs[2]) * -1
};
}
VOID InputManager::SwitchModeToText()
{
SDL_StartTextInput(g_windowHandle);
}
VOID InputManager::SwitchModeToAction()
{
SDL_StopTextInput(g_windowHandle);
}
Vec2 InputManager::GetPointerPosition()
{
return s_pointerPosition;
}
BOOL InputManager::IsKeyDown(IN InputKey key)
{
return s_keys[(UINT8) key];
}
BOOL InputManager::WasKeyPressed(IN InputKey key)
{
return !s_prevKeys[(UINT8) key] && s_keys[(UINT8) key];
}
BOOL InputManager::WasKeyReleased(IN InputKey key)
{
return s_prevKeys[(UINT8) key] && !s_keys[(UINT8) key];
}
BOOL InputManager::IsActionDown(IN Handle action)
{
const auto& t = s_actions[action];
for(const auto& k : t)
if(IsKeyDown(k))
return true;
return false;
}
BOOL InputManager::WasActionPressed(IN Handle action)
{
const auto& t = s_actions[action];
for(const auto& k : t)
if(WasKeyPressed(k))
return true;
return false;
}
BOOL InputManager::WasActionReleased(IN Handle action)
{
const auto& t = s_actions[action];
for(const auto& k : t)
if(WasKeyReleased(k))
return true;
return false;
}
BOOL InputManager::IsActionDown(IN CONST String& action)
{
return IsActionDown(s_actionNames[action]);
}
BOOL InputManager::WasActionPressed(IN CONST String& action)
{
return WasActionPressed(s_actionNames[action]);
}
BOOL InputManager::WasActionReleased(IN CONST String& action)
{
return WasActionReleased(s_actionNames[action]);
}
Handle InputManager::BindAction(IN CONST String &name, IN InputKey key)
{
s_actions.pushBack({key});
const auto handle = s_actions.size() - 1;
s_actionNames[name] = handle;
return handle;
}
VOID InputManager::BindAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey)
{
s_axisInputs[0] = upKey;
s_axisInputs[1] = downKey;
s_axisInputs[2] = leftKey;
s_axisInputs[3] = rightKey;
}
} // namespace ia::iae
namespace ia::iae
{
Vec2 Engine::GetInputAxis()
{
return InputManager::GetAxis();
}
VOID Engine::SwitchInputModeToText()
{
InputManager::SwitchModeToText();
}
VOID Engine::SwitchInputModeToAction()
{
InputManager::SwitchModeToAction();
}
Vec2 Engine::GetInputPointerPosition()
{
return InputManager::GetPointerPosition();
}
BOOL Engine::IsInputKeyDown(IN InputKey key)
{
return InputManager::IsKeyDown(key);
}
BOOL Engine::WasInputKeyPressed(IN InputKey key)
{
return InputManager::WasKeyPressed(key);
}
BOOL Engine::WasInputKeyReleased(IN InputKey key)
{
return InputManager::WasKeyReleased(key);
}
BOOL Engine::IsInputActionDown(IN Handle action)
{
return InputManager::IsActionDown(action);
}
BOOL Engine::WasInputActionPressed(IN Handle action)
{
return InputManager::WasActionPressed(action);
}
BOOL Engine::WasInputActionReleased(IN Handle action)
{
return InputManager::WasActionReleased(action);
}
BOOL Engine::IsInputActionDown(IN CONST String& action)
{
return InputManager::IsActionDown(action);
}
BOOL Engine::WasInputActionPressed(IN CONST String& action)
{
return InputManager::WasActionPressed(action);
}
BOOL Engine::WasInputActionReleased(IN CONST String& action)
{
return InputManager::WasActionReleased(action);
}
Handle Engine::BindInputAction(IN CONST String &name, IN InputKey key)
{
return InputManager::BindAction(name, key);
}
VOID Engine::BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey)
{
InputManager::BindAxis(upKey, downKey, leftKey, rightKey);
}
} // namespace ia::iae

View File

@ -0,0 +1,167 @@
// 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();
WorldManager::FixedUpdate();
g_gameFunctions.OnUpdate(Time::GetFrameDeltaTime());
g_gameFunctions.OnFixedUpdate();
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);
}
FLOAT32 TimePeriod::GetValue() CONST
{
return (FLOAT32) m_value + ((FLOAT32) m_value * (Random::Get() * m_randomAdjustment) / 100.0f);
}
} // 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,25 @@
// 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 <IAEngine/Nodes/CameraNode.hpp>
namespace ia::iae
{
CameraNode::CameraNode(IN CONST String &name) : Node2D(name), m_cameraComponent(AddComponent<CameraComponent>())
{
}
} // namespace ia::iae

View File

@ -0,0 +1,63 @@
// 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 <IAEngine/Nodes/Node2D.hpp>
namespace ia::iae
{
Node2D::Node2D(IN CONST String &name) : INode(name)
{
}
Node2D::~Node2D()
{
for(auto& t: m_components)
delete t;
}
VOID Node2D::Draw()
{
for(auto& t: m_components)
t->Draw();
for(auto& t: m_children)
t->Draw();
}
VOID Node2D::DebugDraw()
{
for(auto& t: m_components)
t->DebugDraw();
for(auto& t: m_children)
t->DebugDraw();
}
VOID Node2D::Update()
{
for(auto& t: m_components)
t->Update();
for(auto& t: m_children)
t->Update();
}
VOID Node2D::FixedUpdate()
{
for(auto& t: m_components)
t->FixedUpdate();
for(auto& t: m_children)
t->FixedUpdate();
}
} // namespace ia::iae

View File

@ -0,0 +1,25 @@
// 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 <IAEngine/Nodes/TextureNode.hpp>
namespace ia::iae
{
TextureNode::TextureNode(IN CONST String &name) : Node2D(name), m_textureComponent(AddComponent<TextureComponent>())
{
}
} // namespace ia::iae

View File

@ -0,0 +1,54 @@
// 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>
#include <Random.hpp>
namespace ia::iae
{
VOID Random::Initialize()
{
srand((INT32)Time::GetUnixMillisecond());
}
VOID Random::Terminate()
{
}
FLOAT32 Random::Get()
{
return ((FLOAT32) rand()) / ((FLOAT32) RAND_MAX);
}
INT32 Random::GetInRange(IN INT32 min, IN INT32 max)
{
return min + (INT32)((max - min) * Get());
}
} // namespace ia::iae
namespace ia::iae
{
FLOAT32 Engine::GetRandomFloat()
{
return Random::Get();
}
INT32 Engine::GetRandomInRange(IN INT32 min, IN INT32 max)
{
return Random::GetInRange(min, max);
}
} // namespace ia::iae

View File

@ -0,0 +1,114 @@
// 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>
#include <IAEngine/GameLibraryInterface.hpp>
EXTERN GameFunctionTable g_gameFunctions;
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();
g_gameFunctions.OnDebugDraw();
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,211 @@
// 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);
}
Vector<UINT8> GPUResourceManager::GetTexturePixelData(IN SDL_GPUTexture *texture, IN INT32 width, IN INT32 height)
{
SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
.size = (UINT32) width * (UINT32) height * 4};
const auto stagingBuffer = SDL_CreateGPUTransferBuffer(Renderer::GetDevice(), &stagingBufferCreateInfo);
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 = texture, .w = (UINT32) width, .h = (UINT32) height, .d = 1};
SDL_DownloadFromGPUTexture(copyPass, &region, &transferInfo);
SDL_EndGPUCopyPass(copyPass);
SDL_SubmitGPUCommandBuffer(cmdBuffer);
SDL_WaitForGPUIdle(Renderer::GetDevice());
Vector<UINT8> result;
result.resize(width * height * 4);
const auto mappedPtr = SDL_MapGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer, false);
SDL_UnmapGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer);
SDL_memcpy(result.data(), mappedPtr, result.size());
SDL_ReleaseGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer);
return result;
}
SDL_GPUTexture* GPUResourceManager::CombineTextures(IN SDL_GPUTexture** textures, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY)
{
SDL_GPUTextureCreateInfo createInfo{.type = SDL_GPU_TEXTURETYPE_2D,
.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM,
.usage = SDL_GPU_TEXTUREUSAGE_SAMPLER,
.width = (UINT32) unitCountX * unitWidth,
.height = (UINT32) unitCountY * unitHeight,
.layer_count_or_depth = 1,
.num_levels = 1};
SDL_GPUTexture *result{};
if (!(result = SDL_CreateGPUTexture(Renderer::GetDevice(), &createInfo)))
THROW_UNKNOWN("Failed to create a SDL GPU Texture: ", SDL_GetError());
const auto cmdBuffer = SDL_AcquireGPUCommandBuffer(Renderer::GetDevice());
const auto copyPass = SDL_BeginGPUCopyPass(cmdBuffer);
for (INT32 y = 0; y < unitCountY; y++)
{
for (INT32 x = 0; x < unitCountX; x++)
{
SDL_GPUTextureLocation src{.texture = textures[x + (y * unitCountX)], .x = 0, .y = 0};
SDL_GPUTextureLocation dst{.texture = result, .x = (UINT32)(x * unitWidth), .y = (UINT32)(y * unitHeight)};
SDL_CopyGPUTextureToTexture(copyPass, &src, &dst, unitWidth, unitHeight, 1, false);
}
}
SDL_EndGPUCopyPass(copyPass);
SDL_SubmitGPUCommandBuffer(cmdBuffer);
SDL_WaitForGPUIdle(Renderer::GetDevice());
return result;
}
} // 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,373 @@
// 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{};
Renderer::Geometry *Renderer::s_quadGeometry{};
VOID Renderer::Initialize()
{
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();
SDL_GetWindowSizeInPixels(g_windowHandle, &s_screenWidth, &s_screenHeight);
OnScreenResize(s_screenWidth, s_screenHeight);
// 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.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;
s_quadGeometry = CreateGeometry(
{
{glm::vec3{0, 1, 0}, glm::vec2{0, 1}, glm::vec4{1.0f, 1.0f, 1.0f, 1.0f}},
{glm::vec3{1, 1, 0}, glm::vec2{1, 1}, glm::vec4{1.0f, 1.0f, 1.0f, 1.0f}},
{glm::vec3{1, 0, 0}, glm::vec2{1, 0}, glm::vec4{1.0f, 1.0f, 1.0f, 1.0f}},
{glm::vec3{0, 0, 0}, glm::vec2{0, 0}, glm::vec4{1.0f, 1.0f, 1.0f, 1.0f}},
},
{0, 1, 2, 2, 3, 0});
}
VOID Renderer::Terminate()
{
SDL_WaitForGPUIdle(s_gpuDevice);
DestroyGeometry(s_quadGeometry);
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()
{
STATIC Mat4 IdentityMatrix(1.0f);
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.ActiveCamera ? s_state.ActiveCamera->GetProjectionMatrix() : &IdentityMatrix, sizeof(Mat4));
SDL_PushGPUVertexUniformData(
s_state.ActiveCommandBuffer, 1,
(s_state.ActiveCamera && !s_state.CameraRelative) ? s_state.ActiveCamera->GetViewMatrix() : &IdentityMatrix,
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)
{
s_screenWidth = newWidth;
s_screenHeight = newHeight;
if (s_renderTargetSceneDepth)
GPUResourceManager::DestroyTexture(s_renderTargetSceneDepth);
if (s_renderTargetSceneColor)
GPUResourceManager::DestroyTexture(s_renderTargetSceneColor);
if (s_renderTargetDebugDrawColor)
GPUResourceManager::DestroyTexture(s_renderTargetDebugDrawColor);
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));
s_state.Scissor = {0, 0, newWidth, newHeight};
s_state.ActiveViewport.x = 0;
s_state.ActiveViewport.y = 0;
s_state.ActiveViewport.w = newWidth;
s_state.ActiveViewport.h = newHeight;
s_state.ActiveViewport.min_depth = 0.0f;
s_state.ActiveViewport.max_depth = 1.0f;
if (s_state.ActiveCamera)
s_state.ActiveCamera->SetViewport(newWidth, newHeight);
}
SDL_GPUTextureFormat Renderer::GetRenderTargetFormat()
{
return SDL_GetGPUSwapchainTextureFormat(s_gpuDevice, g_windowHandle);
}
Renderer::Geometry *Renderer::CreateGeometry(IN CONST Vector<GeometryVertex> &vertices,
IN CONST Vector<INT32> &indices)
{
const auto mesh = new Geometry();
mesh->VertexBuffer = GPUResourceManager::CreateDeviceLocalBuffer(
SDL_GPU_BUFFERUSAGE_VERTEX, vertices.data(), static_cast<UINT32>(vertices.size() * sizeof(vertices[0])));
mesh->IndexBuffer = GPUResourceManager::CreateDeviceLocalBuffer(
SDL_GPU_BUFFERUSAGE_INDEX, indices.data(), static_cast<UINT32>(indices.size() * sizeof(indices[0])));
mesh->IndexCount = static_cast<UINT32>(indices.size());
return mesh;
}
VOID Renderer::DestroyGeometry(IN Geometry *handle)
{
GPUResourceManager::DestroyBuffer(handle->VertexBuffer);
GPUResourceManager::DestroyBuffer(handle->IndexBuffer);
delete handle;
}
VOID Renderer::DrawGeometry(IN Geometry *handle)
{
#pragma pack(push, 1)
STATIC struct
{
INT32 FlippedH{false};
INT32 FlippedV{false};
Vec2 TextureOffset{0.0f, 0.0f};
glm::vec4 ColorOverlay{1.0f, 1.0f, 1.0f, 1.0f};
} s_fragmentUniform{};
#pragma pack(pop)
s_fragmentUniform.ColorOverlay = s_state.ColorOverlay.GetAsFloatVec();
s_fragmentUniform.FlippedH = s_state.FlippedH;
s_fragmentUniform.FlippedV = s_state.FlippedV;
s_fragmentUniform.TextureOffset = s_state.TextureOffset;
SDL_GPUTextureSamplerBinding textureBinding{.texture = s_state.ActiveTexture,
.sampler = GPUResourceManager::GetSampler_LinearRepeat()};
SDL_BindGPUFragmentSamplers(s_state.ActiveRenderPass, 0, &textureBinding, 1);
SDL_PushGPUFragmentUniformData(s_state.ActiveCommandBuffer, 0, &s_fragmentUniform, sizeof(s_fragmentUniform));
SDL_SetGPUScissor(s_state.ActiveRenderPass, &s_state.Scissor);
SDL_SetGPUViewport(s_state.ActiveRenderPass, &s_state.ActiveViewport);
SDL_GPUBufferBinding bufferBindings[] = {{.buffer = handle->VertexBuffer, .offset = 0},
{.buffer = handle->IndexBuffer, .offset = 0}};
SDL_BindGPUVertexBuffers(s_state.ActiveRenderPass, 0, bufferBindings, 1);
SDL_BindGPUIndexBuffer(s_state.ActiveRenderPass, &bufferBindings[1], SDL_GPU_INDEXELEMENTSIZE_32BIT);
SDL_DrawGPUIndexedPrimitives(s_state.ActiveRenderPass, handle->IndexCount, 1, 0, 0, 0);
}
} // namespace ia::iae
namespace ia::iae
{
VOID Engine::SetActiveCamera(IN CameraComponent *cameraComponent)
{
Renderer::s_state.ActiveCamera = cameraComponent;
Renderer::OnScreenResize(Renderer::s_screenWidth, Renderer::s_screenHeight);
}
Handle Engine::CreateGeometry(IN CONST Vector<GeometryVertex> &vertices, IN CONST Vector<INT32> &indices)
{
return (Handle) Renderer::CreateGeometry(vertices, indices);
}
VOID Engine::DestroyGeometry(IN Handle geometry)
{
Renderer::DestroyGeometry((Renderer::Geometry *) geometry);
}
VOID Engine::DrawGeometry(IN Handle handle)
{
Renderer::DrawGeometry((Renderer::Geometry *) 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 = (SDL_GPUTexture *) image;
}
VOID Engine::SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer,
IN INT16 sortIndex)
{
IA_ASSERT(sortIndex <= 0x1FFF);
if (Renderer::s_state.YSortingEnabled)
sortIndex += static_cast<INT16>(position.y);
Renderer::s_state.ModelMatrix =
glm::translate(glm::mat4(1.0f), glm::vec3{position.x, position.y,
static_cast<FLOAT32>((layer << 13) | (sortIndex & 0x1FFF))});
Renderer::s_state.ModelMatrix =
glm::rotate(Renderer::s_state.ModelMatrix, rotation, glm::vec3(0.0f, 0.0f, 1.0f));
Renderer::s_state.ModelMatrix = glm::scale(Renderer::s_state.ModelMatrix, glm::vec3{scale.x, scale.y, 1.0f});
SDL_PushGPUVertexUniformData(Renderer::s_state.ActiveCommandBuffer, 2, &Renderer::s_state.ModelMatrix,
sizeof(Mat4));
}
VOID Engine::SetRenderState_YSortingEnabled(IN BOOL value)
{
Renderer::s_state.YSortingEnabled = value;
}
Handle Engine::GetGeometry_Quad()
{
return (Handle) Renderer::s_quadGeometry;
}
} // 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,150 @@
// 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 <ResourceManager.hpp>
#include <AudioManager.hpp>
#include <Renderer/GPUResourceManager.hpp>
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include <stb_image.h>
#include <stb_image_resize2.h>
namespace ia::iae
{
Vector<Handle> ResourceManager::s_images;
Vector<Handle> ResourceManager::s_sounds;
Map<Handle, UINT64> ResourceManager::s_imageExtents;
VOID ResourceManager::Initialize()
{
}
VOID ResourceManager::Terminate()
{
for (const auto &t : s_images)
GPUResourceManager::DestroyTexture((SDL_GPUTexture *) t);
for (const auto &t : s_sounds)
AudioManager::DestoryAudio(t);
}
Handle ResourceManager::CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
{
INT32 w, h, n;
const auto rgbaData = stbi_load_from_memory(encodedData, encodedDataSize, &w, &h, &n, STBI_rgb_alpha);
const auto result = CreateImage(rgbaData, w, h);
STBI_FREE(rgbaData);
return result;
}
Handle ResourceManager::CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height)
{
const auto handle = (Handle) GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_SAMPLER, width, height,
rgbaData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM);
s_imageExtents[handle] = (((UINT64) width) << 32) | height;
s_images.pushBack(handle);
return handle;
}
Handle ResourceManager::CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
{
const auto handle = AudioManager::CreateAudio(encodedData, encodedDataSize);
s_sounds.pushBack(handle);
return handle;
}
VOID ResourceManager::DestroyImage(IN Handle image)
{
GPUResourceManager::DestroyTexture((SDL_GPUTexture *) image);
}
VOID ResourceManager::DestroySound(IN Handle sound)
{
AudioManager::DestoryAudio(sound);
}
IVec2 ResourceManager::GetImageExtent(IN Handle image)
{
const auto t = s_imageExtents[image];
return {(INT32) (t >> 32), (INT32) t};
}
Handle ResourceManager::RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight)
{
const auto currentExtent = GetImageExtent(image);
const auto pixelData =
GPUResourceManager::GetTexturePixelData((SDL_GPUTexture *) image, currentExtent.x, currentExtent.y);
const auto newPixelData =
stbir_resize_uint8_linear(pixelData.data(), currentExtent.x, currentExtent.y, currentExtent.x * 4, nullptr,
newWidth, newHeight, newWidth * 4, stbir_pixel_layout::STBIR_RGBA);
const auto result = CreateImage(newPixelData, newWidth, newHeight);
free(newPixelData);
return result;
}
Handle ResourceManager::CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY)
{
return (Handle) GPUResourceManager::CombineTextures((SDL_GPUTexture **) images.data(), unitWidth, unitHeight,
unitCountX, unitCountY);
}
} // namespace ia::iae
namespace ia::iae
{
Handle Engine::CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
{
return ResourceManager::CreateImage(encodedData, encodedDataSize);
}
Handle Engine::CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height)
{
return ResourceManager::CreateImage(rgbaData, width, height);
}
Handle Engine::CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
{
return ResourceManager::CreateSound(encodedData, encodedDataSize);
}
VOID Engine::DestroyImage(IN Handle image)
{
ResourceManager::DestroyImage(image);
}
VOID Engine::DestroySound(IN Handle sound)
{
ResourceManager::DestroySound(sound);
}
IVec2 Engine::GetImageExtent(IN Handle image)
{
return ResourceManager::GetImageExtent(image);
}
Handle Engine::RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight)
{
return ResourceManager::RescaleImage(image, newWidth, newHeight);
}
Handle Engine::CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY)
{
return ResourceManager::CombineImages(images, unitWidth, unitHeight, unitCountX, unitCountY);
}
} // namespace ia::iae

View File

@ -0,0 +1,77 @@
// 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 <Scene.hpp>
namespace ia::iae
{
Scene *Scene::Create()
{
return new Scene();
}
Scene *Scene::Create(IN CONST String &sceneXML)
{
const auto scene = new Scene();
return scene;
}
VOID Scene::Destroy(IN Scene *scene)
{
delete scene;
}
VOID Scene::Draw()
{
for (auto &t : m_nodes)
t->Value->Draw();
}
VOID Scene::DebugDraw()
{
for (auto &t : m_nodes)
t->Value->DebugDraw();
}
VOID Scene::FixedUpdate()
{
for (auto &t : m_nodes)
t->Value->FixedUpdate();
}
VOID Scene::Update()
{
for (auto &t : m_nodes)
t->Value->Update();
}
VOID Scene::AddNode(IN RefPtr<INode> node)
{
m_nodes[node->GetName()] = node;
}
INode *Scene::GetNode(IN CONST String &name)
{
return m_nodes[name].get();
}
VOID Scene::RemoveNode(IN CONST String &name)
{
m_nodes[name] = nullptr;
}
} // namespace ia::iae

View File

@ -0,0 +1,102 @@
// 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
{
FLOAT32 g_globalTimeScale = 1.0f;
FLOAT32 g_deltaTime{1 / 60.0f};
INT64 g_lastFrameTick{0};
std::chrono::time_point<std::chrono::high_resolution_clock> g_startMS;
VOID Time::Initialize()
{
g_startMS = std::chrono::high_resolution_clock::now();
}
VOID Time::Terminate()
{
}
VOID Time::NextFrame()
{
const auto t = GetTickCount();
g_deltaTime = t - g_lastFrameTick;
g_lastFrameTick = t;
}
INT64 Time::GetTickCount()
{
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() -
g_startMS)
.count();
}
INT64 Time::GetCurrentSecond()
{
return std::chrono::duration_cast<std::chrono::seconds>(std::chrono::high_resolution_clock::now() - g_startMS)
.count();
}
FLOAT32 Time::GetFrameDeltaTime()
{
return g_deltaTime * g_globalTimeScale;
}
INT64 Time::GetUnixSecond()
{
return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
}
INT64 Time::GetUnixMillisecond()
{
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
}
} // namespace ia::iae
namespace ia::iae
{
VOID Engine::SetTimeScale(IN FLOAT32 scale)
{
g_globalTimeScale = scale;
}
INT64 Engine::GetTickCount()
{
return Time::GetTickCount();
}
INT64 Engine::GetUnixSecond()
{
return Time::GetUnixSecond();
}
INT64 Engine::GetUnixMillisecond()
{
return Time::GetUnixMillisecond();
}
FLOAT32 Engine::GetFrameDeltaTime()
{
return Time::GetFrameDeltaTime();
}
} // namespace ia::iae

View File

@ -0,0 +1,122 @@
// 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
{
Scene *WorldManager::m_activeScene{};
VOID WorldManager::Initialize()
{
m_activeScene = Scene::Create();
}
VOID WorldManager::Terminate()
{
if (m_activeScene)
Scene::Destroy(m_activeScene);
}
VOID WorldManager::Draw()
{
m_activeScene->Draw();
}
VOID WorldManager::DebugDraw()
{
m_activeScene->DebugDraw();
}
VOID WorldManager::Update()
{
m_activeScene->Update();
}
VOID WorldManager::FixedUpdate()
{
m_activeScene->FixedUpdate();
}
VOID WorldManager::ChangeActiveScene(IN Scene *scene)
{
m_activeScene = scene;
}
VOID WorldManager::AddNodeToActiveScene(IN RefPtr<INode> node)
{
m_activeScene->AddNode(node);
}
INode *WorldManager::GetNodeFromActiveScene(IN CONST String &name)
{
return m_activeScene->GetNode(name);
}
VOID WorldManager::RemoveNodeFromActiveScene(IN CONST String &name)
{
m_activeScene->RemoveNode(name);
}
} // namespace ia::iae
namespace ia::iae
{
Handle Engine::CreateScene(IN CONST String &sceneXML)
{
return (Handle) Scene::Create(sceneXML);
}
Handle Engine::CreateEmptyScene()
{
return (Handle) Scene::Create();
}
VOID Engine::DestroyScene(IN Handle handle)
{
Scene::Destroy((Scene *) handle);
}
VOID Engine::ChangeActiveScene(IN Handle scene)
{
WorldManager::ChangeActiveScene((Scene *) scene);
}
VOID Engine::AddNodeToActiveScene(IN RefPtr<INode> node)
{
WorldManager::AddNodeToActiveScene(node);
}
INode *Engine::GetNodeFromActiveScene(IN CONST String &name)
{
return WorldManager::GetNodeFromActiveScene(name);
}
VOID Engine::RemoveNodeFromActiveScene(IN CONST String &name)
{
WorldManager::RemoveNodeFromActiveScene(name);
}
VOID Engine::AddNodeToScene(IN Handle scene, IN RefPtr<INode> node)
{
((Scene *) scene)->AddNode(node);
}
VOID Engine::RemoveNodeFromScene(IN Handle scene, IN CONST String &name)
{
((Scene *) scene)->RemoveNode(name);
}
} // namespace ia::iae

View File

@ -16,15 +16,23 @@
#pragma once
#include <IAEngine/GameInterface.hpp>
#include <IAEngine/Base.hpp>
#if defined(__BUILDING_IAENGINE) && (__BUILDING_IAENGINE)
#define IAE_DLL_API IA_DLL_EXPORT
#else
#define IAE_DLL_API IA_DLL_IMPORT
#endif
#include <SDL3/SDL.h>
#include <SDL3_mixer/SDL_mixer.h>
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));
namespace ia::iae
{
class AudioManager
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC Handle CreateAudio(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC VOID DestoryAudio(IN Handle handle);
private:
STATIC MIX_Mixer *s_mixer;
};
} // namespace ia::iae

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,57 @@
// 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);
STATIC Vec2 GetAxis();
STATIC VOID SwitchModeToText();
STATIC VOID SwitchModeToAction();
STATIC Vec2 GetPointerPosition();
STATIC BOOL IsKeyDown(IN InputKey key);
STATIC BOOL WasKeyPressed(IN InputKey key);
STATIC BOOL WasKeyReleased(IN InputKey key);
STATIC BOOL IsActionDown(IN Handle action);
STATIC BOOL WasActionPressed(IN Handle action);
STATIC BOOL WasActionReleased(IN Handle action);
STATIC BOOL IsActionDown(IN CONST String& action);
STATIC BOOL WasActionPressed(IN CONST String& action);
STATIC BOOL WasActionReleased(IN CONST String& action);
STATIC Handle BindAction(IN CONST String &name, IN InputKey key);
STATIC VOID BindAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
private:
STATIC BOOL s_keys[256];
STATIC BOOL s_prevKeys[256];
STATIC Vec2 s_pointerPosition;
STATIC InputKey s_axisInputs[4];
STATIC Map<String, Handle> s_actionNames;
STATIC Vector<Vector<InputKey>> s_actions;
};
} // namespace ia::iae

View File

@ -0,0 +1,34 @@
// 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();
STATIC FLOAT32 Get();
STATIC INT32 GetInRange(IN INT32 min, IN INT32 max);
};
}

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,42 @@
// 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);
STATIC Vector<UINT8> GetTexturePixelData(IN SDL_GPUTexture* texture, IN INT32 width, IN INT32 height);
STATIC SDL_GPUTexture* CombineTextures(IN SDL_GPUTexture** textures, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY);
};
} // 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,95 @@
// 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:
STATIC CONSTEXPR FLOAT32 MIN_DEPTH = -2097152.0f;
STATIC CONSTEXPR FLOAT32 MAX_DEPTH = 2097152.0f;
struct Geometry
{
INT32 IndexCount{};
SDL_GPUBuffer *IndexBuffer;
SDL_GPUBuffer *VertexBuffer;
};
struct State
{
BOOL FlippedH{false};
BOOL FlippedV{false};
BOOL CameraRelative{true};
BOOL YSortingEnabled{false};
Color ColorOverlay{};
Vec2 TextureOffset{0.0f, 0.0f};
SDL_Rect Scissor{0, 0, 0, 0};
SDL_GPUTexture* ActiveTexture{nullptr};
SDL_GPUViewport ActiveViewport{};
Mat4 ModelMatrix{1.0f};
SDL_GPURenderPass* ActiveRenderPass{};
SDL_GPUCommandBuffer* ActiveCommandBuffer{};
SDL_GPUColorTargetInfo ColorTargetInfo{};
SDL_GPUDepthStencilTargetInfo DepthStencilTargetInfo{};
class CameraComponent *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 Geometry* CreateGeometry(IN CONST Vector<GeometryVertex> &vertices, IN CONST Vector<INT32> &indices);
STATIC VOID DestroyGeometry(IN Geometry* handle);
STATIC VOID DrawGeometry(IN Geometry* handle);
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;
STATIC Geometry* s_quadGeometry;
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,53 @@
// 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
{
struct ImageResource
{
INT32 Width{};
INT32 Height{};
SDL_GPUTexture *Texture{};
};
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC Handle CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC Handle CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
STATIC Handle CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC VOID DestroyImage(IN Handle image);
STATIC VOID DestroySound(IN Handle sound);
STATIC IVec2 GetImageExtent(IN Handle image);
STATIC Handle RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
STATIC Handle CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
IN INT32 unitCountX, IN INT32 unitCountY);
private:
STATIC Vector<Handle> s_images;
STATIC Vector<Handle> s_sounds;
STATIC Map<Handle, UINT64> s_imageExtents;
};
} // 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/Nodes/INode.hpp>
#include <SDL3/SDL.h>
namespace ia::iae
{
class Scene
{
public:
STATIC Scene *Create();
STATIC Scene *Create(IN CONST String &sceneXML);
STATIC VOID Destroy(IN Scene *scene);
public:
VOID Draw();
VOID DebugDraw();
VOID FixedUpdate();
VOID Update();
public:
VOID AddNode(IN RefPtr<INode> node);
INode *GetNode(IN CONST String &name);
VOID RemoveNode(IN CONST String &name);
private:
Map<String, RefPtr<INode>> m_nodes;
};
} // namespace ia::iae

View File

@ -0,0 +1,40 @@
// 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();
STATIC VOID NextFrame();
STATIC INT64 GetTickCount();
STATIC INT64 GetCurrentSecond();
STATIC FLOAT32 GetFrameDeltaTime();
STATIC INT64 GetUnixSecond();
STATIC INT64 GetUnixMillisecond();
};
}

View File

@ -0,0 +1,47 @@
// 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 <Scene.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();
STATIC VOID FixedUpdate();
public:
STATIC VOID ChangeActiveScene(IN Scene* scene);
STATIC VOID AddNodeToActiveScene(IN RefPtr<INode> node);
STATIC INode *GetNodeFromActiveScene(IN CONST String &name);
STATIC VOID RemoveNodeFromActiveScene(IN CONST String &name);
private:
STATIC Scene *m_activeScene;
};
} // namespace ia::iae

View File

@ -16,25 +16,35 @@
#pragma once
#if defined(__BUILDING_IAENGINE) && (__BUILDING_IAENGINE)
#define IAE_DLL_API IA_DLL_EXPORT
#else
#define IAE_DLL_API IA_DLL_IMPORT
#endif
#include <IACore/Map.hpp>
#include <IACore/Logger.hpp>
#include <IACore/Vector.hpp>
#include <IACore/Memory.hpp>
#include <IACore/String.hpp>
#include <IACore/Vector.hpp>
#include <IACore/Exception.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/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>
#define IAE_LOG_TAG "[IAE]: "
#include <chrono>
#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_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_ERROR(...) ia::Logger::Error(IAE_LOG_TAG, __VA_ARGS__)
#define IAE_LOG_SUCCESS(...) ia::Logger::Success(IAE_LOG_TAG, __VA_ARGS__)
namespace ia::iae
{
@ -44,6 +54,59 @@ 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
{
TimePeriod()
{
}
TimePeriod(IN INT32 value, IN INT32 randomAdjustment)
{
SetValue(value);
SetRandomAdjustment(randomAdjustment);
}
VOID SetValue(IN INT32 value)
{
m_value = value;
}
VOID SetRandomAdjustment(IN INT32 adjustment)
{
m_randomAdjustment = adjustment;
}
FLOAT32 GetValue() CONST;
private:
INT32 m_value{};
INT32 m_randomAdjustment{};
};
struct ImageView
{
Handle Image{};
Vec4 Scissor{};
};
struct SoundView
{
Handle Sound{};
INT32 LoopTimes{};
TimePeriod LoopDelay{};
};
struct GeometryVertex
{
Vec2 Position{};
Vec2 TexCoord{};
Vec4 Color{};
};
struct Color
{
@ -52,6 +115,239 @@ namespace ia::iae
UINT8 B{0xFF};
UINT8 A{0xFF};
Vec4 GetAsFloatVec() CONST
{
return {(FLOAT32)R/255.0f, (FLOAT32)G/255.0f, (FLOAT32)B/255.0f, (FLOAT32)A/255.0f};
}
};
/* 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,58 @@
// 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
{
class CameraComponent : public IComponent
{
public:
CameraComponent(IN Node2D *node);
public:
VOID Draw();
VOID DebugDraw();
VOID Update();
VOID FixedUpdate();
public:
VOID SetViewport(IN INT32 width, IN INT32 height);
Vec4 GetViewport() CONST
{
return m_viewport;
}
CONST Mat4 *GetViewMatrix() CONST
{
return &m_viewMatrix;
}
CONST Mat4 *GetProjectionMatrix() CONST
{
return &m_projectionMatrix;
}
private:
Vec4 m_viewport{};
Mat4 m_viewMatrix{1.0f};
Mat4 m_projectionMatrix{1.0f};
};
} // namespace ia::iae

View File

@ -0,0 +1,51 @@
// 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 Node2D;
class IComponent
{
public:
PURE_VIRTUAL(VOID Draw());
PURE_VIRTUAL(VOID DebugDraw());
PURE_VIRTUAL(VOID Update());
PURE_VIRTUAL(VOID FixedUpdate());
public:
IComponent(IN Node2D *node) : m_node(node)
{
}
Node2D *GetNode()
{
return m_node;
}
CONST Node2D *GetNode() CONST
{
return m_node;
}
protected:
Node2D *CONST m_node{};
};
} // namespace ia::iae

View File

@ -0,0 +1,102 @@
// 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
{
class TextureComponent : public IComponent
{
public:
IAE_DLL_API TextureComponent(IN Node2D *node);
public:
VOID Draw();
VOID DebugDraw();
VOID Update();
VOID FixedUpdate();
public:
IAE_DLL_API VOID SetTexture(IN Handle image);
Handle GetTexture() CONST
{
return m_texture;
}
Vec2 &PositionOffset()
{
return m_positionOffset;
}
Vec2 &ScaleOffset()
{
return m_scaleOffset;
}
FLOAT32 &RotationOffset()
{
return m_rotationOffset;
}
Vec2 &TextureOffset()
{
return m_textureOffset;
}
Color &ColorOverlay()
{
return m_colorOverlay;
}
BOOL &IsFlippedH()
{
return m_isFlippedH;
}
BOOL &IsFlippedV()
{
return m_isFlippedV;
}
BOOL &IsCameraRelative()
{
return m_isCameraRelative;
}
Vec2 &DrawnSize()
{
return m_drawnSize;
}
private:
BOOL m_isFlippedH{};
BOOL m_isFlippedV{};
BOOL m_isCameraRelative{true};
Vec2 m_positionOffset{};
Vec2 m_textureOffset{};
Vec2 m_scaleOffset{1.0f, 1.0f};
FLOAT32 m_rotationOffset{};
Color m_colorOverlay{};
Vec2 m_drawnSize{};
Vec2 m_textureExtent{};
Handle m_texture{INVALID_HANDLE};
};
} // namespace ia::iae

View File

@ -16,140 +16,109 @@
#pragma once
#include <IAEngine/Base.hpp>
#include <IAEngine/Nodes/CameraNode.hpp>
#include <IAEngine/Nodes/TileMapNode.hpp>
#include <IAEngine/Nodes/SpriteObjectNode.hpp>
#include <IAEngine/Nodes/TextureObjectNode.hpp>
#include <IAEngine/Components/CameraComponent.hpp>
#include <IAEngine/Components/SoundEmitterComponent.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:
// Event Functions
STATIC Handle CreateEvent(IN CONST String& name);
STATIC VOID DestroyEvent(IN Handle event);
STATIC Handle GetEventByName(IN CONST String& name);
STATIC VOID AddEventListener(IN Handle event, IN std::function<VOID()> callback);
STATIC VOID AddEventListener(IN CONST String& eventName, IN std::function<VOID()> callback);
STATIC VOID BroadcastEvent(IN Handle event);
STATIC VOID BroadcastEvent(IN CONST String& eventName);
// Physics Functions
STATIC Handle CreatePhysicsBody();
STATIC VOID DestroyPhysicsBody(IN Handle body);
STATIC IAE_DLL_API Handle CreateEvent(IN CONST String& name);
STATIC IAE_DLL_API VOID DestroyEvent(IN Handle event);
STATIC IAE_DLL_API Handle GetEventByName(IN CONST String& name);
STATIC IAE_DLL_API VOID AddEventListener(IN Handle event, IN std::function<VOID()> callback);
STATIC IAE_DLL_API VOID AddEventListener(IN CONST String& eventName, IN std::function<VOID()> callback);
STATIC IAE_DLL_API VOID BroadcastEvent(IN Handle event);
STATIC IAE_DLL_API VOID BroadcastEvent(IN CONST String& eventName);
// Renderer Functions
STATIC Handle CreateGeometry(IN CONST Vector<GeometryVertex>& vertices, IN CONST Vector<INT32>& indices);
STATIC VOID DestroyGeometry(IN Handle geometry);
STATIC VOID DrawGeometry(IN Handle handle);
STATIC VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
STATIC IAE_DLL_API Handle GetGeometry_Quad();
STATIC IAE_DLL_API Handle CreateGeometry(IN CONST Vector<GeometryVertex>& vertices, IN CONST Vector<INT32>& indices);
STATIC IAE_DLL_API VOID DestroyGeometry(IN Handle geometry);
STATIC IAE_DLL_API VOID DrawGeometry(IN Handle handle);
STATIC IAE_DLL_API VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
// Renderer State Functions
STATIC VOID SetRenderState_Scissor(IN Vec4 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);
STATIC IAE_DLL_API VOID SetRenderState_Scissor(IN IVec4 rect);
STATIC IAE_DLL_API VOID SetRenderState_FlippedH(IN BOOL value);
STATIC IAE_DLL_API VOID SetRenderState_FlippedV(IN BOOL value);
STATIC IAE_DLL_API VOID SetRenderState_TextureOffset(IN Vec2 off);
STATIC IAE_DLL_API VOID SetRenderState_YSortingEnabled(IN BOOL value);
STATIC IAE_DLL_API VOID SetRenderState_ColorOverlay(IN Color color);
STATIC IAE_DLL_API VOID SetRenderState_CameraRelative(IN BOOL value);
STATIC IAE_DLL_API VOID SetRenderState_Texture(IN Handle image);
STATIC IAE_DLL_API VOID SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN INT16 sortIndex);
// Debug Draw Functions
STATIC VOID DebugDraw_SetColor(IN Color color);
STATIC VOID DebugDraw_StrokeWidth(IN FLOAT32 width);
STATIC VOID DebugDraw_Line(IN Vec2 from, IN Vec2 to);
STATIC VOID DebugDraw_FillRect(IN Vec2 position, IN Vec2 size);
STATIC VOID DebugDraw_StrokeRect(IN Vec2 position, IN Vec2 size);
STATIC IAE_DLL_API VOID DebugDraw_SetColor(IN Color color);
STATIC IAE_DLL_API VOID DebugDraw_StrokeWidth(IN FLOAT32 width);
STATIC IAE_DLL_API VOID DebugDraw_Line(IN Vec2 from, IN Vec2 to);
STATIC IAE_DLL_API VOID DebugDraw_FillRect(IN Vec2 position, IN Vec2 size);
STATIC IAE_DLL_API VOID DebugDraw_StrokeRect(IN Vec2 position, IN Vec2 size);
// Resource Functions
STATIC Handle CreateImage();
STATIC Handle CreateSound();
STATIC VOID DestroyImage(IN Handle image);
STATIC VOID DestroySound(IN Handle sound);
STATIC Vec2 GetImageExtent(IN Handle image);
STATIC VOID RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
STATIC Handle CombineImages(IN CONST Vector<Handle>& images, IN INT32 unitWidth, IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
STATIC IAE_DLL_API Handle CreateImageFromFile(IN CONST String& path);
STATIC IAE_DLL_API Handle CreateSoundFromFile(IN CONST String& path);
STATIC IAE_DLL_API Handle CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC IAE_DLL_API Handle CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
STATIC IAE_DLL_API Handle CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC IAE_DLL_API VOID DestroyImage(IN Handle image);
STATIC IAE_DLL_API VOID DestroySound(IN Handle sound);
STATIC IAE_DLL_API IVec2 GetImageExtent(IN Handle image);
STATIC IAE_DLL_API Handle RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
STATIC IAE_DLL_API Handle CombineImages(IN CONST Vector<Handle>& images, IN INT32 unitWidth, IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
// Game Functions
STATIC VOID SetTimeScale(IN FLOAT32 scale);
STATIC VOID SetActiveCamera(IN ICameraComponent* cameraComponent);
STATIC IAE_DLL_API VOID SetTimeScale(IN FLOAT32 scale);
STATIC IAE_DLL_API VOID SetActiveCamera(IN CameraComponent* cameraComponent);
// Scene Functions
STATIC Handle CreateScene();
STATIC VOID DestroyScene(IN Handle handle);
STATIC VOID ChangeActiveScene(IN Handle scene);
STATIC VOID AddNodeToActiveScene(IN RefPtr<INode> node);
STATIC INode* GetNodeFromActiveScene(IN CONST String& name);
STATIC VOID RemoveNodeFromActiveScene(IN CONST String& name);
STATIC VOID AddNodeToScene(IN Handle scene, IN RefPtr<INode> node);
STATIC VOID RemoveNodeFromScene(IN Handle scene, IN CONST String& name);
STATIC IAE_DLL_API Handle CreateSceneFromFile(IN CONST String& path);
STATIC IAE_DLL_API Handle CreateScene(IN CONST String& sceneXML);
STATIC IAE_DLL_API Handle CreateEmptyScene();
STATIC IAE_DLL_API VOID DestroyScene(IN Handle handle);
STATIC IAE_DLL_API VOID ChangeActiveScene(IN Handle scene);
STATIC IAE_DLL_API VOID AddNodeToActiveScene(IN RefPtr<INode> node);
STATIC IAE_DLL_API INode* GetNodeFromActiveScene(IN CONST String& name);
STATIC IAE_DLL_API VOID RemoveNodeFromActiveScene(IN CONST String& name);
STATIC IAE_DLL_API VOID AddNodeToScene(IN Handle scene, IN RefPtr<INode> node);
STATIC IAE_DLL_API VOID RemoveNodeFromScene(IN Handle scene, IN CONST String& name);
// Input Functions
STATIC Vec2 GetInputAxis();
STATIC VOID SwitchInputModeToText();
STATIC VOID SwitchInputModeToAction();
STATIC Vec2 GetInputPointerPosition();
STATIC BOOL IsInputKeyDown(IN InputKey key);
STATIC BOOL WasInputKeyPressed(IN InputKey key);
STATIC BOOL WasInputKeyReleased(IN InputKey key);
STATIC BOOL IsInputActionDown(IN Handle action);
STATIC BOOL WasInputActionPressed(IN Handle action);
STATIC BOOL WasInputActionReleased(IN Handle action);
STATIC BOOL IsInputActionDown(IN PCCHAR action);
STATIC BOOL WasInputActionPressed(IN PCCHAR action);
STATIC BOOL WasInputActionReleased(IN PCCHAR action);
STATIC Handle BindInputAction(IN CONST String& name, IN InputKey key);
STATIC VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
STATIC IAE_DLL_API Vec2 GetInputAxis();
STATIC IAE_DLL_API VOID SwitchInputModeToText();
STATIC IAE_DLL_API VOID SwitchInputModeToAction();
STATIC IAE_DLL_API Vec2 GetInputPointerPosition();
STATIC IAE_DLL_API BOOL IsInputKeyDown(IN InputKey key);
STATIC IAE_DLL_API BOOL WasInputKeyPressed(IN InputKey key);
STATIC IAE_DLL_API BOOL WasInputKeyReleased(IN InputKey key);
STATIC IAE_DLL_API BOOL IsInputActionDown(IN Handle action);
STATIC IAE_DLL_API BOOL WasInputActionPressed(IN Handle action);
STATIC IAE_DLL_API BOOL WasInputActionReleased(IN Handle action);
STATIC IAE_DLL_API BOOL IsInputActionDown(IN CONST String& action);
STATIC IAE_DLL_API BOOL WasInputActionPressed(IN CONST String& action);
STATIC IAE_DLL_API BOOL WasInputActionReleased(IN CONST String& action);
STATIC IAE_DLL_API Handle BindInputAction(IN CONST String& name, IN InputKey key);
STATIC IAE_DLL_API VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
// Random Functions
STATIC FLOAT32 GetRandomFloat();
STATIC INT32 GetRandomInRange(IN INT32 min, IN INT32 max);
STATIC IAE_DLL_API FLOAT32 GetRandomFloat();
STATIC IAE_DLL_API INT32 GetRandomInRange(IN INT32 min, IN INT32 max);
// Time Functions
STATIC INT64 GetTickCount();
STATIC INT64 GetUnixSecond();
STATIC INT64 GetUnixMillisecond();
STATIC FLOAT32 GetFrameDeltaTime();
STATIC IAE_DLL_API INT64 GetTickCount();
STATIC IAE_DLL_API INT64 GetUnixSecond();
STATIC IAE_DLL_API INT64 GetUnixMillisecond();
STATIC IAE_DLL_API FLOAT32 GetFrameDeltaTime();
// Engine Functions
STATIC IAE_DLL_API BOOL IsDebugMode();
};
}

View File

@ -0,0 +1,21 @@
// 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/GameLibraryInterface.hpp>
C_DECL(IAE_DLL_API INT32 IAEngine_Run(IN GameFunctionTable gameFunctionTable));

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/Components/CameraComponent.hpp>
#include <IAEngine/Nodes/Node2D.hpp>
namespace ia::iae
{
class CameraNode : public Node2D
{
public:
IAE_DLL_API CameraNode(IN CONST String &name);
public:
CameraComponent *GetCameraComponent()
{
return m_cameraComponent;
}
protected:
CameraComponent *CONST m_cameraComponent{};
};
} // namespace ia::iae

View File

@ -0,0 +1,44 @@
// 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
{
public:
INode(IN CONST String &name) : m_name(name)
{
}
PURE_VIRTUAL(VOID Draw());
PURE_VIRTUAL(VOID DebugDraw());
PURE_VIRTUAL(VOID Update());
PURE_VIRTUAL(VOID FixedUpdate());
public:
CONST String &GetName() CONST
{
return m_name;
}
protected:
CONST String m_name;
};
} // namespace ia::iae

View File

@ -0,0 +1,200 @@
// 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>
#include <IAEngine/Nodes/INode.hpp>
namespace ia::iae
{
class Node2D : public INode
{
public:
IAE_DLL_API Node2D(IN CONST String &name);
IAE_DLL_API ~Node2D();
public:
template<typename _component_type> _component_type *AddComponent()
{
const auto t = new _component_type(this);
m_components.pushBack(t);
return t;
}
template<typename _component_type> _component_type *GetComponent()
{
for (auto &c : m_components)
{
_component_type *comp = dynamic_cast<_component_type *>(c.get());
if (comp)
return comp;
}
return nullptr;
}
template<typename _component_type> Vector<_component_type *> GetComponents()
{
Vector<_component_type *> result;
for (auto &c : m_components)
{
_component_type *comp = dynamic_cast<_component_type *>(c.get());
if (comp)
result.pushBack(comp);
}
return result;
}
public:
VOID Translate(IN Vec2 v)
{
m_local.Position += v;
RecalculatePosition();
}
VOID Scale(IN FLOAT32 v)
{
m_local.Scale *= v;
RecalculateScale();
}
VOID Scale(IN Vec2 v)
{
m_local.Scale *= v;
RecalculateScale();
}
VOID Rotate(IN FLOAT32 v)
{
m_local.Rotation += v;
RecalculateRotation();
}
VOID SetLocalPosition(IN CONST Vec2 &v)
{
m_local.Position = v;
RecalculatePosition();
}
VOID SetLocalScale(IN CONST Vec2 &v)
{
m_local.Scale = v;
RecalculateScale();
}
VOID SetLocalRotation(IN FLOAT32 v)
{
m_local.Rotation = v;
RecalculateRotation();
}
public:
CONST Vec2 &GetPosition() CONST
{
return m_global.Position;
}
CONST Vec2 &GetScale() CONST
{
return m_global.Scale;
}
CONST FLOAT32 &GetRotation() CONST
{
return m_global.Rotation;
}
CONST Vec2 &GetLocalPosition() CONST
{
return m_local.Position;
}
CONST Vec2 &GetLocalScale() CONST
{
return m_local.Scale;
}
CONST FLOAT32 &GetLocalRotation() CONST
{
return m_local.Rotation;
}
UINT8 &Layer()
{
return m_layer;
}
INT16 &SortIndex()
{
return m_sortIndex;
}
CONST UINT8 &Layer() CONST
{
return m_layer;
}
CONST INT16 &SortIndex() CONST
{
return m_sortIndex;
}
protected:
VOID RecalculatePosition()
{
m_global.Position = (m_parent ? m_parent->GetPosition() : Vec2{}) + m_local.Position;
for (auto &c : m_children)
c->RecalculatePosition();
}
VOID RecalculateRotation()
{
m_global.Rotation = (m_parent ? m_parent->GetRotation() : 0) + m_local.Rotation;
for (auto &c : m_children)
c->RecalculateRotation();
}
VOID RecalculateScale()
{
m_global.Scale = (m_parent ? m_parent->GetScale() : Vec2{}) + m_local.Scale;
for (auto &c : m_children)
c->RecalculateScale();
}
protected:
RefPtr<Node2D> m_parent{};
Vector<IComponent *> m_components;
Vector<RefPtr<Node2D>> m_children{};
private:
struct
{
FLOAT32 Rotation{0.0f};
Vec2 Position{0.0f, 0.0f};
Vec2 Scale{1.0f, 1.0f};
} m_local{}, m_global{};
UINT8 m_layer{};
INT16 m_sortIndex{};
public:
VOID Draw();
VOID DebugDraw();
VOID Update();
VOID FixedUpdate();
};
} // namespace ia::iae

View File

@ -0,0 +1,25 @@
// 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/Node2D.hpp>
#include <IAEngine/Components/SpriteComponent.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/SpriteNode.hpp>
namespace ia::iae
{
}

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/Components/TextureComponent.hpp>
#include <IAEngine/Nodes/Node2D.hpp>
namespace ia::iae
{
class TextureNode : public Node2D
{
public:
IAE_DLL_API TextureNode(IN CONST String &name);
public:
TextureComponent *GetTextureComponent()
{
return m_textureComponent;
}
protected:
TextureComponent *CONST m_textureComponent{};
};
} // 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/TextureNode.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,7 @@
set(SRC_FILES
"Src/Imp/CPP/Main.cpp"
)
add_library(IAERuntime SHARED ${SRC_FILES})
target_link_libraries(IAERuntime PRIVATE IAEngine nlohmann_json SDL3::SDL3)

View File

View File

@ -2,6 +2,6 @@ set(SRC_FILES
"Src/Imp/CPP/Main.cpp"
)
add_executable(IAEngineRuntimeWin ${SRC_FILES})
add_executable(IAERuntime ${SRC_FILES})
target_link_libraries(IAEngineRuntimeWin PRIVATE IAEngine nlohmann_json SDL3::SDL3)
target_link_libraries(IAERuntime PRIVATE IAEngine nlohmann_json SDL3::SDL3)

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.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.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");
if(!IAEngine_OnInitialize(gameFunctionTable))
return SDL_APP_FAILURE;
gameFunctionTable.GetName = (PCCHAR (*)()) GetProcAddress(gameLib, "Game_GetName");
gameFunctionTable.GetVersion = (UINT64 (*)()) GetProcAddress(gameLib, "Game_GetVersion");
gameFunctionTable.GetPackageName = (PCCHAR (*)()) GetProcAddress(gameLib, "Game_GetPackageName");
gameFunctionTable.GetDeveloperName = (PCCHAR (*)()) GetProcAddress(gameLib, "Game_GetDeveloperName");
gameFunctionTable.GetPublisherName = (PCCHAR (*)()) GetProcAddress(gameLib, "Game_GetPublisherName");
return SDL_APP_CONTINUE;
}
void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
IAEngine_OnTerminate();
SDL_Quit();
return IAEngine_Run(gameFunctionTable);
}

View File

@ -0,0 +1 @@
Shout out to Anim86 for this amazing sprite pack! https://anim86.itch.io/space-shoter-starter-pack

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -16,14 +16,24 @@
#include <Game.hpp>
Handle g_spriteBG;
RefPtr<TextureNode> backgroundNode;
RefPtr<CameraNode> mainCamera;
C_DECL(IA_DLL_EXPORT VOID Game_OnInitialize())
{
GAME_LOG_INFO("Booting Game");
g_spriteBG = Engine::RescaleImage(Engine::CreateImageFromFile("Resources/Sprites/bg.png"), 800, 600);
mainCamera = MakeRefPtr<CameraNode>("MainCamera");
Engine::SetActiveCamera(mainCamera->GetCameraComponent());
backgroundNode = MakeRefPtr<TextureNode>("BG");
backgroundNode->GetTextureComponent()->SetTexture(g_spriteBG);
Engine::AddNodeToActiveScene(backgroundNode);
}
C_DECL(IA_DLL_EXPORT VOID Game_OnTerminate())
{
GAME_LOG_INFO("Shutting down Game");
}
C_DECL(IA_DLL_EXPORT VOID Game_OnDebugDraw())

View File

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

1
Tools/BuildAndroid.bat Normal file
View File

@ -0,0 +1 @@
cmake -S . -B ./build-android -DCMAKE_TOOLCHAIN_FILE="$NDK_PATH\build\cmake\android.toolchain.cmake" -DANDROID_ABI=x86_64

28
Vendor/CMakeLists.txt vendored
View File

@ -78,18 +78,24 @@ add_subdirectory(pugixml/)
# -----------------------------------------------
add_subdirectory(json/)
# -----------------------------------------------
# STB
# -----------------------------------------------
add_library(STB INTERFACE)
target_include_directories(STB INTERFACE stb/)
# -----------------------------------------------
# NativeFileDialog
# -----------------------------------------------
add_library(
NFD STATIC
"nativefiledialog/src/nfd_common.c"
"nativefiledialog/src/nfd_win.cpp"
)
target_include_directories(
NFD PUBLIC
"nativefiledialog/src/include"
)
#add_library(
# NFD STATIC
#
# "nativefiledialog/src/nfd_common.c"
# "nativefiledialog/src/nfd_win.cpp"
#)
#target_include_directories(
# NFD PUBLIC
#
# "nativefiledialog/src/include"
#)

2
Vendor/IACore vendored

7988
Vendor/stb/stb_image.h vendored Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More