Rework EnTT integration
- Update EnTT to 3.11.1 - Moved EnTT wrapper to EnTTWorld, inheriting EntityWorld - AppEntitySystemComponent can now handles multiple EntityWorld - Headers relying on EnTT are now automatically included if NAZARA_ENTT is defined - Renamed SystemGraph to EnttSystemGraph (as it depends on it for now)
This commit is contained in:
committed by
Jérôme Leclercq
parent
d5f281a768
commit
97fa4d98be
@@ -3,7 +3,6 @@
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Core/AppEntitySystemComponent.hpp>
|
||||
#include <Nazara/Core/Systems.hpp>
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Graphics/Components.hpp>
|
||||
#include <Nazara/Graphics/Systems.hpp>
|
||||
#include <Nazara/Math/PidController.hpp>
|
||||
#include <Nazara/Physics2D.hpp>
|
||||
#include <Nazara/Physics2D/Components.hpp>
|
||||
#include <Nazara/Physics2D/Systems.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Utility/Components.hpp>
|
||||
#include <Nazara/Widgets.hpp>
|
||||
#include <entt/entt.hpp>
|
||||
#include <array>
|
||||
@@ -42,8 +35,10 @@ int main()
|
||||
auto& windowing = app.AddComponent<Nz::AppWindowingComponent>();
|
||||
|
||||
auto& ecs = app.AddComponent<Nz::AppEntitySystemComponent>();
|
||||
Nz::Physics2DSystem& physSytem = ecs.AddSystem<Nz::Physics2DSystem>();
|
||||
Nz::RenderSystem& renderSystem = ecs.AddSystem<Nz::RenderSystem>();
|
||||
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
Nz::Physics2DSystem& physSytem = world.AddSystem<Nz::Physics2DSystem>();
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
|
||||
std::string windowTitle = "Physics 2D";
|
||||
Nz::Window& window = windowing.CreateWindow(Nz::VideoMode(1920, 1080, 32), windowTitle);
|
||||
@@ -55,7 +50,7 @@ int main()
|
||||
|
||||
physSytem.GetPhysWorld().SetGravity({ 0.f, -98.1f });
|
||||
|
||||
entt::handle viewer = ecs.CreateEntity();
|
||||
entt::handle viewer = world.CreateEntity();
|
||||
{
|
||||
viewer.emplace<Nz::NodeComponent>();
|
||||
auto& cameraComponent = viewer.emplace<Nz::CameraComponent>(&windowSwapchain.GetSwapchain(), Nz::ProjectionType::Orthographic);
|
||||
@@ -77,7 +72,7 @@ int main()
|
||||
{
|
||||
for (std::size_t x = 0; x < 30; ++x)
|
||||
{
|
||||
entt::handle spriteEntity = ecs.CreateEntity();
|
||||
entt::handle spriteEntity = world.CreateEntity();
|
||||
{
|
||||
std::shared_ptr<Nz::Sprite> sprite = std::make_shared<Nz::Sprite>(spriteMaterial);
|
||||
sprite->SetSize({ 32.f, 32.f });
|
||||
@@ -93,7 +88,7 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
entt::handle groundEntity = ecs.CreateEntity();
|
||||
entt::handle groundEntity = world.CreateEntity();
|
||||
{
|
||||
std::shared_ptr<Nz::Tilemap> tilemap = std::make_shared<Nz::Tilemap>(Nz::Vector2ui(40, 20), Nz::Vector2f(64.f, 64.f), 18);
|
||||
tilemap->SetOrigin({ 0.5f, 0.5f });
|
||||
@@ -138,7 +133,7 @@ int main()
|
||||
|
||||
if (secondClock.RestartIfOver(Nz::Time::Second()))
|
||||
{
|
||||
window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(ecs.GetRegistry().alive()) + " entities");
|
||||
window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(world.GetRegistry().alive()) + " entities");
|
||||
fps = 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,3 +2,4 @@ target("Physics2DDemo")
|
||||
add_deps("NazaraGraphics", "NazaraPhysics2D")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Core/AppEntitySystemComponent.hpp>
|
||||
#include <Nazara/Core/Systems.hpp>
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Graphics/Components.hpp>
|
||||
#include <Nazara/Graphics/Systems.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Math/PidController.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Physics3D/Components.hpp>
|
||||
#include <Nazara/Physics3D/Systems.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Utility/Components.hpp>
|
||||
#include <entt/entt.hpp>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
@@ -42,8 +34,10 @@ int main()
|
||||
auto& windowing = app.AddComponent<Nz::AppWindowingComponent>();
|
||||
|
||||
auto& ecs = app.AddComponent<Nz::AppEntitySystemComponent>();
|
||||
Nz::Physics3DSystem& physSytem = ecs.AddSystem<Nz::Physics3DSystem>();
|
||||
Nz::RenderSystem& renderSystem = ecs.AddSystem<Nz::RenderSystem>();
|
||||
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
Nz::Physics3DSystem& physSytem = world.AddSystem<Nz::Physics3DSystem>();
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
|
||||
std::string windowTitle = "Physics 3D";
|
||||
Nz::Window& window = windowing.CreateWindow(Nz::VideoMode(1920, 1080, 32), windowTitle);
|
||||
@@ -107,7 +101,7 @@ int main()
|
||||
|
||||
Nz::Vector2ui windowSize = window.GetSize();
|
||||
|
||||
entt::handle viewer = ecs.CreateEntity();
|
||||
entt::handle viewer = world.CreateEntity();
|
||||
{
|
||||
viewer.emplace<Nz::NodeComponent>();
|
||||
auto& cameraComponent = viewer.emplace<Nz::CameraComponent>(&windowSwapchain.GetSwapchain());
|
||||
@@ -138,7 +132,7 @@ int main()
|
||||
colliderModel->SetMaterial(i, colliderMat);
|
||||
}
|
||||
|
||||
entt::handle textEntity = ecs.CreateEntity();
|
||||
entt::handle textEntity = world.CreateEntity();
|
||||
{
|
||||
auto& entityGfx = textEntity.emplace<Nz::GraphicsComponent>();
|
||||
entityGfx.AttachRenderable(sprite, 1);
|
||||
@@ -146,9 +140,9 @@ int main()
|
||||
auto& entityNode = textEntity.emplace<Nz::NodeComponent>();
|
||||
entityNode.SetPosition(0.f, 5.f, 0.f);
|
||||
}
|
||||
entt::handle playerEntity = ecs.CreateEntity();
|
||||
entt::handle playerEntity = world.CreateEntity();
|
||||
|
||||
entt::handle headingEntity = ecs.CreateEntity();
|
||||
entt::handle headingEntity = world.CreateEntity();
|
||||
{
|
||||
auto& entityLight = playerEntity.emplace<Nz::LightComponent>();
|
||||
auto& spotLight = entityLight.AddLight<Nz::SpotLight>(1);
|
||||
@@ -179,7 +173,7 @@ int main()
|
||||
{
|
||||
for (std::size_t z = 0; z < 3; ++z)
|
||||
{
|
||||
entt::handle entity = ecs.CreateEntity();
|
||||
entt::handle entity = world.CreateEntity();
|
||||
auto& entityGfx = entity.emplace<Nz::GraphicsComponent>();
|
||||
entityGfx.AttachRenderable(model, 1);
|
||||
|
||||
@@ -222,20 +216,20 @@ int main()
|
||||
showColliders = !showColliders;
|
||||
if (showColliders)
|
||||
{
|
||||
auto view = ecs.GetRegistry().view<Nz::GraphicsComponent, Nz::RigidBody3DComponent>();
|
||||
auto view = world.GetRegistry().view<Nz::GraphicsComponent, Nz::RigidBody3DComponent>();
|
||||
for (auto [entity, gfxComponent, _] : view.each())
|
||||
gfxComponent.AttachRenderable(colliderModel, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto view = ecs.GetRegistry().view<Nz::GraphicsComponent, Nz::RigidBody3DComponent>();
|
||||
auto view = world.GetRegistry().view<Nz::GraphicsComponent, Nz::RigidBody3DComponent>();
|
||||
for (auto [entity, gfxComponent, _] : view.each())
|
||||
gfxComponent.DetachRenderable(colliderModel);
|
||||
}
|
||||
}
|
||||
else if (event.virtualKey == Nz::Keyboard::VKey::Space)
|
||||
{
|
||||
entt::handle entity = ecs.CreateEntity();
|
||||
entt::handle entity = world.CreateEntity();
|
||||
auto& entityGfx = entity.emplace<Nz::GraphicsComponent>();
|
||||
entityGfx.AttachRenderable(model, 1);
|
||||
if (showColliders)
|
||||
@@ -270,7 +264,7 @@ int main()
|
||||
{
|
||||
float elapsedTime = deltaTime->AsSeconds();
|
||||
|
||||
auto spaceshipView = ecs.GetRegistry().view<Nz::NodeComponent, Nz::RigidBody3DComponent>();
|
||||
auto spaceshipView = world.GetRegistry().view<Nz::NodeComponent, Nz::RigidBody3DComponent>();
|
||||
for (auto&& [entity, node, _] : spaceshipView.each())
|
||||
{
|
||||
if (entity == playerEntity)
|
||||
@@ -278,7 +272,7 @@ int main()
|
||||
|
||||
Nz::Vector3f spaceshipPos = node.GetPosition(Nz::CoordSys::Global);
|
||||
if (spaceshipPos.GetSquaredLength() > Nz::IntegralPow(20.f, 2))
|
||||
ecs.GetRegistry().destroy(entity);
|
||||
world.GetRegistry().destroy(entity);
|
||||
}
|
||||
|
||||
Nz::RigidBody3DComponent& playerShipBody = playerEntity.get<Nz::RigidBody3DComponent>();
|
||||
@@ -320,7 +314,7 @@ int main()
|
||||
|
||||
if (fpsClock.RestartIfOver(Nz::Time::Second()))
|
||||
{
|
||||
window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(ecs.GetRegistry().alive()) + " entities");
|
||||
window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(world.GetRegistry().alive()) + " entities");
|
||||
fps = 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,3 +2,4 @@ target("PhysicsDemo")
|
||||
add_deps("NazaraGraphics", "NazaraPhysics3D")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Core/AppEntitySystemComponent.hpp>
|
||||
#include <Nazara/Core/Systems.hpp>
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Graphics/Components.hpp>
|
||||
#include <Nazara/Graphics/Systems.hpp>
|
||||
#include <Nazara/Math/PidController.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Physics3D/Components.hpp>
|
||||
#include <Nazara/Physics3D/Systems.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Utility/Components.hpp>
|
||||
#include <Nazara/Utility/Systems.hpp>
|
||||
#include <Nazara/Utility/Plugins/AssimpPlugin.hpp>
|
||||
#include <Nazara/Utils/CallOnExit.hpp>
|
||||
#include <NZSL/Math/FieldOffsets.hpp>
|
||||
@@ -46,10 +37,12 @@ int main()
|
||||
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
||||
|
||||
auto& ecs = app.AddComponent<Nz::AppEntitySystemComponent>();
|
||||
ecs.AddSystem<Nz::SkeletonSystem>();
|
||||
|
||||
Nz::Physics3DSystem& physSytem = ecs.AddSystem<Nz::Physics3DSystem>();
|
||||
Nz::RenderSystem& renderSystem = ecs.AddSystem<Nz::RenderSystem>();
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
world.AddSystem<Nz::SkeletonSystem>();
|
||||
|
||||
Nz::Physics3DSystem& physSytem = world.AddSystem<Nz::Physics3DSystem>();
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
|
||||
auto& windowing = app.AddComponent<Nz::AppWindowingComponent>();
|
||||
|
||||
@@ -62,9 +55,9 @@ int main()
|
||||
Nz::TextureParams texParams;
|
||||
texParams.renderDevice = device;
|
||||
|
||||
entt::handle playerEntity = ecs.CreateEntity();
|
||||
entt::handle playerRotation = ecs.CreateEntity();
|
||||
entt::handle playerCamera = ecs.CreateEntity();
|
||||
entt::handle playerEntity = world.CreateEntity();
|
||||
entt::handle playerRotation = world.CreateEntity();
|
||||
entt::handle playerCamera = world.CreateEntity();
|
||||
{
|
||||
auto& playerNode = playerEntity.emplace<Nz::NodeComponent>();
|
||||
playerNode.SetPosition(0.f, 1.8f, 1.f);
|
||||
@@ -166,8 +159,8 @@ int main()
|
||||
}
|
||||
}*/
|
||||
|
||||
entt::handle bobEntity = ecs.CreateEntity();
|
||||
entt::handle lightEntity1 = ecs.CreateEntity();
|
||||
entt::handle bobEntity = world.CreateEntity();
|
||||
entt::handle lightEntity1 = world.CreateEntity();
|
||||
{
|
||||
auto& lightNode = lightEntity1.emplace<Nz::NodeComponent>();
|
||||
lightNode.SetPosition(Nz::Vector3f::Up() * 3.f + Nz::Vector3f::Backward() * 1.f);
|
||||
@@ -182,7 +175,7 @@ int main()
|
||||
spotLight.EnableShadowCasting(true);
|
||||
}
|
||||
|
||||
entt::handle lightEntity2 = ecs.CreateEntity();
|
||||
entt::handle lightEntity2 = world.CreateEntity();
|
||||
{
|
||||
auto& lightNode = lightEntity2.emplace<Nz::NodeComponent>();
|
||||
lightNode.SetPosition(Nz::Vector3f::Up() * 3.5f + Nz::Vector3f::Right() * 1.5f);
|
||||
@@ -196,7 +189,7 @@ int main()
|
||||
spotLight.UpdateShadowMapSize(1024);
|
||||
}
|
||||
|
||||
entt::handle lightEntity3 = ecs.CreateEntity();
|
||||
entt::handle lightEntity3 = world.CreateEntity();
|
||||
|
||||
{
|
||||
auto& bobNode = bobEntity.emplace<Nz::NodeComponent>();
|
||||
@@ -209,7 +202,7 @@ int main()
|
||||
|
||||
auto& sharedSkeleton = bobEntity.emplace<Nz::SharedSkeletonComponent>(skeleton);
|
||||
|
||||
entt::handle sphereEntity = ecs.CreateEntity();
|
||||
entt::handle sphereEntity = world.CreateEntity();
|
||||
{
|
||||
std::shared_ptr<Nz::Mesh> sphereMesh = std::make_shared<Nz::Mesh>();
|
||||
sphereMesh->CreateStatic();
|
||||
@@ -242,7 +235,7 @@ int main()
|
||||
sphereGfx.AttachRenderable(sphereModel, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
entt::handle smallBobEntity = ecs.CreateEntity();
|
||||
entt::handle smallBobEntity = world.CreateEntity();
|
||||
auto& smallBobNode = smallBobEntity.emplace<Nz::NodeComponent>();
|
||||
smallBobNode.SetParentJoint(bobEntity, "LeftHand");
|
||||
|
||||
@@ -297,7 +290,7 @@ int main()
|
||||
sprite->UpdateRenderLayer(1);
|
||||
sprite->Update(Nz::SimpleTextDrawer::Draw("Shadow-mapping !", 72), 0.002f);
|
||||
|
||||
entt::handle textEntity = ecs.CreateEntity();
|
||||
entt::handle textEntity = world.CreateEntity();
|
||||
{
|
||||
auto& entityGfx = textEntity.emplace<Nz::GraphicsComponent>();
|
||||
entityGfx.AttachRenderable(sprite, 1);
|
||||
@@ -307,7 +300,7 @@ int main()
|
||||
entityNode.SetRotation(Nz::EulerAnglesf(-45.f, 0.f, 0.f));
|
||||
}
|
||||
|
||||
entt::handle planeEntity = ecs.CreateEntity();
|
||||
entt::handle planeEntity = world.CreateEntity();
|
||||
Nz::Boxf floorBox;
|
||||
{
|
||||
Nz::MeshParams meshPrimitiveParams;
|
||||
@@ -353,7 +346,7 @@ int main()
|
||||
std::shared_ptr<Nz::Model> boxModel = std::make_shared<Nz::Model>(std::move(boxMeshGfx), boxMesh.GetAABB());
|
||||
boxModel->SetMaterial(0, planeMat);
|
||||
|
||||
entt::handle boxEntity = ecs.CreateEntity();
|
||||
entt::handle boxEntity = world.CreateEntity();
|
||||
boxEntity.emplace<Nz::NodeComponent>().SetPosition(Nz::Vector3f(0.f, 0.25f, -0.5f));
|
||||
boxEntity.emplace<Nz::GraphicsComponent>().AttachRenderable(boxModel, 0xFFFFFFFF);
|
||||
}
|
||||
@@ -517,7 +510,7 @@ int main()
|
||||
|
||||
if (fpsClock.RestartIfOver(Nz::Time::Second()))
|
||||
{
|
||||
mainWindow.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(ecs.GetRegistry().alive()) + " entities");
|
||||
mainWindow.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(world.GetRegistry().alive()) + " entities");
|
||||
fps = 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,3 +5,4 @@ target("Showcase")
|
||||
add_deps("PluginAssimp", { links = {} })
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
// Sources pour https://github.com/NazaraEngine/NazaraEngine/wiki/(FR)-Tutoriel:-%5B01%5D-Hello-World
|
||||
|
||||
#include <Nazara/Core/Application.hpp>
|
||||
#include <Nazara/Core/AppEntitySystemComponent.hpp>
|
||||
#include <Nazara/Core/Systems.hpp>
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Graphics/Components.hpp>
|
||||
#include <Nazara/Graphics/Systems.hpp>
|
||||
#include <Nazara/Platform/AppWindowingComponent.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Utility/Components.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
@@ -20,11 +15,12 @@ int main()
|
||||
Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1280, 720), "Tut01 - Hello world");
|
||||
|
||||
auto& ecs = app.AddComponent<Nz::AppEntitySystemComponent>();
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
|
||||
Nz::RenderSystem& renderSystem = ecs.AddSystem<Nz::RenderSystem>();
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow);
|
||||
|
||||
entt::handle cameraEntity = ecs.CreateEntity();
|
||||
entt::handle cameraEntity = world.CreateEntity();
|
||||
{
|
||||
cameraEntity.emplace<Nz::NodeComponent>();
|
||||
|
||||
@@ -40,7 +36,7 @@ int main()
|
||||
std::shared_ptr<Nz::TextSprite> textSprite = std::make_shared<Nz::TextSprite>();
|
||||
textSprite->Update(textDrawer);
|
||||
|
||||
entt::handle textEntity = ecs.CreateEntity();
|
||||
entt::handle textEntity = world.CreateEntity();
|
||||
{
|
||||
auto& nodeComponent = textEntity.emplace<Nz::NodeComponent>();
|
||||
auto& gfxComponent = textEntity.emplace<Nz::GraphicsComponent>();
|
||||
|
||||
@@ -2,3 +2,4 @@ target("Tut01_HelloWorld")
|
||||
add_deps("NazaraGraphics")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
// Sources pour https://github.com/NazaraEngine/NazaraEngine/wiki/(FR)-Tutoriel:-%5B02%5D-Gestion-des-événements
|
||||
|
||||
#include <Nazara/Core/Application.hpp>
|
||||
#include <Nazara/Core/AppEntitySystemComponent.hpp>
|
||||
#include <Nazara/Core/Systems.hpp>
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Graphics/Components.hpp>
|
||||
#include <Nazara/Graphics/Systems.hpp>
|
||||
#include <Nazara/Platform/AppWindowingComponent.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Utility/Components.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
@@ -20,11 +15,12 @@ int main()
|
||||
Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1280, 720), "Tut02 - Hello world");
|
||||
|
||||
auto& ecs = app.AddComponent<Nz::AppEntitySystemComponent>();
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
|
||||
Nz::RenderSystem& renderSystem = ecs.AddSystem<Nz::RenderSystem>();
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow);
|
||||
|
||||
entt::handle cameraEntity = ecs.CreateEntity();
|
||||
entt::handle cameraEntity = world.CreateEntity();
|
||||
{
|
||||
cameraEntity.emplace<Nz::NodeComponent>();
|
||||
|
||||
@@ -40,7 +36,7 @@ int main()
|
||||
std::shared_ptr<Nz::TextSprite> textSprite = std::make_shared<Nz::TextSprite>();
|
||||
textSprite->Update(textDrawer);
|
||||
|
||||
entt::handle textEntity = ecs.CreateEntity();
|
||||
entt::handle textEntity = world.CreateEntity();
|
||||
{
|
||||
auto& nodeComponent = textEntity.emplace<Nz::NodeComponent>();
|
||||
auto& gfxComponent = textEntity.emplace<Nz::GraphicsComponent>();
|
||||
|
||||
@@ -2,3 +2,4 @@ target("Tut02_Events")
|
||||
add_deps("NazaraGraphics")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Core/AppEntitySystemComponent.hpp>
|
||||
#include <Nazara/Core/Systems.hpp>
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Graphics/Components.hpp>
|
||||
#include <Nazara/Graphics/Systems.hpp>
|
||||
#include <Nazara/Math/PidController.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Physics3D/Components.hpp>
|
||||
#include <Nazara/Physics3D/Systems.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Utility/Components.hpp>
|
||||
#include <Nazara/Widgets.hpp>
|
||||
#include <Nazara/Widgets/ImageButtonWidget.hpp>
|
||||
#include <Nazara/Widgets/ScrollAreaWidget.hpp>
|
||||
#include <entt/entt.hpp>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
@@ -40,6 +30,7 @@ int main()
|
||||
Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1920, 1080), "Widget demo");
|
||||
|
||||
auto& ecs = app.AddComponent<Nz::AppEntitySystemComponent>();
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
|
||||
auto& fs = app.AddComponent<Nz::AppFilesystemComponent>();
|
||||
{
|
||||
@@ -50,10 +41,10 @@ int main()
|
||||
fs.Mount("assets", resourceDir);
|
||||
}
|
||||
|
||||
Nz::RenderSystem& renderSystem = ecs.AddSystem<Nz::RenderSystem>();
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow);
|
||||
|
||||
Nz::Canvas canvas2D(ecs.GetRegistry(), mainWindow.GetEventHandler(), mainWindow.GetCursorController().CreateHandle(), 0xFFFFFFFF);
|
||||
Nz::Canvas canvas2D(world, mainWindow.GetEventHandler(), mainWindow.GetCursorController().CreateHandle(), 0xFFFFFFFF);
|
||||
canvas2D.Resize(Nz::Vector2f(mainWindow.GetSize()));
|
||||
|
||||
Nz::LabelWidget* labelWidget = canvas2D.Add<Nz::LabelWidget>();
|
||||
@@ -119,7 +110,7 @@ int main()
|
||||
textAreaWidget2->SetBackgroundColor(Nz::Color::White());
|
||||
textAreaWidget2->SetTextColor(Nz::Color::Black());*/
|
||||
|
||||
entt::handle viewer2D = ecs.CreateEntity();
|
||||
entt::handle viewer2D = world.CreateEntity();
|
||||
{
|
||||
viewer2D.emplace<Nz::NodeComponent>();
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ target("WidgetDemo")
|
||||
add_deps("NazaraGraphics", "NazaraPhysics3D", "NazaraWidgets")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
Reference in New Issue
Block a user