Renderer: Replaced RenderTarget::Get[Height|Width] by RenderTarget::GetSize

Utility: Removed Window::Get[Height|Width] methods
This commit is contained in:
Lynix
2017-10-28 23:26:22 +02:00
parent bf8ebbd046
commit d688cecbde
20 changed files with 44 additions and 102 deletions

View File

@@ -307,7 +307,8 @@ int main()
// Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre
// Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved
Nz::Mouse::SetPosition(window.GetWidth() / 2, window.GetHeight() / 2, window);
Nz::Vector2ui size = window.GetSize();
Nz::Mouse::SetPosition(size.x / 2, size.y / 2, window);
break;
}

View File

@@ -251,21 +251,20 @@ bool LogoExample::Update(Ndk::StateMachine& fsm, float elapsedTime)
void LogoExample::ResetParticles(float elapsed)
{
unsigned int width = m_shared.target->GetWidth();
unsigned int height = m_shared.target->GetHeight();
Nz::Vector2ui size = m_shared.target->GetSize();
Nz::Vector2f center = {width / 2.f, height / 2.f};
Nz::Vector2f center = {size.x / 2.f, size.y / 2.f};
Nz::Vector2f offset = center - Nz::Vector2f(Nz::Vector2ui(m_logo.GetSize()) / 2);
std::uniform_real_distribution<float> disX(0.f, float(width));
std::uniform_real_distribution<float> disY(-float(height) * 0.5f, float(height) * 1.5f);
std::uniform_real_distribution<float> disX(0.f, float(size.x));
std::uniform_real_distribution<float> disY(-float(size.y) * 0.5f, float(size.y) * 1.5f);
ParticleData* sprite = static_cast<ParticleData*>(m_particles);
for (PixelData& data : m_pixels)
{
sprite->color = data.color;
sprite->destination = offset + Nz::Vector2f(data.pos);
sprite->position.Set(disX(m_shared.randomGen) - float(width), disY(m_shared.randomGen), 0.f);
sprite->position.Set(disX(m_shared.randomGen) - float(size.x), disY(m_shared.randomGen), 0.f);
sprite->velocity = Nz::Vector2f::Zero();
sprite++;
}

View File

@@ -820,5 +820,6 @@ void SpacebattleExample::OnMouseMoved(const Nz::EventHandler* /*eventHandler*/,
m_turretCannonBaseRotation = Nz::Clamp(m_turretCannonBaseRotation + speed * event.deltaY, -65.f, 40.f);
m_turretBaseRotation -= event.deltaX * speed;
Nz::Mouse::SetPosition(m_shared.target->GetWidth() / 2, m_shared.target->GetHeight() / 2, *m_shared.target);
Nz::Vector2ui size = m_shared.target->GetSize();
Nz::Mouse::SetPosition(size.x / 2, size.y / 2, *m_shared.target);
}

View File

@@ -100,9 +100,10 @@ int main()
Nz::Boxf fpsCountBox = fpsGfx.GetBoundingVolume().aabb;
Nz::Boxf particleCountBox = particleCountGfx.GetBoundingVolume().aabb;
Nz::Vector2ui windowSize = window.GetSize();
demoNameNode.SetPosition(5.f, 5.f);
particleCountNode.SetPosition(5.f, window.GetHeight() - particleCountBox.height - 5.f);
fpsNode.SetPosition(5.f, window.GetHeight() - fpsCountBox.height - particleCountBox.height - 5.f);
particleCountNode.SetPosition(5.f, windowSize.y - particleCountBox.height - 5.f);
fpsNode.SetPosition(5.f, windowSize.x - fpsCountBox.height - particleCountBox.height - 5.f);
shared.demos.push_back(std::make_shared<LogoExample>(shared));

View File

@@ -40,7 +40,8 @@ int main(int argc, char* argv[])
graphicsComponent.Attach(textSprite);
Nz::Boxf textBox = graphicsComponent.GetBoundingVolume().aabb;
nodeComponent.SetPosition(mainWindow.GetWidth() / 2 - textBox.width / 2, mainWindow.GetHeight() / 2 - textBox.height / 2);
Nz::Vector2ui windowSize = mainWindow.GetSize();
nodeComponent.SetPosition(windowSize.x / 2 - textBox.width / 2, windowSize.y / 2 - textBox.height / 2);
while (application.Run())
{