Skip to content

Commit f28664a

Browse files
committed
Fix: improve usage of renderer
remove hardcoded things like clearcolor, vertices, etc ...
1 parent 1ebe5db commit f28664a

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

modules/Interfaces/include/Interfaces/Renderer/IRenderer.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
namespace cae
1212
{
1313

14+
struct Color
15+
{
16+
float r;
17+
float g;
18+
float b;
19+
float a;
20+
};
21+
1422
///
1523
/// @interface IRenderer
1624
/// @brief Interface for renderer
@@ -22,12 +30,14 @@ namespace cae
2230
public:
2331
~IRenderer() override = default;
2432

25-
virtual void initialize(const NativeWindowHandle &nativeWindowHandle) = 0;
33+
virtual void initialize(const NativeWindowHandle &nativeWindowHandle, const Color& clearColor = { 1.F, 1.F, 1.F, 1.F}) = 0;
2634
virtual void draw(const WindowSize &windowSize) = 0;
2735

2836
virtual void setVSyncEnabled(bool enabled) = 0;
2937
virtual bool isVSyncEnabled() const = 0;
3038

39+
virtual void setClearColor(const Color& color) = 0;
40+
3141
}; // interface IRenderer
3242

3343
} // namespace cae

plugins/Renderer/OpenGL/include/OPGL/OPGL.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ namespace cae
3434
[[nodiscard]] utl::PluginType getType() const override { return utl::PluginType::RENDERER; }
3535
[[nodiscard]] utl::PluginPlatform getPlatform() const override { return utl::PluginPlatform::ALL; }
3636

37-
void initialize(const NativeWindowHandle &window) override;
37+
void initialize(const NativeWindowHandle &window, const Color& clearColor) override;
3838
void draw(const WindowSize &windowSize) override;
3939

4040
void setVSyncEnabled(bool enabled) override;
4141
[[nodiscard]] bool isVSyncEnabled() const override;
4242

43+
void setClearColor(const Color& color) override { glClearColor(color.r, color.g, color.b, color.a); }
44+
4345
private:
4446
std::unique_ptr<IContext> m_context;
4547

plugins/Renderer/OpenGL/src/opgl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "OPGL/Context/NSGLContextMac.hpp"
1313
#endif
1414

15-
void cae::OPGL::initialize(const NativeWindowHandle &window)
15+
void cae::OPGL::initialize(const NativeWindowHandle &window, const Color& clearColor)
1616
{
1717
#ifdef __linux__
1818
m_context = std::make_unique<EGLContextLinux>();
@@ -26,7 +26,7 @@ void cae::OPGL::initialize(const NativeWindowHandle &window)
2626
m_context->initialize(window);
2727

2828
glEnable(GL_DEPTH_TEST);
29-
glClearColor(1.F, 1.F, 1.F, 1.F);
29+
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
3030

3131
createShaderProgram();
3232
createTriangle();

plugins/Renderer/Vulkan/include/VULKN/VULKN.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ namespace cae
3232
[[nodiscard]] utl::PluginType getType() const override { return utl::PluginType::RENDERER; }
3333
[[nodiscard]] utl::PluginPlatform getPlatform() const override { return utl::PluginPlatform::ALL; }
3434

35-
void initialize(const NativeWindowHandle &nativeWindowHandle) override {}
36-
void draw(const WindowSize &windowSize) override {};
35+
void initialize(const NativeWindowHandle &nativeWindowHandle, const Color& clearColor) override {}
36+
void draw(const WindowSize &windowSize) override {}
3737

3838
void setVSyncEnabled(bool enabled) override {}
3939
[[nodiscard]] bool isVSyncEnabled() const override { return false; }
40+
41+
void setClearColor(const Color& color) override {}
42+
4043
}; // class VULKN
4144

4245
} // namespace cae

0 commit comments

Comments
 (0)