This commit is contained in:
Isuru Samarathunga
2025-10-09 19:28:54 +05:30
parent 1f9d5426b8
commit 96bad30f15
25 changed files with 813 additions and 69 deletions

View File

@ -138,6 +138,7 @@ namespace ia::iae
VOID GPUResourceManager::DestroyTexture(IN SDL_GPUTexture *handle)
{
if(!handle) return;
SDL_ReleaseGPUTexture(Renderer::GetDevice(), handle);
}

View File

@ -19,6 +19,7 @@
#include <Renderer/EmbeddedShader.hpp>
#include <Renderer/Renderer.hpp>
#include <ResourceManager.hpp>
#include <WorldManager.hpp>
#include <backends/imgui_impl_sdl3.h>
@ -231,6 +232,15 @@ namespace ia::iae
if (s_state.ActiveCamera)
s_state.ActiveCamera->SetViewport(newWidth, newHeight);
const auto activeScene = WorldManager::GetActiveScene();
if (activeScene)
{
const auto sceneExtent = activeScene->Extent();
s_state.SceneScaleFactor = {(FLOAT32) newWidth / (FLOAT32) sceneExtent.x,
(FLOAT32) newHeight / (FLOAT32) sceneExtent.y};
IAE_LOG_INFO("Updated Scene Scale Factor: (", s_state.SceneScaleFactor.x, ", ", s_state.SceneScaleFactor.y, ")");
}
}
SDL_GPUTextureFormat Renderer::GetRenderTargetFormat()
@ -266,7 +276,7 @@ namespace ia::iae
INT32 FlippedH{false};
INT32 FlippedV{false};
Vec2 TextureOffset{0.0f, 0.0f};
glm::vec4 ColorOverlay{1.0f, 1.0f, 1.0f, 1.0f};
Vec4 ColorOverlay{1.0f, 1.0f, 1.0f, 1.0f};
} s_fragmentUniform{};
#pragma pack(pop)
@ -289,6 +299,11 @@ namespace ia::iae
SDL_BindGPUIndexBuffer(s_state.ActiveRenderPass, &bufferBindings[1], SDL_GPU_INDEXELEMENTSIZE_32BIT);
SDL_DrawGPUIndexedPrimitives(s_state.ActiveRenderPass, handle->IndexCount, 1, 0, 0, 0);
}
VOID Renderer::WaitForGPUIdle()
{
SDL_WaitForGPUIdle(s_gpuDevice);
}
} // namespace ia::iae
namespace ia::iae
@ -352,7 +367,7 @@ namespace ia::iae
VOID Engine::SetRenderState_Texture(IN Handle image)
{
Renderer::s_state.ActiveTexture = (SDL_GPUTexture *) image;
Renderer::s_state.ActiveTexture = ResourceManager::GetTextureFromImage(image);
}
VOID Engine::SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer,
@ -363,6 +378,9 @@ namespace ia::iae
if (Renderer::s_state.YSortingEnabled)
sortIndex += static_cast<INT16>(position.y);
position *= Renderer::s_state.SceneScaleFactor;
scale *= Renderer::s_state.SceneScaleFactor;
Renderer::s_state.ModelMatrix =
glm::translate(glm::mat4(1.0f), glm::vec3{position.x, position.y,
static_cast<FLOAT32>((layer << 13) | (sortIndex & 0x1FFF))});

View File

@ -1,24 +0,0 @@
// 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
{
}