mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Small code cleanups
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
26f6156f34
commit
d2e82e72d8
@ -16,6 +16,7 @@ bool g_AudioEnabled = true;
|
||||
int g_AudioVolume = 128;
|
||||
|
||||
using namespace WallpaperEngine::Application;
|
||||
using namespace WallpaperEngine::Core;
|
||||
|
||||
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context) :
|
||||
m_context (context)
|
||||
@ -136,7 +137,7 @@ void CWallpaperApplication::setupContainer ()
|
||||
|
||||
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
|
||||
// TODO: stop doing chdir and use full path
|
||||
if (this->m_project->getWallpaper ()->is <WallpaperEngine::Core::CVideo> () == true)
|
||||
@ -219,12 +220,12 @@ void CWallpaperApplication::show ()
|
||||
// initialize OpenGL driver
|
||||
WallpaperEngine::Render::Drivers::COpenGLDriver videoDriver (this->m_project->getTitle ().c_str ());
|
||||
// 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
|
||||
context.setMouse (new CMouseInput (videoDriver.getWindow ()));
|
||||
// ensure the context knows what wallpaper to render
|
||||
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;
|
||||
|
@ -5,9 +5,13 @@
|
||||
#include "WallpaperEngine/Core/CProject.h"
|
||||
#include "WallpaperEngine/Render/CWallpaper.h"
|
||||
|
||||
namespace WallpaperEngine::Render
|
||||
{
|
||||
class CWallpaper;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Application
|
||||
{
|
||||
using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
|
||||
class CWallpaperApplication
|
||||
@ -24,7 +28,7 @@ namespace WallpaperEngine::Application
|
||||
void setupProperties ();
|
||||
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;
|
||||
CCombinedContainer m_vfs;
|
||||
};
|
||||
|
@ -105,14 +105,14 @@ int64_t audio_seek_data_callback (void* streamarg, int64_t offset, int whence)
|
||||
return offset;
|
||||
}
|
||||
|
||||
CAudioStream::CAudioStream (CAudioContext* context, const std::string& filename) :
|
||||
CAudioStream::CAudioStream (CAudioContext& context, const std::string& filename) :
|
||||
m_audioContext (context),
|
||||
m_swrctx (nullptr)
|
||||
{
|
||||
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_swrctx (nullptr)
|
||||
{
|
||||
@ -144,7 +144,7 @@ CAudioStream::CAudioStream (CAudioContext* context, const void* buffer, int leng
|
||||
this->loadCustomContent ();
|
||||
}
|
||||
|
||||
CAudioStream::CAudioStream(CAudioContext* audioContext, AVCodecContext* context) :
|
||||
CAudioStream::CAudioStream(CAudioContext& audioContext, AVCodecContext* context) :
|
||||
m_context (context),
|
||||
m_queue (new PacketQueue),
|
||||
m_audioContext (audioContext),
|
||||
@ -220,7 +220,7 @@ void CAudioStream::initialize ()
|
||||
int64_t out_channel_layout;
|
||||
|
||||
// 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 2: out_channel_layout = AV_CH_LAYOUT_STEREO; break;
|
||||
@ -233,8 +233,8 @@ void CAudioStream::initialize ()
|
||||
swr_alloc_set_opts2 (
|
||||
&this->m_swrctx,
|
||||
&this->m_out_channel_layout,
|
||||
this->m_audioContext->getFormat (),
|
||||
this->m_audioContext->getSampleRate (),
|
||||
this->m_audioContext.getFormat (),
|
||||
this->m_audioContext.getSampleRate (),
|
||||
&this->m_context->ch_layout,
|
||||
this->m_context->sample_fmt,
|
||||
this->m_context->sample_rate,
|
||||
@ -658,9 +658,9 @@ int CAudioStream::decodeFrame (uint8_t* audioBuffer, int bufferSize)
|
||||
// audio resampling
|
||||
data_size = this->resampleAudio (
|
||||
avFrame,
|
||||
this->m_audioContext->getFormat (),
|
||||
this->m_audioContext->getChannels (),
|
||||
this->m_audioContext->getSampleRate (),
|
||||
this->m_audioContext.getFormat (),
|
||||
this->m_audioContext.getChannels (),
|
||||
this->m_audioContext.getSampleRate (),
|
||||
audioBuffer
|
||||
);
|
||||
assert(data_size <= bufferSize);
|
||||
|
@ -22,9 +22,9 @@ namespace WallpaperEngine::Audio
|
||||
class CAudioStream
|
||||
{
|
||||
public:
|
||||
CAudioStream (CAudioContext* context, const std::string& filename);
|
||||
CAudioStream (CAudioContext* context, const void* buffer, int length);
|
||||
CAudioStream (CAudioContext* audioContext, AVCodecContext* context);
|
||||
CAudioStream (CAudioContext& context, const std::string& filename);
|
||||
CAudioStream (CAudioContext& context, const void* buffer, int length);
|
||||
CAudioStream (CAudioContext& audioContext, AVCodecContext* context);
|
||||
~CAudioStream ();
|
||||
|
||||
void queuePacket (AVPacket* pkt);
|
||||
@ -70,7 +70,7 @@ namespace WallpaperEngine::Audio
|
||||
#endif
|
||||
|
||||
SwrContext* m_swrctx;
|
||||
CAudioContext* m_audioContext;
|
||||
CAudioContext& m_audioContext;
|
||||
bool m_initialized;
|
||||
bool m_repeat;
|
||||
AVCodecContext* m_context = nullptr;
|
||||
|
@ -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 ();
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace WallpaperEngine::Core
|
||||
{
|
||||
friend class CScene;
|
||||
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> T* as () { assert (is <T> ()); return (T*) this; }
|
||||
|
@ -9,7 +9,7 @@
|
||||
using namespace WallpaperEngine::Core;
|
||||
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_type (std::move (type)),
|
||||
m_wallpaper (wallpaper),
|
||||
@ -18,7 +18,7 @@ CProject::CProject (std::string title, std::string type, CWallpaper* wallpaper,
|
||||
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));
|
||||
|
||||
@ -89,7 +89,7 @@ const std::vector<Projects::CProperty*>& CProject::getProperties () const
|
||||
return this->m_properties;
|
||||
}
|
||||
|
||||
CContainer* CProject::getContainer ()
|
||||
CContainer& CProject::getContainer ()
|
||||
{
|
||||
return this->m_container;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace WallpaperEngine::Core
|
||||
class CProject
|
||||
{
|
||||
public:
|
||||
static CProject* fromFile (const std::string& filename, CContainer* container);
|
||||
static CProject* fromFile (const std::string& filename, CContainer& container);
|
||||
|
||||
CWallpaper* getWallpaper () const;
|
||||
|
||||
@ -24,10 +24,10 @@ namespace WallpaperEngine::Core
|
||||
const std::string& getType () const;
|
||||
const std::vector<Projects::CProperty*>& getProperties () const;
|
||||
|
||||
CContainer* getContainer ();
|
||||
CContainer& getContainer ();
|
||||
|
||||
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);
|
||||
private:
|
||||
@ -36,6 +36,6 @@ namespace WallpaperEngine::Core
|
||||
std::string m_title;
|
||||
std::string m_type;
|
||||
CWallpaper* m_wallpaper;
|
||||
CContainer* m_container;
|
||||
CContainer& m_container;
|
||||
};
|
||||
};
|
||||
|
@ -9,7 +9,7 @@
|
||||
using namespace WallpaperEngine::Core;
|
||||
|
||||
CScene::CScene (
|
||||
CContainer* container,
|
||||
CContainer& container,
|
||||
Scenes::CCamera* camera,
|
||||
glm::vec3 ambientColor,
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace WallpaperEngine::Core
|
||||
class CScene : public CWallpaper
|
||||
{
|
||||
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::vector<CObject*>& getObjectsByRenderOrder () const;
|
||||
@ -45,7 +45,7 @@ namespace WallpaperEngine::Core
|
||||
friend class CWallpaper;
|
||||
|
||||
CScene (
|
||||
CContainer* container,
|
||||
CContainer& container,
|
||||
Scenes::CCamera* camera,
|
||||
glm::vec3 ambientColor,
|
||||
CUserSettingBoolean* bloom,
|
||||
@ -70,9 +70,9 @@ namespace WallpaperEngine::Core
|
||||
|
||||
void insertObject (CObject* object);
|
||||
|
||||
CContainer* getContainer ();
|
||||
CContainer& getContainer ();
|
||||
private:
|
||||
CContainer* m_container;
|
||||
CContainer& m_container;
|
||||
Scenes::CCamera* m_camera;
|
||||
|
||||
// data from general section on the json
|
||||
|
@ -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 effectpasses_it = data.find ("passes");
|
||||
@ -204,7 +204,7 @@ void CEffect::dependencyFromJSON (json::const_iterator dependencies_it, CEffect*
|
||||
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))
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
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<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 fbosFromJSON (json::const_iterator fbos_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 insertMaterial (Images::CMaterial* material);
|
||||
|
@ -44,7 +44,7 @@ CImage::CImage (
|
||||
WallpaperEngine::Core::CObject* CImage::fromJSON (
|
||||
CScene* scene,
|
||||
json data,
|
||||
const CContainer* container,
|
||||
const CContainer& container,
|
||||
CUserSettingBoolean* visible,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
|
@ -29,7 +29,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
static CObject* fromJSON (
|
||||
CScene* scene,
|
||||
json data,
|
||||
const CContainer* container,
|
||||
const CContainer& container,
|
||||
CUserSettingBoolean* visible,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
|
@ -6,7 +6,7 @@ using namespace WallpaperEngine::Core::Objects;
|
||||
CParticle* CParticle::fromFile (
|
||||
CScene* scene,
|
||||
const std::string& filename,
|
||||
const CContainer* container,
|
||||
const CContainer& container,
|
||||
CUserSettingBoolean* visible,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
|
@ -19,7 +19,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
static CParticle* fromFile (
|
||||
CScene* scene,
|
||||
const std::string& filename,
|
||||
const CContainer* container,
|
||||
const CContainer& container,
|
||||
CUserSettingBoolean* visible,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
|
@ -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 (
|
||||
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 (
|
||||
filename, json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container)), target
|
||||
|
@ -14,9 +14,9 @@ namespace WallpaperEngine::Core::Objects::Images
|
||||
class CMaterial
|
||||
{
|
||||
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* 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);
|
||||
|
||||
void insertPass (Materials::CPass* mass);
|
||||
|
@ -5,10 +5,10 @@
|
||||
|
||||
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;
|
||||
const void* contents = containers->readFile (file, &length);
|
||||
const void* contents = containers.readFile (file, &length);
|
||||
|
||||
// build a new buffer that can fit in the string
|
||||
char* filedata = new char [length + 1];
|
||||
|
@ -17,5 +17,5 @@ namespace WallpaperEngine::FileSystem
|
||||
* @param file
|
||||
* @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);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ CScene* CObject::getScene () const
|
||||
return this->m_scene;
|
||||
}
|
||||
|
||||
const CContainer* CObject::getContainer () const
|
||||
const CContainer& CObject::getContainer () const
|
||||
{
|
||||
return this->getScene ()->getContainer ();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace WallpaperEngine::Render
|
||||
virtual void render () = 0;
|
||||
|
||||
CScene* getScene () const;
|
||||
const CContainer* getContainer () const;
|
||||
const CContainer& getContainer () const;
|
||||
const int getId () const;
|
||||
|
||||
protected:
|
||||
|
@ -52,12 +52,13 @@ int CustomXIOErrorHandler (Display* dsp)
|
||||
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_screens (std::move (screens)),
|
||||
m_driver (driver),
|
||||
m_container (container),
|
||||
m_textureCache (new CTextureCache (this))
|
||||
m_app (app),
|
||||
m_textureCache (new CTextureCache (*this))
|
||||
{
|
||||
this->initialize ();
|
||||
}
|
||||
@ -274,11 +275,16 @@ CWallpaper* CRenderContext::getWallpaper () const
|
||||
return this->m_wallpaper;
|
||||
}
|
||||
|
||||
const CContainer* CRenderContext::getContainer () const
|
||||
const CContainer& CRenderContext::getContainer () const
|
||||
{
|
||||
return this->m_container;
|
||||
}
|
||||
|
||||
const CWallpaperApplication& CRenderContext::getApp () const
|
||||
{
|
||||
return this->m_app;
|
||||
}
|
||||
|
||||
const ITexture* CRenderContext::resolveTexture (const std::string& name)
|
||||
{
|
||||
return this->m_textureCache->resolve (name);
|
||||
|
@ -5,10 +5,12 @@
|
||||
|
||||
#include "WallpaperEngine/Input/CMouseInput.h"
|
||||
#include "WallpaperEngine/Render/Drivers/CVideoDriver.h"
|
||||
#include "WallpaperEngine/Application/CWallpaperApplication.h"
|
||||
#include "CTextureCache.h"
|
||||
#include "CWallpaper.h"
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
using namespace WallpaperEngine::Application;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Input;
|
||||
using namespace WallpaperEngine::Render::Drivers;
|
||||
@ -18,6 +20,11 @@ namespace WallpaperEngine::Render::Drivers
|
||||
class CVideoDriver;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Application
|
||||
{
|
||||
class CWallpaperApplication;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Render
|
||||
{
|
||||
class CWallpaper;
|
||||
@ -26,7 +33,7 @@ namespace WallpaperEngine::Render
|
||||
class CRenderContext
|
||||
{
|
||||
public:
|
||||
CRenderContext (std::vector <std::string> screens, CVideoDriver& driver, CContainer* container);
|
||||
CRenderContext (std::vector <std::string> screens, CVideoDriver& driver, CContainer& container, CWallpaperApplication& app);
|
||||
~CRenderContext ();
|
||||
|
||||
void initialize ();
|
||||
@ -35,7 +42,8 @@ namespace WallpaperEngine::Render
|
||||
CMouseInput* getMouse () const;
|
||||
void setMouse (CMouseInput* mouse);
|
||||
CWallpaper* getWallpaper () const;
|
||||
const CContainer* getContainer () const;
|
||||
const CContainer& getContainer () const;
|
||||
const CWallpaperApplication& getApp () const;
|
||||
const ITexture* resolveTexture (const std::string& name);
|
||||
|
||||
private:
|
||||
@ -62,7 +70,8 @@ namespace WallpaperEngine::Render
|
||||
std::vector <viewport> m_viewports;
|
||||
CWallpaper* m_wallpaper;
|
||||
CMouseInput* m_mouse;
|
||||
CContainer* m_container;
|
||||
CContainer& m_container;
|
||||
CWallpaperApplication& m_app;
|
||||
CTextureCache* m_textureCache;
|
||||
};
|
||||
}
|
@ -14,7 +14,7 @@ extern float g_TimeLast;
|
||||
using namespace WallpaperEngine;
|
||||
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)
|
||||
{
|
||||
// setup the scene camera
|
||||
@ -245,7 +245,7 @@ void CScene::renderFrame (glm::ivec4 viewport)
|
||||
void CScene::updateMouse (glm::ivec4 viewport)
|
||||
{
|
||||
// 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)
|
||||
|
||||
// rollover the position to the last
|
||||
|
@ -15,7 +15,7 @@ namespace WallpaperEngine::Render
|
||||
class CScene : public CWallpaper
|
||||
{
|
||||
public:
|
||||
CScene (Core::CScene* scene, CRenderContext* context, CAudioContext* audioContext);
|
||||
CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& audioContext);
|
||||
|
||||
CCamera* getCamera () const;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Render;
|
||||
|
||||
CTextureCache::CTextureCache (CRenderContext* context) :
|
||||
CTextureCache::CTextureCache (CRenderContext& context) :
|
||||
m_context (context)
|
||||
{
|
||||
}
|
||||
@ -18,7 +18,7 @@ const ITexture* CTextureCache::resolve (const std::string& filename)
|
||||
if (found != this->m_textureCache.end ())
|
||||
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);
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace WallpaperEngine::Render
|
||||
class CTextureCache
|
||||
{
|
||||
public:
|
||||
CTextureCache (CRenderContext* context);
|
||||
CTextureCache (CRenderContext& context);
|
||||
~CTextureCache ();
|
||||
|
||||
/**
|
||||
@ -36,7 +36,7 @@ namespace WallpaperEngine::Render
|
||||
void store (const std::string& name, const ITexture* texture);
|
||||
|
||||
private:
|
||||
CRenderContext* m_context;
|
||||
CRenderContext& m_context;
|
||||
std::map<std::string, const ITexture*> m_textureCache;
|
||||
};
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ void* get_proc_address (void* ctx, const char* 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),
|
||||
m_width (16),
|
||||
m_height (16)
|
||||
|
@ -12,7 +12,7 @@ namespace WallpaperEngine::Render
|
||||
class CVideo : public CWallpaper
|
||||
{
|
||||
public:
|
||||
CVideo (Core::CVideo* video, CRenderContext* context, CAudioContext* audioContext);
|
||||
CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext);
|
||||
|
||||
Core::CVideo* getVideo ();
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
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_type (std::move(type)),
|
||||
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
|
||||
@ -325,12 +325,12 @@ void CWallpaper::setupFramebuffers ()
|
||||
);
|
||||
}
|
||||
|
||||
CRenderContext* CWallpaper::getContext ()
|
||||
CRenderContext& CWallpaper::getContext ()
|
||||
{
|
||||
return this->m_context;
|
||||
}
|
||||
|
||||
CAudioContext* CWallpaper::getAudioContext ()
|
||||
CAudioContext& CWallpaper::getAudioContext ()
|
||||
{
|
||||
return this->m_audioContext;
|
||||
}
|
||||
@ -365,7 +365,7 @@ CFBO* CWallpaper::getFBO () const
|
||||
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)
|
||||
return new WallpaperEngine::Render::CScene (wallpaper->as <Core::CScene> (), context, audioContext);
|
||||
|
@ -27,7 +27,7 @@ namespace WallpaperEngine::Render
|
||||
|
||||
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 ();
|
||||
|
||||
/**
|
||||
@ -38,17 +38,17 @@ namespace WallpaperEngine::Render
|
||||
/**
|
||||
* @return The container to resolve files for this wallpaper
|
||||
*/
|
||||
const CContainer* getContainer () const;
|
||||
const CContainer& getContainer () const;
|
||||
|
||||
/**
|
||||
* @return The current context rendering this wallpaper
|
||||
*/
|
||||
CRenderContext* getContext ();
|
||||
CRenderContext& getContext ();
|
||||
|
||||
/**
|
||||
* @return The current audio context for this wallpaper
|
||||
*/
|
||||
CAudioContext* getAudioContext ();
|
||||
CAudioContext& getAudioContext ();
|
||||
|
||||
/**
|
||||
* @return The scene's framebuffer
|
||||
@ -112,7 +112,7 @@ namespace WallpaperEngine::Render
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static CWallpaper* fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext* context, CAudioContext* audioContext);
|
||||
static CWallpaper* fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext& context, CAudioContext& audioContext);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -166,10 +166,10 @@ namespace WallpaperEngine::Render
|
||||
/**
|
||||
* Context that is using this wallpaper
|
||||
*/
|
||||
CRenderContext* m_context;
|
||||
CRenderContext& m_context;
|
||||
/*
|
||||
* Audio context that is using this wallpaper
|
||||
*/
|
||||
CAudioContext* m_audioContext;
|
||||
CAudioContext& m_audioContext;
|
||||
};
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
else
|
||||
{
|
||||
// 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
|
||||
|
@ -16,7 +16,7 @@ void CSound::load ()
|
||||
for (const auto& cur : this->m_sound->getSounds ())
|
||||
{
|
||||
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);
|
||||
|
||||
@ -26,7 +26,7 @@ void CSound::load ()
|
||||
this->m_soundBuffer.push_back (filebuffer);
|
||||
|
||||
// add the stream to the context so it can be played
|
||||
this->getScene ()->getAudioContext ()->addStream (stream);
|
||||
this->getScene ()->getAudioContext ().addStream (stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -524,7 +524,7 @@ void CPass::setupUniforms ()
|
||||
textureRef = this->getMaterial ()->getImage ()->getScene ()->findFBO (textureName);
|
||||
}
|
||||
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);
|
||||
}
|
||||
@ -553,7 +553,7 @@ void CPass::setupUniforms ()
|
||||
textureRef = this->getMaterial ()->getImage ()->getScene ()->findFBO (textureName);
|
||||
}
|
||||
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);
|
||||
}
|
||||
@ -693,7 +693,7 @@ void CPass::setupTextures ()
|
||||
else
|
||||
{
|
||||
this->m_textures.emplace_back (
|
||||
this->m_material->getImage ()->getScene ()->getContext ()->resolveTexture ((*cur))
|
||||
this->m_material->getImage ()->getScene ()->getContext ().resolveTexture ((*cur))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ using namespace WallpaperEngine::Assets;
|
||||
namespace WallpaperEngine::Render::Shaders
|
||||
{
|
||||
Compiler::Compiler (
|
||||
const CContainer* container,
|
||||
const CContainer& container,
|
||||
std::string filename,
|
||||
Type type,
|
||||
std::map <std::string, int>* combos,
|
||||
@ -48,11 +48,11 @@ namespace WallpaperEngine::Render::Shaders
|
||||
m_baseCombos ()
|
||||
{
|
||||
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)
|
||||
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)
|
||||
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
|
||||
for (const auto& cur : *this->m_combos)
|
||||
|
@ -51,7 +51,7 @@ namespace WallpaperEngine::Render::Shaders
|
||||
* @param recursive Whether the compiler should add base definitions or not
|
||||
*/
|
||||
Compiler (
|
||||
const CContainer* container,
|
||||
const CContainer& container,
|
||||
std::string filename,
|
||||
Type type,
|
||||
std::map<std::string, int>* combos,
|
||||
@ -259,7 +259,7 @@ namespace WallpaperEngine::Render::Shaders
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user