Ndk: Add support for 2D rendering
Former-commit-id: bdf9257816c8f48b8c0679647978480785720053
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user