Files
IAEngine/Engine/Src/Imp/CPP/Components/TextureComponent.cpp
Isuru Samarathunga 86ed9346aa Optimized Renderer
2025-10-21 10:44:11 +05:30

60 lines
2.0 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 <IAEngine/Components/TextureComponent.hpp>
#include <IAEngine/Engine.hpp>
namespace ia::iae
{
TextureComponent::TextureComponent(IN Node2D *node) : IComponent(node)
{
}
VOID TextureComponent::SetTexture(IN Handle image)
{
m_texture = image;
}
VOID TextureComponent::Draw()
{
const auto t = Engine::GetImageExtent(m_texture);
const auto t2 = Engine::GetImageOriginalExtent(m_texture);
m_textureExtent = {t.x, t.y};
m_drawnSize = m_node->GetScale() * m_textureExtent * m_scaleOffset;
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::DrawGeometry(Engine::GetGeometry_Quad(), m_texture, m_node->GetPosition() + m_positionOffset,
m_node->GetScale() * Vec2{t2.x, t2.y} * m_scaleOffset,
m_node->GetRotation() + m_rotationOffset, m_node->Layer(), m_node->SortIndex());
}
VOID TextureComponent::DebugDraw()
{
}
VOID TextureComponent::Update()
{
}
VOID TextureComponent::FixedUpdate()
{
}
} // namespace ia::iae