mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
chore: more cleanup and fixes
This commit is contained in:
parent
c59c466674
commit
93139b7e21
7
.gitmodules
vendored
7
.gitmodules
vendored
@ -1,21 +1,28 @@
|
||||
[submodule "src/External/glslang-WallpaperEngine"]
|
||||
path = src/External/glslang-WallpaperEngine
|
||||
url = https://github.com/Almamu/glslang-WallpaperEngine.git
|
||||
branch = main
|
||||
[submodule "src/External/SPIRV-Cross-WallpaperEngine"]
|
||||
path = src/External/SPIRV-Cross-WallpaperEngine
|
||||
url = https://github.com/Almamu/SPIRV-Cross-WallpaperEngine.git
|
||||
branch = main
|
||||
[submodule "src/External/stb"]
|
||||
path = src/External/stb
|
||||
url = https://github.com/nothings/stb.git
|
||||
branch = master
|
||||
[submodule "src/External/json"]
|
||||
path = src/External/json
|
||||
url = https://github.com/nlohmann/json.git
|
||||
branch = develop
|
||||
[submodule "src/External/MimeTypes"]
|
||||
path = src/External/MimeTypes
|
||||
url = https://github.com/lasselukkari/MimeTypes.git
|
||||
branch = master
|
||||
[submodule "src/External/kissfft"]
|
||||
path = src/External/kissfft
|
||||
url = https://github.com/mborgerding/kissfft.git
|
||||
branch = master
|
||||
[submodule "src/External/argparse"]
|
||||
path = src/External/argparse
|
||||
url = https://github.com/p-ranav/argparse.git
|
||||
branch = master
|
||||
|
@ -7,7 +7,7 @@ pkgdesc="use steam's wallpaperengine on linux"
|
||||
arch=('x86_64')
|
||||
url="https://github.com/Almamu/linux-wallpaperengine"
|
||||
license=('GPL3')
|
||||
depends=('lz4' 'ffmpeg' 'mpv' 'glfw' 'glew' 'freeglut' 'libpulse' 'fftw')
|
||||
depends=('lz4' 'ffmpeg' 'mpv' 'glfw' 'glew' 'freeglut' 'libpulse')
|
||||
makedepends=('git' 'cmake' 'sdl2' 'glm')
|
||||
provides=("linux-wallpaperengine")
|
||||
source=("${pkgname}::git+https://github.com/Almamu/linux-wallpaperengine.git#branch=main")
|
||||
|
@ -85,8 +85,8 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) :
|
||||
|
||||
const char* str = value.c_str ();
|
||||
const char* delim1 = strchr (str, 'x');
|
||||
const char* delim2 = strchr (str, 'x');
|
||||
const char* delim3 = strchr (str, 'x');
|
||||
const char* delim2 = delim1 ? strchr (delim1, 'x') : nullptr;
|
||||
const char* delim3 = delim2 ? strchr (delim2, 'x') : nullptr;
|
||||
|
||||
if (delim1 == nullptr || delim2 == nullptr || delim3 == nullptr) {
|
||||
sLog.exception ("Window geometry must be in the format: XxYxWxH");
|
||||
@ -177,7 +177,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) :
|
||||
performanceGroup.add_argument ("-f", "--fps")
|
||||
.help ("Limits the FPS to the given number, useful to keep battery consumption low")
|
||||
.default_value (30)
|
||||
.scan<'i', int> ();
|
||||
.store_into(this->settings.render.maximumFPS);
|
||||
|
||||
performanceGroup.add_argument ("--no-fullscreen-pause")
|
||||
.help ("Prevents the background pausing when an app is fullscreen")
|
||||
|
@ -24,7 +24,7 @@ const ITexture* CContainer::readTexture (const std::filesystem::path& filename)
|
||||
glObjectLabel (GL_TEXTURE, result->getTextureID (0), -1, texture.c_str ());
|
||||
#endif /* NDEBUG */
|
||||
|
||||
delete textureContents;
|
||||
delete[] textureContents;
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -87,7 +87,7 @@ std::string CContainer::readFileAsString (const std::filesystem::path& filename)
|
||||
|
||||
// free the intermediate buffer used to generate the std::string
|
||||
delete [] buffer;
|
||||
delete contents;
|
||||
delete [] contents;
|
||||
|
||||
return result;
|
||||
}
|
@ -25,7 +25,7 @@ class CContainer {
|
||||
* Reads the given file from the container and returns it's data
|
||||
* Additionally sets a length parameter to return back the file's length
|
||||
*
|
||||
* The returned string must be freed by the called
|
||||
* The returned string must be deleted[] by the caller
|
||||
*
|
||||
* @param filename The file to read
|
||||
* @param length The file's length after it's been read, null for not getting anything back
|
||||
|
@ -51,25 +51,16 @@ std::filesystem::path CDirectory::resolveRealFile (const std::filesystem::path&
|
||||
}
|
||||
|
||||
const uint8_t* CDirectory::readFile (const std::filesystem::path& filename, uint32_t* length) const {
|
||||
try {
|
||||
std::filesystem::path final = this->resolveRealFile (filename);
|
||||
|
||||
// first check the cache, if the file is there already just return the data in there
|
||||
const auto it = this->m_cache.find (final);
|
||||
|
||||
if (it != this->m_cache.end ()) {
|
||||
if (length != nullptr)
|
||||
*length = it->second.length;
|
||||
|
||||
return it->second.address;
|
||||
}
|
||||
|
||||
FILE* fp = fopen (final.c_str (), "rb");
|
||||
|
||||
|
||||
if (fp == nullptr) {
|
||||
throw CAssetLoadException (filename, "Cannot open file for reading");
|
||||
}
|
||||
|
||||
try {
|
||||
// go to the end, get the position and return to the beginning
|
||||
fseek (fp, 0, SEEK_END);
|
||||
const long size = ftell (fp);
|
||||
@ -87,8 +78,10 @@ const uint8_t* CDirectory::readFile (const std::filesystem::path& filename, uint
|
||||
*length = size;
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
return contents;
|
||||
} catch (std::filesystem::filesystem_error& e) {
|
||||
fclose (fp);
|
||||
throw CAssetLoadException (filename, e.what ());
|
||||
}
|
||||
}
|
@ -24,7 +24,5 @@ class CDirectory final : public CContainer {
|
||||
private:
|
||||
/** The basepath for the directory */
|
||||
std::filesystem::path m_basepath;
|
||||
/** File cache to simplify access to data */
|
||||
std::map<std::filesystem::path, CFileEntry> m_cache;
|
||||
};
|
||||
} // namespace WallpaperEngine::Assets
|
@ -166,21 +166,21 @@ CTexture::~CTexture () {
|
||||
|
||||
GLuint CTexture::getTextureID (uint32_t imageIndex) const {
|
||||
// ensure we do not go out of bounds
|
||||
if (imageIndex > this->m_header->imageCount)
|
||||
if (imageIndex >= this->m_header->imageCount)
|
||||
return this->m_textureID [0];
|
||||
|
||||
return this->m_textureID [imageIndex];
|
||||
}
|
||||
|
||||
uint32_t CTexture::getTextureWidth (uint32_t imageIndex) const {
|
||||
if (imageIndex > this->m_header->imageCount)
|
||||
if (imageIndex >= this->m_header->imageCount)
|
||||
return this->getHeader ()->textureWidth;
|
||||
|
||||
return (*this->m_header->images [imageIndex].begin ())->width;
|
||||
}
|
||||
|
||||
uint32_t CTexture::getTextureHeight (uint32_t imageIndex) const {
|
||||
if (imageIndex > this->m_header->imageCount)
|
||||
if (imageIndex >= this->m_header->imageCount)
|
||||
return this->getHeader ()->textureHeight;
|
||||
|
||||
return (*this->m_header->images [imageIndex].begin ())->height;
|
||||
@ -436,8 +436,10 @@ CTexture::TextureMipmap* CTexture::parseMipmap (const TextureHeader* header, con
|
||||
mipmap->json += *fileData++;
|
||||
}
|
||||
|
||||
// skip the null terminator
|
||||
fileData ++;
|
||||
|
||||
pointer = reinterpret_cast<const uint32_t*> (fileData);
|
||||
pointer ++;
|
||||
}
|
||||
|
||||
mipmap->width = *pointer++;
|
||||
|
@ -5,6 +5,14 @@
|
||||
|
||||
using namespace WallpaperEngine::Assets;
|
||||
|
||||
CVirtualContainer::~CVirtualContainer() {
|
||||
for (auto& [_, entry] : this->m_virtualFiles) {
|
||||
delete entry;
|
||||
}
|
||||
|
||||
this->m_virtualFiles.clear();
|
||||
}
|
||||
|
||||
void CVirtualContainer::add (const std::filesystem::path& filename, const uint8_t* contents, uint32_t length) {
|
||||
this->m_virtualFiles.insert (std::make_pair (filename, new CFileEntry (contents, length)));
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
#include "CContainer.h"
|
||||
#include "CFileEntry.h"
|
||||
@ -15,6 +16,8 @@ using json = nlohmann::json;
|
||||
*/
|
||||
class CVirtualContainer final : public CContainer {
|
||||
public:
|
||||
~CVirtualContainer() override;
|
||||
|
||||
/**
|
||||
* Adds a new file to the virtual container
|
||||
*
|
||||
|
@ -60,7 +60,7 @@ CPulseAudioPlayingDetector::~CPulseAudioPlayingDetector () {
|
||||
void CPulseAudioPlayingDetector::update () {
|
||||
if (!this->getApplicationContext ().settings.audio.automute)
|
||||
return this->setIsPlaying (false);
|
||||
if (this->getFullscreenDetector ()->anythingFullscreen ())
|
||||
if (this->getFullscreenDetector() != nullptr && this->getFullscreenDetector ()->anythingFullscreen ())
|
||||
return this->setIsPlaying (true);
|
||||
|
||||
// reset playing state
|
||||
|
@ -55,7 +55,7 @@ void pa_stream_read_cb (pa_stream* stream, const size_t /*nbytes*/, void* userda
|
||||
|
||||
if (numberOfFullBuffers > 0) {
|
||||
// calculate the start of the last block (we need the end of the previous block, hence the - 1)
|
||||
size_t startOfLastBuffer = dataToCopy + ((numberOfFullBuffers - 1) * WAVE_BUFFER_SIZE);
|
||||
size_t startOfLastBuffer = std::max(dataToCopy + (numberOfFullBuffers - 1) * WAVE_BUFFER_SIZE, currentSize - WAVE_BUFFER_SIZE);
|
||||
// copy directly into the final buffer
|
||||
memcpy (recorder->audioBuffer, &data [startOfLastBuffer], WAVE_BUFFER_SIZE * sizeof (uint8_t));
|
||||
// copy whatever is left to the read/write buffer
|
||||
@ -106,7 +106,7 @@ void pa_server_info_cb (pa_context* ctx, const pa_server_info* info, void* userd
|
||||
monitor_name += ".monitor";
|
||||
|
||||
// setup latency
|
||||
pa_buffer_attr attr = {0};
|
||||
pa_buffer_attr attr {};
|
||||
|
||||
// 10 = latency msecs, 750 = max msecs to store
|
||||
size_t bytesPerSec = pa_bytes_per_second (&spec);
|
||||
@ -151,7 +151,6 @@ void pa_context_notify_cb (pa_context* ctx, void* userdata) {
|
||||
}
|
||||
|
||||
CPulseAudioPlaybackRecorder::CPulseAudioPlaybackRecorder () :
|
||||
m_captureStream (nullptr),
|
||||
m_captureData({
|
||||
.kisscfg = kiss_fftr_alloc (WAVE_BUFFER_SIZE, 0, nullptr, nullptr),
|
||||
.audioBuffer = new uint8_t [WAVE_BUFFER_SIZE],
|
||||
|
@ -32,7 +32,6 @@ class CPulseAudioPlaybackRecorder final : public CPlaybackRecorder {
|
||||
pa_mainloop* m_mainloop;
|
||||
pa_mainloop_api* m_mainloopApi;
|
||||
pa_context* m_context;
|
||||
pa_stream* m_captureStream;
|
||||
SPulseAudioData m_captureData;
|
||||
|
||||
float m_audioFFTbuffer [WAVE_BUFFER_SIZE];
|
||||
|
@ -26,6 +26,14 @@ CProject::CProject (
|
||||
m_properties (properties),
|
||||
m_supportsaudioprocessing (supportsaudioprocessing) {}
|
||||
|
||||
CProject::~CProject () {
|
||||
for (auto& [_, property] : this->m_properties) {
|
||||
delete property;
|
||||
}
|
||||
|
||||
this->m_properties.clear ();
|
||||
}
|
||||
|
||||
CProject* CProject::fromFile (const std::string& filename, const CContainer* container) {
|
||||
json content = json::parse (container->readFileAsString (filename));
|
||||
|
||||
|
@ -21,6 +21,7 @@ class CWallpaper;
|
||||
|
||||
class CProject {
|
||||
public:
|
||||
~CProject();
|
||||
static CProject* fromFile (const std::string& filename, const CContainer* container);
|
||||
|
||||
[[nodiscard]] const CWallpaper* getWallpaper () const;
|
||||
@ -31,7 +32,7 @@ class CProject {
|
||||
[[nodiscard]] const std::string& getWorkshopId () const;
|
||||
[[nodiscard]] bool supportsAudioProcessing () const;
|
||||
|
||||
const CContainer* getContainer () const;
|
||||
[[nodiscard]] const CContainer* getContainer () const;
|
||||
|
||||
protected:
|
||||
CProject (
|
||||
|
@ -156,6 +156,12 @@ template <typename T> bool typeCheck (const nlohmann::json::const_iterator& valu
|
||||
if (value->type () != nlohmann::detail::value_t::boolean) {
|
||||
return false;
|
||||
}
|
||||
} else if constexpr (
|
||||
std::is_same_v<T, glm::vec2> || std::is_same_v<T, glm::vec3> || std::is_same_v<T, glm::vec4> ||
|
||||
std::is_same_v<T, glm::ivec2> || std::is_same_v<T, glm::ivec3> || std::is_same_v<T, glm::ivec4) {
|
||||
if (value->type () != nlohmann::detail::value_t::string) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,19 +1,18 @@
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include "CDynamicValue.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::DynamicValues;
|
||||
|
||||
CDynamicValue::CDynamicValue() :
|
||||
m_ivec4(new glm::ivec4()),
|
||||
m_ivec3(new glm::ivec3()),
|
||||
m_ivec2(new glm::ivec2()),
|
||||
m_vec4 (new glm::vec4()),
|
||||
m_vec3 (new glm::vec3()),
|
||||
m_vec2 (new glm::vec2()),
|
||||
m_float (new float()),
|
||||
m_int (new int()),
|
||||
m_bool (new bool()),
|
||||
m_ivec4 (),
|
||||
m_ivec3 (),
|
||||
m_ivec2 (),
|
||||
m_vec4 (),
|
||||
m_vec3 (),
|
||||
m_vec2 (),
|
||||
m_float (),
|
||||
m_int (),
|
||||
m_bool (),
|
||||
m_outgoingConnections (),
|
||||
m_incomingConnections () {}
|
||||
|
||||
@ -21,140 +20,130 @@ CDynamicValue::~CDynamicValue() {
|
||||
for (auto* connection : this->m_incomingConnections) {
|
||||
connection->destroyOutgoingConnection (this);
|
||||
}
|
||||
|
||||
delete this->m_ivec4;
|
||||
delete this->m_ivec3;
|
||||
delete this->m_ivec2;
|
||||
delete this->m_vec4;
|
||||
delete this->m_vec3;
|
||||
delete this->m_vec2;
|
||||
delete this->m_float;
|
||||
delete this->m_int;
|
||||
delete this->m_bool;
|
||||
}
|
||||
|
||||
void CDynamicValue::update(float newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(static_cast<int> (newValue));
|
||||
*this->m_ivec3 = glm::ivec3(static_cast<int> (newValue));
|
||||
*this->m_ivec2 = glm::ivec2(static_cast<int> (newValue));
|
||||
*this->m_vec4 = glm::vec4(newValue);
|
||||
*this->m_vec3 = glm::vec3(newValue);
|
||||
*this->m_vec2 = glm::vec2(newValue);
|
||||
*this->m_float = newValue;
|
||||
*this->m_int = static_cast<int> (newValue);
|
||||
*this->m_bool = static_cast<int> (newValue);
|
||||
this->m_ivec4 = glm::ivec4(static_cast<int> (newValue));
|
||||
this->m_ivec3 = glm::ivec3(static_cast<int> (newValue));
|
||||
this->m_ivec2 = glm::ivec2(static_cast<int> (newValue));
|
||||
this->m_vec4 = glm::vec4(newValue);
|
||||
this->m_vec3 = glm::vec3(newValue);
|
||||
this->m_vec2 = glm::vec2(newValue);
|
||||
this->m_float = newValue;
|
||||
this->m_int = static_cast<int> (newValue);
|
||||
this->m_bool = static_cast<int> (newValue) != 0;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
|
||||
void CDynamicValue::update(int newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(newValue);
|
||||
*this->m_ivec3 = glm::ivec3(newValue);
|
||||
*this->m_ivec2 = glm::ivec2(newValue);
|
||||
*this->m_vec4 = glm::vec4(static_cast<float> (newValue));
|
||||
*this->m_vec3 = glm::vec3(static_cast<float> (newValue));
|
||||
*this->m_vec2 = glm::vec2(static_cast<float> (newValue));
|
||||
*this->m_float = static_cast<float> (newValue);
|
||||
*this->m_int = newValue;
|
||||
*this->m_bool = newValue;
|
||||
this->m_ivec4 = glm::ivec4(newValue);
|
||||
this->m_ivec3 = glm::ivec3(newValue);
|
||||
this->m_ivec2 = glm::ivec2(newValue);
|
||||
this->m_vec4 = glm::vec4(static_cast<float> (newValue));
|
||||
this->m_vec3 = glm::vec3(static_cast<float> (newValue));
|
||||
this->m_vec2 = glm::vec2(static_cast<float> (newValue));
|
||||
this->m_float = static_cast<float> (newValue);
|
||||
this->m_int = newValue;
|
||||
this->m_bool = newValue != 0;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
|
||||
void CDynamicValue::update(bool newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(newValue);
|
||||
*this->m_ivec3 = glm::ivec3(newValue);
|
||||
*this->m_ivec2 = glm::ivec2(newValue);
|
||||
*this->m_vec4 = glm::vec4(newValue);
|
||||
*this->m_vec3 = glm::vec3(newValue);
|
||||
*this->m_vec2 = glm::vec2(newValue);
|
||||
*this->m_float = newValue;
|
||||
*this->m_int = newValue;
|
||||
*this->m_bool = newValue;
|
||||
this->m_ivec4 = glm::ivec4(newValue);
|
||||
this->m_ivec3 = glm::ivec3(newValue);
|
||||
this->m_ivec2 = glm::ivec2(newValue);
|
||||
this->m_vec4 = glm::vec4(newValue);
|
||||
this->m_vec3 = glm::vec3(newValue);
|
||||
this->m_vec2 = glm::vec2(newValue);
|
||||
this->m_float = newValue;
|
||||
this->m_int = newValue;
|
||||
this->m_bool = newValue;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
|
||||
void CDynamicValue::update(const glm::vec2& newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(newValue, 0, 0);
|
||||
*this->m_ivec3 = glm::ivec3(newValue, 0);
|
||||
*this->m_ivec2 = glm::ivec2(newValue);
|
||||
*this->m_vec2 = newValue;
|
||||
*this->m_vec3 = glm::vec3(newValue, 0.0f);
|
||||
*this->m_vec4 = glm::vec4(newValue, 0.0f, 0.0f);
|
||||
*this->m_float = newValue.x;
|
||||
*this->m_int = static_cast<int> (newValue.x);
|
||||
*this->m_bool = newValue.x != 0.0f;
|
||||
this->m_ivec4 = glm::ivec4(newValue, 0, 0);
|
||||
this->m_ivec3 = glm::ivec3(newValue, 0);
|
||||
this->m_ivec2 = glm::ivec2(newValue);
|
||||
this->m_vec2 = newValue;
|
||||
this->m_vec3 = glm::vec3(newValue, 0.0f);
|
||||
this->m_vec4 = glm::vec4(newValue, 0.0f, 0.0f);
|
||||
this->m_float = newValue.x;
|
||||
this->m_int = static_cast<int> (newValue.x);
|
||||
this->m_bool = newValue.x != 0.0f;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
|
||||
void CDynamicValue::update(const glm::vec3& newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(newValue, 0);
|
||||
*this->m_ivec3 = glm::ivec3(newValue);
|
||||
*this->m_ivec2 = glm::ivec2(newValue);
|
||||
*this->m_vec2 = glm::vec2(newValue);
|
||||
*this->m_vec3 = newValue;
|
||||
*this->m_vec4 = glm::vec4(newValue, 0.0f);
|
||||
*this->m_float = newValue.x;
|
||||
*this->m_int = static_cast<int> (newValue.x);
|
||||
*this->m_bool = newValue.x != 0.0f;
|
||||
this->m_ivec4 = glm::ivec4(newValue, 0);
|
||||
this->m_ivec3 = glm::ivec3(newValue);
|
||||
this->m_ivec2 = glm::ivec2(newValue);
|
||||
this->m_vec2 = glm::vec2(newValue);
|
||||
this->m_vec3 = newValue;
|
||||
this->m_vec4 = glm::vec4(newValue, 0.0f);
|
||||
this->m_float = newValue.x;
|
||||
this->m_int = static_cast<int> (newValue.x);
|
||||
this->m_bool = newValue.x != 0.0f;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
|
||||
void CDynamicValue::update(const glm::vec4& newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(newValue);
|
||||
*this->m_ivec3 = glm::ivec3(newValue);
|
||||
*this->m_ivec2 = glm::ivec2(newValue);
|
||||
*this->m_vec2 = glm::vec2(newValue);
|
||||
*this->m_vec3 = glm::vec3(newValue);
|
||||
*this->m_vec4 = newValue;
|
||||
*this->m_float = newValue.x;
|
||||
*this->m_int = static_cast<int> (newValue.x);
|
||||
*this->m_bool = newValue.x != 0.0f;
|
||||
this->m_ivec4 = glm::ivec4(newValue);
|
||||
this->m_ivec3 = glm::ivec3(newValue);
|
||||
this->m_ivec2 = glm::ivec2(newValue);
|
||||
this->m_vec2 = glm::vec2(newValue);
|
||||
this->m_vec3 = glm::vec3(newValue);
|
||||
this->m_vec4 = newValue;
|
||||
this->m_float = newValue.x;
|
||||
this->m_int = static_cast<int> (newValue.x);
|
||||
this->m_bool = newValue.x != 0.0f;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
|
||||
void CDynamicValue::update(const glm::ivec2& newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(newValue, 0, 0);
|
||||
*this->m_ivec3 = glm::ivec3(newValue, 0);
|
||||
*this->m_ivec2 = glm::ivec2(newValue);
|
||||
*this->m_vec2 = newValue;
|
||||
*this->m_vec3 = glm::vec3(newValue, 0.0f);
|
||||
*this->m_vec4 = glm::vec4(newValue, 0.0f, 0.0f);
|
||||
*this->m_float = static_cast<float> (newValue.x);
|
||||
*this->m_int = static_cast<int> (newValue.x);
|
||||
*this->m_bool = newValue.x;
|
||||
this->m_ivec4 = glm::ivec4(newValue, 0, 0);
|
||||
this->m_ivec3 = glm::ivec3(newValue, 0);
|
||||
this->m_ivec2 = glm::ivec2(newValue);
|
||||
this->m_vec2 = newValue;
|
||||
this->m_vec3 = glm::vec3(newValue, 0.0f);
|
||||
this->m_vec4 = glm::vec4(newValue, 0.0f, 0.0f);
|
||||
this->m_float = static_cast<float> (newValue.x);
|
||||
this->m_int = static_cast<int> (newValue.x);
|
||||
this->m_bool = newValue.x != 0;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
|
||||
void CDynamicValue::update(const glm::ivec3& newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(newValue, 0);
|
||||
*this->m_ivec3 = glm::ivec3(newValue);
|
||||
*this->m_ivec2 = glm::ivec2(newValue);
|
||||
*this->m_vec2 = glm::vec2(newValue);
|
||||
*this->m_vec3 = newValue;
|
||||
*this->m_vec4 = glm::vec4(newValue, 0.0f);
|
||||
*this->m_float = static_cast<float> (newValue.x);
|
||||
*this->m_int = static_cast<int> (newValue.x);
|
||||
*this->m_bool = newValue.x;
|
||||
this->m_ivec4 = glm::ivec4(newValue, 0);
|
||||
this->m_ivec3 = glm::ivec3(newValue);
|
||||
this->m_ivec2 = glm::ivec2(newValue);
|
||||
this->m_vec2 = glm::vec2(newValue);
|
||||
this->m_vec3 = newValue;
|
||||
this->m_vec4 = glm::vec4(newValue, 0.0f);
|
||||
this->m_float = static_cast<float> (newValue.x);
|
||||
this->m_int = static_cast<int> (newValue.x);
|
||||
this->m_bool = newValue.x != 0;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
|
||||
void CDynamicValue::update(const glm::ivec4& newValue) {
|
||||
*this->m_ivec4 = glm::ivec4(newValue);
|
||||
*this->m_ivec3 = glm::ivec3(newValue);
|
||||
*this->m_ivec2 = glm::ivec2(newValue);
|
||||
*this->m_vec2 = glm::vec2(newValue);
|
||||
*this->m_vec3 = glm::vec3(newValue);
|
||||
*this->m_vec4 = newValue;
|
||||
*this->m_float = static_cast<float> (newValue.x);
|
||||
*this->m_int = static_cast<int> (newValue.x);
|
||||
*this->m_bool = newValue.x;
|
||||
this->m_ivec4 = glm::ivec4(newValue);
|
||||
this->m_ivec3 = glm::ivec3(newValue);
|
||||
this->m_ivec2 = glm::ivec2(newValue);
|
||||
this->m_vec2 = glm::vec2(newValue);
|
||||
this->m_vec3 = glm::vec3(newValue);
|
||||
this->m_vec4 = newValue;
|
||||
this->m_float = static_cast<float> (newValue.x);
|
||||
this->m_int = static_cast<int> (newValue.x);
|
||||
this->m_bool = newValue.x != 0;
|
||||
|
||||
this->propagate ();
|
||||
}
|
||||
@ -180,50 +169,50 @@ void CDynamicValue::destroyOutgoingConnection (CDynamicValue* value) const {
|
||||
|
||||
void CDynamicValue::propagate () const {
|
||||
for (auto* cur : this->m_outgoingConnections) {
|
||||
*cur->m_bool = *this->m_bool;
|
||||
*cur->m_int = *this->m_int;
|
||||
*cur->m_float = *this->m_float;
|
||||
*cur->m_ivec2 = *this->m_ivec2;
|
||||
*cur->m_ivec3 = *this->m_ivec3;
|
||||
*cur->m_ivec4 = *this->m_ivec4;
|
||||
*cur->m_vec2 = *this->m_vec2;
|
||||
*cur->m_vec3 = *this->m_vec3;
|
||||
*cur->m_vec4 = *this->m_vec4;
|
||||
cur->m_bool = this->m_bool;
|
||||
cur->m_int = this->m_int;
|
||||
cur->m_float = this->m_float;
|
||||
cur->m_ivec2 = this->m_ivec2;
|
||||
cur->m_ivec3 = this->m_ivec3;
|
||||
cur->m_ivec4 = this->m_ivec4;
|
||||
cur->m_vec2 = this->m_vec2;
|
||||
cur->m_vec3 = this->m_vec3;
|
||||
cur->m_vec4 = this->m_vec4;
|
||||
}
|
||||
}
|
||||
|
||||
const glm::ivec4& CDynamicValue::getIVec4 () const {
|
||||
return *this->m_ivec4;
|
||||
return this->m_ivec4;
|
||||
}
|
||||
|
||||
const glm::ivec3& CDynamicValue::getIVec3 () const {
|
||||
return *this->m_ivec3;
|
||||
return this->m_ivec3;
|
||||
}
|
||||
|
||||
const glm::ivec2& CDynamicValue::getIVec2 () const {
|
||||
return *this->m_ivec2;
|
||||
return this->m_ivec2;
|
||||
}
|
||||
|
||||
const glm::vec4& CDynamicValue::getVec4 () const {
|
||||
return *this->m_vec4;
|
||||
return this->m_vec4;
|
||||
}
|
||||
|
||||
const glm::vec3& CDynamicValue::getVec3 () const {
|
||||
return *this->m_vec3;
|
||||
return this->m_vec3;
|
||||
}
|
||||
|
||||
const glm::vec2& CDynamicValue::getVec2 () const {
|
||||
return *this->m_vec2;
|
||||
return this->m_vec2;
|
||||
}
|
||||
|
||||
const float& CDynamicValue::getFloat () const {
|
||||
return *this->m_float;
|
||||
return this->m_float;
|
||||
}
|
||||
|
||||
const int& CDynamicValue::getInt () const {
|
||||
return *this->m_int;
|
||||
return this->m_int;
|
||||
}
|
||||
|
||||
const bool& CDynamicValue::getBool () const {
|
||||
return *this->m_bool;
|
||||
return this->m_bool;
|
||||
}
|
@ -56,14 +56,14 @@ class CDynamicValue {
|
||||
mutable std::vector<CDynamicValue*> m_outgoingConnections;
|
||||
mutable std::vector<const CDynamicValue*> m_incomingConnections;
|
||||
// different values that we will be casted to automagically
|
||||
glm::ivec4* m_ivec4;
|
||||
glm::ivec3* m_ivec3;
|
||||
glm::ivec2* m_ivec2;
|
||||
glm::vec4* m_vec4;
|
||||
glm::vec3* m_vec3;
|
||||
glm::vec2* m_vec2;
|
||||
float* m_float;
|
||||
int* m_int;
|
||||
bool* m_bool;
|
||||
glm::ivec4 m_ivec4;
|
||||
glm::ivec3 m_ivec3;
|
||||
glm::ivec2 m_ivec2;
|
||||
glm::vec4 m_vec4;
|
||||
glm::vec3 m_vec3;
|
||||
glm::vec2 m_vec2;
|
||||
float m_float;
|
||||
int m_int;
|
||||
bool m_bool;
|
||||
};
|
||||
};
|
@ -191,7 +191,7 @@ std::vector<const Images::CMaterial*> CEffect::materialsFromJSON (
|
||||
const auto bind_it = cur.find ("bind");
|
||||
const auto command_it = cur.find ("command");
|
||||
const auto compose_it = cur.find ("compose");
|
||||
const Images::CMaterial* material;
|
||||
const Images::CMaterial* material = nullptr;
|
||||
|
||||
if (compose_it != cur.end ()) {
|
||||
sLog.error ("Composing materials is not supported yet...");
|
||||
@ -207,7 +207,7 @@ std::vector<const Images::CMaterial*> CEffect::materialsFromJSON (
|
||||
}
|
||||
}
|
||||
|
||||
const Images::CMaterial::OverrideInfo* overrideInfo;
|
||||
const Images::CMaterial::OverrideInfo* overrideInfo = nullptr;
|
||||
const auto overrideIt = overrides.find (materialNumber);
|
||||
|
||||
if (overrideIt != overrides.end ()) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Images/CMaterial.h"
|
||||
|
||||
#include "WallpaperEngine/Core/CObject.h"
|
||||
|
@ -705,15 +705,15 @@ void CPass::addUniform (CShaderVariable* value) {
|
||||
|
||||
void CPass::addUniform (CShaderVariable* value, const CDynamicValue* setting) {
|
||||
if (value->is<CShaderVariableFloat> ()) {
|
||||
this->addUniform (value->getName (), &setting->getFloat ());
|
||||
this->addUniform (value->getName (), setting->getFloat ());
|
||||
} else if (value->is<CShaderVariableInteger> ()) {
|
||||
this->addUniform (value->getName (), &setting->getInt ());
|
||||
this->addUniform (value->getName (), setting->getInt ());
|
||||
} else if (value->is<CShaderVariableVector2> ()) {
|
||||
this->addUniform (value->getName (), &setting->getVec2 ());
|
||||
this->addUniform (value->getName (), setting->getVec2 ());
|
||||
} else if (value->is<CShaderVariableVector3> ()) {
|
||||
this->addUniform (value->getName (), &setting->getVec3 ());
|
||||
this->addUniform (value->getName (), setting->getVec3 ());
|
||||
} else if (value->is<CShaderVariableVector4> ()) {
|
||||
this->addUniform (value->getName (), &setting->getVec4 ());
|
||||
this->addUniform (value->getName (), setting->getVec4 ());
|
||||
} else {
|
||||
sLog.error ("Cannot convert setting dynamic value to ", value->getName (), ". Using default value");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user