diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 8e0fe25..9dfe683 100755 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -868,5 +868,16 @@ void Renderer::UpdateSunProjection() //Pass the bounding box's extents to glOrtho or similar to set up the orthographic projection matrix for the shadow map. } +void Renderer::CreateViewport(int identifier, float left, float top, float right, float bottom) +{ + Viewport v; + v.Left = left; + v.Top = top; + v.Right = right; + v.Bottom = bottom; + m_Viewports[identifier] = v; +} + + diff --git a/src/Renderer.h b/src/Renderer.h index e37d1a8..5bd326b 100755 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -35,6 +35,7 @@ public: void Draw(double dt); void DrawText(); + void CreateViewport(int identifier, float left, float top, float right, float bottom); void AddModelToDraw(Model* model, glm::vec3 position, glm::quat orientation, glm::vec3 scale, bool visible, bool shadowCaster); void AddTextureToDraw(Texture* texture, glm::vec3 position, glm::quat orientation, glm::vec3 scale); void AddTextToDraw(); @@ -67,6 +68,16 @@ public: private: int m_Width, m_Height; + struct Viewport + { + float Left; + float Top; + float Right; + float Bottom; + }; + + std::unordered_map m_Viewports; + struct Light { glm::vec3 Position; diff --git a/src/Systems/RenderSystem.cpp b/src/Systems/RenderSystem.cpp index 4f0e727..ce388c9 100755 --- a/src/Systems/RenderSystem.cpp +++ b/src/Systems/RenderSystem.cpp @@ -2,11 +2,12 @@ #include "RenderSystem.h" #include "World.h" -void Systems::RenderSystem::OnComponentCreated(std::string type, std::shared_ptr component) +void Systems::RenderSystem::OnEntityCommit(EntityID entity) { - if(type == "Model") + auto viewport = m_World->GetComponent(entity, "Viewport"); + if (viewport) { - auto modelComponent = std::static_pointer_cast(component); + m_Renderer->CreateViewport(entity, viewport->Left, viewport->Top, viewport->Right, viewport->Bottom); } } @@ -95,4 +96,3 @@ void Systems::RenderSystem::RegisterResourceTypes(ResourceManager* rm) - diff --git a/src/Systems/RenderSystem.h b/src/Systems/RenderSystem.h index c3cd09a..ab0fa36 100755 --- a/src/Systems/RenderSystem.h +++ b/src/Systems/RenderSystem.h @@ -13,6 +13,7 @@ #include "Components/Sprite.h" #include "Components/PointLight.h" #include "Components/DirectionalLight.h" +#include "Components/Viewport.h" #include "Components/Template.h" #include "Components/Transform.h" @@ -34,7 +35,7 @@ public: std::unordered_map> m_CachedModels; - void OnComponentCreated(std::string type, std:: shared_ptr component) override; + void OnEntityCommit(EntityID entity); void UpdateEntity(double dt, EntityID entity, EntityID parent) override;