mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 05:46:48 +08:00
First attempt at automatically detect orthographic projection's size
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
23585e4a07
commit
4d5cdf57b2
@ -210,7 +210,7 @@ const FloatColor& CScene::getClearColor () const
|
||||
return this->m_clearColor;
|
||||
}
|
||||
|
||||
const Scenes::CProjection* CScene::getOrthogonalProjection () const
|
||||
Scenes::CProjection* CScene::getOrthogonalProjection () const
|
||||
{
|
||||
return this->m_orthogonalProjection;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace WallpaperEngine::Core
|
||||
const double getCameraShakeRoughness() const;
|
||||
const double getCameraShakeSpeed() const;
|
||||
const FloatColor& getClearColor() const;
|
||||
const Scenes::CProjection* getOrthogonalProjection() const;
|
||||
Scenes::CProjection* getOrthogonalProjection() const;
|
||||
const FloatColor& getSkylightColor() const;
|
||||
const Scenes::CCamera* getCamera () const;
|
||||
|
||||
|
@ -8,6 +8,11 @@ CProjection::CProjection (uint32_t width, uint32_t height) :
|
||||
{
|
||||
}
|
||||
|
||||
CProjection::CProjection (bool isAuto) :
|
||||
m_isAuto (isAuto)
|
||||
{
|
||||
}
|
||||
|
||||
const uint32_t& CProjection::getWidth () const
|
||||
{
|
||||
return this->m_width;
|
||||
@ -18,6 +23,21 @@ const uint32_t& CProjection::getHeight () const
|
||||
return this->m_height;
|
||||
}
|
||||
|
||||
const bool CProjection::isAuto () const
|
||||
{
|
||||
return this->m_isAuto;
|
||||
}
|
||||
|
||||
void CProjection::setWidth (uint32_t width)
|
||||
{
|
||||
this->m_width = width;
|
||||
}
|
||||
|
||||
void CProjection::setHeight (uint32_t height)
|
||||
{
|
||||
this->m_height = height;
|
||||
}
|
||||
|
||||
CProjection* CProjection::fromJSON (json data)
|
||||
{
|
||||
auto auto_it = jsonFindDefault <bool> (data, "auto", false);
|
||||
@ -27,7 +47,7 @@ CProjection* CProjection::fromJSON (json data)
|
||||
|
||||
// TODO: PROPERLY SUPPORT AUTO-DETECTING SIZE
|
||||
if (auto_it == true)
|
||||
return new CProjection (1920, 1080);
|
||||
return new CProjection (true);
|
||||
else
|
||||
return new CProjection (
|
||||
*width_it,
|
||||
|
@ -13,10 +13,17 @@ namespace WallpaperEngine::Core::Scenes
|
||||
|
||||
const uint32_t& getWidth () const;
|
||||
const uint32_t& getHeight () const;
|
||||
const bool isAuto () const;
|
||||
|
||||
void setWidth (uint32_t width);
|
||||
void setHeight (uint32_t height);
|
||||
|
||||
protected:
|
||||
CProjection (uint32_t width, uint32_t height);
|
||||
CProjection (bool isAuto);
|
||||
private:
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
bool m_isAuto;
|
||||
};
|
||||
};
|
||||
|
@ -14,10 +14,31 @@ CScene::CScene (Core::CScene* scene, CContainer* container, CContext* context) :
|
||||
{
|
||||
// setup the scene camera
|
||||
this->m_camera = new CCamera (this, scene->getCamera ());
|
||||
|
||||
// detect size if the orthogonal project is auto
|
||||
if (scene->getOrthogonalProjection ()->isAuto () == true)
|
||||
{
|
||||
// calculate the size of the projection based on the size of everything
|
||||
auto cur = scene->getObjects ().begin ();
|
||||
auto end = scene->getObjects ().end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
if ((*cur)->is<Core::Objects::CImage> () == false)
|
||||
continue;
|
||||
|
||||
glm::vec2 size = (*cur)->as <Core::Objects::CImage> ()->getSize ();
|
||||
|
||||
scene->getOrthogonalProjection ()->setWidth (size.x);
|
||||
scene->getOrthogonalProjection ()->setHeight (size.y);
|
||||
}
|
||||
}
|
||||
|
||||
this->m_camera->setOrthogonalProjection (
|
||||
scene->getOrthogonalProjection ()->getWidth (),
|
||||
scene->getOrthogonalProjection ()->getHeight ()
|
||||
);
|
||||
|
||||
// setup framebuffers
|
||||
this->setupFramebuffers ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user