This commit is contained in:
Isuru Samarathunga
2025-11-10 09:49:22 +05:30
parent 73d26b2f35
commit 67cb23d589
69 changed files with 9716 additions and 194 deletions

View File

@ -23,7 +23,9 @@
#include <Vendor/imgui/backends/imgui_impl_sdl3.h>
#include <Vendor/imgui/backends/imgui_impl_sdlgpu3.h>
#include <UI.hpp>
#include <UI/UI.hpp>
#include <LogoIcon.hpp>
namespace ia::iae
{
@ -40,6 +42,11 @@ namespace ia::iae
IVec2 g_windowExtent{800, 600};
RDC_Texture *g_gamePreviewTexture{};
VOID Editor::LoadProject(IN CONST String &directory)
{
m_activeProject = Project::Load(directory);
}
INT32 Editor::Run(IN INT32 argc, IN PCCHAR argv[])
{
INT32 frameCounter{0};
@ -48,13 +55,42 @@ namespace ia::iae
THROW_UNKNOWN("Failed to intialize SDL: ", SDL_GetError());
if (!(g_windowHandle = SDL_CreateWindow("IAEngine", g_windowExtent.x, g_windowExtent.y,
SDL_WINDOW_RESIZABLE | SDL_WINDOW_MAXIMIZED)))
SDL_WINDOW_RESIZABLE)))
THROW_UNKNOWN("Failed to create the SDL window: ", SDL_GetError());
LoadProject(".");
SDL_SetWindowPosition(g_windowHandle, m_activeProject->WindowPosition().x, m_activeProject->WindowPosition().y);
SDL_MaximizeWindow(g_windowHandle);
SDL_GetWindowSizeInPixels(g_windowHandle, &g_windowExtent.x, &g_windowExtent.y);
g_designViewport = gamePreviewResolution;
IAEngine::__Initialize();
SDL_Surface* iconSurface = SDL_CreateSurface(
LOGO_ICON_WIDTH,
LOGO_ICON_HEIGHT,
SDL_PIXELFORMAT_RGBA32
);
if(iconSurface)
{
for(UINT32 i = 0; i < LOGO_ICON_WIDTH * LOGO_ICON_HEIGHT * 4; i += 4)
{
STATIC UINT32 p{0xFFFFFFFF};
const auto pixel = ((PUINT8)&p);
const auto pixels = (PUINT8)iconSurface->pixels;
LOGO_ICON_GET_PIXEL(LOGO_ICON_DATA, pixel);
pixels[i + 0] = pixel[0];
pixels[i + 1] = pixel[1];
pixels[i + 2] = pixel[2];
pixels[i + 3] = 0xFF;
}
SDL_SetWindowIcon(g_windowHandle, iconSurface);
SDL_DestroySurface(iconSurface);
}
SDL_SetWindowTitle(g_windowHandle, BuildString("IAEngine - ", m_activeProject->Name()).c_str());
g_designViewport = SCENE_EDITOR_RESOULTION;
IAEngine::__Initialize(m_activeProject->AssetDirectory());
g_gamePreviewTexture = new RDC_Texture(RDC_Texture::EType::SAMPLED, g_designViewport.x, g_designViewport.y);
@ -67,8 +103,6 @@ namespace ia::iae
imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
ImGui::StyleColorsClassic();
ImGuiStyle &style = ImGui::GetStyle();
style.ScaleAllSizes(mainScale);
style.FontScaleDpi = mainScale;
@ -83,6 +117,8 @@ namespace ia::iae
fontConfig.MergeMode = true;
fontConfig.PixelSnapH = true;
fontConfig.FontDataOwnedByAtlas = false;
fontConfig.GlyphOffset.y = 1.5f;
fontConfig.SizePixels = 12.0f;
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
imGUIIO.Fonts->AddFontDefault();
@ -149,6 +185,11 @@ namespace ia::iae
RDC_Device::WaitForIdle();
}
IVec2 currentWindowPosition{};
SDL_GetWindowPosition(g_windowHandle, &currentWindowPosition.x, &currentWindowPosition.y);
m_activeProject->WindowPosition() = currentWindowPosition;
m_activeProject->Update();
UI::Terminate();
ImGui_ImplSDL3_Shutdown();
@ -163,9 +204,16 @@ namespace ia::iae
return 0;
}
} // namespace ia::iae
VOID Editor::LoadProject(IN CONST String &directory)
{
m_activeProject = Project::Load(directory);
}
} // namespace ia::iae
#include <IAEngine/LibInterface.hpp>
C_DECL(GameRequestedConfig* Game_GetConfigRequest()){
return nullptr;
}
C_DECL(VOID Game_OnInitialize()){}
C_DECL(VOID Game_OnTerminate()){}
C_DECL(VOID Game_OnDebugDraw()){}
C_DECL(VOID Game_OnFixedUpdate()){}
C_DECL(VOID Game_OnUpdate(IN FLOAT32 deltaTime)){}
C_DECL(VOID Game_OnResize(IN INT32 newWidth, IN INT32 newHeight)){}