60 lines
2.0 KiB
C++
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)
|
|
{
|
|
const auto t = Engine::GetImageExtent(image);
|
|
|
|
m_texture = image;
|
|
m_textureExtent = {t.x, t.y};
|
|
}
|
|
|
|
VOID TextureComponent::Draw()
|
|
{
|
|
m_drawnSize = m_node->GetScale() * m_textureExtent * m_scaleOffset;
|
|
|
|
Engine::SetRenderState_Texture(m_texture);
|
|
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::SetRenderState_Transform(m_node->GetPosition() + m_positionOffset, m_drawnSize, m_node->GetRotation() + m_rotationOffset, m_node->Layer(), m_node->SortIndex());
|
|
|
|
Engine::DrawGeometry(Engine::GetGeometry_Quad());
|
|
}
|
|
|
|
VOID TextureComponent::DebugDraw()
|
|
{
|
|
}
|
|
|
|
VOID TextureComponent::Update()
|
|
{
|
|
}
|
|
|
|
VOID TextureComponent::FixedUpdate()
|
|
{
|
|
}
|
|
} // namespace ia::iae
|