Optimized Renderer
This commit is contained in:
@ -0,0 +1,79 @@
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IAEngine/Components/UIImageComponent.hpp>
|
||||
|
||||
namespace ia::iae
|
||||
{
|
||||
class UIButtonComponent : public UIImageComponent
|
||||
{
|
||||
public:
|
||||
UIButtonComponent(IN UINode *node);
|
||||
|
||||
String &Label()
|
||||
{
|
||||
return m_label;
|
||||
}
|
||||
|
||||
CONST String &Label() CONST
|
||||
{
|
||||
return m_label;
|
||||
}
|
||||
|
||||
Vec2 &LabelPosition()
|
||||
{
|
||||
return m_labelPosition;
|
||||
}
|
||||
|
||||
FLOAT32 &LabelSize()
|
||||
{
|
||||
return m_labelSize;
|
||||
}
|
||||
|
||||
Color &LabelColor()
|
||||
{
|
||||
return m_labelColor;
|
||||
}
|
||||
|
||||
public:
|
||||
VOID SetOnDownCallback(IN std::function<VOID()> callback)
|
||||
{
|
||||
m_onDownCallback = callback;
|
||||
}
|
||||
|
||||
VOID SetOnClickCallback(IN std::function<VOID()> callback)
|
||||
{
|
||||
m_onClickCallback = callback;
|
||||
}
|
||||
|
||||
public:
|
||||
VOID Draw();
|
||||
VOID DebugDraw();
|
||||
|
||||
VOID Update();
|
||||
VOID FixedUpdate();
|
||||
|
||||
private:
|
||||
String m_label{};
|
||||
Vec2 m_labelPosition{};
|
||||
FLOAT32 m_labelSize{1.0f};
|
||||
Color m_labelColor{0xFF, 0xFF, 0xFF, 0xFF};
|
||||
std::function<VOID()> m_onDownCallback;
|
||||
std::function<VOID()> m_onClickCallback;
|
||||
};
|
||||
} // namespace ia::iae
|
||||
@ -0,0 +1,54 @@
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IAEngine/Components/IUIComponent.hpp>
|
||||
|
||||
namespace ia::iae
|
||||
{
|
||||
class UIImageComponent : public IUIComponent
|
||||
{
|
||||
public:
|
||||
UIImageComponent(IN UINode *node);
|
||||
|
||||
Handle &Image()
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
|
||||
CONST Handle &Image() CONST
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
|
||||
CONST Vec2 &DrawnSize() CONST
|
||||
{
|
||||
return m_drawnSize;
|
||||
}
|
||||
|
||||
public:
|
||||
VOID Draw();
|
||||
VOID DebugDraw();
|
||||
|
||||
VOID Update();
|
||||
VOID FixedUpdate();
|
||||
|
||||
private:
|
||||
Handle m_image{};
|
||||
Vec2 m_drawnSize{};
|
||||
};
|
||||
} // namespace ia::iae
|
||||
@ -23,7 +23,7 @@ namespace ia::iae
|
||||
class UILabelComponent : public IUIComponent
|
||||
{
|
||||
public:
|
||||
UILabelComponent(IN UINode* node);
|
||||
UILabelComponent(IN UINode *node);
|
||||
|
||||
String &Label()
|
||||
{
|
||||
@ -35,6 +35,11 @@ namespace ia::iae
|
||||
return m_label;
|
||||
}
|
||||
|
||||
struct Color &Color()
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
public:
|
||||
VOID Draw();
|
||||
VOID DebugDraw();
|
||||
@ -44,5 +49,6 @@ namespace ia::iae
|
||||
|
||||
private:
|
||||
String m_label{};
|
||||
struct Color m_color{0xFF, 0xFF, 0xFF, 0xFF};
|
||||
};
|
||||
} // namespace ia::iae
|
||||
@ -47,10 +47,12 @@ namespace ia::iae
|
||||
STATIC Handle GetGeometry_Circle();
|
||||
STATIC Handle CreateGeometry(IN CONST Vector<GeometryVertex> &vertices, IN CONST Vector<INT32> &indices);
|
||||
STATIC VOID DestroyGeometry(IN Handle geometry);
|
||||
STATIC VOID DrawGeometry(IN Handle handle, IN UINT8 layer, IN UINT16 sortIndex);
|
||||
STATIC IVec2 GetDisplayExtent();
|
||||
STATIC FLOAT32 GetDisplayAspectRatio();
|
||||
STATIC VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
|
||||
STATIC VOID DrawGeometry(IN Handle geometry, IN Handle texture, IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
|
||||
STATIC VOID DrawQuad(IN Vec2 position, IN Handle texture, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
|
||||
STATIC VOID DrawCircle(IN Vec2 position, IN Handle texture, IN FLOAT32 radius, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
|
||||
STATIC VOID DrawText(IN CONST String& text, IN Vec2 position, IN FLOAT32 scale, IN FLOAT32 rotation, IN UINT8 layer, IN UINT16 sortIndex);
|
||||
|
||||
// Renderer State Functions
|
||||
@ -61,10 +63,7 @@ namespace ia::iae
|
||||
STATIC VOID SetRenderState_YSortingEnabled(IN BOOL value);
|
||||
STATIC VOID SetRenderState_ColorOverlay(IN Color color);
|
||||
STATIC VOID SetRenderState_CameraRelative(IN BOOL value);
|
||||
STATIC VOID SetRenderState_Texture(IN Handle image);
|
||||
STATIC VOID SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation);
|
||||
STATIC VOID SetRenderState_TransformUI(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation);
|
||||
STATIC Vec2 GetRendererScalingFactor();
|
||||
STATIC Vec2 GetSceneScalingFactor();
|
||||
|
||||
// Debug Draw Functions
|
||||
STATIC VOID DebugDraw_SetColor(IN Color color);
|
||||
@ -107,7 +106,12 @@ namespace ia::iae
|
||||
// Input Functions
|
||||
STATIC VOID Input_SwitchModeToText();
|
||||
STATIC VOID Input_SwitchModeToAction();
|
||||
|
||||
STATIC BOOL Input_IsPointerDown();
|
||||
STATIC Vec2 Input_GetPointerPosition();
|
||||
STATIC BOOL Input_DidPointerClick(IN CONST Vec2& start, IN CONST Vec2& end);
|
||||
STATIC BOOL Input_IsPointerDown(IN CONST Vec2& start, IN CONST Vec2& end);
|
||||
|
||||
STATIC BOOL Input_IsKeyDown(IN InputKey key);
|
||||
STATIC BOOL Input_WasKeyPressed(IN InputKey key);
|
||||
STATIC BOOL Input_WasKeyReleased(IN InputKey key);
|
||||
|
||||
@ -48,11 +48,6 @@ namespace ia::iae
|
||||
return m_extent;
|
||||
}
|
||||
|
||||
IVec2 &Viewport()
|
||||
{
|
||||
return m_viewport;
|
||||
}
|
||||
|
||||
Color &BackgroundColor()
|
||||
{
|
||||
return m_backgroundColor;
|
||||
@ -62,7 +57,6 @@ namespace ia::iae
|
||||
String m_uiMarkup{};
|
||||
String m_uiMarkupStyles{};
|
||||
IVec2 m_extent{100, 100};
|
||||
IVec2 m_viewport{100, 100};
|
||||
CameraComponent *m_camera{};
|
||||
Color m_backgroundColor{0, 0, 0, 255};
|
||||
Map<String, RefPtr<INode>> m_nodes;
|
||||
|
||||
Reference in New Issue
Block a user