Engine API Enhancements

This commit is contained in:
Isuru Samarathunga
2025-10-08 00:45:02 +05:30
parent 57c4309cf2
commit 1f9d5426b8
13 changed files with 205 additions and 141 deletions

View File

@ -17,32 +17,36 @@
#pragma once
#include <IAEngine/Nodes/CameraNode.hpp>
#include <IAEngine/Nodes/TileMapNode.hpp>
#include <IAEngine/Nodes/SpriteObjectNode.hpp>
#include <IAEngine/Nodes/TextureObjectNode.hpp>
#include <IAEngine/Nodes/TileMapNode.hpp>
#include <IAEngine/Components/CameraComponent.hpp>
#include <IAEngine/Components/SoundEmitterComponent.hpp>
#include <IAEngine/Scene.hpp>
namespace ia::iae
{
class Engine
{
public:
public:
// Event Functions
STATIC IAE_DLL_API Handle CreateEvent(IN CONST String& name);
STATIC IAE_DLL_API Handle CreateEvent(IN CONST String &name);
STATIC IAE_DLL_API VOID DestroyEvent(IN Handle event);
STATIC IAE_DLL_API Handle GetEventByName(IN CONST String& name);
STATIC IAE_DLL_API Handle GetEventByName(IN CONST String &name);
STATIC IAE_DLL_API VOID AddEventListener(IN Handle event, IN std::function<VOID()> callback);
STATIC IAE_DLL_API VOID AddEventListener(IN CONST String& eventName, IN std::function<VOID()> callback);
STATIC IAE_DLL_API VOID AddEventListener(IN CONST String &eventName, IN std::function<VOID()> callback);
STATIC IAE_DLL_API VOID BroadcastEvent(IN Handle event);
STATIC IAE_DLL_API VOID BroadcastEvent(IN CONST String& eventName);
STATIC IAE_DLL_API VOID BroadcastEvent(IN CONST String &eventName);
// Renderer Functions
STATIC IAE_DLL_API Handle GetGeometry_Quad();
STATIC IAE_DLL_API Handle CreateGeometry(IN CONST Vector<GeometryVertex>& vertices, IN CONST Vector<INT32>& indices);
STATIC IAE_DLL_API Handle CreateGeometry(IN CONST Vector<GeometryVertex> &vertices,
IN CONST Vector<INT32> &indices);
STATIC IAE_DLL_API VOID DestroyGeometry(IN Handle geometry);
STATIC IAE_DLL_API VOID DrawGeometry(IN Handle handle);
STATIC IAE_DLL_API VOID DrawGeometry(IN Handle handle);
STATIC IAE_DLL_API IVec2 GetDisplayExtent();
STATIC IAE_DLL_API VOID ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight);
// Renderer State Functions
@ -54,7 +58,8 @@ namespace ia::iae
STATIC IAE_DLL_API VOID SetRenderState_ColorOverlay(IN Color color);
STATIC IAE_DLL_API VOID SetRenderState_CameraRelative(IN BOOL value);
STATIC IAE_DLL_API VOID SetRenderState_Texture(IN Handle image);
STATIC IAE_DLL_API VOID SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN UINT8 layer, IN INT16 sortIndex);
STATIC IAE_DLL_API VOID SetRenderState_Transform(IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation,
IN UINT8 layer, IN INT16 sortIndex);
// Debug Draw Functions
STATIC IAE_DLL_API VOID DebugDraw_SetColor(IN Color color);
@ -64,32 +69,33 @@ namespace ia::iae
STATIC IAE_DLL_API VOID DebugDraw_StrokeRect(IN Vec2 position, IN Vec2 size);
// Resource Functions
STATIC IAE_DLL_API Handle CreateImageFromFile(IN CONST String& path);
STATIC IAE_DLL_API Handle CreateSoundFromFile(IN CONST String& path);
STATIC IAE_DLL_API Handle CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC IAE_DLL_API Handle CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
STATIC IAE_DLL_API Handle CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC IAE_DLL_API Handle CreateSoundFromFile(IN CONST String &name, IN CONST String &path);
STATIC IAE_DLL_API Handle CreateImageFromFile(IN CONST String &name, IN CONST String &path,
IN INT32 resizeToWidth = 0, IN INT32 resizeToHeight = 0);
STATIC IAE_DLL_API Handle CreateImage(IN CONST String &name, IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC IAE_DLL_API Handle CreateImage(IN CONST String &name, IN PCUINT8 rgbaData, IN INT32 width,
IN INT32 height);
STATIC IAE_DLL_API Handle CreateSound(IN CONST String &name, IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
STATIC IAE_DLL_API Handle GetImage(IN CONST String &name);
STATIC IAE_DLL_API Handle GetSound(IN CONST String &name);
STATIC IAE_DLL_API VOID DestroyImage(IN Handle image);
STATIC IAE_DLL_API VOID DestroySound(IN Handle sound);
STATIC IAE_DLL_API IVec2 GetImageExtent(IN Handle image);
STATIC IAE_DLL_API Handle RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
STATIC IAE_DLL_API Handle CombineImages(IN CONST Vector<Handle>& images, IN INT32 unitWidth, IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
STATIC IAE_DLL_API Handle ResizeImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
STATIC IAE_DLL_API Handle CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth,
IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
// Game Functions
STATIC IAE_DLL_API VOID SetTimeScale(IN FLOAT32 scale);
STATIC IAE_DLL_API VOID SetActiveCamera(IN CameraComponent* cameraComponent);
STATIC IAE_DLL_API VOID SetActiveCamera(IN CameraComponent *cameraComponent);
// Scene Functions
STATIC IAE_DLL_API Handle CreateSceneFromFile(IN CONST String& path);
STATIC IAE_DLL_API Handle CreateScene(IN CONST String& sceneXML);
STATIC IAE_DLL_API Handle CreateEmptyScene();
STATIC IAE_DLL_API VOID DestroyScene(IN Handle handle);
STATIC IAE_DLL_API VOID ChangeActiveScene(IN Handle scene);
STATIC IAE_DLL_API RefPtr<Scene> CreateSceneFromFile(IN CONST String &path);
STATIC IAE_DLL_API Scene *GetActiveScene();
STATIC IAE_DLL_API VOID ChangeActiveScene(IN RefPtr<Scene> scene);
STATIC IAE_DLL_API VOID AddNodeToActiveScene(IN RefPtr<INode> node);
STATIC IAE_DLL_API INode* GetNodeFromActiveScene(IN CONST String& name);
STATIC IAE_DLL_API VOID RemoveNodeFromActiveScene(IN CONST String& name);
STATIC IAE_DLL_API VOID AddNodeToScene(IN Handle scene, IN RefPtr<INode> node);
STATIC IAE_DLL_API VOID RemoveNodeFromScene(IN Handle scene, IN CONST String& name);
STATIC IAE_DLL_API INode *GetNodeFromActiveScene(IN CONST String &name);
STATIC IAE_DLL_API VOID RemoveNodeFromActiveScene(IN CONST String &name);
// Input Functions
STATIC IAE_DLL_API Vec2 GetInputAxis();
@ -102,11 +108,12 @@ namespace ia::iae
STATIC IAE_DLL_API BOOL IsInputActionDown(IN Handle action);
STATIC IAE_DLL_API BOOL WasInputActionPressed(IN Handle action);
STATIC IAE_DLL_API BOOL WasInputActionReleased(IN Handle action);
STATIC IAE_DLL_API BOOL IsInputActionDown(IN CONST String& action);
STATIC IAE_DLL_API BOOL WasInputActionPressed(IN CONST String& action);
STATIC IAE_DLL_API BOOL WasInputActionReleased(IN CONST String& action);
STATIC IAE_DLL_API Handle BindInputAction(IN CONST String& name, IN InputKey key);
STATIC IAE_DLL_API VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
STATIC IAE_DLL_API BOOL IsInputActionDown(IN CONST String &action);
STATIC IAE_DLL_API BOOL WasInputActionPressed(IN CONST String &action);
STATIC IAE_DLL_API BOOL WasInputActionReleased(IN CONST String &action);
STATIC IAE_DLL_API Handle BindInputAction(IN CONST String &name, IN InputKey key);
STATIC IAE_DLL_API VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey,
IN InputKey rightKey);
// Random Functions
STATIC IAE_DLL_API FLOAT32 GetRandomFloat();
@ -121,4 +128,4 @@ namespace ia::iae
// Engine Functions
STATIC IAE_DLL_API BOOL IsDebugMode();
};
}
} // namespace ia::iae

View File

@ -0,0 +1,51 @@
// 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/Nodes/INode.hpp>
namespace ia::iae
{
class Scene
{
public:
STATIC IAE_DLL_API RefPtr<Scene> Create();
STATIC IAE_DLL_API RefPtr<Scene> Create(IN CONST String &sceneXML);
public:
IAE_DLL_API VOID AddNode(IN RefPtr<INode> node);
IAE_DLL_API INode *GetNode(IN CONST String &name);
IAE_DLL_API VOID RemoveNode(IN CONST String &name);
public:
Color &BackgroundColor()
{
return m_backgroundColor;
}
private:
Color m_backgroundColor{0, 0, 0, 255};
Map<String, RefPtr<INode>> m_nodes;
public:
VOID Draw();
VOID DebugDraw();
VOID FixedUpdate();
VOID Update();
};
} // namespace ia::iae