diff --git a/examples/DeferredShading/main.cpp b/examples/DeferredShading/main.cpp index 5dd4be0f6..0adaff290 100644 --- a/examples/DeferredShading/main.cpp +++ b/examples/DeferredShading/main.cpp @@ -46,7 +46,7 @@ struct SpotLight struct PointLight { - Nz::Color color = Nz::Color::White; + Nz::Color color = Nz::Color::White(); Nz::Vector3f position = Nz::Vector3f::Zero(); float radius = 1.f; @@ -54,7 +54,7 @@ struct PointLight struct SpotLight { - Nz::Color color = Nz::Color::White; + Nz::Color color = Nz::Color::White(); Nz::Matrix4f transformMatrix; Nz::Vector3f position = Nz::Vector3f::Zero(); Nz::Vector3f direction = Nz::Vector3f::Forward(); @@ -769,13 +769,13 @@ int main() Nz::FramePass& gbufferPass = graph.AddPass("GBuffer"); std::size_t geometryAlbedo = gbufferPass.AddOutput(colorTexture); - gbufferPass.SetClearColor(geometryAlbedo, Nz::Color::Black); + gbufferPass.SetClearColor(geometryAlbedo, Nz::Color::Black()); std::size_t geometryNormal = gbufferPass.AddOutput(normalTexture); - gbufferPass.SetClearColor(geometryNormal, Nz::Color::Black); + gbufferPass.SetClearColor(geometryNormal, Nz::Color::Black()); std::size_t positionAttachment = gbufferPass.AddOutput(positionTexture); - gbufferPass.SetClearColor(positionAttachment, Nz::Color::Black); + gbufferPass.SetClearColor(positionAttachment, Nz::Color::Black()); gbufferPass.SetDepthStencilClear(1.f, 0); @@ -849,7 +849,7 @@ int main() lightingPass.AddInput(normalTexture); lightingPass.AddInput(positionTexture); - lightingPass.SetClearColor(lightingPass.AddOutput(lightOutput), Nz::Color::Black); + lightingPass.SetClearColor(lightingPass.AddOutput(lightOutput), Nz::Color::Black()); lightingPass.SetDepthStencilInput(depthBuffer1); Nz::FramePass& forwardPass = graph.AddPass("Forward pass"); @@ -921,7 +921,7 @@ int main() }); occluderPass.AddOutput(occluderTexture); - occluderPass.SetClearColor(0, Nz::Color::Black); + occluderPass.SetClearColor(0, Nz::Color::Black()); occluderPass.SetDepthStencilInput(depthBuffer1); Nz::FramePass& godraysPass = graph.AddPass("Light scattering pass"); @@ -1457,7 +1457,7 @@ int main() frame.Execute([&](Nz::CommandBufferBuilder& builder) { - builder.BeginDebugRegion("UBO Update", Nz::Color::Yellow); + builder.BeginDebugRegion("UBO Update", Nz::Color::Yellow()); { builder.PreTransferBarrier(); @@ -1542,7 +1542,7 @@ int main() builder.BeginRenderPass(windowRT->GetFramebuffer(frame.GetFramebufferIndex()), windowRT->GetRenderPass(), windowRenderRect); { - builder.BeginDebugRegion("Main window rendering", Nz::Color::Green); + builder.BeginDebugRegion("Main window rendering", Nz::Color::Green()); { builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); diff --git a/examples/Physics2DDemo/main.cpp b/examples/Physics2DDemo/main.cpp index 4c44cfcc0..6b278693c 100644 --- a/examples/Physics2DDemo/main.cpp +++ b/examples/Physics2DDemo/main.cpp @@ -107,7 +107,7 @@ int main() { for (unsigned int x = 0; x < 40; ++x) { - tilemap->EnableTile({ x, y }, Nz::Rectf{ 0.f, 0.f, 1.f, 1.f }, Nz::Color::White, (y == 0) ? 1 : 4); + tilemap->EnableTile({ x, y }, Nz::Rectf{ 0.f, 0.f, 1.f, 1.f }, Nz::Color::White(), (y == 0) ? 1 : 4); } } diff --git a/examples/PhysicsDemo/main.cpp b/examples/PhysicsDemo/main.cpp index 3b7cfdaf4..f2a167180 100644 --- a/examples/PhysicsDemo/main.cpp +++ b/examples/PhysicsDemo/main.cpp @@ -116,7 +116,7 @@ int main() auto shipCollider = std::make_shared(vertices, vertexMapper.GetVertexCount(), 0.01f); std::shared_ptr colliderMat = Nz::Graphics::Instance()->GetDefaultMaterials().basicMaterial->Instantiate(); - colliderMat->SetValueProperty("BaseColor", Nz::Color::Green); + colliderMat->SetValueProperty("BaseColor", Nz::Color::Green()); for (std::string_view passName : { "DepthPass", "ForwardPass" }) { colliderMat->UpdatePassStates(passName, [](Nz::RenderStates& states) diff --git a/examples/Showcase/main.cpp b/examples/Showcase/main.cpp index 1a577533e..29b15722d 100644 --- a/examples/Showcase/main.cpp +++ b/examples/Showcase/main.cpp @@ -173,7 +173,7 @@ int main() auto& cameraLight = registry.emplace(lightEntity1); auto& spotLight = cameraLight.AddLight(0xFFFFFFFF); - spotLight.UpdateColor(Nz::Color::Red); + spotLight.UpdateColor(Nz::Color::Red()); spotLight.UpdateInnerAngle(Nz::DegreeAnglef(15.f)); spotLight.UpdateOuterAngle(Nz::DegreeAnglef(20.f)); spotLight.EnableShadowCasting(true); @@ -188,7 +188,7 @@ int main() auto& cameraLight = registry.emplace(lightEntity2); auto& spotLight = cameraLight.AddLight(0xFFFFFFFF); - spotLight.UpdateColor(Nz::Color::Green); + spotLight.UpdateColor(Nz::Color::Green()); spotLight.EnableShadowCasting(true); spotLight.UpdateShadowMapSize(1024); } @@ -258,7 +258,7 @@ int main() auto& cameraLight = registry.emplace(lightEntity3); auto& pointLight = cameraLight.AddLight(0xFFFFFFFF); - pointLight.UpdateColor(Nz::Color::Blue); + pointLight.UpdateColor(Nz::Color::Blue()); pointLight.UpdateRadius(3.f); pointLight.EnableShadowCasting(true); pointLight.UpdateShadowMapSize(2048); @@ -521,13 +521,13 @@ int main() Nz::DebugDrawer& debugDrawer = renderSystem.GetFramePipeline().GetDebugDrawer(); auto& lightNode = registry.get(lightEntity3); - //debugDrawer.DrawLine(lightNode.GetPosition(Nz::CoordSys::Global), lightNode.GetForward() * 10.f, Nz::Color::Blue); + //debugDrawer.DrawLine(lightNode.GetPosition(Nz::CoordSys::Global), lightNode.GetForward() * 10.f, Nz::Color::Blue()); Nz::Vector3f pos = lightNode.GetPosition(Nz::CoordSys::Global); - debugDrawer.DrawBox(Nz::Boxf(pos.x - 0.05f, pos.y - 0.05f, pos.z - 0.05f, 0.1f, 0.1f, 0.1f), Nz::Color::Blue); + debugDrawer.DrawBox(Nz::Boxf(pos.x - 0.05f, pos.y - 0.05f, pos.z - 0.05f, 0.1f, 0.1f, 0.1f), Nz::Color::Blue()); /*debugDrawer.DrawBox(floorBox, Nz::Color::Red); Nz::Boxf intersection; if (floorBox.Intersect(test, &intersection)) - debugDrawer.DrawBox(intersection, Nz::Color::Green);*/ + debugDrawer.DrawBox(intersection, Nz::Color::Green());*/ systemGraph.Update(); diff --git a/examples/WidgetDemo/main.cpp b/examples/WidgetDemo/main.cpp index 771096a12..bfe8b9b3c 100644 --- a/examples/WidgetDemo/main.cpp +++ b/examples/WidgetDemo/main.cpp @@ -90,8 +90,8 @@ int main() textAreaWidget->SetPosition(800.f, 500.f); textAreaWidget->SetText("Je suis un TextAreaWidget !"); textAreaWidget->Resize(Nz::Vector2f(400.f, textAreaWidget->GetPreferredHeight() * 5.f)); - textAreaWidget->SetBackgroundColor(Nz::Color::White); - textAreaWidget->SetTextColor(Nz::Color::Black); + textAreaWidget->SetBackgroundColor(Nz::Color::White()); + textAreaWidget->SetTextColor(Nz::Color::Black()); textAreaWidget->EnableMultiline(true); Nz::CheckboxWidget* checkboxWidget = canvas2D.Add(); @@ -103,8 +103,8 @@ int main() Nz::TextAreaWidget* longTextArea = canvas2D.Add(); longTextArea->EnableLineWrap(true); longTextArea->EnableMultiline(true); - longTextArea->SetBackgroundColor(Nz::Color::White); - longTextArea->SetTextColor(Nz::Color::Black); + longTextArea->SetBackgroundColor(Nz::Color::White()); + longTextArea->SetTextColor(Nz::Color::Black()); longTextArea->SetText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"); Nz::ScrollAreaWidget* scrollBarWidget = canvas2D.Add(longTextArea); @@ -115,8 +115,8 @@ int main() textAreaWidget2->SetPosition(800.f, 700.f); textAreaWidget2->SetText("Je suis un autre TextAreaWidget !"); textAreaWidget2->Resize(Nz::Vector2f(500.f, textAreaWidget2->GetPreferredHeight())); - textAreaWidget2->SetBackgroundColor(Nz::Color::White); - textAreaWidget2->SetTextColor(Nz::Color::Black);*/ + textAreaWidget2->SetBackgroundColor(Nz::Color::White()); + textAreaWidget2->SetTextColor(Nz::Color::Black());*/ entt::entity viewer2D = registry.create(); { diff --git a/include/Nazara/Core/Color.hpp b/include/Nazara/Core/Color.hpp index 2cc9fa282..2af75a687 100644 --- a/include/Nazara/Core/Color.hpp +++ b/include/Nazara/Core/Color.hpp @@ -18,68 +18,68 @@ namespace Nz class Color { public: - inline Color(); - inline Color(float red, float green, float blue, float alpha = 1.f); - inline explicit Color(float lightness); - inline Color(const Color& color) = default; - inline Color(Color&& color) = default; - inline ~Color() = default; + Color() = default; + constexpr Color(float red, float green, float blue, float alpha = 1.f); + constexpr explicit Color(float lightness); + constexpr Color(const Color&) = default; + constexpr Color(Color&&) = default; + ~Color() = default; - inline bool IsOpaque() const; + constexpr bool IsOpaque() const; inline std::string ToString() const; - inline Color operator+(const Color& angles) const; - inline Color operator*(const Color& angles) const; + constexpr Color operator+(const Color& color) const; + constexpr Color operator*(const Color& color) const; - inline Color& operator=(const Color& other) = default; - inline Color& operator=(Color&& other) = default; + constexpr Color& operator=(const Color&) = default; + constexpr Color& operator=(Color&&) = default; - inline Color operator+=(const Color& angles); - inline Color operator*=(const Color& angles); + constexpr Color operator+=(const Color& color); + constexpr Color operator*=(const Color& color); - inline bool operator==(const Color& angles) const; - inline bool operator!=(const Color& angles) const; + constexpr bool operator==(const Color& color) const; + constexpr bool operator!=(const Color& color) const; - static inline Color FromCMY(float cyan, float magenta, float yellow); - static inline Color FromCMYK(float cyan, float magenta, float yellow, float black); - static inline Color FromHSL(float hue, float saturation, float lightness); - static inline Color FromHSV(float hue, float saturation, float value); - static inline Color FromRGB8(UInt8 r, UInt8 g, UInt8 b); - static inline Color FromRGBA8(UInt8 r, UInt8 g, UInt8 b, UInt8 a); - static inline Color FromXYZ(const Vector3f& vec); - static inline Color FromXYZ(float x, float y, float z); - static inline void ToCMY(const Color& color, float* cyan, float* magenta, float* yellow); - static inline void ToCMYK(const Color& color, float* cyan, float* magenta, float* yellow, float* black); - static inline void ToHSL(const Color& color, float* hue, float* saturation, float* lightness); - static inline void ToHSV(const Color& color, float* hue, float* saturation, float* value); - static inline void ToRGB8(const Color& color, UInt8* r, UInt8* g, UInt8* b); - static inline void ToRGBA8(const Color& color, UInt8* r, UInt8* g, UInt8* b, UInt8* a = nullptr); - static inline void ToXYZ(const Color& color, Vector3f* vec); - static inline void ToXYZ(const Color& color, float* x, float* y, float* z); + static constexpr Color FromCMY(float cyan, float magenta, float yellow); + static constexpr Color FromCMYK(float cyan, float magenta, float yellow, float black); + static constexpr Color FromHSL(float hue, float saturation, float lightness); + static constexpr Color FromHSV(float hue, float saturation, float value); + static constexpr Color FromRGB8(UInt8 r, UInt8 g, UInt8 b); + static constexpr Color FromRGBA8(UInt8 r, UInt8 g, UInt8 b, UInt8 a); + static constexpr Color FromXYZ(const Vector3f& vec); + static constexpr Color FromXYZ(float x, float y, float z); + static constexpr void ToCMY(const Color& color, float* cyan, float* magenta, float* yellow); + static constexpr void ToCMYK(const Color& color, float* cyan, float* magenta, float* yellow, float* black); + static constexpr void ToHSL(const Color& color, float* hue, float* saturation, float* lightness); + static constexpr void ToHSV(const Color& color, float* hue, float* saturation, float* value); + static constexpr void ToRGB8(const Color& color, UInt8* r, UInt8* g, UInt8* b); + static constexpr void ToRGBA8(const Color& color, UInt8* r, UInt8* g, UInt8* b, UInt8* a = nullptr); + static constexpr void ToXYZ(const Color& color, Vector3f* vec); + static constexpr void ToXYZ(const Color& color, float* x, float* y, float* z); + + static constexpr Color Black(); + static constexpr Color Blue(); + static constexpr Color Cyan(); + static constexpr Color Gray(); + static constexpr Color Green(); + static constexpr Color Magenta(); + static constexpr Color Orange(); + static constexpr Color Red(); + static constexpr Color Yellow(); + static constexpr Color White(); float r, g, b, a; - static NAZARA_CORE_API const Color Black; - static NAZARA_CORE_API const Color Blue; - static NAZARA_CORE_API const Color Cyan; - static NAZARA_CORE_API const Color Gray; - static NAZARA_CORE_API const Color Green; - static NAZARA_CORE_API const Color Magenta; - static NAZARA_CORE_API const Color Orange; - static NAZARA_CORE_API const Color Red; - static NAZARA_CORE_API const Color Yellow; - static NAZARA_CORE_API const Color White; - private: - static float Hue2RGB(float v1, float v2, float vH); + static constexpr float Hue2RGB(float v1, float v2, float vH); }; inline bool Serialize(SerializationContext& context, const Color& color, TypeTag); inline bool Unserialize(SerializationContext& context, Color* color, TypeTag); -} -std::ostream& operator<<(std::ostream& out, const Nz::Color& color); + std::ostream& operator<<(std::ostream& out, const Color& color); +} #include diff --git a/include/Nazara/Core/Color.inl b/include/Nazara/Core/Color.inl index df49f8665..0c07d833d 100644 --- a/include/Nazara/Core/Color.inl +++ b/include/Nazara/Core/Color.inl @@ -16,13 +16,6 @@ namespace Nz * \brief Core class that represents a color */ - /*! - * \brief Constructs a Color object by default - */ - inline Color::Color() - { - } - /*! * \brief Constructs a Color object with values * @@ -31,8 +24,7 @@ namespace Nz * \param blue Blue value * \param alpha Alpha value */ - - inline Color::Color(float red, float green, float blue, float alpha) : + constexpr Color::Color(float red, float green, float blue, float alpha) : r(red), g(green), b(blue), @@ -45,8 +37,7 @@ namespace Nz * * \param lightness Value for r, g and b */ - - inline Color::Color(float lightness) : + constexpr Color::Color(float lightness) : r(lightness), g(lightness), b(lightness), @@ -58,7 +49,7 @@ namespace Nz * \brief Return true is the color has no degree of transparency * \return true if the color has an alpha value of 255 */ - inline bool Color::IsOpaque() const + constexpr bool Color::IsOpaque() const { return a >= 1.f; } @@ -87,16 +78,9 @@ namespace Nz * * \param color Other color */ - - inline Color Color::operator+(const Color& color) const + constexpr Color Color::operator+(const Color& color) const { - Color c; - c.r = r + color.r; - c.g = g + color.g; - c.b = b + color.b; - c.a = a + color.a; - - return c; + return Color(r + color.r, g + color.g, b + color.b, a + color.a); } /*! @@ -105,16 +89,9 @@ namespace Nz * * \param color Other color */ - - inline Color Color::operator*(const Color& color) const + constexpr Color Color::operator*(const Color& color) const { - Color c; - c.r = r * color.r; - c.g = g * color.g; - c.b = b * color.b; - c.a = a * color.a; - - return c; + return Color(r * color.r, g * color.g, b * color.b, a * color.a); } /*! @@ -123,8 +100,7 @@ namespace Nz * * \param color Other color */ - - inline Color Color::operator+=(const Color& color) + constexpr Color Color::operator+=(const Color& color) { return operator=(operator+(color)); } @@ -135,8 +111,7 @@ namespace Nz * * \param color Other color */ - - inline Color Color::operator*=(const Color& color) + constexpr Color Color::operator*=(const Color& color) { return operator=(operator*(color)); } @@ -147,8 +122,7 @@ namespace Nz * * \param color Color to compare */ - - inline bool Color::operator==(const Color& color) const + constexpr bool Color::operator==(const Color& color) const { return NumberEquals(r, color.r) && NumberEquals(g, color.g) && @@ -162,8 +136,7 @@ namespace Nz * * \param color Color to compare */ - - inline bool Color::operator!=(const Color& color) const + constexpr bool Color::operator!=(const Color& color) const { return !operator==(color); } @@ -178,7 +151,7 @@ namespace Nz * \param magenta Magenta component * \param yellow Yellow component */ - inline Color Color::FromCMY(float cyan, float magenta, float yellow) + constexpr Color Color::FromCMY(float cyan, float magenta, float yellow) { return Color(1.f - cyan, 1.f - magenta, 1.f - yellow); } @@ -192,7 +165,7 @@ namespace Nz * \param yellow Yellow component * \param black Black component */ - inline Color Color::FromCMYK(float cyan, float magenta, float yellow, float black) + constexpr Color Color::FromCMYK(float cyan, float magenta, float yellow, float black) { return FromCMY(cyan * (1.f - black) + black, magenta * (1.f - black) + black, @@ -207,13 +180,13 @@ namespace Nz * \param saturation Saturation component [0, 1] * \param lightness Lightness component [0, 1] */ - inline Color Color::FromHSL(float hue, float saturation, float lightness) + constexpr Color Color::FromHSL(float hue, float saturation, float lightness) { if (NumberEquals(saturation, 0.f)) return Color(lightness); else { - float v2; + float v2 = 0.f; if (lightness < 0.5f) v2 = lightness * (1.f + saturation); else @@ -236,7 +209,7 @@ namespace Nz * \param saturation Saturation component in [0, 1] * \param value Value component in [0, 1] */ - inline Color Color::FromHSV(float hue, float saturation, float value) + constexpr Color Color::FromHSV(float hue, float saturation, float value) { if (NumberEquals(saturation, 0.f)) return Color(value); @@ -252,7 +225,9 @@ namespace Nz float v2 = value * (1.f - saturation * (h - i)); float v3 = value * (1.f - saturation * (1.f - (h - i))); - float r, g, b; + float r = 0.f; + float g = 0.f; + float b = 0.f; switch (i) { case 0: @@ -304,7 +279,7 @@ namespace Nz * \param g Green value * \param b Blue value */ - inline Color Color::FromRGB8(UInt8 r, UInt8 g, UInt8 b) + constexpr Color Color::FromRGB8(UInt8 r, UInt8 g, UInt8 b) { return Color(r / 255.f, g / 255.f, b / 255.f); } @@ -318,7 +293,7 @@ namespace Nz * \param b Blue value * \param a Alpha value */ - inline Color Color::FromRGBA8(UInt8 r, UInt8 g, UInt8 b, UInt8 a) + constexpr Color Color::FromRGBA8(UInt8 r, UInt8 g, UInt8 b, UInt8 a) { return Color(r / 255.f, g / 255.f, b / 255.f, a / 255.f); } @@ -329,7 +304,7 @@ namespace Nz * * \param vec Vector3 representing the space color */ - inline Color Color::FromXYZ(const Vector3f& vec) + constexpr Color Color::FromXYZ(const Vector3f& vec) { return FromXYZ(vec.x, vec.y, vec.z); } @@ -342,7 +317,7 @@ namespace Nz * \param y Y component * \param z Z component */ - inline Color Color::FromXYZ(float x, float y, float z) + constexpr Color Color::FromXYZ(float x, float y, float z) { x /= 100.f; // X from 0 to 95.047 y /= 100.f; // Y from 0 to 100.000 @@ -378,7 +353,7 @@ namespace Nz * \param magenta Magenta component * \param yellow Yellow component */ - inline void Color::ToCMY(const Color& color, float* cyan, float* magenta, float* yellow) + constexpr void Color::ToCMY(const Color& color, float* cyan, float* magenta, float* yellow) { *cyan = 1.f - color.r; *magenta = 1.f - color.g; @@ -393,10 +368,11 @@ namespace Nz * \param magenta Magenta component * \param yellow Yellow component */ - - inline void Color::ToCMYK(const Color& color, float* cyan, float* magenta, float* yellow, float* black) + constexpr void Color::ToCMYK(const Color& color, float* cyan, float* magenta, float* yellow, float* black) { - float c, m, y; + float c = 0.f; + float m = 0.f; + float y = 0.f; ToCMY(color, &c, &m, &y); float k = std::min({1.f, c, m, y}); @@ -426,7 +402,7 @@ namespace Nz * \param saturation Saturation component in [0, 1] * \param lightness Lightness component in [0, 1] */ - inline void Color::ToHSL(const Color& color, float* hue, float* saturation, float* lightness) + constexpr void Color::ToHSL(const Color& color, float* hue, float* saturation, float* lightness) { float r = color.r; float g = color.g; @@ -457,7 +433,7 @@ namespace Nz float deltaG = ((max - g) / 6.f + deltaMax / 2.f) / deltaMax; float deltaB = ((max - b) / 6.f + deltaMax / 2.f) / deltaMax; - float h; + float h = 0.f; if (NumberEquals(r, max)) h = deltaB - deltaG; @@ -483,7 +459,7 @@ namespace Nz * \param saturation Saturation component * \param value Value component */ - inline void Color::ToHSV(const Color& color, float* hue, float* saturation, float* value) + constexpr void Color::ToHSV(const Color& color, float* hue, float* saturation, float* value) { float r = color.r; float g = color.g; @@ -511,7 +487,7 @@ namespace Nz float deltaG = ((max - g) / 6.f + deltaMax / 2.f) / deltaMax; float deltaB = ((max - b) / 6.f + deltaMax / 2.f) / deltaMax; - float h; + float h = 0.f; if (NumberEquals(r, max)) h = deltaB - deltaG; @@ -539,7 +515,7 @@ namespace Nz * * \remark Values are clamped to [0;255] */ - static inline void ToRGB8(const Color& color, UInt8* r, UInt8* g, UInt8* b) + constexpr void Color::ToRGB8(const Color& color, UInt8* r, UInt8* g, UInt8* b) { *r = static_cast(Clamp(color.r * 255.f, 0.f, 255.f)); *g = static_cast(Clamp(color.g * 255.f, 0.f, 255.f)); @@ -557,7 +533,7 @@ namespace Nz * * \remark Values are clamped to [0;255] */ - static inline void ToRGBA8(const Color& color, UInt8* r, UInt8* g, UInt8* b, UInt8* a) + constexpr void Color::ToRGBA8(const Color& color, UInt8* r, UInt8* g, UInt8* b, UInt8* a) { *r = static_cast(Clamp(color.r * 255.f, 0.f, 255.f)); *g = static_cast(Clamp(color.g * 255.f, 0.f, 255.f)); @@ -571,7 +547,7 @@ namespace Nz * \param color Color to transform * \param vec Vector3 representing the space color */ - inline void Color::ToXYZ(const Color& color, Vector3f* vec) + constexpr void Color::ToXYZ(const Color& color, Vector3f* vec) { return ToXYZ(color, &vec->x, &vec->y, &vec->z); } @@ -584,7 +560,7 @@ namespace Nz * \param y Y component * \param z Z component */ - inline void Color::ToXYZ(const Color& color, float* x, float* y, float* z) + constexpr void Color::ToXYZ(const Color& color, float* x, float* y, float* z) { float r = color.r; //< R from 0 to 255 float g = color.g; //< G from 0 to 255 @@ -615,6 +591,56 @@ namespace Nz *z = r*0.0193f + g*0.1192f + b*0.9505f; } + constexpr Color Color::Black() + { + return Color(0.f, 0.f, 0.f); + } + + constexpr Color Color::Blue() + { + return Color(0.f, 0.f, 1.f); + } + + constexpr Color Color::Cyan() + { + return Color(0.f, 1.f, 1.f); + } + + constexpr Color Color::Gray() + { + return Color(80.f / 255.f, 80.f / 255.f, 80.f / 255.f); + } + + constexpr Color Color::Green() + { + return Color(0.f, 1.f, 0.f); + } + + constexpr Color Color::Magenta() + { + return Color(1.f, 0.f, 1.f); + } + + constexpr Color Color::Orange() + { + return Color(1.f, 165.f / 255.f, 0.f); + } + + constexpr Color Color::Red() + { + return Color(1.f, 0.f, 0.f); + } + + constexpr Color Color::Yellow() + { + return Color(1.f, 1.f, 0.f); + } + + constexpr Color Color::White() + { + return Color(1.f, 1.f, 1.f); + } + /*! * \brief Converts HUE representation to RGV * \return RGB corresponding @@ -623,7 +649,7 @@ namespace Nz * \param v2 V2 component * \param vH VH component */ - inline float Color::Hue2RGB(float v1, float v2, float vH) + constexpr float Color::Hue2RGB(float v1, float v2, float vH) { if (vH < 0.f) vH += 1; @@ -690,19 +716,18 @@ namespace Nz return true; } -} -/*! -* \brief Output operator -* \return The stream -* -* \param out The stream -* \param color The color to output -*/ - -inline std::ostream& operator<<(std::ostream& out, const Nz::Color& color) -{ - return out << color.ToString(); + /*! + * \brief Output operator + * \return The stream + * + * \param out The stream + * \param color The color to output + */ + inline std::ostream& operator<<(std::ostream& out, const Color& color) + { + return out << color.ToString(); + } } #include diff --git a/include/Nazara/Graphics/Camera.inl b/include/Nazara/Graphics/Camera.inl index e61032712..13293f98d 100644 --- a/include/Nazara/Graphics/Camera.inl +++ b/include/Nazara/Graphics/Camera.inl @@ -10,7 +10,7 @@ namespace Nz { inline Camera::Camera(const RenderTarget* renderTarget, ProjectionType projectionType) : m_renderTarget(nullptr), - m_clearColor(Color::Black), + m_clearColor(Color::Black()), m_fov(90.f), m_renderOrder(0), m_projectionType(projectionType), diff --git a/include/Nazara/Graphics/DirectionalLight.inl b/include/Nazara/Graphics/DirectionalLight.inl index 2a5ee4138..082546279 100644 --- a/include/Nazara/Graphics/DirectionalLight.inl +++ b/include/Nazara/Graphics/DirectionalLight.inl @@ -11,7 +11,7 @@ namespace Nz { inline DirectionalLight::DirectionalLight() : Light(SafeCast(BasicLightType::Directional)), - m_color(Color::White), + m_color(Color::White()), m_ambientFactor(0.2f), m_diffuseFactor(1.f) { diff --git a/include/Nazara/Graphics/PointLight.inl b/include/Nazara/Graphics/PointLight.inl index 07f64e9d9..0de93b5bb 100644 --- a/include/Nazara/Graphics/PointLight.inl +++ b/include/Nazara/Graphics/PointLight.inl @@ -11,7 +11,7 @@ namespace Nz { inline PointLight::PointLight() : Light(SafeCast(BasicLightType::Point)), - m_color(Color::White), + m_color(Color::White()), m_position(Vector3f::Zero()), m_ambientFactor(0.2f), m_diffuseFactor(1.f) diff --git a/include/Nazara/Graphics/SpotLight.inl b/include/Nazara/Graphics/SpotLight.inl index b68df4953..c3a45722e 100644 --- a/include/Nazara/Graphics/SpotLight.inl +++ b/include/Nazara/Graphics/SpotLight.inl @@ -11,7 +11,7 @@ namespace Nz { inline SpotLight::SpotLight() : Light(SafeCast(BasicLightType::Spot)), - m_color(Color::White), + m_color(Color::White()), m_position(Vector3f::Zero()), m_ambientFactor(0.2f), m_diffuseFactor(1.f) diff --git a/include/Nazara/Graphics/Tilemap.hpp b/include/Nazara/Graphics/Tilemap.hpp index e215a3414..5ec825fe5 100644 --- a/include/Nazara/Graphics/Tilemap.hpp +++ b/include/Nazara/Graphics/Tilemap.hpp @@ -37,12 +37,12 @@ namespace Nz inline void EnableIsometricMode(bool isometric); - inline void EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); - inline void EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); - inline void EnableTiles(const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); - inline void EnableTiles(const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); - inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); - inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color = Color::White(), std::size_t materialIndex = 0U); + inline void EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color = Color::White(), std::size_t materialIndex = 0U); + inline void EnableTiles(const Rectf& coords, const Color& color = Color::White(), std::size_t materialIndex = 0U); + inline void EnableTiles(const Rectui& rect, const Color& color = Color::White(), std::size_t materialIndex = 0U); + inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color = Color::White(), std::size_t materialIndex = 0U); + inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color = Color::White(), std::size_t materialIndex = 0U); inline const Vector2ui& GetMapSize() const; const std::shared_ptr& GetMaterial(std::size_t i) const override; @@ -60,7 +60,7 @@ namespace Nz struct Tile { std::size_t layerIndex = 0U; - Color color = Color::White; + Color color = Color::White(); Rectf textureCoords = Rectf::Zero(); bool enabled = false; }; diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index 952593b0d..950947c80 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -34,11 +34,11 @@ namespace Nz using ContactPostSolveCallback = std::function; using ContactStartCallback = std::function; - using DebugDrawCircleCallback = std::function; - using DebugDrawDotCallback = std::function; - using DebugDrawPolygonCallback = std::function; - using DebugDrawSegmentCallback = std::function; - using DebugDrawTickSegmentCallback = std::function; + using DebugDrawCircleCallback = std::function; + using DebugDrawDotCallback = std::function; + using DebugDrawPolygonCallback = std::function; + using DebugDrawSegmentCallback = std::function; + using DebugDrawTickSegmentCallback = std::function; using DebugDrawGetColorCallback = std::function; public: diff --git a/include/Nazara/Renderer/CommandBufferBuilder.hpp b/include/Nazara/Renderer/CommandBufferBuilder.hpp index 1929b2d62..2ea8eb12a 100644 --- a/include/Nazara/Renderer/CommandBufferBuilder.hpp +++ b/include/Nazara/Renderer/CommandBufferBuilder.hpp @@ -83,7 +83,7 @@ namespace Nz struct ClearValues { - Color color = Color::Black; + Color color = Color::Black(); float depth = 1.f; UInt32 stencil = 0; }; diff --git a/include/Nazara/Utility/Formats/MTLParser.hpp b/include/Nazara/Utility/Formats/MTLParser.hpp index bf3260489..65b7cfda5 100644 --- a/include/Nazara/Utility/Formats/MTLParser.hpp +++ b/include/Nazara/Utility/Formats/MTLParser.hpp @@ -35,9 +35,9 @@ namespace Nz struct Material { - Color ambient = Color::White; - Color diffuse = Color::White; - Color specular = Color::White; + Color ambient = Color::White(); + Color diffuse = Color::White(); + Color specular = Color::White(); std::string alphaMap; std::string ambientMap; std::string bumpMap; diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index 3f9da9cb2..1ade063a5 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -60,9 +60,9 @@ namespace Nz inline SimpleTextDrawer& operator=(const SimpleTextDrawer& drawer); inline SimpleTextDrawer& operator=(SimpleTextDrawer&& drawer) noexcept; - static inline SimpleTextDrawer Draw(const std::string& str, unsigned int characterSize, TextStyleFlags style = TextStyle_Regular, const Color& color = Color::White); + static inline SimpleTextDrawer Draw(const std::string& str, unsigned int characterSize, TextStyleFlags style = TextStyle_Regular, const Color& color = Color::White()); static inline SimpleTextDrawer Draw(const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor); - static inline SimpleTextDrawer Draw(const std::shared_ptr& font, const std::string& str, unsigned int characterSize, TextStyleFlags style = TextStyle_Regular, const Color& color = Color::White); + static inline SimpleTextDrawer Draw(const std::shared_ptr& font, const std::string& str, unsigned int characterSize, TextStyleFlags style = TextStyle_Regular, const Color& color = Color::White()); static inline SimpleTextDrawer Draw(const std::shared_ptr& font, const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor); private: diff --git a/include/Nazara/Utility/SimpleTextDrawer.inl b/include/Nazara/Utility/SimpleTextDrawer.inl index 9da30299c..ed2f300e3 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.inl +++ b/include/Nazara/Utility/SimpleTextDrawer.inl @@ -8,8 +8,8 @@ namespace Nz { inline SimpleTextDrawer::SimpleTextDrawer() : - m_color(Color::White), - m_outlineColor(Color::Black), + m_color(Color::White()), + m_outlineColor(Color::Black()), m_style(TextStyle_Regular), m_colorUpdated(true), m_glyphUpdated(true), diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 61fed0897..7a1f410c0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -120,7 +120,7 @@ namespace Nz inline void CommandBuffer::BeginDebugRegion(const char* label) { - return BeginDebugRegion(label, Color::Black); + return BeginDebugRegion(label, Color::Black()); } inline void CommandBuffer::BeginDebugRegion(const char* label, Color color) @@ -380,7 +380,7 @@ namespace Nz inline void CommandBuffer::InsertDebugLabel(const char* label) { - return InsertDebugLabel(label, Color::Black); + return InsertDebugLabel(label, Color::Black()); } inline void CommandBuffer::InsertDebugLabel(const char* label, Color color) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 9247a4d3e..c8b633e58 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -481,7 +481,7 @@ std::shared_ptr ProcessSubMesh(const std::filesystem::path& originP else { for (unsigned int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) - *colorPtr++ = Nz::Color::White; + *colorPtr++ = Nz::Color::White(); } } diff --git a/src/Nazara/Core/Color.cpp b/src/Nazara/Core/Color.cpp deleted file mode 100644 index 9979c4a58..000000000 --- a/src/Nazara/Core/Color.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - const Color Color::Black(0.f, 0.f, 0.f); - const Color Color::Blue(0.f, 0.f, 1.f); - const Color Color::Cyan(0.f, 1.f, 1.f); - const Color Color::Gray(80.f / 255.f, 80.f / 255.f, 80.f / 255.f); - const Color Color::Green(0.f, 1.f, 0.f); - const Color Color::Magenta(1.f, 0.f, 1.f); - const Color Color::Orange(1.f, 165.f / 255.f, 0.f); - const Color Color::Red(1.f, 0.f, 0.f); - const Color Color::Yellow(1.f, 1.f, 0.f); - const Color Color::White(1.f, 1.f, 1.f); -} diff --git a/src/Nazara/Graphics/BakedFrameGraph.cpp b/src/Nazara/Graphics/BakedFrameGraph.cpp index 6b57530b9..ed5481b7f 100644 --- a/src/Nazara/Graphics/BakedFrameGraph.cpp +++ b/src/Nazara/Graphics/BakedFrameGraph.cpp @@ -65,7 +65,7 @@ namespace Nz builder.BeginRenderPass(*passData.framebuffer, *passData.renderPass, passData.renderRect, passData.outputClearValues.data(), passData.outputClearValues.size()); if (!passData.name.empty()) - builder.BeginDebugRegion(passData.name, Color::Green); + builder.BeginDebugRegion(passData.name, Color::Green()); FramePassEnvironment env{ *this, diff --git a/src/Nazara/Graphics/ForwardFramePipeline.cpp b/src/Nazara/Graphics/ForwardFramePipeline.cpp index cc3ce6f5a..39eec1871 100644 --- a/src/Nazara/Graphics/ForwardFramePipeline.cpp +++ b/src/Nazara/Graphics/ForwardFramePipeline.cpp @@ -323,7 +323,7 @@ namespace Nz // Update UBOs and materials renderFrame.Execute([&](CommandBufferBuilder& builder) { - builder.BeginDebugRegion("CPU to GPU transfers", Color::Yellow); + builder.BeginDebugRegion("CPU to GPU transfers", Color::Yellow()); { builder.PreTransferBarrier(); @@ -446,13 +446,13 @@ namespace Nz builder.TextureBarrier(PipelineStage::ColorOutput, PipelineStage::FragmentShader, MemoryAccess::ColorWrite, MemoryAccess::ShaderRead, TextureLayout::ColorOutput, TextureLayout::ColorInput, *sourceTexture); std::array clearValues; - clearValues[0].color = Color::Black; + clearValues[0].color = Color::Black(); clearValues[1].depth = 1.f; clearValues[1].stencil = 0; builder.BeginRenderPass(renderTarget.GetFramebuffer(renderFrame.GetFramebufferIndex()), renderTarget.GetRenderPass(), renderRegion, { clearValues[0], clearValues[1] }); { - builder.BeginDebugRegion("Main window rendering", Color::Green); + builder.BeginDebugRegion("Main window rendering", Color::Green()); { builder.SetScissor(renderRegion); builder.SetViewport(renderRegion); @@ -636,7 +636,7 @@ namespace Nz mergePass.AddInput(viewerData->debugColorAttachment); mergePass.AddOutput(renderTargetData.finalAttachment); - mergePass.SetClearColor(0, Color::Black); + mergePass.SetClearColor(0, Color::Black()); mergePass.SetCommandCallback([&targetViewers](CommandBufferBuilder& builder, const FramePassEnvironment& env) { diff --git a/src/Nazara/Graphics/ForwardPipelinePass.cpp b/src/Nazara/Graphics/ForwardPipelinePass.cpp index d5a176f1b..d472c3d17 100644 --- a/src/Nazara/Graphics/ForwardPipelinePass.cpp +++ b/src/Nazara/Graphics/ForwardPipelinePass.cpp @@ -182,7 +182,7 @@ namespace Nz renderFrame.Execute([&](CommandBufferBuilder& builder) { - builder.BeginDebugRegion("Light UBO Update", Color::Yellow); + builder.BeginDebugRegion("Light UBO Update", Color::Yellow()); { for (auto& lightUboData : m_lightDataBuffers) { diff --git a/src/Nazara/Graphics/LinearSlicedSprite.cpp b/src/Nazara/Graphics/LinearSlicedSprite.cpp index 6c364348a..88f0ef557 100644 --- a/src/Nazara/Graphics/LinearSlicedSprite.cpp +++ b/src/Nazara/Graphics/LinearSlicedSprite.cpp @@ -15,7 +15,7 @@ namespace Nz m_material(std::move(material)), m_sectionCount(0), m_spriteCount(0), - m_color(Color::White), + m_color(Color::White()), m_orientation(orientation), m_textureCoords(0.f, 0.f, 1.f, 1.f), m_origin(0.f, 0.f), diff --git a/src/Nazara/Graphics/PredefinedMaterials.cpp b/src/Nazara/Graphics/PredefinedMaterials.cpp index 09b53048d..1ddafb3c8 100644 --- a/src/Nazara/Graphics/PredefinedMaterials.cpp +++ b/src/Nazara/Graphics/PredefinedMaterials.cpp @@ -13,7 +13,7 @@ namespace Nz { void PredefinedMaterials::AddBasicSettings(MaterialSettings& settings) { - settings.AddValueProperty("BaseColor", Color::White); + settings.AddValueProperty("BaseColor", Color::White()); settings.AddValueProperty("AlphaTest", false); settings.AddValueProperty("AlphaTestThreshold", 0.2f); settings.AddTextureProperty("BaseColorMap", ImageType::E2D); @@ -43,8 +43,8 @@ namespace Nz void PredefinedMaterials::AddPhongSettings(MaterialSettings& settings) { - settings.AddValueProperty("AmbientColor", Color::Black); - settings.AddValueProperty("SpecularColor", Color::White); + settings.AddValueProperty("AmbientColor", Color::Black()); + settings.AddValueProperty("SpecularColor", Color::White()); settings.AddValueProperty("Shininess", 2.f); settings.AddTextureProperty("EmissiveMap", ImageType::E2D); settings.AddTextureProperty("HeightMap", ImageType::E2D); diff --git a/src/Nazara/Graphics/SlicedSprite.cpp b/src/Nazara/Graphics/SlicedSprite.cpp index b988d82b3..6c4f10d1c 100644 --- a/src/Nazara/Graphics/SlicedSprite.cpp +++ b/src/Nazara/Graphics/SlicedSprite.cpp @@ -13,7 +13,7 @@ namespace Nz { SlicedSprite::SlicedSprite(std::shared_ptr material) : m_material(std::move(material)), - m_color(Color::White), + m_color(Color::White()), m_textureCoords(0.f, 0.f, 1.f, 1.f), m_origin(0.f, 0.f), m_size(64.f, 64.f) diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 1b47a2c68..d51c99708 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -14,12 +14,12 @@ namespace Nz { Sprite::Sprite(std::shared_ptr material) : m_material(std::move(material)), - m_color(Color::White), + m_color(Color::White()), m_textureCoords(0.f, 0.f, 1.f, 1.f), m_origin(0.f, 0.f), m_size(64.f, 64.f) { - m_cornerColor.fill(Color::White); + m_cornerColor.fill(Color::White()); UpdateVertices(); } diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp index fdcfc8d19..bb9bc2e92 100644 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ b/src/Nazara/Renderer/DebugDrawer.cpp @@ -173,7 +173,7 @@ namespace Nz { renderFrame.Execute([&](CommandBufferBuilder& builder) { - builder.BeginDebugRegion("Debug drawer upload", Color::Yellow); + builder.BeginDebugRegion("Debug drawer upload", Color::Yellow()); { if (m_viewerDataUpdated) { diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index e31ce5e36..8053fa6e1 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -228,7 +228,7 @@ namespace Nz if (auto colorPtr = vertexMapper.GetComponentPtr(VertexComponent::Color)) { for (UInt32 v = 0; v < header.num_vertices; ++v) - *colorPtr++ = Color::White; + *colorPtr++ = Color::White(); } vertexMapper.Unmap(); diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index a553de555..d739a2f43 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -205,7 +205,7 @@ namespace Nz if (auto colorPtr = vertexMapper.GetComponentPtr(VertexComponent::Color)) { for (std::size_t j = 0; j < md5Mesh.vertices.size(); ++j) - *colorPtr++ = Color::White; + *colorPtr++ = Color::White(); } vertexMapper.Unmap(); @@ -316,7 +316,7 @@ namespace Nz if (auto colorPtr = vertexMapper.GetComponentPtr(VertexComponent::Color)) { for (std::size_t j = 0; j < md5Mesh.vertices.size(); ++j) - *colorPtr++ = Color::White; + *colorPtr++ = Color::White(); } vertexMapper.Unmap(); diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 837f91912..ac79a5e60 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -313,7 +313,7 @@ namespace Nz if (auto colorPtr = vertexMapper.GetComponentPtr(VertexComponent::Color)) { for (UInt32 j = 0; j < vertexCount; ++j) - colorPtr[j] = Color::White; + colorPtr[j] = Color::White(); } vertexMapper.Unmap(); diff --git a/src/Nazara/Utility/RichTextDrawer.cpp b/src/Nazara/Utility/RichTextDrawer.cpp index 6995ae8c9..3b25954e7 100644 --- a/src/Nazara/Utility/RichTextDrawer.cpp +++ b/src/Nazara/Utility/RichTextDrawer.cpp @@ -10,8 +10,8 @@ namespace Nz { RichTextDrawer::RichTextDrawer() : - m_defaultColor(Color::White), - m_defaultOutlineColor(Color::Black), + m_defaultColor(Color::White()), + m_defaultOutlineColor(Color::Black()), m_defaultStyle(TextStyle_Regular), m_glyphUpdated(false), m_defaultCharacterSpacingOffset(0.f), diff --git a/src/Nazara/Widgets/AbstractTextAreaWidget.cpp b/src/Nazara/Widgets/AbstractTextAreaWidget.cpp index a191dd781..8c4e443ab 100644 --- a/src/Nazara/Widgets/AbstractTextAreaWidget.cpp +++ b/src/Nazara/Widgets/AbstractTextAreaWidget.cpp @@ -612,7 +612,7 @@ namespace Nz float endX = (i == m_cursorPositionEnd.y) ? GetGlyphPos({ m_cursorPositionEnd.x, i }) : lineInfo.bounds.width; float spriteSize = std::max(endX - beginX, 1.f); - cursor.sprite->SetColor((m_cursorPositionBegin == m_cursorPositionEnd) ? Color::Black : Color(0.f, 0.f, 0.f, 0.2f)); + cursor.sprite->SetColor((m_cursorPositionBegin == m_cursorPositionEnd) ? Color::Black() : Color(0.f, 0.f, 0.f, 0.2f)); cursor.sprite->SetSize(Vector2f(spriteSize, lineInfo.bounds.height)); registry.get(cursor.entity).SetPosition(beginX, textHeight - lineInfo.bounds.y - lineInfo.bounds.height); diff --git a/src/Nazara/Widgets/ImageButtonWidget.cpp b/src/Nazara/Widgets/ImageButtonWidget.cpp index e9b282d9a..30d06d629 100644 --- a/src/Nazara/Widgets/ImageButtonWidget.cpp +++ b/src/Nazara/Widgets/ImageButtonWidget.cpp @@ -13,7 +13,7 @@ namespace Nz m_hoveredMaterial(std::move(hoveredMaterial)), m_material(std::move(material)), m_pressedMaterial(std::move(pressedMaterial)), - m_color(Color::White), + m_color(Color::White()), m_textureCoords(0.f, 0.f, 1.f, 1.f), m_cornerSize(cornerSize), m_cornerTexCoords(cornerTexCoords) diff --git a/tests/ComputeTest/main.cpp b/tests/ComputeTest/main.cpp index aaa3e1c9e..6fb7bd2a7 100644 --- a/tests/ComputeTest/main.cpp +++ b/tests/ComputeTest/main.cpp @@ -171,12 +171,12 @@ int main() } builder.EndDebugRegion(); - builder.BeginDebugRegion("Main window rendering", Nz::Color::Green); + builder.BeginDebugRegion("Main window rendering", Nz::Color::Green()); { Nz::Recti renderRect(0, 0, window.GetSize().x, window.GetSize().y); Nz::CommandBufferBuilder::ClearValues clearValues[2]; - clearValues[0].color = Nz::Color::Gray; + clearValues[0].color = Nz::Color::Gray(); clearValues[1].depth = 1.f; clearValues[1].stencil = 0; diff --git a/tests/GraphicsTest/main.cpp b/tests/GraphicsTest/main.cpp index fbdc7d150..5dc82cc07 100644 --- a/tests/GraphicsTest/main.cpp +++ b/tests/GraphicsTest/main.cpp @@ -69,10 +69,10 @@ int main() std::shared_ptr materialInstance = std::make_shared(material); materialInstance->SetTextureProperty(0, diffuseTexture); - materialInstance->SetValueProperty(0, Nz::Color::White); + materialInstance->SetValueProperty(0, Nz::Color::White()); std::shared_ptr materialInstance2 = std::make_shared(material); - materialInstance2->SetValueProperty(0, Nz::Color::Green); + materialInstance2->SetValueProperty(0, Nz::Color::Green()); Nz::Model model(std::move(gfxMesh), spaceshipMesh->GetAABB()); for (std::size_t i = 0; i < model.GetSubMeshCount(); ++i) @@ -81,7 +81,7 @@ int main() Nz::Vector2ui windowSize = window.GetSize(); Nz::Camera camera(window.GetRenderTarget()); - camera.UpdateClearColor(Nz::Color::Gray); + camera.UpdateClearColor(Nz::Color::Gray()); Nz::ViewerInstance& viewerInstance = camera.GetViewerInstance(); viewerInstance.UpdateTargetSize(Nz::Vector2f(window.GetSize())); @@ -219,7 +219,7 @@ int main() continue; } - framePipeline.GetDebugDrawer().DrawLine(Nz::Vector3f::Zero(), Nz::Vector3f::Forward(), Nz::Color::Blue); + framePipeline.GetDebugDrawer().DrawLine(Nz::Vector3f::Zero(), Nz::Vector3f::Forward(), Nz::Color::Blue()); viewerInstance.UpdateViewMatrix(Nz::Matrix4f::TransformInverse(viewerPos, camAngles)); viewerInstance.UpdateEyePosition(viewerPos); diff --git a/tests/RenderTest/main.cpp b/tests/RenderTest/main.cpp index 2f4a989eb..7ff9e796a 100644 --- a/tests/RenderTest/main.cpp +++ b/tests/RenderTest/main.cpp @@ -348,7 +348,7 @@ int main() Nz::Boxf aabb = spaceship->GetAABB(); aabb.Transform(ubo.modelMatrix); - debugDrawer.DrawBox(aabb, Nz::Color::Green); + debugDrawer.DrawBox(aabb, Nz::Color::Green()); ubo.viewMatrix = Nz::Matrix4f::TransformInverse(viewerPos, camAngles); @@ -360,7 +360,7 @@ int main() frame.Execute([&](Nz::CommandBufferBuilder& builder) { - builder.BeginDebugRegion("UBO Update", Nz::Color::Yellow); + builder.BeginDebugRegion("UBO Update", Nz::Color::Yellow()); { builder.PreTransferBarrier(); builder.CopyBuffer(allocation, uniformBuffer.get()); @@ -380,11 +380,11 @@ int main() Nz::Recti renderRect(0, 0, window.GetSize().x, window.GetSize().y); Nz::CommandBufferBuilder::ClearValues clearValues[2]; - clearValues[0].color = Nz::Color::Black; + clearValues[0].color = Nz::Color::Black(); clearValues[1].depth = 1.f; clearValues[1].stencil = 0; - builder.BeginDebugRegion("Main window rendering", Nz::Color::Green); + builder.BeginDebugRegion("Main window rendering", Nz::Color::Green()); { builder.BeginRenderPass(windowRT->GetFramebuffer(frame.GetFramebufferIndex()), windowRT->GetRenderPass(), renderRect, { clearValues[0], clearValues[1] }); { diff --git a/tests/UnitTests/Engine/Core/SerializationTest.cpp b/tests/UnitTests/Engine/Core/SerializationTest.cpp index 90f163b8f..5b061b91c 100644 --- a/tests/UnitTests/Engine/Core/SerializationTest.cpp +++ b/tests/UnitTests/Engine/Core/SerializationTest.cpp @@ -236,10 +236,10 @@ SCENARIO("Serialization", "[CORE][SERIALIZATION]") THEN("Color") { context.stream->SetCursorPos(0); - Nz::Color red = Nz::Color::Red; + Nz::Color red = Nz::Color::Red(); Nz::Color copy(red); REQUIRE(Serialize(context, red)); - red = Nz::Color::Black; + red = Nz::Color::Black(); REQUIRE(red != copy); context.stream->SetCursorPos(0); REQUIRE(Unserialize(context, &red));