Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renderbackend: Rework Canvas 2D-Rendering #244

Merged
merged 46 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3362bbf
Renderbackend: Just fix some finidings
kullingk Oct 10, 2024
5381835
Update Component.h
kimkulling Oct 10, 2024
1e4cfff
Canvas: Add docs and improvements
kimkulling Oct 10, 2024
683a8bd
Update CanvasRenderer.h
kimkulling Oct 11, 2024
a0202a0
Update CanvasRenderer.h
kimkulling Oct 11, 2024
1ffb692
Update CanvasRenderer.cpp
kimkulling Oct 11, 2024
ce8090d
Update MaterialBuilder.h
kimkulling Oct 11, 2024
a13930f
Canvas2D: Add prototype for text rendering
kimkulling Oct 14, 2024
883ada3
Canvas:Remove dead code.
kimkulling Oct 14, 2024
29dcb52
Canvas: Add font service
kullingk Oct 15, 2024
4c578ff
Canvas: Add font service
kullingk Oct 15, 2024
3e79c55
vcpkg: latest greatest
kimkulling Oct 16, 2024
037efdd
Canvas: Prepare text rendering
kullingk Oct 17, 2024
8e08167
Canvas: Fix the build
kullingk Oct 21, 2024
617083b
Canvas: Add missing doc
kullingk Oct 22, 2024
ed8f8f3
Merge branch 'master' of https://github.com/kimkulling/osre
kimkulling Oct 22, 2024
6b0bef5
cppcore: latest greatest
kimkulling Oct 23, 2024
aa8725c
Canvas: Adapt new hash
kimkulling Oct 23, 2024
516cdbf
Canvas: Ensure that all font materials are assigned to the used meshes.
kimkulling Oct 23, 2024
e825f62
Refactroings
kullingk Oct 24, 2024
789a398
cppcore: latest greatest
kimkulling Oct 29, 2024
b4c72a8
Canvas: fix overwide when setting color
kimkulling Oct 29, 2024
891c945
Mesh: Remove dead code
kullingk Oct 30, 2024
1a25271
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kullingk Oct 30, 2024
5d4e316
Canvas: next steps
kullingk Oct 30, 2024
231a3f6
Canvas: Setup canvas renderer
kullingk Oct 30, 2024
bc1f0e8
Canvas: Some small refactorings.
kimkulling Nov 4, 2024
c6f53b1
Canvas: Add text rendering prototype.
kimkulling Nov 5, 2024
a859d0e
Canvas: Fix crashes
kullingk Nov 6, 2024
4ddd758
Canvas: Fix material access.
kullingk Nov 7, 2024
135975c
Add container for text rendering
kullingk Nov 8, 2024
b2fdcdf
Canvas: Separate text rendering from 2d canvas rendering
kullingk Nov 8, 2024
d0f4dbd
Canvas:Fix review findings
kimkulling Nov 8, 2024
5bbcacf
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kimkulling Nov 8, 2024
7678db4
Canvas: cleanup
kullingk Nov 11, 2024
7023c4e
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kimkulling Nov 11, 2024
2c756c7
merge
kimkulling Nov 11, 2024
ddfe258
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kimkulling Nov 11, 2024
3d6de71
CI: Add missing dep
kimkulling Nov 11, 2024
6325e47
Fix build
kimkulling Nov 11, 2024
85e6e67
Merge branch 'kimkulling/fix_2d_coords' of https://github.com/kimkull…
kimkulling Nov 11, 2024
edbde48
Canvas: Fix the build.
kullingk Nov 12, 2024
9bf581d
cppcore: latest master
kimkulling Nov 12, 2024
4f5557d
Remove dead code
kimkulling Nov 12, 2024
f91a4f9
Canvas: fix review findins
kullingk Nov 13, 2024
2e927c1
Canvas: fix review findins
kullingk Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
sudo apt-get update -y -qq
sudo apt-get install libsdl2-dev libglm-dev libglew-dev libgtest-dev
sudo apt-get install libsdl2-dev libglm-dev libglew-dev libgtest-dev googletest
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

🛠️ Refactor suggestion

Consider removing redundant Google Test package.

The project uses GTest with modern CMake configuration (find_package(GTest CONFIG REQUIRED)) and links against the namespaced targets (GTest::gtest and GTest::gtest_main). In Ubuntu, libgtest-dev is sufficient for this setup, making the additional googletest package redundant.

-        sudo apt-get install libsdl2-dev libglm-dev libglew-dev libgtest-dev googletest
+        sudo apt-get install libsdl2-dev libglm-dev libglew-dev libgtest-dev
🔗 Analysis chain

Consider removing redundant Google Test package.

The line installs both libgtest-dev and googletest packages, which appear to be redundant as they both provide Google Test framework. This could potentially lead to version conflicts.

Consider using only one package:

-        sudo apt-get install libsdl2-dev libglm-dev libglew-dev libgtest-dev googletest
+        sudo apt-get install libsdl2-dev libglm-dev libglew-dev libgtest-dev

Let's verify the Google Test setup and package information:


Let me verify the CMake configuration to understand how GTest is being used.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check package information for Google Test packages
# Expected results: Show that these packages provide the same framework

# Check package details
apt-cache show libgtest-dev
apt-cache show googletest

# Verify if tests are properly configured in CMake
rg -l "find_package\(.*GTest.*\)" -g "CMakeLists.txt"

Length of output: 295


Script:

#!/bin/bash
# Check the CMake configuration for GTest
cat test/UnitTests/CMakeLists.txt

# Look for any GTest-related includes or dependencies
rg -g "CMakeLists.txt" "GTest|gtest" -A 3 -B 3

Length of output: 4686


- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down
11 changes: 7 additions & 4 deletions samples/02_Demo2D/Demo2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static constexpr c8 Tag[] = "ModelLoadingApp";
//-------------------------------------------------------------------------------------------------
class Demo2DApp : public App::AppBase {
TransformMatrixBlock mTransformMatrix;
CanvasRenderer *mCanvasRenderer;
CanvasRenderer *mCanvasRenderer;

public:
Demo2DApp(int argc, char *argv[]) :
Expand All @@ -66,7 +66,7 @@ class Demo2DApp : public App::AppBase {

protected:
bool onCreate() override {
Properties::Settings *baseSettings(AppBase::getSettings());
Properties::Settings *baseSettings = AppBase::getSettings();
if (baseSettings == nullptr) {
return false;
}
Expand All @@ -75,8 +75,9 @@ class Demo2DApp : public App::AppBase {
if (!AppBase::onCreate()) {
return false;
}

mCanvasRenderer = new CanvasRenderer(2, 0, 0, 1024, 768);

mCanvasRenderer = AppBase::getCanvasRenderer();

mCanvasRenderer->selectLayer(0);
const Color4 Red(1, 0, 0, 0);
mCanvasRenderer->setColor(Red);
Expand Down Expand Up @@ -109,6 +110,8 @@ class Demo2DApp : public App::AppBase {

mCanvasRenderer->drawRect(100, 1000, 110, 124, true);

mCanvasRenderer->drawText(300, 100, "Test");

kimkulling marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Editor/src/Gui/UIElementsWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ bool UIElementsWin32::init() {

// needed for the RichEdit control in the about/help dialog
lib = LoadLibrary("riched20.dll");
osre_assert(lib != nullptr);
if (lib == nullptr) {
osre_assert(lib != nullptr);
return false;
}
Comment on lines +43 to +46
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance error handling with detailed failure information.

While the added error handling is an improvement, consider enhancing it with more detailed error reporting:

     lib = LoadLibrary("riched20.dll");
     if (lib == nullptr) {
+        DWORD error = GetLastError();
+        osre_error("Failed to load riched20.dll: error code %lu", error);
         osre_assert(lib != nullptr);
         return false;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (lib == nullptr) {
osre_assert(lib != nullptr);
return false;
}
if (lib == nullptr) {
DWORD error = GetLastError();
osre_error("Failed to load riched20.dll: error code %lu", error);
osre_assert(lib != nullptr);
return false;
}


// load windows common controls library to get XP style
InitCommonControls();
Expand Down
7 changes: 4 additions & 3 deletions src/Editor/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ int main(int argc, char *argv[]) {
std::cout << "Editor version 0.1\n";

OsreEdApp osreApp(argc, argv);
if (!osreApp.initWindow(100, 100, 1024, 768, "OSRE-Ed",
WindowMode::Windowed,
WindowType::Child,
if (!osreApp.initWindow(100, 100, 1024, 768, "OSRE-Ed",
WindowMode::Windowed,
WindowType::Child,
RenderBackendType::OpenGLRenderBackend)) {
osre_error(Tag, "Cannot open the window.");
return AppError;
}

Expand Down
7 changes: 4 additions & 3 deletions src/Engine/Animation/AnimatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ using VectorChannelArray = ::cppcore::TArray<VectorChannel>;
template <class T>
struct AnimatorBase {
void operator () ( T &out, const T &a, const T &b, f32 d ) const {
out = a + ( b - a ) * d;
out = a + (b - a) * d;
}
};

/// @brief
enum class TransformCommandType {
Invalid = -1,
RotateXCommandPositive = 0,
Expand Down Expand Up @@ -166,5 +167,5 @@ class OSRE_EXPORT AnimationControllerBase {
AnimationControllerBase() = default;
};

}
}
} // namespace Animation
} // namespace OSRE
33 changes: 31 additions & 2 deletions src/Engine/App/AppBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "RenderBackend/Pipeline.h"
#include "RenderBackend/RenderBackendService.h"
#include "RenderBackend/TransformMatrixBlock.h"
#include "RenderBackend/2D/CanvasRenderer.h"
#include "App/CameraComponent.h"
#include "RenderBackend/MaterialBuilder.h"

Expand Down Expand Up @@ -83,6 +84,7 @@ AppBase::AppBase(i32 argc, const c8 *argv[], const String &supportedArgs, const
mMouseEvListener(nullptr),
mKeyboardEvListener(nullptr),
mIds(nullptr),
mCanvasRenderer(nullptr) {
mStageMode(StageMode::Stage3D),
mShutdownRequested(false) {
mSettings->setString(Properties::Settings::RenderAPI, "opengl");
Expand Down Expand Up @@ -133,7 +135,7 @@ void AppBase::update() {
if (mAppState == State::Created) {
mAppState = State::Running;
}

onUpdate();
}

Expand Down Expand Up @@ -240,6 +242,21 @@ void AppBase::setWindowsTitle(const String &title) {
}
}

RenderBackend::CanvasRenderer* AppBase::getCanvasRenderer() const {
return (CanvasRenderer*) mCanvasRenderer;
}
Comment on lines +242 to +244
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use static_cast instead of C-style cast.

For better type safety in modern C++, prefer static_cast over C-style cast when performing pointer type conversions.

-    return (CanvasRenderer*) mCanvasRenderer;
+    return static_cast<CanvasRenderer*>(mCanvasRenderer);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RenderBackend::CanvasRenderer* AppBase::getCanvasRenderer() const {
return (CanvasRenderer*) mCanvasRenderer;
}
RenderBackend::CanvasRenderer* AppBase::getCanvasRenderer() const {
return static_cast<CanvasRenderer*>(mCanvasRenderer);
}


static void attachMouseEventPtrs(EventPtrArray &eventArray) {
eventArray.add(&MouseButtonDownEvent);
eventArray.add(&MouseButtonUpEvent);
eventArray.add(&MouseMoveEvent);
}

static void attachKeyboardEventPtrs(EventPtrArray &eventArray) {
eventArray.add(&KeyboardButtonDownEvent);
eventArray.add(&KeyboardButtonUpEvent);
}

bool AppBase::onCreate() {
if (mAppState != State::Uninited) {
osre_debug(Tag, "AppBase::State not in expected state: Uninited.");
Expand Down Expand Up @@ -295,7 +312,7 @@ bool AppBase::onCreate() {

// enable render-back-end
RenderBackend::CreateRendererEventData *data = new CreateRendererEventData(mPlatformInterface->getRootWindow());
data->m_pipeline = mRbService->createDefault3DPipeline();
data->Pipeline = mRbService->createDefault3DPipeline();
mRbService->sendEvent(&RenderBackend::OnCreateRendererEvent, data);

mTimer = Platform::PlatformInterface::getInstance()->getTimer();
Expand Down Expand Up @@ -323,6 +340,14 @@ bool AppBase::onCreate() {

App::AssetRegistry::registerAssetPathInBinFolder("assets", "assets");

Rect2ui rect;
mPlatformInterface->getRootWindow()->getWindowsRect(rect);
mCanvasRenderer = new CanvasRenderer(2, (i32)rect.getX1(), (i32)rect.getY1(), (i32)rect.getWidth(), (i32)rect.getHeight());

Check warning

Code scanning / CodeQL

Resource not released in destructor Warning

Resource mCanvasRenderer is acquired by class AppBase but not released in the destructor. It is released from onDestroy on line 353, so this function may need to be called from the destructor.
if (!mCanvasRenderer->create()) {
osre_error(Tag, "Error while creating the canvas renderer.");
return false;
}

mAppState = State::Created;
osre_debug(Tag, "Set application state to Created.");

Expand Down Expand Up @@ -361,6 +386,9 @@ bool AppBase::onDestroy() {
delete mIds;
mIds = nullptr;

delete mCanvasRenderer;
mCanvasRenderer = nullptr;

Comment on lines +375 to +377
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add null check and proper cleanup call before deletion.

For safer cleanup, add a null check and call the destroy method before deletion.

-    delete mCanvasRenderer;
-    mCanvasRenderer = nullptr;
+    if (mCanvasRenderer != nullptr) {
+        mCanvasRenderer->destroy();
+        delete mCanvasRenderer;
+        mCanvasRenderer = nullptr;
+    }

Committable suggestion was skipped due to low confidence.

delete mMouseEvListener;
mMouseEvListener = nullptr;

Expand Down Expand Up @@ -412,3 +440,4 @@ void AppBase::getResolution(ui32 &width, ui32 &height) {

} // Namespace App
} // Namespace OSRE

24 changes: 20 additions & 4 deletions src/Engine/App/AppBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ namespace Properties {

namespace RenderBackend {
struct TransformMatrixBlock;
struct IRenderPath;

class CanvasRenderer;
}

namespace App {
Expand All @@ -62,20 +65,23 @@ class AppBase;
//-------------------------------------------------------------------------------------------------
/// @ingroup Engine
///
/// @brief
/// @brief This class implements the keyboard event listener.
//-------------------------------------------------------------------------------------------------
class OSRE_EXPORT KeyboardEventListener : public Platform::OSEventListener {
public:
/// @brief The class constructor.
KeyboardEventListener() :
OSEventListener("App/KeyboardEventListener"),
mLast(Platform::KEY_UNKNOWN) {
clearKeyMap();
}

~KeyboardEventListener() override {
// empty
}
/// @brief The class destructor.
~KeyboardEventListener() override = default;

/// @brief The event handler.
/// @param osEvent The os-specific event.
/// @param data The event-related data.
void onOSEvent(const Common::Event &osEvent, const Common::EventData *data) override {
auto keyData = (Platform::KeyboardButtonEventData *)data;
if (osEvent == Platform::KeyboardButtonDownEvent) {
Expand All @@ -87,14 +93,20 @@ class OSRE_EXPORT KeyboardEventListener : public Platform::OSEventListener {
}
}

/// @brief Returns true, when the key is pressed
/// @param key The key to look for
/// @return true for is pressed.
bool isKeyPressed(Platform::Key key) const {
return mKeymap[key] == 1;
}
Comment on lines 99 to 101
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add bounds checking to prevent buffer overflow.

The direct array access in isKeyPressed could lead to buffer overflow if an invalid key is provided.

Add bounds checking:

 bool isKeyPressed(Platform::Key key) const {
+    if (static_cast<size_t>(key) >= Platform::KEY_LAST) {
+        return false;
+    }
     return mKeymap[key] == 1;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bool isKeyPressed(Platform::Key key) const {
return mKeymap[key] == 1;
}
bool isKeyPressed(Platform::Key key) const {
if (static_cast<size_t>(key) >= Platform::KEY_LAST) {
return false;
}
return mKeymap[key] == 1;
}


/// @brief Will return the latest pressed key.
/// @return The latest pressed key.
Platform::Key getLastKey() const {
return mLast;
}
Comment on lines +103 to 107
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add bounds checking for getLastKey method.

The getLastKey method should validate that mLast is within valid bounds before returning it.

 Platform::Key getLastKey() const {
+    if (mLast >= Platform::KEY_LAST) {
+        return Platform::KEY_UNKNOWN;
+    }
     return mLast; 
 }

Committable suggestion was skipped due to low confidence.


/// @brief Clearn the map.
void clearKeyMap() {
::memset(mKeymap, 0, sizeof(char) * Platform::KEY_LAST);
}
Comment on lines +96 to 112
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance type safety in keyboard state management.

Consider these improvements for better type safety and maintainability:

  1. Use std::array<bool, Platform::KEY_LAST> instead of raw array
  2. Use std::fill instead of memset
  3. Add explicit initialization in the constructor
 class OSRE_EXPORT KeyboardEventListener : public Platform::OSEventListener {
 private:
     Platform::Key mLast;
-    char mKeymap[Platform::KEY_LAST];
+    std::array<bool, Platform::KEY_LAST> mKeymap;
 public:
     KeyboardEventListener() :
             OSEventListener("App/KeyboardEventListener"),
-            mLast(Platform::KEY_UNKNOWN) {
-        clearKeyMap();
+            mLast(Platform::KEY_UNKNOWN),
+            mKeymap{} {
     }

     void clearKeyMap() {
-        ::memset(mKeymap, 0, sizeof(char) * Platform::KEY_LAST);
+        mKeymap.fill(false);
     }

     bool isKeyPressed(Platform::Key key) const {
         return mKeymap[key];
     }

Committable suggestion skipped: line range outside the PR's diff.

Expand Down Expand Up @@ -250,6 +262,9 @@ class OSRE_EXPORT AppBase {
/// @return The keyboard listener.
virtual KeyboardEventListener *getKeyboardEventListener() const;

/// @brief
virtual RenderBackend::CanvasRenderer *getCanvasRenderer() const;

Comment on lines +266 to +267
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Resolve type mismatch between member variable and getter return type.

There's a type mismatch:

  • getCanvasRenderer() returns RenderBackend::CanvasRenderer*
  • mCanvasRenderer is of type RenderBackend::IRenderPath*

This could lead to type conversion issues or undefined behavior if not handled correctly.

Either:

  1. Change the member variable type to match the getter:
-    RenderBackend::IRenderPath *mCanvasRenderer;
+    RenderBackend::CanvasRenderer *mCanvasRenderer;
  1. Or change the getter return type to match the member variable:
-    virtual RenderBackend::CanvasRenderer *getCanvasRenderer() const;
+    virtual RenderBackend::IRenderPath *getCanvasRenderer() const;

Please clarify the intended type relationship between these components.

Also applies to: 305-305

protected:
/// @brief The onCreate callback, override this for your own creation stuff.
/// @return true if successful, false if not.
Expand Down Expand Up @@ -292,6 +307,7 @@ class OSRE_EXPORT AppBase {
Common::Ids *mIds;
StageMode mStageMode;
bool mShutdownRequested;
RenderBackend::IRenderPath *mCanvasRenderer;
};

inline Stage *AppBase::getStage() const {
Expand Down
12 changes: 7 additions & 5 deletions src/Engine/App/AppCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,22 @@ template<class T> class TAbstractCtrlBase;

/// @brief Describes the requested render API for the backend.
enum class RenderBackendType {
Invalid = -1, ///< Invalid render API.
OpenGLRenderBackend = 0, ///< OpenGL render API.
VulkanRenderBackend ///< Vulkan render API.
VulkanRenderBackend, ///< Vulkan render API.
Count ///< Number of render APIs.
};

struct MouseInputState {
i32 mRelX, mRelY, mAbsX, mAbsY;
ui32 mLastX, mLastY;
cppcore::TBitField<ui32> mMouseButtonState;
i32 RelX, RelY, AbsX, AbsY;
ui32 LastX, LastY;
cppcore::TBitField<ui32> MouseButtonState;

MouseInputState();
};

inline MouseInputState::MouseInputState() :
mRelX(0), mRelY(0), mAbsX(0), mAbsY(0), mLastX(0), mLastY(0), mMouseButtonState() {
RelX(0), RelY(0), AbsX(0), AbsY(0), LastX(0), LastY(0), MouseButtonState() {
// empty
}

Expand Down
5 changes: 3 additions & 2 deletions src/Engine/App/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ bool RenderComponent::onRender(RenderBackendService *renderBackendSrv) {
return true;
}

LightComponent::LightComponent(Entity *owner)
: Component(owner, ComponentType::LightComponentType), mLight(nullptr) {}
LightComponent::LightComponent(Entity *owner) : Component(owner, ComponentType::LightComponentType), mLight(nullptr) {
// empty
}

void LightComponent::setLight(RenderBackend::Light *light) {
mLight = light;
Expand Down
44 changes: 23 additions & 21 deletions src/Engine/App/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum class ComponentType {
TransformComponentType, ///< For all transformation types.
LightComponentType, ///< For light types.
CameraComponentType, ///< For camera components.
AnimationComponentType, ///<
AnimationComponentType, ///< For animation support.
Count ///< The number of components.
};

Expand Down Expand Up @@ -127,33 +127,35 @@ class OSRE_EXPORT RenderComponent : public Component {
/// @brief The class constructor.
/// @param owner The owning entity.
RenderComponent(Entity *owner);

/// @brief The class destructor.
~RenderComponent() override = default;

/// @brief Returns the number of meshes
/// @return The number of stored meshes.
size_t getNumMeshes() const;

/// @brief Returns the mesh at a given index.
/// @param[in] idx The requested index.
/// @return The mesh os a nullptr if the index in invalid.
RenderBackend::Mesh *getMeshAt(size_t idx) const;

/// @brief Returns the mesh array.
/// @param[inout] array
/// @param[inout] array The mesh array managed by the component.
void getMeshArray(RenderBackend::MeshArray &array);
/// @brief
/// @param geo
void addStaticMesh(RenderBackend::Mesh *geo);
/// @brief
/// @param array

/// @brief Will add a new mesh.
/// @param mesh Thew mesh to add.
void addStaticMesh(RenderBackend::Mesh *mesh);

/// @brief Will add an array of new meshes.
/// @param array The array with enw meshes.
void addStaticMeshArray(const RenderBackend::MeshArray &array);

protected:
/// The update callback.
bool onUpdate(Time dt) override;
/// The render callback.
bool onRender(RenderBackend::RenderBackendService *rbSrv) override;

private:
Expand All @@ -163,19 +165,19 @@ class OSRE_EXPORT RenderComponent : public Component {
//-------------------------------------------------------------------------------------------------
/// @ingroup Engine
///
/// @brief
/// @brief This component class implements a light.
//-------------------------------------------------------------------------------------------------
class LightComponent final : public Component {
public:
/// @brief
/// @param owner
/// @brief The class constructor.
/// @param owner The owning entity.
LightComponent(Entity *owner);
/// @brief

/// @brief The class destructor.
~LightComponent() override = default;
/// @brief
/// @param light

/// @brief Will set a new light instance.
/// @param light Thew new light.
void setLight(RenderBackend::Light *light);

protected:
Expand Down
Loading
Loading