Merge branch 'main' of git@github.com:Almamu/linux-wallpaperengine.git

This commit is contained in:
Alexis Maiquez 2021-12-04 23:45:09 +01:00
commit 577b81215b
4 changed files with 51 additions and 15 deletions

View File

@ -16,11 +16,17 @@ CImage::CImage (
const glm::vec3& scale,
const glm::vec3& angles,
const glm::vec2& size,
std::string alignment) :
std::string alignment,
const glm::vec3& color,
float alpha,
float brightness) :
CObject (visible, id, std::move(name), Type, origin, scale, angles),
m_size (size),
m_material (material),
m_alignment (std::move(alignment))
m_alignment (std::move(alignment)),
m_color (color),
m_alpha (alpha),
m_brightness (brightness)
{
}
@ -37,6 +43,9 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
auto image_it = data.find ("image");
auto size_val = jsonFindDefault <std::string> (data, "size", "0.0 0.0"); // this one might need some adjustment
auto alignment = jsonFindDefault <std::string> (data, "alignment", "center");
auto alpha = jsonFindDefault <float> (data, "alpha", 1.0);
auto color_val = jsonFindDefault <std::string> (data, "color", "1.0 1.0 1.0");
auto brightness_val = jsonFindDefault <float> (data, "brightness", 1.0);
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile ((*image_it).get <std::string> (), container));
@ -51,7 +60,10 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
scale,
angles,
WallpaperEngine::Core::aToVector2 (size_val),
alignment
alignment,
WallpaperEngine::Core::aToVector3 (color_val),
alpha,
brightness_val
);
}
@ -70,5 +82,19 @@ const std::string& CImage::getAlignment () const
return this->m_alignment;
}
const float CImage::getAlpha () const
{
return this->m_alpha;
}
const glm::vec3& CImage::getColor () const
{
return this->m_color;
}
const float CImage::getBrightness () const
{
return this->m_brightness;
}
const std::string CImage::Type = "image";

View File

@ -31,6 +31,9 @@ namespace WallpaperEngine::Core::Objects
const Images::CMaterial* getMaterial () const;
const glm::vec2& getSize () const;
const std::string& getAlignment () const;
const float getAlpha () const;
const glm::vec3& getColor () const;
const float getBrightness () const;
protected:
CImage (
@ -42,7 +45,10 @@ namespace WallpaperEngine::Core::Objects
const glm::vec3& scale,
const glm::vec3& angles,
const glm::vec2& size,
std::string alignment
std::string alignment,
const glm::vec3& color,
float alpha,
float brightness
);
static const std::string Type;
@ -51,5 +57,8 @@ namespace WallpaperEngine::Core::Objects
glm::vec2 m_size;
Images::CMaterial* m_material;
std::string m_alignment;
float m_alpha;
float m_brightness;
glm::vec3 m_color;
};
};

View File

@ -24,15 +24,14 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
float xright = 0.0f;
float ybottom = 0.0f;
// TODO: TAKE INTO ACCOUNT SCALE
// depending on the alignment these values might change, for now just support center
if (this->getImage ()->getAlignment () == "center")
{
// calculate the real position of the image
xleft = (-scene_width / 2) + (origin.x - (size.x / 2));
xright = (-scene_width / 2) + (origin.x + (size.x / 2));
ytop = (-scene_height / 2) + origin.y + (size.y / 2);
ybottom = (-scene_height / 2) + (origin.y - (size.y / 2));
xleft = (-scene_width / 2) + (origin.x - (size.x * scale.x / 2));
xright = (-scene_width / 2) + (origin.x + (size.x * scale.x / 2));
ytop = (-scene_height / 2) + origin.y + (size.y * scale.y / 2);
ybottom = (-scene_height / 2) + (origin.y - (size.y * scale.y / 2));
}
else
{
@ -165,8 +164,7 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
this->m_modelViewProjectionScreen =
this->getScene ()->getCamera ()->getProjection () *
this->getScene ()->getCamera ()->getLookAt () *
glm::scale (glm::mat4 (1.0f), scale);
this->getScene ()->getCamera ()->getLookAt ();
this->m_modelViewProjectionPass =
glm::ortho<float> (-size.x / 2, size.x / 2, -size.y / 2, size.y / 2, 0, 10000);

View File

@ -72,6 +72,9 @@ void CPass::render (CFBO* drawTo, ITexture* input, GLuint position, GLuint texco
// set proper viewport based on what we're drawing to
glViewport (0, 0, drawTo->getRealWidth (), drawTo->getRealHeight ());
if (drawTo != this->m_material->getImage ()->getScene ()->getFBO())
glClear (GL_COLOR_BUFFER_BIT);
// set texture blending
if (this->m_pass->getBlendingMode () == "translucent")
{
@ -462,10 +465,10 @@ void CPass::setupUniforms ()
}
// register variables like brightness and alpha with some default value
this->addUniform ("g_Brightness", 1.0f);
this->addUniform ("g_UserAlpha", 1.0f);
this->addUniform ("g_Alpha", 1.0f);
this->addUniform ("g_Color", glm::vec3 {1.0f, 1.0f, 1.0f});
this->addUniform ("g_Brightness", this->m_material->getImage ()->getImage ()->getBrightness ());
this->addUniform ("g_UserAlpha", this->m_material->getImage ()->getImage ()->getAlpha ());
this->addUniform ("g_Alpha", this->m_material->getImage ()->getImage ()->getAlpha ());
this->addUniform ("g_Color", this->m_material->getImage ()->getImage ()->getColor ());
// add some external variables
this->addUniform ("g_Time", &g_Time);
// add model-view-projection matrix