Properly support different wallpapers

This commit is contained in:
IceCryptonym 2020-04-05 17:47:09 +10:00
parent 8b53316b2c
commit 64bcfd00a2
23 changed files with 257 additions and 229 deletions

View File

@ -47,8 +47,12 @@ add_executable(
src/WallpaperEngine/Render/Shaders/Compiler.h
src/WallpaperEngine/Render/Shaders/Compiler.cpp
src/WallpaperEngine/Render/CWallpaper.h
src/WallpaperEngine/Render/CWallpaper.cpp
src/WallpaperEngine/Render/CScene.h
src/WallpaperEngine/Render/CScene.cpp
src/WallpaperEngine/Render/CVideo.h
src/WallpaperEngine/Render/CVideo.cpp
src/WallpaperEngine/Render/CCamera.h
src/WallpaperEngine/Render/CCamera.cpp
src/WallpaperEngine/Render/CObject.h
@ -58,8 +62,6 @@ add_executable(
src/WallpaperEngine/Render/Objects/CImage.cpp
src/WallpaperEngine/Render/Objects/CSound.h
src/WallpaperEngine/Render/Objects/CSound.cpp
src/WallpaperEngine/Render/Objects/CVideo.h
src/WallpaperEngine/Render/Objects/CVideo.cpp
src/WallpaperEngine/Render/Objects/CEffect.h
src/WallpaperEngine/Render/Objects/CEffect.cpp
@ -86,8 +88,12 @@ add_executable(
src/WallpaperEngine/Core/CProject.cpp
src/WallpaperEngine/Core/CProject.h
src/WallpaperEngine/Core/CWallpaper.cpp
src/WallpaperEngine/Core/CWallpaper.h
src/WallpaperEngine/Core/CScene.cpp
src/WallpaperEngine/Core/CScene.h
src/WallpaperEngine/Core/CVideo.cpp
src/WallpaperEngine/Core/CVideo.h
src/WallpaperEngine/Core/CObject.cpp
src/WallpaperEngine/Core/CObject.h
@ -105,8 +111,6 @@ add_executable(
src/WallpaperEngine/Core/Objects/CImage.h
src/WallpaperEngine/Core/Objects/CSound.cpp
src/WallpaperEngine/Core/Objects/CSound.h
src/WallpaperEngine/Core/Objects/CVideo.cpp
src/WallpaperEngine/Core/Objects/CVideo.h
src/WallpaperEngine/Core/Objects/CEffect.cpp
src/WallpaperEngine/Core/Objects/CEffect.h
src/WallpaperEngine/Core/Objects/CParticle.cpp

View File

@ -6,7 +6,9 @@
#include "WallpaperEngine/Core/CProject.h"
#include "WallpaperEngine/Irrlicht/CContext.h"
#include "WallpaperEngine/Render/CWallpaper.h"
#include "WallpaperEngine/Render/CScene.h"
#include "WallpaperEngine/Render/CVideo.h"
enum BACKGROUND_RUN_MODE
{
@ -161,14 +163,27 @@ int main (int argc, char* argv[])
}
WallpaperEngine::Core::CProject* project = WallpaperEngine::Core::CProject::fromFile (project_path);
WallpaperEngine::Render::CScene* scene = new WallpaperEngine::Render::CScene (project, IrrlichtContext);
WallpaperEngine::Render::CWallpaper* wallpaper;
if (strcmp (project->getType ().c_str (), "scene") == 0)
{
wallpaper = new WallpaperEngine::Render::CScene (project->getWallpaper ()->as <WallpaperEngine::Core::CScene> (), IrrlichtContext);
IrrlichtContext->getDevice ()->getSceneManager ()->setAmbientLight (
wallpaper->getWallpaperData ()->as <WallpaperEngine::Core::CScene> ()->getAmbientColor ().toSColor ()
);
}
else if (strcmp (project->getType ().c_str (), "video") == 0)
{
wallpaper = new WallpaperEngine::Render::CVideo (
project->getWallpaper ()->as <WallpaperEngine::Core::CVideo> (),
IrrlichtContext->getDevice ()->getVideoDriver ()
);
}
irr::u32 minimumTime = 1000 / maximumFPS;
irr::u32 startTime = 0;
irr::u32 endTime = 0;
IrrlichtContext->getDevice ()->getSceneManager ()->setAmbientLight (scene->getScene ()->getAmbientColor ().toSColor ());
while (IrrlichtContext && IrrlichtContext->getDevice () && IrrlichtContext->getDevice ()->run ())
{
if (IrrlichtContext->getDevice ()->getVideoDriver () == nullptr)
@ -176,7 +191,7 @@ int main (int argc, char* argv[])
startTime = IrrlichtContext->getDevice ()->getTimer ()->getTime ();
IrrlichtContext->renderFrame (scene);
wallpaper->renderWallpaper ();
endTime = IrrlichtContext->getDevice ()->getTimer ()->getTime ();

View File

@ -1,15 +1,17 @@
#include <WallpaperEngine/FileSystem/FileSystem.h>
#include "CProject.h"
#include "CScene.h"
#include "CVideo.h"
using namespace WallpaperEngine::Core;
CProject::CProject (std::string title, std::string type, CScene *scene) :
CProject::CProject (std::string title, std::string type, CWallpaper* wallpaper) :
m_title (std::move (title)),
m_type (std::move (type)),
m_scene (scene)
m_wallpaper (wallpaper)
{
this->m_scene->setProject (this);
this->m_wallpaper->setProject (this);
}
CProject* CProject::fromFile (const irr::io::path& filename)
@ -20,11 +22,23 @@ CProject* CProject::fromFile (const irr::io::path& filename)
auto type = jsonFindRequired (content, "type", "Project type missing");
auto file = jsonFindRequired (content, "file", "Project's main file missing");
auto general = content.find ("general");
CWallpaper* wallpaper;
if (strcmp ((*type).get <std::string> ().c_str (), "scene") == 0)
{
wallpaper = CScene::fromFile ((*file).get <std::string> ().c_str ());
}
else if (strcmp ((*type).get <std::string> ().c_str (), "video") == 0)
{
wallpaper = new CVideo ((*file).get <std::string> ().c_str ());
}
else
throw std::runtime_error ("Unsupported wallpaper type");
CProject* project = new CProject (
*title,
*type,
CScene::fromFile ((*file).get <std::string> ().c_str (), (*type).get <std::string> ().c_str())
wallpaper
);
if (general != content.end ())
@ -48,9 +62,9 @@ CProject* CProject::fromFile (const irr::io::path& filename)
return project;
}
const CScene* CProject::getScene () const
CWallpaper* CProject::getWallpaper () const
{
return this->m_scene;
return this->m_wallpaper;
}
const std::string& CProject::getTitle () const

View File

@ -2,7 +2,7 @@
#include <irrlicht/irrlicht.h>
#include "CScene.h"
#include "CWallpaper.h"
#include "WallpaperEngine/Core/Core.h"
#include "WallpaperEngine/Core/Projects/CProperty.h"
@ -10,21 +10,21 @@ namespace WallpaperEngine::Core
{
using json = nlohmann::json;
class CScene;
class CWallpaper;
class CProject
{
public:
static CProject* fromFile (const irr::io::path& filename);
const CScene* getScene () const;
CWallpaper* getWallpaper () const;
const std::string& getTitle () const;
const std::string& getType () const;
const std::vector<Projects::CProperty*>& getProperties () const;
protected:
CProject (std::string title, std::string type, CScene* scene);
CProject (std::string title, std::string type, CWallpaper* wallpaper);
void insertProperty (Projects::CProperty* property);
private:
@ -32,7 +32,6 @@ namespace WallpaperEngine::Core
std::string m_title;
std::string m_type;
CScene* m_scene;
CWallpaper* m_wallpaper;
};
};

View File

@ -1,33 +1,10 @@
#include "CScene.h"
#include "CProject.h"
#include "WallpaperEngine/Core/Objects/CVideo.h"
#include "WallpaperEngine/FileSystem/FileSystem.h"
using namespace WallpaperEngine::Core;
CScene::CScene () :
m_camera (new Core::Scenes::CCamera()),
m_ambientColor (irr::video::SColorf (0)),
m_bloom (false),
m_bloomStrength (0),
m_bloomThreshold (0),
m_cameraFade (false),
m_cameraParallax (false),
m_cameraParallaxAmount (0),
m_cameraParallaxDelay (0),
m_cameraParallaxMouseInfluence (0),
m_cameraPreview (false),
m_cameraShake (false),
m_cameraShakeAmplitude (0),
m_cameraShakeRoughness (0),
m_cameraShakeSpeed (0),
m_clearColor (irr::video::SColorf (0)),
m_orthogonalProjection (new Core::Scenes::CProjection()),
m_skylightColor (irr::video::SColorf (0))
{
}
CScene::CScene (
Scenes::CCamera* camera,
irr::video::SColorf ambientColor,
@ -47,6 +24,7 @@ CScene::CScene (
irr::video::SColorf clearColor,
Scenes::CProjection* orthogonalProjection,
irr::video::SColorf skylightColor) :
CWallpaper (Type),
m_camera (camera),
m_ambientColor (ambientColor),
m_bloom (bloom),
@ -68,21 +46,7 @@ CScene::CScene (
{
}
CScene* CScene::fromFile (const irr::io::path& filename, const char *type)
{
if (strcmp(type, "scene") == 0)
{
return loadScene (filename);
}
else if (strcmp(type, "video") == 0)
{
return loadVideo (filename);
}
throw std::runtime_error("Unsupported wallpaper type");
}
CScene* CScene::loadScene (const irr::io::path& filename)
CScene* CScene::fromFile (const irr::io::path& filename)
{
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename));
@ -142,17 +106,6 @@ CScene* CScene::loadScene (const irr::io::path& filename)
return scene;
}
CScene* CScene::loadVideo (const irr::io::path& filename)
{
CScene* scene = new CScene();
scene->insertObject (
new Core::Objects::CVideo(filename)
);
return scene;
}
const std::vector<CObject*>& CScene::getObjects () const
{
return this->m_objects;
@ -163,16 +116,6 @@ void CScene::insertObject (CObject* object)
this->m_objects.push_back (object);
}
CProject* CScene::getProject ()
{
return this->m_project;
}
void CScene::setProject (CProject* project)
{
this->m_project = project;
}
const Scenes::CCamera* CScene::getCamera () const
{
return this->m_camera;
@ -262,3 +205,5 @@ const irr::video::SColorf& CScene::getSkylightColor () const
{
return this->m_skylightColor;
}
const std::string CScene::Type = "scene";

View File

@ -2,8 +2,8 @@
#include <irrlicht/irrlicht.h>
#include "CProject.h"
#include "CObject.h"
#include "CWallpaper.h"
#include "Core.h"
@ -14,19 +14,13 @@ namespace WallpaperEngine::Core
{
using json = nlohmann::json;
class CProject;
class CObject;
class CScene
class CScene : public CWallpaper
{
public:
CScene ();
static CScene* fromFile (const irr::io::path& filename);
static CScene* fromFile (const irr::io::path& filename, const char *type);
static CScene* loadScene (const irr::io::path& filename);
static CScene* loadVideo (const irr::io::path& filename);
CProject* getProject ();
const std::vector<CObject*>& getObjects () const;
const irr::video::SColorf& getAmbientColor() const;
@ -49,9 +43,7 @@ namespace WallpaperEngine::Core
const Scenes::CCamera* getCamera () const;
protected:
friend class CProject;
void setProject (CProject* project);
friend class CWallpaper;
CScene (
Scenes::CCamera* camera,
@ -74,9 +66,10 @@ namespace WallpaperEngine::Core
irr::video::SColorf skylightColor
);
static const std::string Type;
void insertObject (CObject* object);
private:
CProject* m_project;
Scenes::CCamera* m_camera;
// data from general section on the json

View File

@ -1,10 +1,10 @@
#include "CVideo.h"
using namespace WallpaperEngine::Core::Objects;
using namespace WallpaperEngine::Core;
CVideo::CVideo (
const irr::io::path& filename) :
CObject (true, 0, "video", Type, irr::core::vector3df(0), irr::core::vector3df(0), irr::core::vector3df(0))
CWallpaper (Type)
{
if (avformat_open_input (&m_formatCtx, filename.c_str(), NULL, NULL) < 0)
throw std::runtime_error ("Failed to open file");
@ -55,17 +55,14 @@ void CVideo::initFrames (int width, int height)
if (m_videoFrameRGB == nullptr)
throw std::runtime_error ("Failed to allocate video frame");
m_width = width;
m_height = height;
int numBytes = av_image_get_buffer_size (AV_PIX_FMT_RGB24, m_width, m_height, 1);
int numBytes = av_image_get_buffer_size (AV_PIX_FMT_RGB24, width, height, 1);
uint8_t* buffer = (uint8_t*)av_malloc (numBytes * sizeof (uint8_t));
av_image_fill_arrays (m_videoFrameRGB->data, m_videoFrameRGB->linesize, buffer, AV_PIX_FMT_RGB24, m_width, m_height, 1);
av_image_fill_arrays (m_videoFrameRGB->data, m_videoFrameRGB->linesize, buffer, AV_PIX_FMT_RGB24, width, height, 1);
m_swsCtx = sws_getContext (m_codecCtx->width, m_codecCtx->height,
m_codecCtx->pix_fmt,
m_width, m_height,
width, height,
AV_PIX_FMT_RGB24,
SWS_BILINEAR, NULL, NULL, NULL);
@ -135,14 +132,4 @@ void CVideo::restartStream ()
avcodec_flush_buffers (m_codecCtx);
}
int CVideo::getWidth () const
{
return this->m_width;
}
int CVideo::getHeight () const
{
return this->m_height;
}
const std::string CVideo::Type = "video";

View File

@ -2,8 +2,8 @@
#include <irrlicht/irrlicht.h>
#include "WallpaperEngine/Core/Core.h"
#include "WallpaperEngine/Core/CObject.h"
#include "Core.h"
#include "CWallpaper.h"
extern "C"
{
@ -13,12 +13,10 @@ extern "C"
#include <libswscale/swscale.h>
}
namespace WallpaperEngine::Core::Objects
namespace WallpaperEngine::Core
{
class CVideo : public CObject
class CVideo : public CWallpaper
{
friend class CObject;
public:
CVideo (
const irr::io::path& filename
@ -29,14 +27,13 @@ namespace WallpaperEngine::Core::Objects
void getNextFrame ();
void writeFrameToImage (irr::video::IImage* image);
int getWidth () const;
int getHeight () const;
protected:
void restartStream ();
friend class CWallpaper;
static const std::string Type;
void restartStream ();
private:
AVFormatContext* m_formatCtx = nullptr;
AVCodecContext* m_codecCtx = nullptr;
@ -45,6 +42,5 @@ namespace WallpaperEngine::Core::Objects
SwsContext* m_swsCtx = nullptr;
int m_videoStream = -1, m_audioStream = -1;
int m_width, m_height;
};
};

View File

@ -0,0 +1,18 @@
#include "CWallpaper.h"
using namespace WallpaperEngine::Core;
CWallpaper::CWallpaper (std::string type) :
m_type (type)
{
}
CProject* CWallpaper::getProject ()
{
return this->m_project;
}
void CWallpaper::setProject (CProject* project)
{
this->m_project = project;
}

View File

@ -0,0 +1,33 @@
#pragma once
#include <assert.h>
#include "CProject.h"
namespace WallpaperEngine::Core
{
class CProject;
class CWallpaper
{
public:
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> bool is () { return this->m_type == T::Type; }
CWallpaper (std::string type);
CProject* getProject ();
protected:
friend class CProject;
void setProject (CProject* project);
private:
CProject* m_project;
std::string m_type;
};
}

View File

@ -2,13 +2,6 @@
using namespace WallpaperEngine::Core::Scenes;
CCamera::CCamera () :
m_center (0),
m_eye (0),
m_up (0)
{
}
CCamera::CCamera (irr::core::vector3df center, irr::core::vector3df eye, irr::core::vector3df up) :
m_center (center),
m_eye (eye),

View File

@ -11,7 +11,6 @@ namespace WallpaperEngine::Core::Scenes
class CCamera
{
public:
CCamera ();
static CCamera* fromJSON (json data);
const irr::core::vector3df& getCenter () const;

View File

@ -2,12 +2,6 @@
using namespace WallpaperEngine::Core::Scenes;
CProjection::CProjection () :
m_width (0),
m_height (0)
{
}
CProjection::CProjection (irr::u32 width, irr::u32 height) :
m_width (width),
m_height (height)

View File

@ -11,7 +11,6 @@ namespace WallpaperEngine::Core::Scenes
class CProjection
{
public:
CProjection ();
static CProjection* fromJSON (json data);
const irr::u32& getWidth () const;

View File

@ -188,7 +188,7 @@ void CContext::renderFrame (Render::CScene* scene)
void CContext::drawScene (Render::CScene* scene, bool backBuffer)
{
this->getDevice ()->getVideoDriver ()->beginScene (backBuffer, true, scene->getScene ()->getClearColor ().toSColor());
this->getDevice ()->getVideoDriver ()->beginScene (backBuffer, true, scene->getWallpaperData ()->as <Core::CScene> ()->getClearColor ().toSColor());
this->getDevice ()->getSceneManager ()->drawAll ();
this->getDevice ()->getVideoDriver ()->endScene ();
}

View File

@ -1,11 +1,9 @@
#include "WallpaperEngine/Irrlicht/CContext.h"
#include "WallpaperEngine/Core/Objects/CImage.h"
#include "WallpaperEngine/Core/Objects/CVideo.h"
#include "WallpaperEngine/Core/Objects/CSound.h"
#include "WallpaperEngine/Render/Objects/CImage.h"
#include "WallpaperEngine/Render/Objects/CVideo.h"
#include "WallpaperEngine/Render/Objects/CSound.h"
#include "CScene.h"
@ -13,23 +11,22 @@
using namespace WallpaperEngine;
using namespace WallpaperEngine::Render;
CScene::CScene (const Core::CProject* project, Irrlicht::CContext* context) :
CScene::CScene (Core::CScene* scene, Irrlicht::CContext* context) :
CWallpaper (scene, Type),
irr::scene::ISceneNode (
context->getDevice ()->getSceneManager ()->getRootSceneNode (),
context->getDevice ()->getSceneManager ()
),
m_project (project),
m_scene (project->getScene ()),
m_context (context)
{
this->m_camera = new CCamera (this, this->m_project->getScene ()->getCamera ());
this->m_camera = new CCamera (this, scene->getCamera ());
this->m_camera->setOrthogonalProjection (
this->m_scene->getOrthogonalProjection ()->getWidth (),
this->m_scene->getOrthogonalProjection ()->getHeight ()
scene->getOrthogonalProjection ()->getWidth (),
scene->getOrthogonalProjection ()->getHeight ()
);
auto cur = this->m_scene->getObjects ().begin ();
auto end = this->m_scene->getObjects ().end ();
auto cur = scene->getObjects ().begin ();
auto end = scene->getObjects ().end ();
int highestId = 0;
@ -42,13 +39,6 @@ CScene::CScene (const Core::CProject* project, Irrlicht::CContext* context) :
{
new Objects::CImage (this, (*cur)->as<Core::Objects::CImage>());
}
else if ((*cur)->is<Core::Objects::CVideo>() == true)
{
Core::Objects::CVideo* video = (*cur)->as<Core::Objects::CVideo>();
video->initFrames (m_context->getDevice ()->getVideoDriver ()->getScreenSize().Width,
m_context->getDevice ()->getVideoDriver ()->getScreenSize().Height);
new Objects::CVideo (this, video);
}
else if ((*cur)->is<Core::Objects::CSound>() == true)
{
new Objects::CSound (this, (*cur)->as<Core::Objects::CSound>());
@ -69,11 +59,6 @@ Irrlicht::CContext* CScene::getContext ()
return this->m_context;
}
const Core::CScene* CScene::getScene () const
{
return this->m_scene;
}
CCamera* CScene::getCamera () const
{
return this->m_camera;
@ -88,6 +73,11 @@ void CScene::render ()
{
}
void CScene::renderWallpaper ()
{
this->m_context->renderFrame (this);
}
const irr::core::aabbox3d<irr::f32>& CScene::getBoundingBox () const
{
return this->m_boundingBox;
@ -97,4 +87,6 @@ void CScene::OnRegisterSceneNode ()
SceneManager->registerNodeForRendering (this);
ISceneNode::OnRegisterSceneNode ();
}
}
const std::string CScene::Type = "scene";

View File

@ -2,9 +2,10 @@
#include "CCamera.h"
#include "WallpaperEngine/Core/CProject.h"
#include "WallpaperEngine/Core/CScene.h"
#include "WallpaperEngine/Render/CWallpaper.h"
#include "WallpaperEngine/Irrlicht/CContext.h"
namespace WallpaperEngine::Irrlicht
@ -16,23 +17,28 @@ namespace WallpaperEngine::Render
{
class CCamera;
class CScene : public irr::scene::ISceneNode
class CScene : public CWallpaper, public irr::scene::ISceneNode
{
public:
CScene (const Core::CProject* project, Irrlicht::CContext* context);
CScene (Core::CScene* scene, Irrlicht::CContext* context);
~CScene () override;
Irrlicht::CContext* getContext ();
const Core::CScene* getScene () const;
CCamera* getCamera () const;
int nextId ();
void render () override;
const irr::core::aabbox3d<irr::f32>& getBoundingBox() const override;
void OnRegisterSceneNode () override;
void renderWallpaper () override;
protected:
friend class CWallpaper;
static const std::string Type;
private:
const Core::CProject* m_project;
const Core::CScene* m_scene;
CCamera* m_camera;
Irrlicht::CContext* m_context;
irr::u32 m_nextId;

View File

@ -0,0 +1,30 @@
#include "CVideo.h"
using namespace WallpaperEngine;
using namespace WallpaperEngine::Render;
CVideo::CVideo (Core::CVideo* video, irr::video::IVideoDriver* driver) :
CWallpaper (video, Type),
m_driver (driver)
{
int width = driver->getScreenSize ().Width;
int height = driver->getScreenSize ().Height;
video->initFrames (width, height);
m_frameImage = m_driver->createImage (irr::video::ECOLOR_FORMAT::ECF_R8G8B8,
irr::core::dimension2du(width, height));
}
void CVideo::renderWallpaper ()
{
Core::CVideo* video = m_wallpaperData->as <Core::CVideo> ();
video->getNextFrame ();
video->writeFrameToImage (m_frameImage);
m_driver->removeTexture (m_frameTexture);
m_frameTexture = m_driver->addTexture ("frameTexture", m_frameImage);
m_driver->draw2DImage (m_frameTexture, irr::core::vector2di(0));
}
const std::string CVideo::Type = "video";

View File

@ -0,0 +1,31 @@
#pragma once
#include <irrlicht/irrlicht.h>
#include "WallpaperEngine/Core/CVideo.h"
#include "WallpaperEngine/Render/CWallpaper.h"
namespace WallpaperEngine::Render
{
class CWallpaper;
class CVideo : public CWallpaper
{
public:
CVideo (Core::CVideo* video, irr::video::IVideoDriver* driver);
void renderWallpaper () override;
protected:
friend class CWallpaper;
static const std::string Type;
private:
irr::video::IImage* m_frameImage;
irr::video::ITexture* m_frameTexture;
irr::video::IVideoDriver* m_driver;
};
};

View File

@ -0,0 +1,14 @@
#include "CWallpaper.h"
using namespace WallpaperEngine::Render;
CWallpaper::CWallpaper (Core::CWallpaper* wallpaperData, std::string type) :
m_wallpaperData (wallpaperData),
m_type (type)
{
}
WallpaperEngine::Core::CWallpaper* CWallpaper::getWallpaperData ()
{
return this->m_wallpaperData;
}

View File

@ -0,0 +1,29 @@
#pragma once
#include <assert.h>
#include "WallpaperEngine/Core/CWallpaper.h"
namespace WallpaperEngine::Render
{
class CWallpaper
{
public:
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> bool is () { return this->m_type == T::Type; }
CWallpaper (Core::CWallpaper* wallpaperData, std::string type);
Core::CWallpaper* getWallpaperData ();
virtual void renderWallpaper () = 0;
protected:
Core::CWallpaper* m_wallpaperData;
private:
std::string m_type;
};
}

View File

@ -1,35 +0,0 @@
#include "CVideo.h"
using namespace WallpaperEngine;
using namespace WallpaperEngine::Render::Objects;
CVideo::CVideo (CScene* scene, Core::Objects::CVideo* video) :
Render::CObject (scene, Type, video),
m_video (video)
{
m_frameImage = this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->createImage (irr::video::ECOLOR_FORMAT::ECF_R8G8B8,
irr::core::dimension2du(m_video->getWidth(), m_video->getHeight()));
this->m_boundingBox = irr::core::aabbox3d<irr::f32> (0, 0, 0, 0, 0, 0);
}
void CVideo::render ()
{
irr::video::IVideoDriver* driver = this->getScene ()->getContext ()->getDevice ()->getVideoDriver ();
m_video->getNextFrame ();
m_video->writeFrameToImage (m_frameImage);
driver->removeTexture (m_frameTexture);
m_frameTexture = driver->addTexture ("frameTexture", m_frameImage);
driver->draw2DImage (m_frameTexture, irr::core::vector2di(0));
}
const irr::core::aabbox3d<irr::f32>& CVideo::getBoundingBox () const
{
return this->m_boundingBox;
}
const std::string CVideo::Type = "video";

View File

@ -1,28 +0,0 @@
#pragma once
#include "WallpaperEngine/Core/Objects/CVideo.h"
#include "WallpaperEngine/Render/CScene.h"
#include "WallpaperEngine/Render/CObject.h"
namespace WallpaperEngine::Render::Objects
{
class CVideo : public CObject
{
public:
CVideo (CScene* scene, Core::Objects::CVideo* video);
void render () override;
const irr::core::aabbox3d<irr::f32>& getBoundingBox () const override;
protected:
static const std::string Type;
private:
irr::video::IImage* m_frameImage;
irr::video::ITexture* m_frameTexture;
Core::Objects::CVideo* m_video;
irr::core::aabbox3d<irr::f32> m_boundingBox;
};
};