chore: more cleanup, default initialization of values wherever possible

This commit is contained in:
Almamu 2025-04-26 04:52:10 +02:00
parent 918b80ae69
commit f5da9a01f6
96 changed files with 345 additions and 442 deletions

View File

@ -6,14 +6,21 @@
#include <sstream>
#include <sys/stat.h>
const char* assets_default_paths [] = {".steam/steam/steamapps/common", ".local/share/Steam/steamapps/common",
".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common",
"snap/steam/common/.local/share/Steam/steamapps/common", nullptr};
const char* assets_default_paths [] = {
".steam/steam/steamapps/common",
".local/share/Steam/steamapps/common",
".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common",
"snap/steam/common/.local/share/Steam/steamapps/common",
nullptr
};
const char* workshop_content_default_paths [] = {
".local/share/Steam/steamapps/workshop/content", ".steam/steam/steamapps/workshop/content",
".local/share/Steam/steamapps/workshop/content",
".steam/steam/steamapps/workshop/content",
".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/workshop/content",
"snap/steam/common/.local/share/Steam/steamapps/workshop/content", nullptr};
"snap/steam/common/.local/share/Steam/steamapps/workshop/content",
nullptr
};
std::filesystem::path detectHomepath () {
char* home = getenv ("HOME");

View File

@ -16,44 +16,7 @@ using namespace WallpaperEngine::Application;
CApplicationContext::CApplicationContext (int argc, char* argv []) :
m_argc (argc),
m_argv (argv),
settings ({
.general = {
.onlyListProperties = false,
.dumpStructure = false,
.assets = "",
.defaultBackground = "",
.screenBackgrounds = {},
.properties = {},
.screenScalings = {},
.screenClamps = {},
},
.render = {
.mode = NORMAL_WINDOW,
.maximumFPS = 30,
.pauseOnFullscreen = true,
.window =
{
.geometry = {},
.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs,
.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs,
},
},
.audio = {
.enabled = true,
.volume = 15,
.automute = true,
.audioprocessing = true,
},
.mouse = {
.enabled = true,
},
.screenshot = {
.take = false,
.delay = 5,
.path = "",
},
}) {
m_argv (argv) {
std::string lastScreen;
argparse::ArgumentParser program ("linux-wallpaperengine", "0.0", argparse::default_arguments::help);

View File

@ -104,7 +104,43 @@ class CApplicationContext {
/** The path to where the screenshot must be saved */
std::filesystem::path path;
} screenshot;
} settings;
} settings = {
.general = {
.onlyListProperties = false,
.dumpStructure = false,
.assets = "",
.defaultBackground = "",
.screenBackgrounds = {},
.properties = {},
.screenScalings = {},
.screenClamps = {},
},
.render = {
.mode = NORMAL_WINDOW,
.maximumFPS = 30,
.pauseOnFullscreen = true,
.window =
{
.geometry = {},
.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs,
.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs,
},
},
.audio = {
.enabled = true,
.volume = 15,
.automute = true,
.audioprocessing = true,
},
.mouse = {
.enabled = true,
},
.screenshot = {
.take = false,
.delay = 5,
.path = "",
},
};
CApplicationState state;

View File

@ -10,24 +10,7 @@
#include "WallpaperEngine/Render/CWallpaper.h"
#include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h"
#include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h"
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h"
#endif
#ifdef ENABLE_X11
#include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h"
#endif
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h"
#endif
#include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h"
#ifdef ENABLE_X11
#include "WallpaperEngine/Render/Drivers/Output/CX11Output.h"
#endif
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h"
#endif
#include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h"
@ -126,15 +109,15 @@ class CWallpaperApplication {
/** The application context that contains the current app settings */
CApplicationContext& m_context;
/** Maps screens to backgrounds */
std::map<std::string, std::shared_ptr <Core::CProject>> m_backgrounds;
std::map<std::string, std::shared_ptr <Core::CProject>> m_backgrounds {};
std::unique_ptr <WallpaperEngine::Audio::Drivers::Detectors::CAudioPlayingDetector> m_audioDetector;
std::unique_ptr <WallpaperEngine::Audio::CAudioContext> m_audioContext;
std::unique_ptr <WallpaperEngine::Audio::Drivers::CSDLAudioDriver> m_audioDriver;
std::unique_ptr <WallpaperEngine::Audio::Drivers::Recorders::CPlaybackRecorder> m_audioRecorder;
std::unique_ptr <WallpaperEngine::Render::CRenderContext> m_renderContext;
std::unique_ptr <WallpaperEngine::Render::Drivers::CVideoDriver> m_videoDriver;
std::unique_ptr <WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector> m_fullScreenDetector;
std::unique_ptr <WallpaperEngine::WebBrowser::CWebBrowserContext> m_browserContext;
std::unique_ptr <WallpaperEngine::Audio::Drivers::Detectors::CAudioPlayingDetector> m_audioDetector = nullptr;
std::unique_ptr <WallpaperEngine::Audio::CAudioContext> m_audioContext = nullptr;
std::unique_ptr <WallpaperEngine::Audio::Drivers::CSDLAudioDriver> m_audioDriver = nullptr;
std::unique_ptr <WallpaperEngine::Audio::Drivers::Recorders::CPlaybackRecorder> m_audioRecorder = nullptr;
std::unique_ptr <WallpaperEngine::Render::CRenderContext> m_renderContext = nullptr;
std::unique_ptr <WallpaperEngine::Render::Drivers::CVideoDriver> m_videoDriver = nullptr;
std::unique_ptr <WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector> m_fullScreenDetector = nullptr;
std::unique_ptr <WallpaperEngine::WebBrowser::CWebBrowserContext> m_browserContext = nullptr;
};
} // namespace WallpaperEngine::Application

View File

@ -10,6 +10,6 @@ class CAssetLoadException final : public std::exception {
[[nodiscard]] const char* what () const noexcept override;
private:
std::string m_message;
std::string m_message {};
};
} // namespace WallpaperEngine::Assets

View File

@ -32,6 +32,6 @@ class CCombinedContainer final : public CContainer {
private:
/** The list of containers to search files off from */
std::vector<std::shared_ptr<CContainer>> m_containers;
std::vector<std::shared_ptr<CContainer>> m_containers {};
};
}; // namespace WallpaperEngine::Assets

View File

@ -21,6 +21,6 @@ class CDirectory final : public CContainer {
private:
/** The basepath for the directory */
std::filesystem::path m_basepath;
std::filesystem::path m_basepath {};
};
} // namespace WallpaperEngine::Assets

View File

@ -15,8 +15,8 @@ class CFileEntry {
~CFileEntry() = default;
/** File contents */
std::shared_ptr<const uint8_t[]> content;
std::shared_ptr<const uint8_t[]> content = nullptr;
/** File length */
uint32_t length;
uint32_t length = 0;
};
} // namespace WallpaperEngine::Assets

View File

@ -61,8 +61,8 @@ class CPackage final : public CContainer {
private:
/** The path to the package file */
std::filesystem::path m_path;
std::filesystem::path m_path {};
/** Contents of the package file */
std::map<std::string, std::unique_ptr<CFileEntry>> m_contents;
std::map<std::string, std::unique_ptr<CFileEntry>> m_contents {};
};
} // namespace WallpaperEngine::Assets

View File

@ -10,6 +10,6 @@ class CPackageLoadException final : public std::exception {
[[nodiscard]] const char* what () const noexcept override;
private:
std::string m_message;
std::string m_message {};
};
} // namespace WallpaperEngine::Assets

View File

@ -98,7 +98,7 @@ class CTexture final : public ITexture {
/** Pointer to the uncompressed data */
std::unique_ptr<char[]> uncompressedData = nullptr;
/** JSON data */
std::string json;
std::string json {};
/**
* Performs actual decompression of the compressed data
*/
@ -120,33 +120,33 @@ class CTexture final : public ITexture {
/** The version of the animated data */
AnimatedVersion animatedVersion = AnimatedVersion::TEXSUNKN;
/** Flags with extra texture information */
TextureFlags flags;
TextureFlags flags = TextureFlags::NoFlags;
/** Real width of the texture */
uint32_t width;
uint32_t width = 0;
/** Real height of the texture */
uint32_t height;
uint32_t height = 0;
/** Texture width in memory (power of 2) */
uint32_t textureWidth;
uint32_t textureWidth = 0;
/** Texture height in memory (power of 2) */
uint32_t textureHeight;
uint32_t textureHeight = 0;
/** Gif width */
uint32_t gifWidth;
uint32_t gifWidth = 0;
/** Gif height */
uint32_t gifHeight;
uint32_t gifHeight = 0;
/** Texture data format */
TextureFormat format;
TextureFormat format = TextureFormat::UNKNOWN;
/** Free Image format */
FreeImageFormat freeImageFormat = FreeImageFormat::FIF_UNKNOWN;
/** Indicates if we have an MP4 video */
bool isVideoMp4{};
bool isVideoMp4 = false;
/** The amount of images in the texture file */
uint32_t imageCount;
uint32_t imageCount = 0;
/** Number of mipmap levels on the texture */
uint32_t mipmapCount;
uint32_t mipmapCount = 0;
/** List of mipmaps */
std::map<uint32_t, std::vector<std::shared_ptr<TextureMipmap>>> images;
std::map<uint32_t, std::vector<std::shared_ptr<TextureMipmap>>> images {};
/** List of animation frames */
std::vector<std::shared_ptr<TextureFrame>> frames;
std::vector<std::shared_ptr<TextureFrame>> frames {};
};
public:
@ -206,10 +206,10 @@ class CTexture final : public ITexture {
void setupOpenGLParameters (uint32_t textureID);
/** The texture header */
std::unique_ptr<TextureHeader> m_header;
std::unique_ptr<TextureHeader> m_header = nullptr;
/** OpenGL's texture ID */
GLuint* m_textureID;
GLuint* m_textureID = nullptr;
/** Resolution vector of the texture */
glm::vec4 m_resolution;
glm::vec4 m_resolution {};
};
} // namespace WallpaperEngine::Assets

View File

@ -24,19 +24,19 @@ class ITexture {
virtual ~TextureFrame () = default;
/** The image index of this frame */
uint32_t frameNumber;
uint32_t frameNumber = 0;
/** The amount of time this frame spends being displayed */
float frametime;
float frametime = 0.0f;
/** The x position of the frame in the texture */
float x;
float x = 0.0f;
/** The y position of the frame in the texture */
float y;
float y = 0.0f;
/** The width of the frame in the texture */
float width1;
float width2;
float width1 = 0.0f;
float width2 = 0.0f;
/** The height of the frame in the texture */
float height1;
float height2;
float height1 = 0.0f;
float height2 = 0.0f;
};
/**

View File

@ -5,9 +5,6 @@
#include <iostream>
// maximum size of the queue to prevent reading too much data
#define MAX_QUEUE_SIZE (5 * 1024 * 1024)
#define MIN_FRAMES (25)
#define NO_AUDIO_STREAM (-1)
using namespace WallpaperEngine::Audio;
@ -90,15 +87,11 @@ int64_t audio_seek_data_callback (void* streamarg, int64_t offset, int whence) {
}
CAudioStream::CAudioStream (CAudioContext& context, const std::string& filename) :
m_swrctx (nullptr),
m_audioStream(NO_AUDIO_STREAM),
m_audioContext (context) {
this->loadCustomContent (filename.c_str ());
}
CAudioStream::CAudioStream (CAudioContext& context, std::shared_ptr<const uint8_t[]> buffer, uint32_t length) :
m_swrctx (nullptr),
m_audioStream(NO_AUDIO_STREAM),
m_audioContext (context) {
// setup a custom context first
this->m_formatContext = avformat_alloc_context ();
@ -122,9 +115,7 @@ CAudioStream::CAudioStream (CAudioContext& context, std::shared_ptr<const uint8_
}
CAudioStream::CAudioStream (CAudioContext& audioContext, AVCodecContext* context) :
m_swrctx (nullptr),
m_audioContext (audioContext),
m_audioStream(NO_AUDIO_STREAM),
m_context (context),
m_queue (new PacketQueue) {
this->initialize ();

View File

@ -24,6 +24,10 @@ extern "C" {
#define FF_API_OLD_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_MAJOR < 59)
#endif
#define MAX_QUEUE_SIZE (5 * 1024 * 1024)
#define MIN_FRAMES (25)
#define NO_AUDIO_STREAM (-1)
namespace WallpaperEngine::Audio {
class CAudioContext;
@ -167,23 +171,23 @@ class CAudioStream {
void initialize ();
/** The SwrContext that handles resampling */
SwrContext* m_swrctx;
SwrContext* m_swrctx = nullptr;
/** The audio context this stream will be played under */
CAudioContext& m_audioContext;
/** If this stream was properly initialized or not */
bool m_initialized {};
bool m_initialized = false;
/** Repeat enabled? */
bool m_repeat {};
bool m_repeat = false;
/** The codec context that contains the original audio format information */
AVCodecContext* m_context = nullptr;
/** The format context that controls how data is read off the file */
AVFormatContext* m_formatContext = nullptr;
/** The stream index for the audio being played */
int m_audioStream;
int m_audioStream = NO_AUDIO_STREAM;
/** File data pointer */
std::shared_ptr<const uint8_t[]> m_buffer;
std::shared_ptr<const uint8_t[]> m_buffer = nullptr;
/** The length of the file data pointer */
uint32_t m_length {};
uint32_t m_length = 0;
/** The read position on the file data pointer */
uint32_t m_position = 0;
@ -196,16 +200,16 @@ class CAudioStream {
*/
struct PacketQueue {
#if FF_API_FIFO_OLD_API
AVFifoBuffer* packetList;
AVFifoBuffer* packetList = nullptr;
#else
AVFifo* packetList;
AVFifo* packetList = nullptr;
#endif
int nb_packets;
int size;
int64_t duration;
SDL_mutex* mutex;
SDL_cond* wait;
SDL_cond* cond;
int nb_packets = 0;
int size = 0;
int64_t duration = 0;
SDL_mutex* mutex = nullptr;
SDL_cond* wait = nullptr;
SDL_cond* cond = nullptr;
}* m_queue {};
};
} // namespace WallpaperEngine::Audio

View File

@ -69,7 +69,6 @@ CSDLAudioDriver::CSDLAudioDriver (
Recorders::CPlaybackRecorder& recorder
) :
CAudioDriver (applicationContext, detector, recorder),
m_initialized (false),
m_audioSpec () {
if (SDL_InitSubSystem (SDL_INIT_AUDIO) < 0) {
sLog.error ("Cannot initialize SDL audio system, SDL_GetError: ", SDL_GetError ());

View File

@ -53,10 +53,10 @@ class CSDLAudioDriver final : public CAudioDriver {
/** The device's ID */
SDL_AudioDeviceID m_deviceID;
/** If the driver is initialized or not */
bool m_initialized;
bool m_initialized = false;
/** The sound output configuration */
SDL_AudioSpec m_audioSpec;
SDL_AudioSpec m_audioSpec {};
/** All the playable steams */
std::vector<CSDLAudioBuffer*> m_streams;
std::vector<CSDLAudioBuffer*> m_streams {};
};
} // namespace WallpaperEngine::Audio::Drivers

View File

@ -4,7 +4,6 @@ namespace WallpaperEngine::Audio::Drivers::Detectors {
CAudioPlayingDetector::CAudioPlayingDetector (
Application::CApplicationContext& appContext,
const Render::Drivers::Detectors::CFullScreenDetector& fullscreenDetector) :
m_isPlaying (false),
m_applicationContext (appContext),
m_fullscreenDetector (fullscreenDetector) {}

View File

@ -52,7 +52,7 @@ class CAudioPlayingDetector {
[[nodiscard]] const Render::Drivers::Detectors::CFullScreenDetector& getFullscreenDetector () const;
private:
bool m_isPlaying;
bool m_isPlaying = false;
Application::CApplicationContext& m_applicationContext;
const Render::Drivers::Detectors::CFullScreenDetector& m_fullscreenDetector;

View File

@ -32,10 +32,7 @@ void defaultSinkInfoCallback (pa_context* context, const pa_server_info* info, v
CPulseAudioPlayingDetector::CPulseAudioPlayingDetector (
Application::CApplicationContext& appContext,
const Render::Drivers::Detectors::CFullScreenDetector& fullscreenDetector) :
CAudioPlayingDetector (appContext, fullscreenDetector),
m_mainloop (nullptr),
m_mainloopApi (nullptr),
m_context (nullptr) {
CAudioPlayingDetector (appContext, fullscreenDetector) {
this->m_mainloop = pa_mainloop_new ();
this->m_mainloopApi = pa_mainloop_get_api (this->m_mainloop);
this->m_context = pa_context_new (this->m_mainloopApi, "wallpaperengine");

View File

@ -15,8 +15,8 @@ class CPulseAudioPlayingDetector final : public CAudioPlayingDetector {
void update () override;
private:
pa_mainloop* m_mainloop;
pa_mainloop_api* m_mainloopApi;
pa_context* m_context;
pa_mainloop* m_mainloop = nullptr;
pa_mainloop_api* m_mainloopApi = nullptr;
pa_context* m_context = nullptr;
};
} // namespace WallpaperEngine::Audio::Drivers::Detectors

View File

@ -155,9 +155,7 @@ CPulseAudioPlaybackRecorder::CPulseAudioPlaybackRecorder () :
.kisscfg = kiss_fftr_alloc (WAVE_BUFFER_SIZE, 0, nullptr, nullptr),
.audioBuffer = new uint8_t [WAVE_BUFFER_SIZE],
.audioBufferTmp = new uint8_t [WAVE_BUFFER_SIZE]
}),
m_audioFFTbuffer {0},
m_FFTinfo {0} {
}) {
this->m_mainloop = pa_mainloop_new ();
this->m_mainloopApi = pa_mainloop_get_api (this->m_mainloop);
this->m_context = pa_context_new (this->m_mainloopApi, "wallpaperengine-audioprocessing");

View File

@ -34,7 +34,7 @@ class CPulseAudioPlaybackRecorder final : public CPlaybackRecorder {
pa_context* m_context;
SPulseAudioData m_captureData;
float m_audioFFTbuffer [WAVE_BUFFER_SIZE];
float m_audioFFTbuffer [WAVE_BUFFER_SIZE] = {0.0f};
kiss_fft_cpx m_FFTinfo [WAVE_BUFFER_SIZE / 2 + 1] = {0};
float m_FFTdestination64 [64] = {0};
float m_FFTdestination32 [32] = {0};

View File

@ -72,7 +72,7 @@ class CObject {
private:
const CUserSettingBoolean* m_visible;
int m_id;
int m_id = 0;
const std::string m_name;
const CUserSettingVector3* m_origin;
const CUserSettingVector3* m_scale;

View File

@ -49,6 +49,6 @@ class CProject {
const std::string m_type;
const bool m_supportsaudioprocessing;
const CWallpaper* m_wallpaper;
std::shared_ptr<const CContainer> m_container;
std::shared_ptr<const CContainer> m_container = nullptr;
};
} // namespace WallpaperEngine::Core

View File

@ -3,19 +3,6 @@
using namespace WallpaperEngine::Core::DynamicValues;
CDynamicValue::CDynamicValue() :
m_ivec4 (),
m_ivec3 (),
m_ivec2 (),
m_vec4 (),
m_vec3 (),
m_vec2 (),
m_float (),
m_int (),
m_bool (),
m_outgoingConnections (),
m_incomingConnections () {}
CDynamicValue::~CDynamicValue() {
for (auto* connection : this->m_incomingConnections) {
connection->destroyOutgoingConnection (this);

View File

@ -8,7 +8,6 @@
namespace WallpaperEngine::Core::DynamicValues {
class CDynamicValue {
public:
CDynamicValue ();
~CDynamicValue ();
[[nodiscard]] const glm::ivec4& getIVec4 () const;
@ -53,17 +52,17 @@ class CDynamicValue {
virtual void propagate () const;
private:
mutable std::vector<CDynamicValue*> m_outgoingConnections;
mutable std::vector<const CDynamicValue*> m_incomingConnections;
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 = 0.0f;
int m_int = 0;
bool m_bool = false;
};
};

View File

@ -37,7 +37,7 @@ CEffect::CEffect (
const CEffect* CEffect::fromJSON (
const json& data, const CUserSettingBoolean* visible, const CProject& project, const Images::CMaterial* material,
std::shared_ptr<const CContainer> container
const std::shared_ptr<const CContainer>& container
) {
const auto file = jsonFindRequired <std::string> (data, "file", "Object effect must have a file");
const auto effectpasses_it = data.find ("passes");

View File

@ -33,7 +33,7 @@ class CEffect {
static const CEffect* fromJSON (
const json& data, const CUserSettingBoolean* visible, const CProject& object, const Images::CMaterial* material,
std::shared_ptr<const CContainer> container);
const std::shared_ptr<const CContainer>& container);
/**
* @return List of dependencies for the effect to work

View File

@ -113,10 +113,10 @@ class CImage : public CObject {
/** Override for effects */
const std::vector<const Objects::CEffect*> m_effects;
/** If the image is fullscreen or not */
bool m_fullscreen;
bool m_fullscreen = false;
/** If the image is passthrough or not */
bool m_passthrough;
bool m_passthrough = false;
/** If the image's size should be automatically determined */
bool m_autosize;
bool m_autosize = false;
};
} // namespace WallpaperEngine::Core::Objects

View File

@ -41,7 +41,7 @@ class CSound : public CObject {
private:
/** If the sounds should repeat or not */
bool m_repeat;
bool m_repeat = false;
/** The list of sounds to play */
std::vector<std::string> m_sounds;
};

View File

@ -16,8 +16,7 @@ CPass::CPass (std::string blending, std::string cullmode, std::string depthtest,
m_shader (std::move(shader)),
m_textures (std::move(textures)),
m_combos (std::move(combos)),
m_constants (std::move(constants))
{}
m_constants (std::move(constants)) {}
const CPass* CPass::fromJSON (const json& data, const CMaterial::OverrideInfo* overrides) {
// TODO: FIGURE OUT DEFAULT BLENDING MODE

View File

@ -70,6 +70,6 @@ const glm::vec3& CEmitter::getOrigin () const {
return this->m_origin;
}
double CEmitter::getRate () const {
const double CEmitter::getRate () const {
return this->m_rate;
}

View File

@ -39,7 +39,7 @@ class CEmitter {
/**
* @return The rate of particle emission
*/
[[nodiscard]] double getRate () const;
[[nodiscard]] const double getRate () const;
protected:
CEmitter (
@ -60,6 +60,6 @@ class CEmitter {
/** The center of the emitter */
const glm::vec3 m_origin;
/** The rate of emission */
double m_rate;
const double m_rate;
};
} // namespace WallpaperEngine::Core::Objects::Particles

View File

@ -79,7 +79,7 @@ class CScene : public CWallpaper {
const Scenes::CProjection* m_orthogonalProjection;
const glm::vec3 m_skylightColor;
std::map<uint32_t, const CObject*> m_objects;
std::vector<const CObject*> m_objectsByRenderOrder;
std::map<uint32_t, const CObject*> m_objects = {};
std::vector<const CObject*> m_objectsByRenderOrder = {};
};
} // namespace WallpaperEngine::Core

View File

@ -16,19 +16,16 @@ extern "C"
#include <libswscale/swscale.h>
}
namespace WallpaperEngine::Core::Wallpapers
{
class CWeb : public CWallpaper {
public:
CWeb (std::string filename, const CProject& project);
namespace WallpaperEngine::Core::Wallpapers {
class CWeb : public CWallpaper {
public:
CWeb (std::string filename, const CProject& project);
const std::string& getFilename () const;
const std::string& getFilename () const;
protected:
friend class CWallpaper;
protected:
friend class CWallpaper;
const std::string m_filename;
private:
};
const std::string m_filename;
};
}

View File

@ -6,11 +6,7 @@
using namespace WallpaperEngine::Input::Drivers;
CGLFWMouseInput::CGLFWMouseInput (const Render::Drivers::CGLFWOpenGLDriver& driver) :
m_driver (driver),
m_mousePosition (),
m_reportedPosition (),
m_leftClick (MouseClickStatus::Released),
m_rightClick (MouseClickStatus::Released) {}
m_driver (driver) {}
void CGLFWMouseInput::update () {
if (!this->m_driver.getApp ().getContext ().settings.mouse.enabled) {

View File

@ -42,9 +42,9 @@ class CGLFWMouseInput final : public CMouseInput {
/**
* The current mouse position
*/
glm::dvec2 m_mousePosition;
glm::dvec2 m_reportedPosition;
MouseClickStatus m_leftClick;
MouseClickStatus m_rightClick;
glm::dvec2 m_mousePosition = {};
glm::dvec2 m_reportedPosition = {};
MouseClickStatus m_leftClick = Released;
MouseClickStatus m_rightClick = Released;
};
} // namespace WallpaperEngine::Input::Drivers

View File

@ -5,8 +5,7 @@
using namespace WallpaperEngine::Input::Drivers;
CWaylandMouseInput::CWaylandMouseInput (const WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver& driver) :
m_waylandDriver (driver),
m_pos () {}
m_waylandDriver (driver) {}
void CWaylandMouseInput::update () {}

View File

@ -44,7 +44,7 @@ class CWaylandMouseInput final : public CMouseInput {
*/
const WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver& m_waylandDriver;
glm::dvec2 m_pos;
glm::dvec2 m_pos = {};
};
} // namespace WallpaperEngine::Input::Drivers

View File

@ -80,8 +80,8 @@ class CLog {
return buffer.str ();
}
std::vector<std::ostream*> mOutputs;
std::vector<std::ostream*> mErrors;
std::vector<std::ostream*> mOutputs = {};
std::vector<std::ostream*> mErrors = {};
static std::unique_ptr<CLog> sInstance;
};
} // namespace WallpaperEngine::Logging

View File

@ -9,8 +9,6 @@ using namespace WallpaperEngine::PrettyPrinter;
using namespace WallpaperEngine::Render::Objects;
CPrettyPrinter::CPrettyPrinter () :
m_level (0),
m_buffer (),
m_out (&this->m_buffer) {}
void CPrettyPrinter::printWallpaper (const CWallpaper& wallpaper) {

View File

@ -101,8 +101,8 @@ class CPrettyPrinter {
*/
void printTextureInfo (const ITexture& texture);
int m_level;
std::stringbuf m_buffer;
int m_level = 0;
std::stringbuf m_buffer = {};
std::ostream m_out;
};
}

View File

@ -7,9 +7,6 @@ using namespace WallpaperEngine;
using namespace WallpaperEngine::Render;
CCamera::CCamera (Wallpapers::CScene* scene, const Core::Scenes::CCamera* camera) :
m_isOrthogonal (false),
m_projection (),
m_lookat (),
m_camera (camera),
m_scene (scene) {
// get the lookat position

View File

@ -19,19 +19,19 @@ class CCamera {
void setOrthogonalProjection (float width, float height);
const glm::vec3& getCenter () const;
const glm::vec3& getEye () const;
const glm::vec3& getUp () const;
const glm::mat4& getProjection () const;
const glm::mat4& getLookAt () const;
Wallpapers::CScene* getScene () const;
bool isOrthogonal () const;
[[nodiscard]] const glm::vec3& getCenter () const;
[[nodiscard]] const glm::vec3& getEye () const;
[[nodiscard]] const glm::vec3& getUp () const;
[[nodiscard]] const glm::mat4& getProjection () const;
[[nodiscard]] const glm::mat4& getLookAt () const;
[[nodiscard]] Wallpapers::CScene* getScene () const;
[[nodiscard]] bool isOrthogonal () const;
private:
bool m_isOrthogonal;
glm::mat4 m_projection;
glm::mat4 m_lookat;
bool m_isOrthogonal = false;
glm::mat4 m_projection = {};
glm::mat4 m_lookat = {};
const Core::Scenes::CCamera* m_camera;
Wallpapers::CScene* m_scene;
Wallpapers::CScene* m_scene = nullptr;
};
} // namespace WallpaperEngine::Render

View File

@ -5,10 +5,6 @@ using namespace WallpaperEngine::Render;
CFBO::CFBO (std::string name, ITexture::TextureFormat format, ITexture::TextureFlags flags, float scale,
uint32_t realWidth, uint32_t realHeight, uint32_t textureWidth, uint32_t textureHeight) :
m_framebuffer (GL_NONE),
m_depthbuffer (GL_NONE),
m_texture (GL_NONE),
m_resolution (),
m_scale (scale),
m_name (std::move (name)),
m_format (format),

View File

@ -31,15 +31,15 @@ class CFBO final : public ITexture {
[[nodiscard]] bool isAnimated () const override;
private:
GLuint m_framebuffer;
GLuint m_depthbuffer;
GLuint m_texture;
glm::vec4 m_resolution;
float m_scale;
std::string m_name;
ITexture::TextureFormat m_format;
ITexture::TextureFlags m_flags;
GLuint m_framebuffer = GL_NONE;
GLuint m_depthbuffer = GL_NONE;
GLuint m_texture = GL_NONE;
glm::vec4 m_resolution = {};
float m_scale = 0;
std::string m_name = "";
ITexture::TextureFormat m_format = UNKNOWN;
ITexture::TextureFlags m_flags = NoFlags;
/** Placeholder for frames, FBOs only have ONE */
std::vector<std::shared_ptr<TextureFrame>> m_frames;
std::vector<std::shared_ptr<TextureFrame>> m_frames = {};
};
} // namespace WallpaperEngine::Render

View File

@ -45,7 +45,7 @@ class CObject : public Helpers::CContextAware {
virtual ~CObject () override = default;
private:
Wallpapers::CScene* m_scene;
Wallpapers::CScene* m_scene = nullptr;
const Core::CObject* m_object;
};
} // namespace WallpaperEngine::Render

View File

@ -48,11 +48,11 @@ class CRenderContext {
/** Video driver in use */
Drivers::CVideoDriver& m_driver;
/** Maps screen -> wallpaper list */
std::map<std::string, CWallpaper*> m_wallpapers;
std::map<std::string, CWallpaper*> m_wallpapers = {};
/** App that holds the render context */
CWallpaperApplication& m_app;
/** Texture cache for the render */
CTextureCache* m_textureCache;
CTextureCache* m_textureCache = nullptr;
};
} // namespace Render
} // namespace WallpaperEngine

View File

@ -40,6 +40,6 @@ class CTextureCache final : Helpers::CContextAware {
private:
/** Cached textures */
std::map<std::string, std::shared_ptr<const ITexture>> m_textureCache;
std::map<std::string, std::shared_ptr<const ITexture>> m_textureCache = {};
};
} // namespace WallpaperEngine::Render

View File

@ -179,24 +179,24 @@ class CWallpaper : public Helpers::CContextAware {
[[nodiscard]] const Core::CWallpaper* getWallpaperData () const;
/** The FBO used for scene output */
std::shared_ptr<const CFBO> m_sceneFBO;
std::shared_ptr<const CFBO> m_sceneFBO = nullptr;
private:
/** The texture used for the scene output */
GLuint m_texCoordBuffer;
GLuint m_positionBuffer;
GLuint m_shader;
GLuint m_texCoordBuffer = GL_NONE;
GLuint m_positionBuffer = GL_NONE;
GLuint m_shader = GL_NONE;
// shader variables
GLint g_Texture0;
GLint a_Position;
GLint a_TexCoord;
GLuint m_vaoBuffer;
GLint g_Texture0 = GL_NONE;
GLint a_Position = GL_NONE;
GLint a_TexCoord = GL_NONE;
GLuint m_vaoBuffer = GL_NONE;
/** The framebuffer to draw the background to */
GLuint m_destFramebuffer;
GLuint m_destFramebuffer = GL_NONE;
/** Setups OpenGL's shaders for this wallpaper backbuffer */
void setupShaders ();
/** List of FBOs registered for this wallpaper */
std::map<std::string, std::shared_ptr<const CFBO>> m_fbos;
std::map<std::string, std::shared_ptr<const CFBO>> m_fbos = {};
/** Audio context that is using this wallpaper */
CAudioContext& m_audioContext;
/** Current Wallpaper state */

View File

@ -2,6 +2,9 @@
#include "CVideoFactories.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h"
#ifdef ENABLE_X11
#include "WallpaperEngine/Render/Drivers/Output/CX11Output.h"
#endif
#define GLFW_EXPOSE_NATIVE_X11
#include <GLFW/glfw3native.h>
@ -19,8 +22,7 @@ CGLFWOpenGLDriver::CGLFWOpenGLDriver (
) :
m_mouseInput (*this),
CVideoDriver (app, m_mouseInput),
m_context (context),
m_frameCounter (0) {
m_context (context) {
glfwSetErrorCallback (CustomGLFWErrorHandler);
// initialize glfw

View File

@ -38,8 +38,8 @@ class CGLFWOpenGLDriver final : public CVideoDriver {
private:
CApplicationContext& m_context;
Input::Drivers::CGLFWMouseInput m_mouseInput;
Output::COutput* m_output;
GLFWwindow* m_window;
uint32_t m_frameCounter;
Output::COutput* m_output = nullptr;
GLFWwindow* m_window = nullptr;
uint32_t m_frameCounter = 0;
};
} // namespace WallpaperEngine::Render::Drivers

View File

@ -63,8 +63,8 @@ class CVideoFactories {
using SessionTypeToFactoryType = std::map <std::string, DriverConstructionFunc>;
using WindowModeToSessionType = std::map <CApplicationContext::WINDOW_MODE, SessionTypeToFactoryType>;
SessionTypeToFullscreenDetectorType m_fullscreenFactories;
WindowModeToSessionType m_driverFactories;
SessionTypeToFullscreenDetectorType m_fullscreenFactories = {};
WindowModeToSessionType m_driverFactories = {};
static std::unique_ptr<CVideoFactories> sInstance;
};
} // namespace WallpaperEngine::Render::Drivers

View File

@ -84,21 +84,21 @@ class CWaylandOpenGLDriver final : public CVideoDriver {
[[nodiscard]] SWaylandContext* getWaylandContext ();
/** List of available screens */
std::vector<Output::CWaylandOutputViewport*> m_screens;
std::vector<Output::CWaylandOutputViewport*> m_screens = {};
private:
/** The output used by the driver */
Output::CWaylandOutput m_output;
/** The EGL context in use */
SEGLContext m_eglContext;
SEGLContext m_eglContext = {};
/** The Wayland context in use */
SWaylandContext m_waylandContext;
SWaylandContext m_waylandContext = {};
mutable bool m_requestedExit;
void initEGL ();
void finishEGL () const;
uint32_t m_frameCounter;
uint32_t m_frameCounter = 0;
CApplicationContext& m_context;
CWaylandMouseInput m_mouseInput;

View File

@ -25,8 +25,8 @@ class CWaylandFullScreenDetector final : public CFullScreenDetector {
uint32_t m_fullscreenCount = 0;
friend void handleGlobal (void* data, struct wl_registry* registry, uint32_t name, const char* interface,
uint32_t version);
friend void handleGlobal (
void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
};
} // namespace WallpaperEngine::Render::Drivers::Detectors

View File

@ -98,7 +98,7 @@ bool CX11FullScreenDetector::anythingFullscreen () const {
continue;
// compare width and height with the different screens we have
for (const auto& [viewport, name] : this->m_screens) {
for (const auto& [name, viewport] : this->m_screens) {
if (attribs.x == viewport.x && attribs.y == viewport.y && attribs.width == viewport.z &&
attribs.height == viewport.w) {
isFullscreen = true;
@ -154,7 +154,7 @@ void CX11FullScreenDetector::initialize () {
continue;
// add the screen to the list of screens
this->m_screens.push_back ({{crtc->x, crtc->y, crtc->width, crtc->height}, info->name});
this->m_screens.emplace (std::string (info->name), glm::ivec4 (crtc->x, crtc->y, crtc->width, crtc->height));
XRRFreeCrtcInfo (crtc);
}

View File

@ -24,14 +24,9 @@ class CX11FullScreenDetector final : public CFullScreenDetector {
void initialize ();
void stop ();
struct ScreenInfo {
glm::ivec4 viewport;
std::string name;
};
Display* m_display;
Display* m_display = nullptr;
Window m_root;
std::vector<ScreenInfo> m_screens;
std::map<std::string, glm::ivec4> m_screens = {};
CVideoDriver& m_driver;
};
} // namespace Detectors

View File

@ -3,8 +3,6 @@
using namespace WallpaperEngine::Render::Drivers::Output;
COutput::COutput (CApplicationContext& context, CVideoDriver& driver) :
m_fullWidth (0),
m_fullHeight (0),
m_context (context),
m_driver (driver) {}

View File

@ -42,9 +42,9 @@ class COutput {
virtual void updateRender () const = 0;
protected:
mutable int m_fullWidth;
mutable int m_fullHeight;
mutable std::map<std::string, COutputViewport*> m_viewports;
mutable int m_fullWidth = 0;
mutable int m_fullHeight = 0;
mutable std::map<std::string, COutputViewport*> m_viewports = {};
CApplicationContext& m_context;
CVideoDriver& m_driver;
};

View File

@ -32,8 +32,8 @@ class CWaylandOutputViewport final : public COutputViewport {
*/
CWaylandOpenGLDriver* getDriver ();
wl_output* output;
glm::ivec2 size;
wl_output* output = nullptr;
glm::ivec2 size = {};
uint32_t waylandName;
int scale = 1;
bool initialized = false;
@ -69,7 +69,7 @@ class CWaylandOutputViewport final : public COutputViewport {
void resize ();
private:
CWaylandOpenGLDriver* m_driver;
CWaylandOpenGLDriver* m_driver = nullptr;
};
} // namespace Output
} // namespace WallpaperEngine::Render::Drivers

View File

@ -28,13 +28,13 @@ class CX11Output final : public COutput {
void loadScreenInfo ();
void free ();
Display* m_display;
Display* m_display = nullptr;
Pixmap m_pixmap;
Window m_root;
GC m_gc;
char* m_imageData;
uint32_t m_imageSize;
XImage* m_image;
std::vector<COutputViewport*> m_screens;
char* m_imageData = nullptr;
uint32_t m_imageSize = 0;
XImage* m_image = nullptr;
std::vector<COutputViewport*> m_screens = {};
};
} // namespace WallpaperEngine::Render::Drivers::Output

View File

@ -38,10 +38,10 @@ class CEffect {
void generatePasses ();
void generateFBOs ();
CImage* m_image;
CImage* m_image = nullptr;
const Core::Objects::CEffect* m_effect;
std::map<std::string, std::shared_ptr<const CFBO>> m_fbos;
std::vector<Effects::CMaterial*> m_materials;
std::map<std::string, std::shared_ptr<const CFBO>> m_fbos = {};
std::vector<Effects::CMaterial*> m_materials = {};
};
} // namespace WallpaperEngine::Render::Objects

View File

@ -61,39 +61,39 @@ class CImage final : public CObject {
void updateScreenSpacePosition ();
private:
std::shared_ptr<const ITexture> m_texture;
std::shared_ptr<const ITexture> m_texture = nullptr;
GLuint m_sceneSpacePosition;
GLuint m_copySpacePosition;
GLuint m_passSpacePosition;
GLuint m_texcoordCopy;
GLuint m_texcoordPass;
glm::mat4 m_modelViewProjectionScreen;
glm::mat4 m_modelViewProjectionPass;
glm::mat4 m_modelViewProjectionCopy;
glm::mat4 m_modelViewProjectionScreenInverse;
glm::mat4 m_modelViewProjectionPassInverse;
glm::mat4 m_modelViewProjectionCopyInverse;
glm::mat4 m_modelViewProjectionScreen = {};
glm::mat4 m_modelViewProjectionPass = {};
glm::mat4 m_modelViewProjectionCopy = {};
glm::mat4 m_modelViewProjectionScreenInverse = {};
glm::mat4 m_modelViewProjectionPassInverse = {};
glm::mat4 m_modelViewProjectionCopyInverse = {};
glm::mat4 m_modelMatrix;
glm::mat4 m_viewProjectionMatrix;
glm::mat4 m_modelMatrix = {};
glm::mat4 m_viewProjectionMatrix = {};
std::shared_ptr<const CFBO> m_mainFBO;
std::shared_ptr<const CFBO> m_subFBO;
std::shared_ptr<const CFBO> m_currentMainFBO;
std::shared_ptr<const CFBO> m_currentSubFBO;
std::shared_ptr<const CFBO> m_mainFBO = nullptr;
std::shared_ptr<const CFBO> m_subFBO = nullptr;
std::shared_ptr<const CFBO> m_currentMainFBO = nullptr;
std::shared_ptr<const CFBO> m_currentSubFBO = nullptr;
const Core::Objects::CImage* m_image;
std::vector<CEffect*> m_effects;
Effects::CMaterial* m_material;
Effects::CMaterial* m_colorBlendMaterial;
std::vector<Effects::CPass*> m_passes;
std::vector<CEffect*> m_effects = {};
Effects::CMaterial* m_material = nullptr;
Effects::CMaterial* m_colorBlendMaterial = nullptr;
std::vector<Effects::CPass*> m_passes = {};
glm::vec4 m_pos;
glm::vec4 m_pos = {};
double m_animationTime;
double m_animationTime = 0.0;
bool m_initialized;
bool m_initialized = false;
};
} // namespace WallpaperEngine::Render::Objects

View File

@ -23,8 +23,8 @@ class CSound final : public CObject {
void load ();
private:
std::vector<std::shared_ptr<const uint8_t[]>> m_soundBuffer;
std::vector<Audio::CAudioStream*> m_audioStreams;
std::vector<std::shared_ptr<const uint8_t[]>> m_soundBuffer = {};
std::vector<Audio::CAudioStream*> m_audioStreams = {};
const Core::Objects::CSound* m_sound;
};

View File

@ -37,6 +37,6 @@ class CMaterial final : public Helpers::CContextAware {
const Render::Objects::CEffect* m_effect;
const Core::Objects::Images::CMaterial* m_material;
std::vector<CPass*> m_passes;
std::vector<CPass*> m_passes = {};
};
} // namespace WallpaperEngine::Render::Objects::Effects

View File

@ -148,14 +148,14 @@ class CPass final : public Helpers::CContextAware {
std::shared_ptr<const ITexture> resolveTexture (std::shared_ptr<const ITexture> expected, int index, std::shared_ptr<const ITexture> previous = nullptr);
CMaterial* m_material;
CMaterial* m_material = nullptr;
const Core::Objects::Images::Materials::CPass* m_pass;
std::map<int, std::shared_ptr<const CFBO>> m_fbos;
std::map<std::string, int> m_combos;
std::vector<AttribEntry*> m_attribs;
std::map<std::string, UniformEntry*> m_uniforms;
std::map<std::string, ReferenceUniformEntry*> m_referenceUniforms;
std::string m_blendingmode;
std::map<int, std::shared_ptr<const CFBO>> m_fbos = {};
std::map<std::string, int> m_combos = {};
std::vector<AttribEntry*> m_attribs = {};
std::map<std::string, UniformEntry*> m_uniforms = {};
std::map<std::string, ReferenceUniformEntry*> m_referenceUniforms = {};
std::string m_blendingmode = "";
const glm::mat4* m_modelViewProjectionMatrix;
const glm::mat4* m_modelViewProjectionMatrixInverse;
const glm::mat4* m_modelMatrix;
@ -164,12 +164,12 @@ class CPass final : public Helpers::CContextAware {
/**
* Contains the final map of textures to be used
*/
std::map<int, std::shared_ptr<const ITexture>> m_textures;
std::map<int, std::shared_ptr<const ITexture>> m_textures = {};
Render::Shaders::CShader* m_shader;
Render::Shaders::CShader* m_shader = nullptr;
std::shared_ptr<const CFBO> m_drawTo;
std::shared_ptr<const ITexture> m_input;
std::shared_ptr<const CFBO> m_drawTo = nullptr;
std::shared_ptr<const ITexture> m_input = nullptr;
GLuint m_programID;

View File

@ -129,7 +129,7 @@ CGLSLContext::~CGLSLContext () {
CGLSLContext& CGLSLContext::get () {
if (sInstance == nullptr)
sInstance = std::make_shared<CGLSLContext> ();
sInstance = std::make_unique <CGLSLContext> ();
return *sInstance;
}
@ -195,4 +195,4 @@ std::pair<std::string, std::string> CGLSLContext::toGlsl (const std::string& ver
}
std::shared_ptr<CGLSLContext> CGLSLContext::sInstance = nullptr;
std::unique_ptr <CGLSLContext> CGLSLContext::sInstance = nullptr;

View File

@ -25,6 +25,6 @@ class CGLSLContext {
[[nodiscard]] static CGLSLContext& get ();
private:
static std::shared_ptr<CGLSLContext> sInstance;
static std::unique_ptr <CGLSLContext> sInstance;
};
} // namespace WallpaperEngine::Render::Shaders

View File

@ -85,11 +85,11 @@ class CShader {
/**
* The shader file this instance is loading
*/
std::string m_file;
std::string m_file = "";
/**
* The parameters the shader needs
*/
std::vector<Variables::CShaderVariable*> m_parameters;
std::vector<Variables::CShaderVariable*> m_parameters = {};
/**
* The combos the shader should be generated with
*/

View File

@ -103,27 +103,27 @@ class CShaderUnit {
/**
* The filename of this shader unit
*/
std::string m_file;
std::string m_file = "";
/**
* Shader's original contents
*/
std::string m_content;
std::string m_content = "";
/**
* Includes content to be added on compilation
*/
std::string m_includes;
std::string m_includes = "";
/**
* Shader's content after the preprocessing step
*/
std::string m_preprocessed;
std::string m_preprocessed = "";
/**
* Shader's code after the compilation of glslang and spirv
*/
std::string m_final;
std::string m_final = "";
/**
* The parameters the shader needs
*/
std::vector<Variables::CShaderVariable*> m_parameters;
std::vector<Variables::CShaderVariable*> m_parameters = {};
/**
* Pre-defined values for the combos
*/
@ -131,11 +131,11 @@ class CShaderUnit {
/**
* The combos discovered in the pre-processing step that were not in the combos list
*/
std::map<std::string, int> m_discoveredCombos;
std::map<std::string, int> m_discoveredCombos = {};
/**
* The combos used by this unit that should be added
*/
std::map<std::string, bool> m_usedCombos;
std::map<std::string, bool> m_usedCombos = {};
/**
* The constants defined for this unit
*/
@ -143,7 +143,7 @@ class CShaderUnit {
/** The textures that are already applied to this shader */
const std::map<int, std::string> m_passTextures;
/** The default textures to use when a texture is not applied in a given slot */
std::map<int, std::string> m_defaultTextures;
std::map<int, std::string> m_defaultTextures = {};
/**
* The shader unit this unit is linked to
*/

View File

@ -4,9 +4,6 @@
using namespace WallpaperEngine::Render::Shaders::Variables;
CShaderVariable::CShaderVariable (std::string type) :
m_type (std::move (type)) {}
const std::string& CShaderVariable::getIdentifierName () const {
return this->m_identifierName;
}
@ -15,9 +12,6 @@ const std::string& CShaderVariable::getName () const {
return this->m_name;
}
const std::string& CShaderVariable::getType () const {
return this->m_type;
}
void CShaderVariable::setIdentifierName (std::string identifierName) {
this->m_identifierName = std::move (identifierName);

View File

@ -6,33 +6,36 @@
namespace WallpaperEngine::Render::Shaders::Variables {
class CShaderVariable : public Core::DynamicValues::CDynamicValue {
public:
CShaderVariable (std::string type);
virtual ~CShaderVariable () = default;
template <class T> [[nodiscard]] const T* as () const {
assert (is<T> ());
return reinterpret_cast<const T*> (this);
if (is <T> ()) {
return static_cast <const T*> (this);
}
throw std::bad_cast ();
}
template <class T> [[nodiscard]] T* as () {
assert (is<T> ());
return reinterpret_cast<T*> (this);
if (is <T> ()) {
return static_cast <T*> (this);
}
throw std::bad_cast ();
}
template <class T> [[nodiscard]] bool is () {
return this->m_type == T::Type;
template <class T> [[nodiscard]] bool is () const {
return typeid (*this) == typeid(T);
}
[[nodiscard]] const std::string& getIdentifierName () const;
[[nodiscard]] const std::string& getName () const;
[[nodiscard]] const std::string& getType () const;
void setIdentifierName (std::string identifierName);
void setName (const std::string& name);
private:
std::string m_identifierName;
std::string m_name;
std::string m_type;
std::string m_identifierName = "";
std::string m_name = "";
};
} // namespace WallpaperEngine::Render::Shaders::Variables

View File

@ -5,14 +5,12 @@
using namespace WallpaperEngine::Render::Shaders::Variables;
CShaderVariableFloat::CShaderVariableFloat (float defaultValue) :
CShaderVariable (Type) {
CShaderVariable () {
this->update (defaultValue);
}
CShaderVariableFloat::CShaderVariableFloat (float defaultValue, const std::string& name) :
CShaderVariable (Type) {
CShaderVariable () {
this->setName (name);
this->update (defaultValue);
}
const std::string CShaderVariableFloat::Type = "float";

View File

@ -7,7 +7,5 @@ class CShaderVariableFloat final : public CShaderVariable {
public:
explicit CShaderVariableFloat (float defaultValue);
CShaderVariableFloat (float defaultValue, const std::string& name);
static const std::string Type;
};
} // namespace WallpaperEngine::Render::Shaders::Variables

View File

@ -5,15 +5,12 @@
using namespace WallpaperEngine::Render::Shaders::Variables;
CShaderVariableInteger::CShaderVariableInteger (int32_t defaultValue) :
CShaderVariable (Type) {
CShaderVariable () {
this->update (defaultValue);
}
CShaderVariableInteger::CShaderVariableInteger (int32_t defaultValue, const std::string& name) :
CShaderVariable (Type) {
CShaderVariable () {
this->setName (name);
this->update (defaultValue);
}
const std::string CShaderVariableInteger::Type = "int";

View File

@ -7,7 +7,5 @@ class CShaderVariableInteger final : public CShaderVariable {
public:
explicit CShaderVariableInteger (int32_t defaultValue);
CShaderVariableInteger (int32_t defaultValue, const std::string& name);
static const std::string Type;
};
} // namespace WallpaperEngine::Render::Shaders::Variables

View File

@ -5,14 +5,12 @@
using namespace WallpaperEngine::Render::Shaders::Variables;
CShaderVariableVector2::CShaderVariableVector2 (const glm::vec2& defaultValue) :
CShaderVariable (Type) {
CShaderVariable () {
this->update (defaultValue);
}
CShaderVariableVector2::CShaderVariableVector2 (const glm::vec2& defaultValue, const std::string& name) :
CShaderVariable (Type) {
CShaderVariable () {
this->setName (name);
this->update (defaultValue);
}
const std::string CShaderVariableVector2::Type = "vec2";

View File

@ -8,7 +8,5 @@ class CShaderVariableVector2 final : public CShaderVariable {
public:
explicit CShaderVariableVector2 (const glm::vec2& defaultValue);
CShaderVariableVector2 (const glm::vec2& defaultValue, const std::string& name);
static const std::string Type;
};
} // namespace WallpaperEngine::Render::Shaders::Variables

View File

@ -3,14 +3,12 @@
using namespace WallpaperEngine::Render::Shaders::Variables;
CShaderVariableVector3::CShaderVariableVector3 (const glm::vec3& defaultValue) :
CShaderVariable (Type) {
CShaderVariable () {
this->update (defaultValue);
}
CShaderVariableVector3::CShaderVariableVector3 (const glm::vec3& defaultValue, const std::string& name) :
CShaderVariable (Type) {
CShaderVariable () {
this->setName (name);
this->update (defaultValue);
}
const std::string CShaderVariableVector3::Type = "vec3";

View File

@ -9,7 +9,5 @@ class CShaderVariableVector3 final : public CShaderVariable {
public:
explicit CShaderVariableVector3 (const glm::vec3& defaultValue);
CShaderVariableVector3 (const glm::vec3& defaultValue, const std::string& name);
static const std::string Type;
};
} // namespace WallpaperEngine::Render::Shaders::Variables

View File

@ -5,14 +5,12 @@
using namespace WallpaperEngine::Render::Shaders::Variables;
CShaderVariableVector4::CShaderVariableVector4 (const glm::vec4& defaultValue) :
CShaderVariable (Type) {
CShaderVariable () {
this->update (defaultValue);
}
CShaderVariableVector4::CShaderVariableVector4 (const glm::vec4& defaultValue, const std::string& name) :
CShaderVariable (Type) {
CShaderVariable () {
this->setName (name);
this->update (defaultValue);
}
const std::string CShaderVariableVector4::Type = "vec4";

View File

@ -8,7 +8,5 @@ class CShaderVariableVector4 final : public CShaderVariable {
public:
explicit CShaderVariableVector4 (const glm::vec4& defaultValue);
CShaderVariableVector4 (const glm::vec4& defaultValue, const std::string& name);
static const std::string Type;
};
} // namespace WallpaperEngine::Render::Shaders::Variables

View File

@ -41,15 +41,15 @@ class CScene final : public CWallpaper {
private:
Render::CObject* createObject (const Core::CObject* object);
CCamera* m_camera;
CObject* m_bloomObject;
std::map<int, CObject*> m_objects;
std::vector<CObject*> m_objectsByRenderOrder;
glm::vec2 m_mousePosition;
glm::vec2 m_mousePositionLast;
glm::vec2 m_parallaxDisplacement;
std::shared_ptr<const CFBO> _rt_4FrameBuffer;
std::shared_ptr<const CFBO> _rt_8FrameBuffer;
std::shared_ptr<const CFBO> _rt_Bloom;
CCamera* m_camera = nullptr;
CObject* m_bloomObject = nullptr;
std::map<int, CObject*> m_objects = {};
std::vector<CObject*> m_objectsByRenderOrder = {};
glm::vec2 m_mousePosition = {};
glm::vec2 m_mousePositionLast = {};
glm::vec2 m_parallaxDisplacement = {};
std::shared_ptr<const CFBO> _rt_4FrameBuffer = nullptr;
std::shared_ptr<const CFBO> _rt_8FrameBuffer = nullptr;
std::shared_ptr<const CFBO> _rt_Bloom = nullptr;
};
} // namespace WallpaperEngine::Render::Wallpaper

View File

@ -16,11 +16,7 @@ CVideo::CVideo (
const CWallpaperState::TextureUVsScaling& scalingMode,
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
) :
CWallpaper (video, context, audioContext, scalingMode, clampMode),
m_mpvGl (nullptr),
m_paused (false),
m_width (16),
m_height (16) {
CWallpaper (video, context, audioContext, scalingMode, clampMode) {
double volume = this->getContext ().getApp ().getContext ().settings.audio.volume * 100.0 / 128.0;
// create mpv contexts

View File

@ -29,11 +29,11 @@ class CVideo final : public CWallpaper {
friend class CWallpaper;
private:
mpv_handle* m_mpv;
mpv_render_context* m_mpvGl;
mpv_handle* m_mpv = nullptr;
mpv_render_context* m_mpvGl = nullptr;
bool m_paused;
int64_t m_width;
int64_t m_height;
bool m_paused = false;
int64_t m_width = 16;
int64_t m_height = 16;
};
} // namespace WallpaperEngine::Render::Wallpapers

View File

@ -16,15 +16,7 @@ CWeb::CWeb (
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
) :
CWallpaper (web, context, audioContext, scalingMode, clampMode),
m_browserContext (browserContext),
m_browser (),
m_client (),
m_width (16),
m_height (16),
m_leftClick (WallpaperEngine::Input::MouseClickStatus::Released),
m_rightClick (WallpaperEngine::Input::MouseClickStatus::Released),
m_mousePosition(),
m_mousePositionLast() {
m_browserContext (browserContext) {
// setup framebuffers
this->setupFramebuffers ();

View File

@ -47,17 +47,17 @@ class CWeb : public CWallpaper
private:
WallpaperEngine::WebBrowser::CWebBrowserContext& m_browserContext;
CefRefPtr<CefBrowser> m_browser;
CefRefPtr<WallpaperEngine::WebBrowser::CEF::CBrowserClient> m_client;
CefRefPtr<CefBrowser> m_browser = nullptr;
CefRefPtr<WallpaperEngine::WebBrowser::CEF::CBrowserClient> m_client = nullptr;
WallpaperEngine::WebBrowser::CEF::CRenderHandler* m_renderHandler = nullptr;
int m_width;
int m_height;
int m_width = 16;
int m_height = 17;
WallpaperEngine::Input::MouseClickStatus m_leftClick;
WallpaperEngine::Input::MouseClickStatus m_rightClick;
WallpaperEngine::Input::MouseClickStatus m_leftClick = Input::Released;
WallpaperEngine::Input::MouseClickStatus m_rightClick = Input::Released;
glm::vec2 m_mousePosition;
glm::vec2 m_mousePositionLast;
glm::vec2 m_mousePosition = {};
glm::vec2 m_mousePositionLast = {};
};
}

View File

@ -2,9 +2,8 @@
using namespace WallpaperEngine::WebBrowser::CEF;
CBrowserClient::CBrowserClient(CefRefPtr<CefRenderHandler> ptr)
: m_renderHandler(std::move(ptr))
{}
CBrowserClient::CBrowserClient(CefRefPtr<CefRenderHandler> ptr) :
m_renderHandler(std::move(ptr)) {}
CefRefPtr<CefRenderHandler> CBrowserClient::GetRenderHandler()
{

View File

@ -14,7 +14,7 @@ class CBrowserClient: public CefClient
[[nodiscard]] CefRefPtr<CefRenderHandler> GetRenderHandler() override;
CefRefPtr<CefRenderHandler> m_renderHandler;
CefRefPtr<CefRenderHandler> m_renderHandler = nullptr;
IMPLEMENT_REFCOUNTING(CBrowserClient);
};

View File

@ -2,7 +2,8 @@
using namespace WallpaperEngine::WebBrowser::CEF;
CRenderHandler::CRenderHandler (WallpaperEngine::Render::Wallpapers::CWeb* webdata) : m_webdata (webdata) {}
CRenderHandler::CRenderHandler (WallpaperEngine::Render::Wallpapers::CWeb* webdata) :
m_webdata (webdata) {}
// Required by CEF
void CRenderHandler::GetViewRect (CefRefPtr<CefBrowser> browser, CefRect& rect) {

View File

@ -30,7 +30,7 @@ class CRenderHandler : public CefRenderHandler {
IMPLEMENT_REFCOUNTING (CRenderHandler);
private:
WallpaperEngine::Render::Wallpapers::CWeb* m_webdata;
WallpaperEngine::Render::Wallpapers::CWeb* m_webdata = nullptr;
[[nodiscard]] int getWidth () const;
[[nodiscard]] int getHeight () const;

View File

@ -4,7 +4,6 @@
using namespace WallpaperEngine::WebBrowser::CEF;
CSubprocessApp::CSubprocessApp (WallpaperEngine::Application::CWallpaperApplication& application) :
m_handlerFactories (),
m_application (application) {
for (const auto& [_, info] : this->m_application.getBackgrounds()) {
this->m_handlerFactories [info->getWorkshopId ()] = new CWPSchemeHandlerFactory (info);

View File

@ -20,7 +20,7 @@ class CSubprocessApp : public CefApp {
const std::map<std::string, CWPSchemeHandlerFactory*>& getHandlerFactories () const;
private:
std::map<std::string, CWPSchemeHandlerFactory*> m_handlerFactories;
std::map<std::string, CWPSchemeHandlerFactory*> m_handlerFactories = {};
WallpaperEngine::Application::CWallpaperApplication& m_application;
IMPLEMENT_REFCOUNTING (CSubprocessApp);
DISALLOW_COPY_AND_ASSIGN (CSubprocessApp);

View File

@ -32,13 +32,13 @@ class CWPSchemeHandler : public CefResourceHandler {
CefRefPtr<CefResourceReadCallback> callback) override;
private:
std::shared_ptr<const Core::CProject> m_project;
std::shared_ptr<const Core::CProject> m_project = nullptr;
std::shared_ptr<const Assets::CContainer> m_container;
std::shared_ptr<const uint8_t[]> m_contents;
uint32_t m_filesize;
std::string m_mimeType;
uint32_t m_offset;
std::shared_ptr<const Assets::CContainer> m_container = nullptr;
std::shared_ptr<const uint8_t[]> m_contents = nullptr;
uint32_t m_filesize = 0;
std::string m_mimeType = "";
uint32_t m_offset = 0;
IMPLEMENT_REFCOUNTING(CWPSchemeHandler);

View File

@ -18,7 +18,7 @@ class CWPSchemeHandlerFactory : public CefSchemeHandlerFactory {
static std::string generateSchemeName (const std::string& workshopId);
private:
std::shared_ptr<const Core::CProject> m_project;
std::shared_ptr<const Core::CProject> m_project = nullptr;
IMPLEMENT_REFCOUNTING (CWPSchemeHandlerFactory);
DISALLOW_COPY_AND_ASSIGN (CWPSchemeHandlerFactory);

View File

@ -19,8 +19,8 @@ namespace WallpaperEngine::WebBrowser {
~CWebBrowserContext();
private:
CefRefPtr<CefApp> m_browserApplication;
CefRefPtr<CefCommandLine> m_commandLine;
CefRefPtr<CefApp> m_browserApplication = nullptr;
CefRefPtr<CefCommandLine> m_commandLine = nullptr;
WallpaperEngine::Application::CWallpaperApplication& m_wallpaperApplication;
};
} // namespace WallpaperEngine::WebBrowser