Files
IAEngine/Src/Editor/imp/cpp/UI/View/Game.cpp
Isuru Samarathunga a2b80ef600 Fixes
2025-11-14 09:43:09 +05:30

99 lines
2.2 KiB
C++

// 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 <Editor.hpp>
#include <UI/View/Game.hpp>
#include <RenderCore/RenderCore.hpp>
#include <IAEngine/LibInterface.hpp>
namespace ia::iae
{
VOID View_Game::Initialize()
{
SetName("Game");
SetIcon(ICON_FA_GAMEPAD);
IAEngine::__Initialize(SCENE_EDITOR_RESOULTION, Editor::Instance().GetActiveProject()->AssetDirectory());
m_gameRenderTexture = new RDC_Texture(RDC_Texture::EType::SAMPLED, SCENE_EDITOR_RESOULTION.x, SCENE_EDITOR_RESOULTION.y);
}
VOID View_Game::Terminate()
{
delete m_gameRenderTexture;
}
VOID View_Game::Render()
{
PreRender();
ImGui::Image(m_gameRenderTexture->GetHandle(), m_extent);
PostRender();
}
VOID View_Game::Update()
{
STATIC INT32 frameCounter{0};
IAEngine::__Update();
frameCounter++;
if (frameCounter >= 60)
{
frameCounter = 0;
IAEngine::__FixedUpdate();
}
IAEngine::__RenderToTexture(m_gameRenderTexture->GetHandle());
}
VOID View_Game::OnEvent(IN SDL_Event *event)
{
IAEngine::__ProcessEvent(event);
}
} // namespace ia::iae
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))
{
}