More viewport stuff
This commit is contained in:
@@ -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.
|
//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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public:
|
|||||||
void Draw(double dt);
|
void Draw(double dt);
|
||||||
void DrawText();
|
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 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 AddTextureToDraw(Texture* texture, glm::vec3 position, glm::quat orientation, glm::vec3 scale);
|
||||||
void AddTextToDraw();
|
void AddTextToDraw();
|
||||||
@@ -67,6 +68,16 @@ public:
|
|||||||
private:
|
private:
|
||||||
int m_Width, m_Height;
|
int m_Width, m_Height;
|
||||||
|
|
||||||
|
struct Viewport
|
||||||
|
{
|
||||||
|
float Left;
|
||||||
|
float Top;
|
||||||
|
float Right;
|
||||||
|
float Bottom;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unordered_map<int, Viewport> m_Viewports;
|
||||||
|
|
||||||
struct Light
|
struct Light
|
||||||
{
|
{
|
||||||
glm::vec3 Position;
|
glm::vec3 Position;
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
#include "RenderSystem.h"
|
#include "RenderSystem.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
|
||||||
void Systems::RenderSystem::OnComponentCreated(std::string type, std::shared_ptr<Component> component)
|
void Systems::RenderSystem::OnEntityCommit(EntityID entity)
|
||||||
{
|
{
|
||||||
if(type == "Model")
|
auto viewport = m_World->GetComponent<Components::Viewport>(entity, "Viewport");
|
||||||
|
if (viewport)
|
||||||
{
|
{
|
||||||
auto modelComponent = std::static_pointer_cast<Components::Model>(component);
|
m_Renderer->CreateViewport(entity, viewport->Left, viewport->Top, viewport->Right, viewport->Bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,4 +96,3 @@ void Systems::RenderSystem::RegisterResourceTypes(ResourceManager* rm)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "Components/Sprite.h"
|
#include "Components/Sprite.h"
|
||||||
#include "Components/PointLight.h"
|
#include "Components/PointLight.h"
|
||||||
#include "Components/DirectionalLight.h"
|
#include "Components/DirectionalLight.h"
|
||||||
|
#include "Components/Viewport.h"
|
||||||
|
|
||||||
#include "Components/Template.h"
|
#include "Components/Template.h"
|
||||||
#include "Components/Transform.h"
|
#include "Components/Transform.h"
|
||||||
@@ -34,7 +35,7 @@ public:
|
|||||||
|
|
||||||
std::unordered_map<std::string, std::shared_ptr<Model>> m_CachedModels;
|
std::unordered_map<std::string, std::shared_ptr<Model>> m_CachedModels;
|
||||||
|
|
||||||
void OnComponentCreated(std::string type, std:: shared_ptr<Component> component) override;
|
void OnEntityCommit(EntityID entity);
|
||||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user