Core: Make Color constexpr

This commit is contained in:
SirLynix
2022-12-29 12:13:00 +01:00
parent 3d88746060
commit 9a553e5e9d
38 changed files with 227 additions and 222 deletions

View File

@@ -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) });

View File

@@ -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);
}
}

View File

@@ -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)

View File

@@ -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();

View File

@@ -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();
{