Ndk: Add support for 2D rendering

Former-commit-id: bdf9257816c8f48b8c0679647978480785720053
This commit is contained in:
Lynix
2015-09-18 12:34:05 +02:00
parent dd7afa970f
commit 859544eaa7
10 changed files with 140 additions and 11 deletions

View File

@@ -11,7 +11,9 @@
namespace Ndk
{
RenderSystem::RenderSystem()
RenderSystem::RenderSystem() :
m_coordinateSystemMatrix(NzMatrix4f::Identity()),
m_coordinateSystemInvalidated(true)
{
SetDefaultBackground(NzColorBackground::New());
SetUpdateRate(0.f);
@@ -54,6 +56,18 @@ namespace Ndk
{
NazaraUnused(elapsedTime);
// Invalidate every renderable if the coordinate system changed
if (m_coordinateSystemInvalidated)
{
for (const Ndk::EntityHandle& drawable : m_drawables)
{
GraphicsComponent& graphicsComponent = drawable->GetComponent<GraphicsComponent>();
graphicsComponent.InvalidateTransformMatrix();
}
m_coordinateSystemInvalidated = false;
}
for (const Ndk::EntityHandle& camera : m_cameras)
{
CameraComponent& camComponent = camera->GetComponent<CameraComponent>();
@@ -76,7 +90,8 @@ namespace Ndk
LightComponent& lightComponent = light->GetComponent<LightComponent>();
NodeComponent& drawableNode = light->GetComponent<NodeComponent>();
lightComponent.AddToRenderQueue(renderQueue, drawableNode.GetTransformMatrix());
///TODO: Cache somehow?
lightComponent.AddToRenderQueue(renderQueue, m_coordinateSystemMatrix * drawableNode.GetTransformMatrix());
}
NzSceneData sceneData;