// Sources pour https://github.com/NazaraEngine/NazaraEngine/wiki/(FR)-Tutoriel:-%5B01%5D-Hello-World #include #include #include #include #include #include int main(int argc, char* argv[]) { // Mise en place de l'application, de la fenêtre et du monde Nz::Application app(argc, argv); auto& windowing = app.AddComponent(); Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1280, 720), "Tut01 - Hello world"); auto& ecs = app.AddComponent(); auto& world = ecs.AddWorld(); auto& renderSystem = world.AddSystem(); Nz::WindowSwapchain& windowSwapchain = renderSystem.CreateSwapchain(mainWindow); // Création de la caméra entt::handle cameraEntity = world.CreateEntity(); { cameraEntity.emplace(); auto& cameraComponent = cameraEntity.emplace(std::make_shared(windowSwapchain), Nz::ProjectionType::Orthographic); cameraComponent.UpdateClearColor(Nz::Color(0.46f, 0.48f, 0.84f, 1.f)); } // Création d'un texte Nz::SimpleTextDrawer textDrawer; textDrawer.SetText("Hello world !"); textDrawer.SetCharacterSize(72); textDrawer.SetTextOutlineThickness(4.f); std::shared_ptr textSprite = std::make_shared(); textSprite->Update(textDrawer); entt::handle textEntity = world.CreateEntity(); { auto& nodeComponent = textEntity.emplace(); auto& gfxComponent = textEntity.emplace(); gfxComponent.AttachRenderable(textSprite); Nz::Boxf textBox = textSprite->GetAABB(); Nz::Vector2ui windowSize = mainWindow.GetSize(); nodeComponent.SetPosition({ windowSize.x / 2 - textBox.width / 2, windowSize.y / 2 - textBox.height / 2 }); } return app.Run(); }