linux-wallpaperengine/src/WallpaperEngine/Render/CCamera.cpp
Alexis Maiquez 291b7e364a - removed/commented out most irrlicht-specific code
~ written close to equivalent versions in OpenGL code using GLM and GLFW
~ written replacements for texture and package loading to not use irrlicht anymore
~ updated shader compiler as we now don't need to replace attributes anymore
+ added support for texture flags in the texture header (as they're needed for opengl to get proper information)

TODO: REWRITE VIDEO PLAYER SUPPORT AS THIS UPDATE EFFECTIVELY BREAKS IT

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
2021-08-31 01:14:08 +02:00

63 lines
1.6 KiB
C++

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "CCamera.h"
using namespace WallpaperEngine;
using namespace WallpaperEngine::Render;
using namespace WallpaperEngine::Core::Types;
CCamera::CCamera (CScene* scene, const Core::Scenes::CCamera* camera) :
m_camera (camera),
m_scene (scene),
m_isOrthogonal (false)
{
// get the lookat position
// TODO: ENSURE THIS IS ONLY USED WHEN NOT DOING AN ORTOGRAPHIC CAMERA AS IT THROWS OFF POINTS
this->m_lookat = glm::lookAt (this->getEye (), this->getCenter (), this->getUp ());
}
CCamera::~CCamera ()
{
this->m_sceneCamera->remove ();
}
const glm::vec3& CCamera::getCenter () const
{
return this->m_camera->getCenter ();
}
const glm::vec3& CCamera::getEye () const
{
return this->m_camera->getEye ();
}
const glm::vec3& CCamera::getUp () const
{
return this->m_camera->getUp ();
}
const glm::mat4& CCamera::getProjection () const
{
return this->m_projection;
}
const glm::mat4& CCamera::getLookAt () const
{
return this->m_lookat;
}
const bool CCamera::isOrthogonal () const
{
return this->m_isOrthogonal;
}
void CCamera::setOrthogonalProjection (float width, float height)
{
// TODO: GET THE ZNEAR AND ZFAR FROM THE BACKGROUND (IF AVAILABLE)
// get the orthogonal projection (the float is there to ensure the values are casted to float, so maths do work)
this->m_projection = glm::ortho <float> (0, width, 0, height, 0, 1000);
this->m_projection = glm::translate (this->m_projection, this->getEye ());
// update the orthogonal flag
this->m_isOrthogonal = true;
}