Core: Make Color constexpr
This commit is contained in:
parent
3d88746060
commit
9a553e5e9d
|
|
@ -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) });
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ int main()
|
|||
auto shipCollider = std::make_shared<Nz::ConvexCollider3D>(vertices, vertexMapper.GetVertexCount(), 0.01f);
|
||||
|
||||
std::shared_ptr<Nz::MaterialInstance> 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)
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ int main()
|
|||
auto& cameraLight = registry.emplace<Nz::LightComponent>(lightEntity1);
|
||||
|
||||
auto& spotLight = cameraLight.AddLight<Nz::SpotLight>(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<Nz::LightComponent>(lightEntity2);
|
||||
|
||||
auto& spotLight = cameraLight.AddLight<Nz::SpotLight>(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<Nz::LightComponent>(lightEntity3);
|
||||
|
||||
auto& pointLight = cameraLight.AddLight<Nz::PointLight>(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<Nz::NodeComponent>(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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Nz::CheckboxWidget>();
|
||||
|
|
@ -103,8 +103,8 @@ int main()
|
|||
Nz::TextAreaWidget* longTextArea = canvas2D.Add<Nz::TextAreaWidget>();
|
||||
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<Nz::ScrollAreaWidget>(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();
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<Color>);
|
||||
inline bool Unserialize(SerializationContext& context, Color* color, TypeTag<Color>);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Nz::Color& color);
|
||||
std::ostream& operator<<(std::ostream& out, const Color& color);
|
||||
}
|
||||
|
||||
#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<UInt8>(Clamp(color.r * 255.f, 0.f, 255.f));
|
||||
*g = static_cast<UInt8>(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<UInt8>(Clamp(color.r * 255.f, 0.f, 255.f));
|
||||
*g = static_cast<UInt8>(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 <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Nz
|
|||
{
|
||||
inline DirectionalLight::DirectionalLight() :
|
||||
Light(SafeCast<UInt8>(BasicLightType::Directional)),
|
||||
m_color(Color::White),
|
||||
m_color(Color::White()),
|
||||
m_ambientFactor(0.2f),
|
||||
m_diffuseFactor(1.f)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Nz
|
|||
{
|
||||
inline PointLight::PointLight() :
|
||||
Light(SafeCast<UInt8>(BasicLightType::Point)),
|
||||
m_color(Color::White),
|
||||
m_color(Color::White()),
|
||||
m_position(Vector3f::Zero()),
|
||||
m_ambientFactor(0.2f),
|
||||
m_diffuseFactor(1.f)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Nz
|
|||
{
|
||||
inline SpotLight::SpotLight() :
|
||||
Light(SafeCast<UInt8>(BasicLightType::Spot)),
|
||||
m_color(Color::White),
|
||||
m_color(Color::White()),
|
||||
m_position(Vector3f::Zero()),
|
||||
m_ambientFactor(0.2f),
|
||||
m_diffuseFactor(1.f)
|
||||
|
|
|
|||
|
|
@ -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<MaterialInstance>& 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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ namespace Nz
|
|||
using ContactPostSolveCallback = std::function<void(PhysWorld2D& world, Arbiter2D& arbiter, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
|
||||
using ContactStartCallback = std::function<bool(PhysWorld2D& world, Arbiter2D& arbiter, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
|
||||
|
||||
using DebugDrawCircleCallback = std::function<void(const Vector2f& origin, const RadianAnglef& rotation, float radius, Color outlineColor, Color fillColor, void* userdata)>;
|
||||
using DebugDrawDotCallback = std::function<void(const Vector2f& origin, float radius, Color color, void* userdata)>;
|
||||
using DebugDrawPolygonCallback = std::function<void(const Vector2f* vertices, std::size_t vertexCount, float radius, Color outlineColor, Color fillColor, void* userdata)>;
|
||||
using DebugDrawSegmentCallback = std::function<void(const Vector2f& first, const Vector2f& second, Color color, void* userdata)>;
|
||||
using DebugDrawTickSegmentCallback = std::function<void(const Vector2f& first, const Vector2f& second, float thickness, Color outlineColor, Color fillColor, void* userdata)>;
|
||||
using DebugDrawCircleCallback = std::function<void(const Vector2f& origin, const RadianAnglef& rotation, float radius, const Color& outlineColor, const Color& fillColor, void* userdata)>;
|
||||
using DebugDrawDotCallback = std::function<void(const Vector2f& origin, float radius, const Color& color, void* userdata)>;
|
||||
using DebugDrawPolygonCallback = std::function<void(const Vector2f* vertices, std::size_t vertexCount, float radius, const Color& outlineColor, const Color& fillColor, void* userdata)>;
|
||||
using DebugDrawSegmentCallback = std::function<void(const Vector2f& first, const Vector2f& second, const Color& color, void* userdata)>;
|
||||
using DebugDrawTickSegmentCallback = std::function<void(const Vector2f& first, const Vector2f& second, float thickness, const Color& outlineColor, const Color& fillColor, void* userdata)>;
|
||||
using DebugDrawGetColorCallback = std::function<Color(RigidBody2D& body, std::size_t shapeIndex, void* userdata)>;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace Nz
|
|||
|
||||
struct ClearValues
|
||||
{
|
||||
Color color = Color::Black;
|
||||
Color color = Color::Black();
|
||||
float depth = 1.f;
|
||||
UInt32 stencil = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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>& 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>& 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>& font, const std::string& str, unsigned int characterSize, TextStyleFlags style, const Color& color, float outlineThickness, const Color& outlineColor);
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ std::shared_ptr<Nz::SubMesh> ProcessSubMesh(const std::filesystem::path& originP
|
|||
else
|
||||
{
|
||||
for (unsigned int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
|
||||
*colorPtr++ = Nz::Color::White;
|
||||
*colorPtr++ = Nz::Color::White();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<CommandBufferBuilder::ClearValues, 2> 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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Nz
|
|||
{
|
||||
void PredefinedMaterials::AddBasicSettings(MaterialSettings& settings)
|
||||
{
|
||||
settings.AddValueProperty<Color>("BaseColor", Color::White);
|
||||
settings.AddValueProperty<Color>("BaseColor", Color::White());
|
||||
settings.AddValueProperty<bool>("AlphaTest", false);
|
||||
settings.AddValueProperty<float>("AlphaTestThreshold", 0.2f);
|
||||
settings.AddTextureProperty("BaseColorMap", ImageType::E2D);
|
||||
|
|
@ -43,8 +43,8 @@ namespace Nz
|
|||
|
||||
void PredefinedMaterials::AddPhongSettings(MaterialSettings& settings)
|
||||
{
|
||||
settings.AddValueProperty<Color>("AmbientColor", Color::Black);
|
||||
settings.AddValueProperty<Color>("SpecularColor", Color::White);
|
||||
settings.AddValueProperty<Color>("AmbientColor", Color::Black());
|
||||
settings.AddValueProperty<Color>("SpecularColor", Color::White());
|
||||
settings.AddValueProperty<float>("Shininess", 2.f);
|
||||
settings.AddTextureProperty("EmissiveMap", ImageType::E2D);
|
||||
settings.AddTextureProperty("HeightMap", ImageType::E2D);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Nz
|
|||
{
|
||||
SlicedSprite::SlicedSprite(std::shared_ptr<MaterialInstance> 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)
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ namespace Nz
|
|||
{
|
||||
Sprite::Sprite(std::shared_ptr<MaterialInstance> 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ namespace Nz
|
|||
if (auto colorPtr = vertexMapper.GetComponentPtr<Color>(VertexComponent::Color))
|
||||
{
|
||||
for (UInt32 v = 0; v < header.num_vertices; ++v)
|
||||
*colorPtr++ = Color::White;
|
||||
*colorPtr++ = Color::White();
|
||||
}
|
||||
|
||||
vertexMapper.Unmap();
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ namespace Nz
|
|||
if (auto colorPtr = vertexMapper.GetComponentPtr<Color>(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<Color>(VertexComponent::Color))
|
||||
{
|
||||
for (std::size_t j = 0; j < md5Mesh.vertices.size(); ++j)
|
||||
*colorPtr++ = Color::White;
|
||||
*colorPtr++ = Color::White();
|
||||
}
|
||||
|
||||
vertexMapper.Unmap();
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ namespace Nz
|
|||
if (auto colorPtr = vertexMapper.GetComponentPtr<Color>(VertexComponent::Color))
|
||||
{
|
||||
for (UInt32 j = 0; j < vertexCount; ++j)
|
||||
colorPtr[j] = Color::White;
|
||||
colorPtr[j] = Color::White();
|
||||
}
|
||||
|
||||
vertexMapper.Unmap();
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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<NodeComponent>(cursor.entity).SetPosition(beginX, textHeight - lineInfo.bounds.y - lineInfo.bounds.height);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -69,10 +69,10 @@ int main()
|
|||
|
||||
std::shared_ptr<Nz::MaterialInstance> materialInstance = std::make_shared<Nz::MaterialInstance>(material);
|
||||
materialInstance->SetTextureProperty(0, diffuseTexture);
|
||||
materialInstance->SetValueProperty(0, Nz::Color::White);
|
||||
materialInstance->SetValueProperty(0, Nz::Color::White());
|
||||
|
||||
std::shared_ptr<Nz::MaterialInstance> materialInstance2 = std::make_shared<Nz::MaterialInstance>(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);
|
||||
|
|
|
|||
|
|
@ -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] });
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue