#include <opengl-playground/globalcanvassettings.hpp>

glm::mat4 GlobalCanvasSettings::m_proj = glm::mat4(1.0f);
glm::mat4 GlobalCanvasSettings::m_view = glm::mat4(1.0f);
glm::mat4 GlobalCanvasSettings::m_proj_view = glm::mat4(1.0f);

void GlobalCanvasSettings::setProjectionMatrix(const glm::mat4 &proj)
{
	GlobalCanvasSettings::m_proj = proj;
	GlobalCanvasSettings::calculatePVMatrix();
}

void GlobalCanvasSettings::setViewMatrix(const glm::mat4 &view)
{
	GlobalCanvasSettings::m_view = view;
	GlobalCanvasSettings::calculatePVMatrix();
}

const glm::mat4 &GlobalCanvasSettings::getViewMatrix()
{
	return GlobalCanvasSettings::m_view;
}

const glm::mat4 &GlobalCanvasSettings::getProjectionMatrix()
{
	return GlobalCanvasSettings::m_proj;
}

const glm::mat4 &GlobalCanvasSettings::getPVMatrix()
{
	return GlobalCanvasSettings::m_proj_view;
}

void GlobalCanvasSettings::calculatePVMatrix()
{
	GlobalCanvasSettings::m_proj_view = GlobalCanvasSettings::m_proj * GlobalCanvasSettings::m_view;
}
