Added a Size parameter to View class
Allowing independent from rendertarget size Former-commit-id: c131b6dd95692c72a969bf0cc6edd997911bbe58
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
NzView::NzView() :
|
||||
m_targetRegion(0.f, 0.f, 1.f, 1.f),
|
||||
m_size(0.f),
|
||||
m_target(nullptr),
|
||||
m_frustumUpdated(false),
|
||||
m_projectionMatrixUpdated(false),
|
||||
@@ -20,6 +21,12 @@ m_zNear(-1.f)
|
||||
{
|
||||
}
|
||||
|
||||
NzView::NzView(const NzVector2f& size) :
|
||||
NzView() // On délègue
|
||||
{
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
NzView::~NzView()
|
||||
{
|
||||
if (m_target)
|
||||
@@ -256,10 +263,16 @@ void NzView::UpdateFrustum() const
|
||||
|
||||
void NzView::UpdateProjectionMatrix() const
|
||||
{
|
||||
if (!m_viewportUpdated)
|
||||
UpdateViewport();
|
||||
if (m_size.x <= 0.f || m_size.y <= 0.f) // Si la taille est nulle, on prendra la taille du viewport
|
||||
{
|
||||
if (!m_viewportUpdated)
|
||||
UpdateViewport();
|
||||
|
||||
m_projectionMatrix.MakeOrtho(0.f, m_viewport.width, 0.f, m_viewport.height, m_zNear, m_zFar);
|
||||
}
|
||||
else
|
||||
m_projectionMatrix.MakeOrtho(0.f, m_size.x, 0.f, m_size.y, m_zNear, m_zFar);
|
||||
|
||||
m_projectionMatrix.MakeOrtho(m_viewport.x, m_viewport.x + m_viewport.width, m_viewport.y, m_viewport.y + m_viewport.height, m_zNear, m_zFar);
|
||||
m_projectionMatrixUpdated = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user