Small code cleanups

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2023-02-08 14:27:41 +01:00
parent 26f6156f34
commit d2e82e72d8
37 changed files with 111 additions and 91 deletions

View File

@ -16,6 +16,7 @@ bool g_AudioEnabled = true;
int g_AudioVolume = 128; int g_AudioVolume = 128;
using namespace WallpaperEngine::Application; using namespace WallpaperEngine::Application;
using namespace WallpaperEngine::Core;
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context) : CWallpaperApplication::CWallpaperApplication (CApplicationContext& context) :
m_context (context) m_context (context)
@ -136,7 +137,7 @@ void CWallpaperApplication::setupContainer ()
void CWallpaperApplication::loadProject () void CWallpaperApplication::loadProject ()
{ {
this->m_project = CProject::fromFile ("project.json", &this->m_vfs); this->m_project = CProject::fromFile ("project.json", this->m_vfs);
// go to the right folder so the videos will play // go to the right folder so the videos will play
// TODO: stop doing chdir and use full path // TODO: stop doing chdir and use full path
if (this->m_project->getWallpaper ()->is <WallpaperEngine::Core::CVideo> () == true) if (this->m_project->getWallpaper ()->is <WallpaperEngine::Core::CVideo> () == true)
@ -219,12 +220,12 @@ void CWallpaperApplication::show ()
// initialize OpenGL driver // initialize OpenGL driver
WallpaperEngine::Render::Drivers::COpenGLDriver videoDriver (this->m_project->getTitle ().c_str ()); WallpaperEngine::Render::Drivers::COpenGLDriver videoDriver (this->m_project->getTitle ().c_str ());
// initialize render context // initialize render context
WallpaperEngine::Render::CRenderContext context (this->m_context.screens, videoDriver, &this->m_vfs); WallpaperEngine::Render::CRenderContext context (this->m_context.screens, videoDriver, this->m_vfs, *this);
// initialize mouse support // initialize mouse support
context.setMouse (new CMouseInput (videoDriver.getWindow ())); context.setMouse (new CMouseInput (videoDriver.getWindow ()));
// ensure the context knows what wallpaper to render // ensure the context knows what wallpaper to render
context.setWallpaper ( context.setWallpaper (
WallpaperEngine::Render::CWallpaper::fromWallpaper (this->m_project->getWallpaper (), &context, &audioContext) WallpaperEngine::Render::CWallpaper::fromWallpaper (this->m_project->getWallpaper (), context, audioContext)
); );
float startTime, endTime, minimumTime = 1.0f / this->m_context.maximumFPS; float startTime, endTime, minimumTime = 1.0f / this->m_context.maximumFPS;

View File

@ -5,9 +5,13 @@
#include "WallpaperEngine/Core/CProject.h" #include "WallpaperEngine/Core/CProject.h"
#include "WallpaperEngine/Render/CWallpaper.h" #include "WallpaperEngine/Render/CWallpaper.h"
namespace WallpaperEngine::Render
{
class CWallpaper;
}
namespace WallpaperEngine::Application namespace WallpaperEngine::Application
{ {
using namespace WallpaperEngine::Core;
using namespace WallpaperEngine::Assets; using namespace WallpaperEngine::Assets;
class CWallpaperApplication class CWallpaperApplication
@ -24,7 +28,7 @@ namespace WallpaperEngine::Application
void setupProperties (); void setupProperties ();
void takeScreenshot (WallpaperEngine::Render::CWallpaper* wp, const std::filesystem::path& filename, FREE_IMAGE_FORMAT format); void takeScreenshot (WallpaperEngine::Render::CWallpaper* wp, const std::filesystem::path& filename, FREE_IMAGE_FORMAT format);
CProject* m_project; Core::CProject* m_project;
CApplicationContext& m_context; CApplicationContext& m_context;
CCombinedContainer m_vfs; CCombinedContainer m_vfs;
}; };

View File

@ -105,14 +105,14 @@ int64_t audio_seek_data_callback (void* streamarg, int64_t offset, int whence)
return offset; return offset;
} }
CAudioStream::CAudioStream (CAudioContext* context, const std::string& filename) : CAudioStream::CAudioStream (CAudioContext& context, const std::string& filename) :
m_audioContext (context), m_audioContext (context),
m_swrctx (nullptr) m_swrctx (nullptr)
{ {
this->loadCustomContent (filename.c_str ()); this->loadCustomContent (filename.c_str ());
} }
CAudioStream::CAudioStream (CAudioContext* context, const void* buffer, int length) : CAudioStream::CAudioStream (CAudioContext& context, const void* buffer, int length) :
m_audioContext (context), m_audioContext (context),
m_swrctx (nullptr) m_swrctx (nullptr)
{ {
@ -144,7 +144,7 @@ CAudioStream::CAudioStream (CAudioContext* context, const void* buffer, int leng
this->loadCustomContent (); this->loadCustomContent ();
} }
CAudioStream::CAudioStream(CAudioContext* audioContext, AVCodecContext* context) : CAudioStream::CAudioStream(CAudioContext& audioContext, AVCodecContext* context) :
m_context (context), m_context (context),
m_queue (new PacketQueue), m_queue (new PacketQueue),
m_audioContext (audioContext), m_audioContext (audioContext),
@ -220,7 +220,7 @@ void CAudioStream::initialize ()
int64_t out_channel_layout; int64_t out_channel_layout;
// set output audio channels based on the input audio channels // set output audio channels based on the input audio channels
switch (this->m_audioContext->getChannels ()) switch (this->m_audioContext.getChannels ())
{ {
case 1: out_channel_layout = AV_CH_LAYOUT_MONO; break; case 1: out_channel_layout = AV_CH_LAYOUT_MONO; break;
case 2: out_channel_layout = AV_CH_LAYOUT_STEREO; break; case 2: out_channel_layout = AV_CH_LAYOUT_STEREO; break;
@ -233,8 +233,8 @@ void CAudioStream::initialize ()
swr_alloc_set_opts2 ( swr_alloc_set_opts2 (
&this->m_swrctx, &this->m_swrctx,
&this->m_out_channel_layout, &this->m_out_channel_layout,
this->m_audioContext->getFormat (), this->m_audioContext.getFormat (),
this->m_audioContext->getSampleRate (), this->m_audioContext.getSampleRate (),
&this->m_context->ch_layout, &this->m_context->ch_layout,
this->m_context->sample_fmt, this->m_context->sample_fmt,
this->m_context->sample_rate, this->m_context->sample_rate,
@ -658,9 +658,9 @@ int CAudioStream::decodeFrame (uint8_t* audioBuffer, int bufferSize)
// audio resampling // audio resampling
data_size = this->resampleAudio ( data_size = this->resampleAudio (
avFrame, avFrame,
this->m_audioContext->getFormat (), this->m_audioContext.getFormat (),
this->m_audioContext->getChannels (), this->m_audioContext.getChannels (),
this->m_audioContext->getSampleRate (), this->m_audioContext.getSampleRate (),
audioBuffer audioBuffer
); );
assert(data_size <= bufferSize); assert(data_size <= bufferSize);

View File

@ -22,9 +22,9 @@ namespace WallpaperEngine::Audio
class CAudioStream class CAudioStream
{ {
public: public:
CAudioStream (CAudioContext* context, const std::string& filename); CAudioStream (CAudioContext& context, const std::string& filename);
CAudioStream (CAudioContext* context, const void* buffer, int length); CAudioStream (CAudioContext& context, const void* buffer, int length);
CAudioStream (CAudioContext* audioContext, AVCodecContext* context); CAudioStream (CAudioContext& audioContext, AVCodecContext* context);
~CAudioStream (); ~CAudioStream ();
void queuePacket (AVPacket* pkt); void queuePacket (AVPacket* pkt);
@ -70,7 +70,7 @@ namespace WallpaperEngine::Audio
#endif #endif
SwrContext* m_swrctx; SwrContext* m_swrctx;
CAudioContext* m_audioContext; CAudioContext& m_audioContext;
bool m_initialized; bool m_initialized;
bool m_repeat; bool m_repeat;
AVCodecContext* m_context = nullptr; AVCodecContext* m_context = nullptr;

View File

@ -35,7 +35,7 @@ CObject::CObject (
{ {
} }
CObject* CObject::fromJSON (json data, CScene* scene, const CContainer* container) CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& container)
{ {
std::string json = data.dump (); std::string json = data.dump ();

View File

@ -33,7 +33,7 @@ namespace WallpaperEngine::Core
{ {
friend class CScene; friend class CScene;
public: public:
static CObject* fromJSON (json data, CScene* scene, const CContainer* container); static CObject* fromJSON (json data, CScene* scene, const CContainer& container);
template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; } template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; }
template<class T> T* as () { assert (is <T> ()); return (T*) this; } template<class T> T* as () { assert (is <T> ()); return (T*) this; }

View File

@ -9,7 +9,7 @@
using namespace WallpaperEngine::Core; using namespace WallpaperEngine::Core;
using namespace WallpaperEngine::Assets; using namespace WallpaperEngine::Assets;
CProject::CProject (std::string title, std::string type, CWallpaper* wallpaper, CContainer* container) : CProject::CProject (std::string title, std::string type, CWallpaper* wallpaper, CContainer& container) :
m_title (std::move (title)), m_title (std::move (title)),
m_type (std::move (type)), m_type (std::move (type)),
m_wallpaper (wallpaper), m_wallpaper (wallpaper),
@ -18,7 +18,7 @@ CProject::CProject (std::string title, std::string type, CWallpaper* wallpaper,
this->m_wallpaper->setProject (this); this->m_wallpaper->setProject (this);
} }
CProject* CProject::fromFile (const std::string& filename, CContainer* container) CProject* CProject::fromFile (const std::string& filename, CContainer& container)
{ {
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container)); json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container));
@ -89,7 +89,7 @@ const std::vector<Projects::CProperty*>& CProject::getProperties () const
return this->m_properties; return this->m_properties;
} }
CContainer* CProject::getContainer () CContainer& CProject::getContainer ()
{ {
return this->m_container; return this->m_container;
} }

View File

@ -16,7 +16,7 @@ namespace WallpaperEngine::Core
class CProject class CProject
{ {
public: public:
static CProject* fromFile (const std::string& filename, CContainer* container); static CProject* fromFile (const std::string& filename, CContainer& container);
CWallpaper* getWallpaper () const; CWallpaper* getWallpaper () const;
@ -24,10 +24,10 @@ namespace WallpaperEngine::Core
const std::string& getType () const; const std::string& getType () const;
const std::vector<Projects::CProperty*>& getProperties () const; const std::vector<Projects::CProperty*>& getProperties () const;
CContainer* getContainer (); CContainer& getContainer ();
protected: protected:
CProject (std::string title, std::string type, CWallpaper* wallpaper, CContainer* container); CProject (std::string title, std::string type, CWallpaper* wallpaper, CContainer& container);
void insertProperty (Projects::CProperty* property); void insertProperty (Projects::CProperty* property);
private: private:
@ -36,6 +36,6 @@ namespace WallpaperEngine::Core
std::string m_title; std::string m_title;
std::string m_type; std::string m_type;
CWallpaper* m_wallpaper; CWallpaper* m_wallpaper;
CContainer* m_container; CContainer& m_container;
}; };
}; };

View File

@ -9,7 +9,7 @@
using namespace WallpaperEngine::Core; using namespace WallpaperEngine::Core;
CScene::CScene ( CScene::CScene (
CContainer* container, CContainer& container,
Scenes::CCamera* camera, Scenes::CCamera* camera,
glm::vec3 ambientColor, glm::vec3 ambientColor,
CUserSettingBoolean* bloom, CUserSettingBoolean* bloom,
@ -51,7 +51,7 @@ CScene::CScene (
{ {
} }
CScene* CScene::fromFile (const std::string& filename, CContainer* container) CScene* CScene::fromFile (const std::string& filename, CContainer& container)
{ {
std::string stringContent = WallpaperEngine::FileSystem::loadFullFile (filename, container); std::string stringContent = WallpaperEngine::FileSystem::loadFullFile (filename, container);
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container)); json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container));
@ -126,7 +126,7 @@ void CScene::insertObject (CObject* object)
} }
} }
CContainer* CScene::getContainer () CContainer& CScene::getContainer ()
{ {
return this->m_container; return this->m_container;
} }

View File

@ -17,7 +17,7 @@ namespace WallpaperEngine::Core
class CScene : public CWallpaper class CScene : public CWallpaper
{ {
public: public:
static CScene* fromFile (const std::string& filename, CContainer* container); static CScene* fromFile (const std::string& filename, CContainer& container);
const std::map<uint32_t, CObject*>& getObjects () const; const std::map<uint32_t, CObject*>& getObjects () const;
const std::vector<CObject*>& getObjectsByRenderOrder () const; const std::vector<CObject*>& getObjectsByRenderOrder () const;
@ -45,7 +45,7 @@ namespace WallpaperEngine::Core
friend class CWallpaper; friend class CWallpaper;
CScene ( CScene (
CContainer* container, CContainer& container,
Scenes::CCamera* camera, Scenes::CCamera* camera,
glm::vec3 ambientColor, glm::vec3 ambientColor,
CUserSettingBoolean* bloom, CUserSettingBoolean* bloom,
@ -70,9 +70,9 @@ namespace WallpaperEngine::Core
void insertObject (CObject* object); void insertObject (CObject* object);
CContainer* getContainer (); CContainer& getContainer ();
private: private:
CContainer* m_container; CContainer& m_container;
Scenes::CCamera* m_camera; Scenes::CCamera* m_camera;
// data from general section on the json // data from general section on the json

View File

@ -36,7 +36,7 @@ CEffect::CEffect (
{ {
} }
CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, Core::CObject* object, const CContainer* container) CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, Core::CObject* object, const CContainer& container)
{ {
auto file_it = jsonFindRequired (data, "file", "Object effect must have a file"); auto file_it = jsonFindRequired (data, "file", "Object effect must have a file");
auto effectpasses_it = data.find ("passes"); auto effectpasses_it = data.find ("passes");
@ -204,7 +204,7 @@ void CEffect::dependencyFromJSON (json::const_iterator dependencies_it, CEffect*
effect->insertDependency (cur); effect->insertDependency (cur);
} }
void CEffect::materialsFromJSON (json::const_iterator passes_it, CEffect* effect, const CContainer* container) void CEffect::materialsFromJSON (json::const_iterator passes_it, CEffect* effect, const CContainer& container)
{ {
for (const auto& cur : (*passes_it)) for (const auto& cur : (*passes_it))
{ {

View File

@ -35,7 +35,7 @@ namespace WallpaperEngine::Core::Objects
CUserSettingBoolean* visible CUserSettingBoolean* visible
); );
static CEffect* fromJSON (json data, CUserSettingBoolean* visible, Core::CObject* object, const CContainer* container); static CEffect* fromJSON (json data, CUserSettingBoolean* visible, Core::CObject* object, const CContainer& container);
const std::vector<std::string>& getDependencies () const; const std::vector<std::string>& getDependencies () const;
const std::vector<Images::CMaterial*>& getMaterials () const; const std::vector<Images::CMaterial*>& getMaterials () const;
@ -48,7 +48,7 @@ namespace WallpaperEngine::Core::Objects
static void combosFromJSON (json::const_iterator combos_it, Core::Objects::Images::Materials::CPass* pass); static void combosFromJSON (json::const_iterator combos_it, Core::Objects::Images::Materials::CPass* pass);
static void fbosFromJSON (json::const_iterator fbos_it, CEffect* effect); static void fbosFromJSON (json::const_iterator fbos_it, CEffect* effect);
static void dependencyFromJSON (json::const_iterator dependencies_it, CEffect* effect); static void dependencyFromJSON (json::const_iterator dependencies_it, CEffect* effect);
static void materialsFromJSON (json::const_iterator passes_it, CEffect* effect, const CContainer* container); static void materialsFromJSON (json::const_iterator passes_it, CEffect* effect, const CContainer& container);
void insertDependency (const std::string& dep); void insertDependency (const std::string& dep);
void insertMaterial (Images::CMaterial* material); void insertMaterial (Images::CMaterial* material);

View File

@ -44,7 +44,7 @@ CImage::CImage (
WallpaperEngine::Core::CObject* CImage::fromJSON ( WallpaperEngine::Core::CObject* CImage::fromJSON (
CScene* scene, CScene* scene,
json data, json data,
const CContainer* container, const CContainer& container,
CUserSettingBoolean* visible, CUserSettingBoolean* visible,
uint32_t id, uint32_t id,
std::string name, std::string name,

View File

@ -29,7 +29,7 @@ namespace WallpaperEngine::Core::Objects
static CObject* fromJSON ( static CObject* fromJSON (
CScene* scene, CScene* scene,
json data, json data,
const CContainer* container, const CContainer& container,
CUserSettingBoolean* visible, CUserSettingBoolean* visible,
uint32_t id, uint32_t id,
std::string name, std::string name,

View File

@ -6,7 +6,7 @@ using namespace WallpaperEngine::Core::Objects;
CParticle* CParticle::fromFile ( CParticle* CParticle::fromFile (
CScene* scene, CScene* scene,
const std::string& filename, const std::string& filename,
const CContainer* container, const CContainer& container,
CUserSettingBoolean* visible, CUserSettingBoolean* visible,
uint32_t id, uint32_t id,
std::string name, std::string name,

View File

@ -19,7 +19,7 @@ namespace WallpaperEngine::Core::Objects
static CParticle* fromFile ( static CParticle* fromFile (
CScene* scene, CScene* scene,
const std::string& filename, const std::string& filename,
const CContainer* container, const CContainer& container,
CUserSettingBoolean* visible, CUserSettingBoolean* visible,
uint32_t id, uint32_t id,
std::string name, std::string name,

View File

@ -15,13 +15,13 @@ CMaterial::CMaterial (const std::string& name) :
{ {
} }
CMaterial* CMaterial::fromFile (const std::string& filename, const CContainer* container) CMaterial* CMaterial::fromFile (const std::string& filename, const CContainer& container)
{ {
return fromJSON ( return fromJSON (
filename, json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container)) filename, json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container))
); );
} }
CMaterial* CMaterial::fromFile (const std::string& filename, const std::string& target, const CContainer* container) CMaterial* CMaterial::fromFile (const std::string& filename, const std::string& target, const CContainer& container)
{ {
return fromJSON ( return fromJSON (
filename, json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container)), target filename, json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container)), target

View File

@ -14,9 +14,9 @@ namespace WallpaperEngine::Core::Objects::Images
class CMaterial class CMaterial
{ {
public: public:
static CMaterial* fromFile (const std::string& filename, const CContainer* container); static CMaterial* fromFile (const std::string& filename, const CContainer& container);
static CMaterial* fromJSON (const std::string& name, json data); static CMaterial* fromJSON (const std::string& name, json data);
static CMaterial* fromFile (const std::string& filename, const std::string& target, const CContainer* container); static CMaterial* fromFile (const std::string& filename, const std::string& target, const CContainer& container);
static CMaterial* fromJSON (const std::string& name, json data, const std::string& target); static CMaterial* fromJSON (const std::string& name, json data, const std::string& target);
void insertPass (Materials::CPass* mass); void insertPass (Materials::CPass* mass);

View File

@ -5,10 +5,10 @@
using namespace WallpaperEngine; using namespace WallpaperEngine;
std::string FileSystem::loadFullFile (const std::string& file, const WallpaperEngine::Assets::CContainer* containers) std::string FileSystem::loadFullFile (const std::string& file, const WallpaperEngine::Assets::CContainer& containers)
{ {
uint32_t length = 0; uint32_t length = 0;
const void* contents = containers->readFile (file, &length); const void* contents = containers.readFile (file, &length);
// build a new buffer that can fit in the string // build a new buffer that can fit in the string
char* filedata = new char [length + 1]; char* filedata = new char [length + 1];

View File

@ -17,5 +17,5 @@ namespace WallpaperEngine::FileSystem
* @param file * @param file
* @return * @return
*/ */
std::string loadFullFile (const std::string& file, const WallpaperEngine::Assets::CContainer* containers); std::string loadFullFile (const std::string& file, const WallpaperEngine::Assets::CContainer& containers);
} }

View File

@ -21,7 +21,7 @@ CScene* CObject::getScene () const
return this->m_scene; return this->m_scene;
} }
const CContainer* CObject::getContainer () const const CContainer& CObject::getContainer () const
{ {
return this->getScene ()->getContainer (); return this->getScene ()->getContainer ();
} }

View File

@ -21,7 +21,7 @@ namespace WallpaperEngine::Render
virtual void render () = 0; virtual void render () = 0;
CScene* getScene () const; CScene* getScene () const;
const CContainer* getContainer () const; const CContainer& getContainer () const;
const int getId () const; const int getId () const;
protected: protected:

View File

@ -52,12 +52,13 @@ int CustomXIOErrorHandler (Display* dsp)
return 0; return 0;
} }
CRenderContext::CRenderContext (std::vector <std::string> screens, CVideoDriver& driver, CContainer* container) : CRenderContext::CRenderContext (std::vector <std::string> screens, CVideoDriver& driver, CContainer& container, CWallpaperApplication& app) :
m_wallpaper (nullptr), m_wallpaper (nullptr),
m_screens (std::move (screens)), m_screens (std::move (screens)),
m_driver (driver), m_driver (driver),
m_container (container), m_container (container),
m_textureCache (new CTextureCache (this)) m_app (app),
m_textureCache (new CTextureCache (*this))
{ {
this->initialize (); this->initialize ();
} }
@ -274,11 +275,16 @@ CWallpaper* CRenderContext::getWallpaper () const
return this->m_wallpaper; return this->m_wallpaper;
} }
const CContainer* CRenderContext::getContainer () const const CContainer& CRenderContext::getContainer () const
{ {
return this->m_container; return this->m_container;
} }
const CWallpaperApplication& CRenderContext::getApp () const
{
return this->m_app;
}
const ITexture* CRenderContext::resolveTexture (const std::string& name) const ITexture* CRenderContext::resolveTexture (const std::string& name)
{ {
return this->m_textureCache->resolve (name); return this->m_textureCache->resolve (name);

View File

@ -5,10 +5,12 @@
#include "WallpaperEngine/Input/CMouseInput.h" #include "WallpaperEngine/Input/CMouseInput.h"
#include "WallpaperEngine/Render/Drivers/CVideoDriver.h" #include "WallpaperEngine/Render/Drivers/CVideoDriver.h"
#include "WallpaperEngine/Application/CWallpaperApplication.h"
#include "CTextureCache.h" #include "CTextureCache.h"
#include "CWallpaper.h" #include "CWallpaper.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
using namespace WallpaperEngine::Application;
using namespace WallpaperEngine::Assets; using namespace WallpaperEngine::Assets;
using namespace WallpaperEngine::Input; using namespace WallpaperEngine::Input;
using namespace WallpaperEngine::Render::Drivers; using namespace WallpaperEngine::Render::Drivers;
@ -18,6 +20,11 @@ namespace WallpaperEngine::Render::Drivers
class CVideoDriver; class CVideoDriver;
} }
namespace WallpaperEngine::Application
{
class CWallpaperApplication;
}
namespace WallpaperEngine::Render namespace WallpaperEngine::Render
{ {
class CWallpaper; class CWallpaper;
@ -26,7 +33,7 @@ namespace WallpaperEngine::Render
class CRenderContext class CRenderContext
{ {
public: public:
CRenderContext (std::vector <std::string> screens, CVideoDriver& driver, CContainer* container); CRenderContext (std::vector <std::string> screens, CVideoDriver& driver, CContainer& container, CWallpaperApplication& app);
~CRenderContext (); ~CRenderContext ();
void initialize (); void initialize ();
@ -35,7 +42,8 @@ namespace WallpaperEngine::Render
CMouseInput* getMouse () const; CMouseInput* getMouse () const;
void setMouse (CMouseInput* mouse); void setMouse (CMouseInput* mouse);
CWallpaper* getWallpaper () const; CWallpaper* getWallpaper () const;
const CContainer* getContainer () const; const CContainer& getContainer () const;
const CWallpaperApplication& getApp () const;
const ITexture* resolveTexture (const std::string& name); const ITexture* resolveTexture (const std::string& name);
private: private:
@ -62,7 +70,8 @@ namespace WallpaperEngine::Render
std::vector <viewport> m_viewports; std::vector <viewport> m_viewports;
CWallpaper* m_wallpaper; CWallpaper* m_wallpaper;
CMouseInput* m_mouse; CMouseInput* m_mouse;
CContainer* m_container; CContainer& m_container;
CWallpaperApplication& m_app;
CTextureCache* m_textureCache; CTextureCache* m_textureCache;
}; };
} }

View File

@ -14,7 +14,7 @@ extern float g_TimeLast;
using namespace WallpaperEngine; using namespace WallpaperEngine;
using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render;
CScene::CScene (Core::CScene* scene, CRenderContext* context, CAudioContext* audioContext) : CScene::CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& audioContext) :
CWallpaper (scene, Type, context, audioContext) CWallpaper (scene, Type, context, audioContext)
{ {
// setup the scene camera // setup the scene camera
@ -245,7 +245,7 @@ void CScene::renderFrame (glm::ivec4 viewport)
void CScene::updateMouse (glm::ivec4 viewport) void CScene::updateMouse (glm::ivec4 viewport)
{ {
// update virtual mouse position first // update virtual mouse position first
CMouseInput* mouse = this->getContext ()->getMouse (); CMouseInput* mouse = this->getContext ().getMouse ();
// TODO: PROPERLY TRANSLATE THESE TO WHAT'S VISIBLE ON SCREEN (FOR BACKGROUNDS THAT DO NOT EXACTLY FIT ON SCREEN) // TODO: PROPERLY TRANSLATE THESE TO WHAT'S VISIBLE ON SCREEN (FOR BACKGROUNDS THAT DO NOT EXACTLY FIT ON SCREEN)
// rollover the position to the last // rollover the position to the last

View File

@ -15,7 +15,7 @@ namespace WallpaperEngine::Render
class CScene : public CWallpaper class CScene : public CWallpaper
{ {
public: public:
CScene (Core::CScene* scene, CRenderContext* context, CAudioContext* audioContext); CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& audioContext);
CCamera* getCamera () const; CCamera* getCamera () const;

View File

@ -2,7 +2,7 @@
using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render;
CTextureCache::CTextureCache (CRenderContext* context) : CTextureCache::CTextureCache (CRenderContext& context) :
m_context (context) m_context (context)
{ {
} }
@ -18,7 +18,7 @@ const ITexture* CTextureCache::resolve (const std::string& filename)
if (found != this->m_textureCache.end ()) if (found != this->m_textureCache.end ())
return (*found).second; return (*found).second;
const ITexture* texture = this->m_context->getContainer ()->readTexture (filename); const ITexture* texture = this->m_context.getContainer ().readTexture (filename);
this->store (filename, texture); this->store (filename, texture);

View File

@ -15,7 +15,7 @@ namespace WallpaperEngine::Render
class CTextureCache class CTextureCache
{ {
public: public:
CTextureCache (CRenderContext* context); CTextureCache (CRenderContext& context);
~CTextureCache (); ~CTextureCache ();
/** /**
@ -36,7 +36,7 @@ namespace WallpaperEngine::Render
void store (const std::string& name, const ITexture* texture); void store (const std::string& name, const ITexture* texture);
private: private:
CRenderContext* m_context; CRenderContext& m_context;
std::map<std::string, const ITexture*> m_textureCache; std::map<std::string, const ITexture*> m_textureCache;
}; };
} }

View File

@ -15,7 +15,7 @@ void* get_proc_address (void* ctx, const char* name)
return reinterpret_cast <void*> (glfwGetProcAddress (name)); return reinterpret_cast <void*> (glfwGetProcAddress (name));
} }
CVideo::CVideo (Core::CVideo* video, CRenderContext* context, CAudioContext* audioContext) : CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext) :
CWallpaper (video, Type, context, audioContext), CWallpaper (video, Type, context, audioContext),
m_width (16), m_width (16),
m_height (16) m_height (16)

View File

@ -12,7 +12,7 @@ namespace WallpaperEngine::Render
class CVideo : public CWallpaper class CVideo : public CWallpaper
{ {
public: public:
CVideo (Core::CVideo* video, CRenderContext* context, CAudioContext* audioContext); CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext);
Core::CVideo* getVideo (); Core::CVideo* getVideo ();

View File

@ -9,7 +9,7 @@
using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render;
CWallpaper::CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CRenderContext* context, CAudioContext* audioContext) : CWallpaper::CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CRenderContext& context, CAudioContext& audioContext) :
m_wallpaperData (wallpaperData), m_wallpaperData (wallpaperData),
m_type (std::move(type)), m_type (std::move(type)),
m_context (context), m_context (context),
@ -54,9 +54,9 @@ CWallpaper::~CWallpaper ()
{ {
} }
const CContainer* CWallpaper::getContainer () const const CContainer& CWallpaper::getContainer () const
{ {
return this->m_context->getContainer (); return this->m_context.getContainer ();
} }
WallpaperEngine::Core::CWallpaper* CWallpaper::getWallpaperData () const WallpaperEngine::Core::CWallpaper* CWallpaper::getWallpaperData () const
@ -325,12 +325,12 @@ void CWallpaper::setupFramebuffers ()
); );
} }
CRenderContext* CWallpaper::getContext () CRenderContext& CWallpaper::getContext ()
{ {
return this->m_context; return this->m_context;
} }
CAudioContext* CWallpaper::getAudioContext () CAudioContext& CWallpaper::getAudioContext ()
{ {
return this->m_audioContext; return this->m_audioContext;
} }
@ -365,7 +365,7 @@ CFBO* CWallpaper::getFBO () const
return this->m_sceneFBO; return this->m_sceneFBO;
} }
CWallpaper* CWallpaper::fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext* context, CAudioContext* audioContext) CWallpaper* CWallpaper::fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext& context, CAudioContext& audioContext)
{ {
if (wallpaper->is <Core::CScene> () == true) if (wallpaper->is <Core::CScene> () == true)
return new WallpaperEngine::Render::CScene (wallpaper->as <Core::CScene> (), context, audioContext); return new WallpaperEngine::Render::CScene (wallpaper->as <Core::CScene> (), context, audioContext);

View File

@ -27,7 +27,7 @@ namespace WallpaperEngine::Render
template<class T> bool is () { return this->m_type == T::Type; } template<class T> bool is () { return this->m_type == T::Type; }
CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CRenderContext* context, CAudioContext* audioContext); CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CRenderContext& context, CAudioContext& audioContext);
~CWallpaper (); ~CWallpaper ();
/** /**
@ -38,17 +38,17 @@ namespace WallpaperEngine::Render
/** /**
* @return The container to resolve files for this wallpaper * @return The container to resolve files for this wallpaper
*/ */
const CContainer* getContainer () const; const CContainer& getContainer () const;
/** /**
* @return The current context rendering this wallpaper * @return The current context rendering this wallpaper
*/ */
CRenderContext* getContext (); CRenderContext& getContext ();
/** /**
* @return The current audio context for this wallpaper * @return The current audio context for this wallpaper
*/ */
CAudioContext* getAudioContext (); CAudioContext& getAudioContext ();
/** /**
* @return The scene's framebuffer * @return The scene's framebuffer
@ -112,7 +112,7 @@ namespace WallpaperEngine::Render
* *
* @return * @return
*/ */
static CWallpaper* fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext* context, CAudioContext* audioContext); static CWallpaper* fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext& context, CAudioContext& audioContext);
protected: protected:
/** /**
@ -166,10 +166,10 @@ namespace WallpaperEngine::Render
/** /**
* Context that is using this wallpaper * Context that is using this wallpaper
*/ */
CRenderContext* m_context; CRenderContext& m_context;
/* /*
* Audio context that is using this wallpaper * Audio context that is using this wallpaper
*/ */
CAudioContext* m_audioContext; CAudioContext& m_audioContext;
}; };
} }

View File

@ -69,7 +69,7 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
else else
{ {
// get the first texture on the first pass (this one represents the image assigned to this object) // get the first texture on the first pass (this one represents the image assigned to this object)
this->m_texture = this->getScene ()->getContext ()->resolveTexture (textureName); this->m_texture = this->getScene ()->getContext ().resolveTexture (textureName);
} }
} }
else else

View File

@ -16,7 +16,7 @@ void CSound::load ()
for (const auto& cur : this->m_sound->getSounds ()) for (const auto& cur : this->m_sound->getSounds ())
{ {
uint32_t filesize = 0; uint32_t filesize = 0;
const void* filebuffer = this->getContainer ()->readFile (cur, &filesize); const void* filebuffer = this->getContainer ().readFile (cur, &filesize);
auto stream = new Audio::CAudioStream (this->getScene ()->getAudioContext (), filebuffer, filesize); auto stream = new Audio::CAudioStream (this->getScene ()->getAudioContext (), filebuffer, filesize);
@ -26,7 +26,7 @@ void CSound::load ()
this->m_soundBuffer.push_back (filebuffer); this->m_soundBuffer.push_back (filebuffer);
// add the stream to the context so it can be played // add the stream to the context so it can be played
this->getScene ()->getAudioContext ()->addStream (stream); this->getScene ()->getAudioContext ().addStream (stream);
} }
} }

View File

@ -524,7 +524,7 @@ void CPass::setupUniforms ()
textureRef = this->getMaterial ()->getImage ()->getScene ()->findFBO (textureName); textureRef = this->getMaterial ()->getImage ()->getScene ()->findFBO (textureName);
} }
else else
textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ()->resolveTexture (textureName); textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ().resolveTexture (textureName);
this->m_finalTextures.insert_or_assign ((*fragCur).first, textureRef); this->m_finalTextures.insert_or_assign ((*fragCur).first, textureRef);
} }
@ -553,7 +553,7 @@ void CPass::setupUniforms ()
textureRef = this->getMaterial ()->getImage ()->getScene ()->findFBO (textureName); textureRef = this->getMaterial ()->getImage ()->getScene ()->findFBO (textureName);
} }
else else
textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ()->resolveTexture (textureName); textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ().resolveTexture (textureName);
this->m_finalTextures.insert_or_assign ((*vertCur).first, textureRef); this->m_finalTextures.insert_or_assign ((*vertCur).first, textureRef);
} }
@ -693,7 +693,7 @@ void CPass::setupTextures ()
else else
{ {
this->m_textures.emplace_back ( this->m_textures.emplace_back (
this->m_material->getImage ()->getScene ()->getContext ()->resolveTexture ((*cur)) this->m_material->getImage ()->getScene ()->getContext ().resolveTexture ((*cur))
); );
} }
} }

View File

@ -27,7 +27,7 @@ using namespace WallpaperEngine::Assets;
namespace WallpaperEngine::Render::Shaders namespace WallpaperEngine::Render::Shaders
{ {
Compiler::Compiler ( Compiler::Compiler (
const CContainer* container, const CContainer& container,
std::string filename, std::string filename,
Type type, Type type,
std::map <std::string, int>* combos, std::map <std::string, int>* combos,
@ -48,11 +48,11 @@ namespace WallpaperEngine::Render::Shaders
m_baseCombos () m_baseCombos ()
{ {
if (type == Type_Vertex) if (type == Type_Vertex)
this->m_content = this->m_container->readVertexShader (this->m_file); this->m_content = this->m_container.readVertexShader (this->m_file);
else if (type == Type_Pixel) else if (type == Type_Pixel)
this->m_content = this->m_container->readFragmentShader (this->m_file); this->m_content = this->m_container.readFragmentShader (this->m_file);
else if (type == Type_Include) else if (type == Type_Include)
this->m_content = this->m_container->readIncludeShader (this->m_file); this->m_content = this->m_container.readIncludeShader (this->m_file);
// clone the combos into the baseCombos to keep track of values that must be embedded no matter what // clone the combos into the baseCombos to keep track of values that must be embedded no matter what
for (const auto& cur : *this->m_combos) for (const auto& cur : *this->m_combos)

View File

@ -51,7 +51,7 @@ namespace WallpaperEngine::Render::Shaders
* @param recursive Whether the compiler should add base definitions or not * @param recursive Whether the compiler should add base definitions or not
*/ */
Compiler ( Compiler (
const CContainer* container, const CContainer& container,
std::string filename, std::string filename,
Type type, Type type,
std::map<std::string, int>* combos, std::map<std::string, int>* combos,
@ -259,7 +259,7 @@ namespace WallpaperEngine::Render::Shaders
/** /**
* The container to load files from * The container to load files from
*/ */
const CContainer* m_container; const CContainer& m_container;
/** /**
* List of textures that the shader expects (inferred from sampler2D and it's JSON data) * List of textures that the shader expects (inferred from sampler2D and it's JSON data)
*/ */