Cleanup 2/2

This commit is contained in:
Isuru Samarathunga
2025-11-05 16:23:50 +05:30
parent 7d6e8ef695
commit 80dc50d279
14 changed files with 275 additions and 74 deletions

View File

@ -14,4 +14,4 @@ add_executable(IAE_Editor ${SRC_FILES})
target_include_directories(IAE_Editor PRIVATE imp/hpp)
target_link_libraries(IAE_Editor PRIVATE RenderCore)
target_link_libraries(IAE_Editor PRIVATE IAEngine)

View File

@ -14,9 +14,11 @@
// 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/IAEngine.hpp>
#include <RenderCore/RenderCore.hpp>
#include <SDL3/SDL.h>
#include <Vendor/imgui/backends/imgui_impl_sdl3.h>
#include <Vendor/imgui/backends/imgui_impl_sdlgpu3.h>
#include <Vendor/imgui/imgui.h>
@ -25,11 +27,14 @@ namespace ia::iae
{
ImDrawData *g_imDrawData{};
SDL_Window *g_windowHandle{};
EXTERN Vec2 g_designViewport;
EXTERN SDL_Window *g_windowHandle;
INT32 Run(IN INT32 argc, IN PCCHAR argv[])
{
INT32 frameCounter{0};
IVec2 windowExtent{800, 600};
g_designViewport = windowExtent;
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMEPAD))
THROW_UNKNOWN("Failed to intialize SDL: ", SDL_GetError());
@ -40,15 +45,15 @@ namespace ia::iae
SDL_MaximizeWindow(g_windowHandle);
SDL_GetWindowSizeInPixels(g_windowHandle, &windowExtent.x, &windowExtent.y);
RDC::Initialize(windowExtent, g_windowHandle, true);
const auto mainScale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
IAEngine::__Initialize();
auto gamePreviewTexture = new RDC_Texture(RDC_Texture::EType::SAMPLED, 800, 600);
const auto mainScale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
IMGUI_CHECKVERSION();
ImGui::CreateContext();
auto& imGUIIO = ImGui::GetIO();
auto &imGUIIO = ImGui::GetIO();
imGUIIO.IniFilename = nullptr;
imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
@ -71,9 +76,18 @@ namespace ia::iae
SDL_PollEvent(&event);
if (event.type == SDL_EVENT_QUIT)
break;
IAEngine::__ProcessEvent(&event);
IAEngine::__Update();
ImGui_ImplSDL3_ProcessEvent(&event);
RDC::RenderToTexture(gamePreviewTexture->GetHandle());
frameCounter++;
if (frameCounter >= 60)
{
frameCounter = 0;
IAEngine::__FixedUpdate();
}
IAEngine::__RenderToTexture(gamePreviewTexture->GetHandle());
ImGui_ImplSDLGPU3_NewFrame();
ImGui_ImplSDL3_NewFrame();
@ -122,7 +136,7 @@ namespace ia::iae
delete gamePreviewTexture;
RDC::Terminate();
IAEngine::__Terminate();
SDL_DestroyWindow(g_windowHandle);
@ -133,4 +147,36 @@ namespace ia::iae
int main(int argc, char *argv[])
{
return ia::iae::Run(argc, (const char **) argv);
}
#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())
{
RDC::DrawRect({10, 10}, {700, 500}, {1.0f, 0.0f, 0.0f, 1.0f});
}
C_DECL(VOID Game_OnFixedUpdate())
{
}
C_DECL(VOID Game_OnUpdate(IN FLOAT32 deltaTime))
{
}
C_DECL(VOID Game_OnResize(IN INT32 newWidth, IN INT32 newHeight))
{
}