#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);
glm::vec3 GlobalCanvasSettings::m_cam_pos = glm::vec3(0.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;
}

const glm::vec3 &GlobalCanvasSettings::getCameraPosition()
{
	return GlobalCanvasSettings::m_cam_pos;
}

void GlobalCanvasSettings::setCameraPosition(const glm::vec3 &cam_pos)
{
	GlobalCanvasSettings::m_cam_pos = cam_pos;
}

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