Former-commit-id: 9f98c2fea531e23540c213d3c1e4c85391fc9e1a [formerly b3cb8fff86ac0a754b72baf9e6278f20b407ef17] [formerly 8665dec44d98961698bdeaa63e670e2e15de7d1d [formerly d8dfeaae490b2efd430599f2b1fa02c531aa4de6]] Former-commit-id: 51c00f9263c4c7e193bf2ca8de860e03e9d0f402 [formerly d09b90f14e62f85c0056bf4ba872d9975efde1eb] Former-commit-id: f82b2332083d6d6099ebece01e239c99d15f3b5f
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
// Sources pour https://github.com/DigitalPulseSoftware/NazaraEngine/wiki/(FR)-Tutoriel-01---Hello-World
|
|
|
|
#include <Nazara/Graphics.hpp>
|
|
#include <Nazara/Renderer.hpp>
|
|
#include <Nazara/Utility.hpp>
|
|
#include <NDK/Application.hpp>
|
|
#include <NDK/Components.hpp>
|
|
#include <NDK/Systems.hpp>
|
|
#include <NDK/World.hpp>
|
|
#include <iostream>
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
Ndk::Application application(argc, argv);
|
|
|
|
Nz::RenderWindow& mainWindow = application.AddWindow<Nz::RenderWindow>();
|
|
mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test");
|
|
|
|
|
|
Ndk::World& world = application.AddWorld();
|
|
world.GetSystem<Ndk::RenderSystem>().SetGlobalUp(Nz::Vector3f::Down());
|
|
world.GetSystem<Ndk::RenderSystem>().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(192, 100, 100)));
|
|
|
|
|
|
Ndk::EntityHandle viewEntity = world.CreateEntity();
|
|
viewEntity->AddComponent<Ndk::NodeComponent>();
|
|
|
|
Ndk::CameraComponent& viewer = viewEntity->AddComponent<Ndk::CameraComponent>();
|
|
viewer.SetTarget(&mainWindow);
|
|
viewer.SetProjectionType(Nz::ProjectionType_Orthogonal);
|
|
|
|
|
|
Nz::TextSpriteRef textSprite = Nz::TextSprite::New();
|
|
textSprite->Update(Nz::SimpleTextDrawer::Draw("Hello world !", 72));
|
|
|
|
Ndk::EntityHandle text = world.CreateEntity();
|
|
Ndk::NodeComponent& nodeComponent = text->AddComponent<Ndk::NodeComponent>();
|
|
|
|
Ndk::GraphicsComponent& graphicsComponent = text->AddComponent<Ndk::GraphicsComponent>();
|
|
graphicsComponent.Attach(textSprite);
|
|
|
|
Nz::Boxf textBox = graphicsComponent.GetBoundingVolume().aabb;
|
|
nodeComponent.SetPosition(mainWindow.GetWidth() / 2 - textBox.width / 2, mainWindow.GetHeight() / 2 - textBox.height / 2);
|
|
|
|
while (application.Run())
|
|
{
|
|
mainWindow.Display();
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|