~ Removed static variables in namespace WallpaperEngine::Irrlicht and moved to a context approach

This includes changes to old code to be compatible, the externs won't be used once the renderer is rewritten and the old code removed

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2019-09-05 17:24:16 +02:00
parent 1c50095ead
commit b8b3c2899d
22 changed files with 1072 additions and 906 deletions

View File

@ -48,14 +48,14 @@ add_executable(
src/WallpaperEngine/video/material.h
src/WallpaperEngine/texture.cpp
src/WallpaperEngine/texture.h
src/WallpaperEngine/Irrlicht/CContext.h
src/WallpaperEngine/Irrlicht/CContext.cpp
src/WallpaperEngine/Irrlicht/CImageLoaderTEX.h
src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp
src/WallpaperEngine/Irrlicht/CPkgReader.h
src/WallpaperEngine/Irrlicht/CPkgReader.cpp
src/WallpaperEngine/Irrlicht/CFileList.h
src/WallpaperEngine/Irrlicht/CFileList.cpp
src/WallpaperEngine/Irrlicht/Irrlicht.cpp
src/WallpaperEngine/Irrlicht/Irrlicht.h
src/WallpaperEngine/sound.cpp
src/WallpaperEngine/sound.h

View File

@ -8,20 +8,26 @@
#include <SDL_mixer.h>
#include <SDL.h>
#include <X11/Xlib.h>
#include "WallpaperEngine/Render/Shaders/Compiler.h"
#include "WallpaperEngine/project.h"
#include "WallpaperEngine/Irrlicht/Irrlicht.h"
#include "WallpaperEngine/Irrlicht/CImageLoaderTEX.h"
#include "WallpaperEngine/Core/CProject.h"
#include "WallpaperEngine/Irrlicht/CContext.h"
int WinID = 0;
irr::SIrrlichtCreationParameters _irr_params;
irr::f32 g_Time = 0;
WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
int init_irrlicht()
{
IrrlichtContext = new WallpaperEngine::Irrlicht::CContext ();
// prepare basic configuration for irrlicht
_irr_params.AntiAlias = 8;
_irr_params.Bits = 16;
@ -38,31 +44,34 @@ int init_irrlicht()
_irr_params.WithAlphaChannel = false;
_irr_params.ZBufferBits = 24;
_irr_params.LoggingLevel = irr::ELL_DEBUG;
_irr_params.WindowId = reinterpret_cast<void*> (WinID);
WallpaperEngine::Irrlicht::device = irr::createDeviceEx (_irr_params);
Display* display = XOpenDisplay (NULL);
int screen = XDefaultScreen (display);
if (WallpaperEngine::Irrlicht::device == nullptr)
_irr_params.WindowId = reinterpret_cast<void*> (XRootWindow (display, screen));
IrrlichtContext->setDevice (irr::createDeviceEx (_irr_params));
if (IrrlichtContext->getDevice () == nullptr)
{
return 1;
}
WallpaperEngine::Irrlicht::device->setWindowCaption (L"Test game");
WallpaperEngine::Irrlicht::driver = WallpaperEngine::Irrlicht::device->getVideoDriver();
IrrlichtContext->getDevice ()->setWindowCaption (L"Test game");
// check for ps and vs support
if (
WallpaperEngine::Irrlicht::driver->queryFeature (irr::video::EVDF_PIXEL_SHADER_1_1) == false &&
WallpaperEngine::Irrlicht::driver->queryFeature (irr::video::EVDF_ARB_FRAGMENT_PROGRAM_1) == false)
IrrlichtContext->getDevice ()->getVideoDriver()->queryFeature (irr::video::EVDF_PIXEL_SHADER_1_1) == false &&
IrrlichtContext->getDevice ()->getVideoDriver()->queryFeature (irr::video::EVDF_ARB_FRAGMENT_PROGRAM_1) == false)
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("WARNING: Pixel shaders disabled because of missing driver/hardware support");
IrrlichtContext->getDevice ()->getLogger ()->log ("WARNING: Pixel shaders disabled because of missing driver/hardware support");
}
if (
WallpaperEngine::Irrlicht::driver->queryFeature (irr::video::EVDF_VERTEX_SHADER_1_1) == false &&
WallpaperEngine::Irrlicht::driver->queryFeature (irr::video::EVDF_ARB_VERTEX_PROGRAM_1) == false)
IrrlichtContext->getDevice ()->getVideoDriver()->queryFeature (irr::video::EVDF_VERTEX_SHADER_1_1) == false &&
IrrlichtContext->getDevice ()->getVideoDriver()->queryFeature (irr::video::EVDF_ARB_VERTEX_PROGRAM_1) == false)
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("WARNING: Vertex shaders disabled because of missing driver/hardware support");
IrrlichtContext->getDevice ()->getLogger ()->log ("WARNING: Vertex shaders disabled because of missing driver/hardware support");
}
return 0;
@ -71,11 +80,15 @@ int init_irrlicht()
void preconfigure_wallpaper_engine ()
{
// load the assets from wallpaper engine
WallpaperEngine::Irrlicht::device->getFileSystem ()->addFileArchive ("assets.zip", true, false);
IrrlichtContext->getDevice ()->getFileSystem ()->addFileArchive ("assets.zip", true, false);
// register custom loaders
WallpaperEngine::Irrlicht::driver->addExternalImageLoader (new WallpaperEngine::Irrlicht::CImageLoaderTex ());
WallpaperEngine::Irrlicht::device->getFileSystem ()->addArchiveLoader (new WallpaperEngine::Irrlicht::CArchiveLoaderPkg (WallpaperEngine::Irrlicht::device->getFileSystem ()));
IrrlichtContext->getDevice ()->getVideoDriver()->addExternalImageLoader (
new WallpaperEngine::Irrlicht::CImageLoaderTex (IrrlichtContext)
);
IrrlichtContext->getDevice ()->getFileSystem ()->addArchiveLoader (
new WallpaperEngine::Irrlicht::CArchiveLoaderPkg (IrrlichtContext)
);
}
void print_help (const char* route)
@ -158,7 +171,7 @@ int main (int argc, char* argv[])
std::cout << "Initializing irrlicht to WindowID " << WinID << std::endl;
if (init_irrlicht())
if (init_irrlicht ())
{
return 1;
}
@ -178,21 +191,21 @@ int main (int argc, char* argv[])
// pkg mode
case 1:
path = stringPathFixes(path);
wallpaper_path = WallpaperEngine::Irrlicht::device->getFileSystem ()->getAbsolutePath (path.c_str ());
wallpaper_path = IrrlichtContext->getDevice ()->getFileSystem ()->getAbsolutePath (path.c_str ());
project_path = wallpaper_path + "project.json";
scene_path = wallpaper_path + "scene.pkg";
WallpaperEngine::Irrlicht::device->getFileSystem ()->addFileArchive (scene_path, true, false); // add the pkg file to the lookup list
IrrlichtContext->getDevice ()->getFileSystem ()->addFileArchive (scene_path, true, false); // add the pkg file to the lookup list
break;
// folder mode
case 2:
path = stringPathFixes(path);
wallpaper_path = WallpaperEngine::Irrlicht::device->getFileSystem ()->getAbsolutePath (path.c_str ());
wallpaper_path = IrrlichtContext->getDevice ()->getFileSystem ()->getAbsolutePath (path.c_str ());
project_path = wallpaper_path + "project.json";
// set our working directory
WallpaperEngine::Irrlicht::device->getFileSystem ()->changeWorkingDirectoryTo (wallpaper_path);
IrrlichtContext->getDevice ()->getFileSystem ()->changeWorkingDirectoryTo (wallpaper_path);
break;
default:
@ -205,7 +218,7 @@ int main (int argc, char* argv[])
if (SDL_Init (SDL_INIT_AUDIO) < 0 || mixer_flags != Mix_Init (mixer_flags))
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Cannot initialize SDL audio system", irr::ELL_ERROR);
IrrlichtContext->getDevice ()->getLogger ()->log ("Cannot initialize SDL audio system", irr::ELL_ERROR);
return -1;
}
@ -221,7 +234,10 @@ int main (int argc, char* argv[])
}
else
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Non-orthogonal cameras not supported yet!!", irr::ELL_ERROR);
IrrlichtContext->getDevice ()->getLogger ()->log (
"Non-orthogonal cameras not supported yet!!", irr::ELL_ERROR
);
return -2;
}
@ -232,11 +248,11 @@ int main (int argc, char* argv[])
int32_t minimumTime = 1000 / 90;
int32_t currentTime = 0;
while (WallpaperEngine::Irrlicht::device->run () && WallpaperEngine::Irrlicht::driver)
while (IrrlichtContext->getDevice ()->run () && IrrlichtContext && IrrlichtContext->getDevice ())
{
// if (device->isWindowActive ())
{
currentTime = WallpaperEngine::Irrlicht::device->getTimer ()->getTime ();
currentTime = IrrlichtContext->getDevice ()->getTimer ()->getTime ();
g_Time = currentTime / 1000.0f;
if (currentTime - lastTime > minimumTime)
@ -246,7 +262,7 @@ int main (int argc, char* argv[])
}
else
{
WallpaperEngine::Irrlicht::device->sleep (1, false);
IrrlichtContext->getDevice ()->sleep (1, false);
}
}
}

View File

@ -2,13 +2,15 @@
#include "FileSystem.h"
// engine includes
#include "WallpaperEngine/Irrlicht/Irrlicht.h"
#include "WallpaperEngine/Irrlicht/CContext.h"
extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
namespace WallpaperEngine::FileSystem
{
std::string loadFullFile (irr::io::path file)
{
irr::io::IReadFile* reader = WallpaperEngine::Irrlicht::device->getFileSystem ()->createAndOpenFile (file);
irr::io::IReadFile* reader = IrrlichtContext->getDevice ()->getFileSystem ()->createAndOpenFile (file);
if (reader == NULL)
throw std::runtime_error ("Cannot open file " + std::string (file.c_str ()) + " for reading");

View File

@ -0,0 +1,14 @@
#include "CContext.h"
namespace WallpaperEngine::Irrlicht
{
void CContext::setDevice (irr::IrrlichtDevice* device)
{
this->m_device = device;
}
irr::IrrlichtDevice* CContext::getDevice ()
{
return this->m_device;
}
};

View File

@ -0,0 +1,16 @@
#pragma once
#include <irrlicht/irrlicht.h>
namespace WallpaperEngine::Irrlicht
{
class CContext
{
public:
void setDevice (irr::IrrlichtDevice* device);
irr::IrrlichtDevice* getDevice ();
private:
irr::IrrlichtDevice* m_device;
};
};

View File

@ -2,145 +2,135 @@
#include "CFileList.h"
using namespace WallpaperEngine::Irrlicht;
using namespace irr;
static const io::path emptyFileListEntry;
CFileList::CFileList(const io::path& path, bool ignoreCase, bool ignorePaths)
: IgnorePaths(ignorePaths), IgnoreCase(ignoreCase), Path(path)
namespace WallpaperEngine::Irrlicht
{
Path.replace('\\', '/');
}
static const irr::io::path emptyFileListEntry;
CFileList::~CFileList()
{
Files.clear();
}
CFileList::CFileList (const irr::io::path& path, bool ignoreCase, bool ignorePaths) :
m_ignorePaths (ignorePaths),
m_ignoreCase (ignoreCase),
m_path(path)
{
this->m_path.replace ('\\', '/');
}
u32 CFileList::getFileCount() const
{
return Files.size();
}
CFileList::~CFileList ()
{
this->m_files.clear ();
}
void CFileList::sort()
{
Files.sort();
}
irr::u32 CFileList::getFileCount () const
{
return this->m_files.size ();
}
const io::path& CFileList::getFileName(u32 index) const
{
if (index >= Files.size())
return emptyFileListEntry;
void CFileList::sort ()
{
this->m_files.sort ();
}
return Files[index].Name;
}
const irr::io::path& CFileList::getFileName (irr::u32 index) const
{
return (index < this->m_files.size ()) ? this->m_files [index].Name : emptyFileListEntry;
}
//! Gets the full name of a file in the list, path included, based on an index.
const io::path& CFileList::getFullFileName(u32 index) const
{
if (index >= Files.size())
return emptyFileListEntry;
return Files[index].FullName;
}
//! adds a file or folder
u32 CFileList::addItem(const io::path& fullPath, u32 offset, u32 size, bool isDirectory, u32 id)
{
SFileListEntry entry;
entry.ID = id ? id : Files.size();
entry.Offset = offset;
entry.Size = size;
entry.Name = fullPath;
entry.Name.replace('\\', '/');
entry.IsDirectory = isDirectory;
// remove trailing slash
if (entry.Name.lastChar() == '/')
const irr::io::path& CFileList::getFullFileName (irr::u32 index) const
{
entry.IsDirectory = true;
entry.Name[entry.Name.size()-1] = 0;
entry.Name.validate();
return (index < this->m_files.size ()) ? this->m_files [index].FullName : emptyFileListEntry;
}
if (IgnoreCase)
entry.Name.make_lower();
//! adds a file or folder
irr::u32 CFileList::addItem (const irr::io::path& fullPath, irr::u32 offset, irr::u32 size, bool isDirectory, irr::u32 id)
{
SFileListEntry entry;
entry.ID = id ? id : this->m_files.size ();
entry.Offset = offset;
entry.Size = size;
entry.Name = fullPath;
entry.Name.replace ('\\', '/');
entry.IsDirectory = isDirectory;
entry.FullName = entry.Name;
// remove trailing slash
if (entry.Name.lastChar () == '/')
{
entry.IsDirectory = true;
entry.Name [entry.Name.size ()-1] = 0;
entry.Name.validate ();
}
core::deletePathFromFilename(entry.Name);
if (this->m_ignoreCase)
entry.Name.make_lower ();
if (IgnorePaths)
entry.FullName = entry.Name;
//os::Printer::log(Path.c_str(), entry.FullName);
irr::core::deletePathFromFilename (entry.Name);
Files.push_back(entry);
if (this->m_ignorePaths)
entry.FullName = entry.Name;
return Files.size() - 1;
}
this->m_files.push_back (entry);
return this->m_files.size () - 1;
}
//! Returns the ID of a file in the file list, based on an index.
u32 CFileList::getID(u32 index) const
{
return index < Files.size() ? Files[index].ID : 0;
}
irr::u32 CFileList::getID (irr::u32 index) const
{
return (index < this->m_files.size ()) ? this->m_files [index].ID : 0;
}
bool CFileList::isDirectory(u32 index) const
{
bool ret = false;
if (index < Files.size())
ret = Files[index].IsDirectory;
return ret;
}
bool CFileList::isDirectory (irr::u32 index) const
{
return (index < this->m_files.size ()) ? this->m_files [index].IsDirectory : false;
}
//! Returns the size of a file
u32 CFileList::getFileSize(u32 index) const
{
return index < Files.size() ? Files[index].Size : 0;
}
irr::u32 CFileList::getFileSize (irr::u32 index) const
{
return (index < this->m_files.size ()) ? this->m_files [index].Size : 0;
}
//! Returns the size of a file
u32 CFileList::getFileOffset(u32 index) const
{
return index < Files.size() ? Files[index].Offset : 0;
}
irr::u32 CFileList::getFileOffset (irr::u32 index) const
{
return (index < this->m_files.size ()) ? this->m_files [index].Offset : 0;
}
//! Searches for a file or folder within the list, returns the index
s32 CFileList::findFile(const io::path& filename, bool isDirectory = false) const
{
SFileListEntry entry;
// we only need FullName to be set for the search
entry.FullName = filename;
entry.IsDirectory = isDirectory;
// exchange
entry.FullName.replace('\\', '/');
// remove trailing slash
if (entry.FullName.lastChar() == '/')
irr::s32 CFileList::findFile (const irr::io::path& filename, bool isDirectory = false) const
{
entry.IsDirectory = true;
entry.FullName[entry.FullName.size()-1] = 0;
entry.FullName.validate();
SFileListEntry entry;
// we only need FullName to be set for the search
entry.FullName = filename;
entry.IsDirectory = isDirectory;
// exchange
entry.FullName.replace('\\', '/');
// remove trailing slash
if (entry.FullName.lastChar () == '/')
{
entry.IsDirectory = true;
entry.FullName [entry.FullName.size ()-1] = 0;
entry.FullName.validate ();
}
if (this->m_ignoreCase)
entry.FullName.make_lower ();
if (this->m_ignorePaths)
irr::core::deletePathFromFilename (entry.FullName);
return this->m_files.binary_search (entry);
}
if (IgnoreCase)
entry.FullName.make_lower();
if (IgnorePaths)
core::deletePathFromFilename(entry.FullName);
return Files.binary_search(entry);
}
//! Returns the base path of the file list
const io::path& CFileList::getPath() const
{
return Path;
}
const irr::io::path& CFileList::getPath () const
{
return m_path;
}
};

View File

@ -2,8 +2,6 @@
#include <irrlicht/irrlicht.h>
using namespace irr;
namespace WallpaperEngine::Irrlicht
{
//! An entry in a list of files, can be a folder or a file.
@ -12,49 +10,49 @@ namespace WallpaperEngine::Irrlicht
//! The name of the file
/** If this is a file or folder in the virtual filesystem and the archive
was created with the ignoreCase flag then the file name will be lower case. */
io::path Name;
irr::io::path Name;
//! The name of the file including the path
/** If this is a file or folder in the virtual filesystem and the archive was
created with the ignoreDirs flag then it will be the same as Name. */
io::path FullName;
irr::io::path FullName;
//! The size of the file in bytes
u32 Size;
irr::u32 Size;
//! The ID of the file in an archive
/** This is used to link the FileList entry to extra info held about this
file in an archive, which can hold things like data offset and CRC. */
u32 ID;
irr::u32 ID;
//! FileOffset inside an archive
u32 Offset;
irr::u32 Offset;
//! True if this is a folder, false if not.
bool IsDirectory;
//! The == operator is provided so that CFileList can slowly search the list!
bool operator ==(const struct SFileListEntry& other) const
bool operator == (const struct SFileListEntry& other) const
{
if (IsDirectory != other.IsDirectory)
return false;
return FullName.equals_ignore_case(other.FullName);
return FullName.equals_ignore_case (other.FullName);
}
//! The < operator is provided so that CFileList can sort and quickly search the list.
bool operator <(const struct SFileListEntry& other) const
bool operator < (const struct SFileListEntry& other) const
{
if (IsDirectory != other.IsDirectory)
return IsDirectory;
return FullName.lower_ignore_case(other.FullName);
return FullName.lower_ignore_case (other.FullName);
}
};
//! Implementation of a file list
class CFileList : public io::IFileList
class CFileList : public irr::io::IFileList
{
public:
@ -62,10 +60,10 @@ namespace WallpaperEngine::Irrlicht
//! Constructor
/** \param path The path of this file archive */
CFileList(const io::path& path, bool ignoreCase, bool ignorePaths);
CFileList (const irr::io::path& path, bool ignoreCase, bool ignorePaths);
//! Destructor
virtual ~CFileList();
virtual ~CFileList ();
//! Add as a file or folder to the list
/** \param fullPath The file name including path, up to the root of the file list.
@ -73,51 +71,51 @@ namespace WallpaperEngine::Irrlicht
\param offset The offset where the file is stored in an archive
\param size The size of the file in bytes.
\param id The ID of the file in the archive which owns it */
virtual u32 addItem(const io::path& fullPath, u32 offset, u32 size, bool isDirectory, u32 id=0);
virtual irr::u32 addItem (const irr::io::path& fullPath, irr::u32 offset, irr::u32 size, bool isDirectory, irr::u32 id=0);
//! Sorts the file list. You should call this after adding any items to the file list
virtual void sort();
virtual void sort ();
//! Returns the amount of files in the filelist.
virtual u32 getFileCount() const;
virtual irr::u32 getFileCount () const;
//! Gets the name of a file in the list, based on an index.
virtual const io::path& getFileName(u32 index) const;
virtual const irr::io::path& getFileName (irr::u32 index) const;
//! Gets the full name of a file in the list, path included, based on an index.
virtual const io::path& getFullFileName(u32 index) const;
virtual const irr::io::path& getFullFileName (irr::u32 index) const;
//! Returns the ID of a file in the file list, based on an index.
virtual u32 getID(u32 index) const;
virtual irr::u32 getID (irr::u32 index) const;
//! Returns true if the file is a directory
virtual bool isDirectory(u32 index) const;
virtual bool isDirectory (irr::u32 index) const;
//! Returns the size of a file
virtual u32 getFileSize(u32 index) const;
virtual irr::u32 getFileSize (irr::u32 index) const;
//! Returns the offest of a file
virtual u32 getFileOffset(u32 index) const;
virtual irr::u32 getFileOffset (irr::u32 index) const;
//! Searches for a file or folder within the list, returns the index
virtual s32 findFile(const io::path& filename, bool isFolder) const;
virtual irr::s32 findFile (const irr::io::path& filename, bool isFolder) const;
//! Returns the base path of the file list
virtual const io::path& getPath() const;
virtual const irr::io::path& getPath () const;
protected:
//! Ignore paths when adding or searching for files
bool IgnorePaths;
bool m_ignorePaths;
//! Ignore case when adding or searching for files
bool IgnoreCase;
bool m_ignoreCase;
//! Path to the file list
io::path Path;
irr::io::path m_path;
//! List of files
core::array<SFileListEntry> Files;
irr::core::array<SFileListEntry> m_files;
};
}

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,123 @@
#pragma once
#include <irrlicht/irrlicht.h>
#include <vector>
using namespace irr;
using namespace irr::video;
#include <irrlicht/irrlicht.h>
#include "CContext.h"
namespace WallpaperEngine::Irrlicht
{
//! Surface Loader for PNG files
class CImageLoaderTex : public IImageLoader
class CImageLoaderTex : public irr::video::IImageLoader
{
public:
CImageLoaderTex (CContext* context);
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".png")
virtual bool isALoadableFileExtension(const io::path& filename) const;
virtual bool isALoadableFileExtension(const irr::io::path& filename) const;
//! returns true if the file maybe is able to be loaded by this class
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
//! creates a surface from the file
virtual IImage* loadImage(io::IReadFile* input) const;
virtual irr::video::IImage* loadImage(irr::io::IReadFile* input) const;
virtual void loadImageFromARGB8Data (IImage* output, const char* input, u32 width, u32 height, u32 mipmap_width) const;
virtual void loadImageFromARGB8Data (irr::video::IImage* output, const char* input, irr::u32 width, irr::u32 height, irr::u32 mipmap_width) const;
virtual void loadImageFromDXT1 (IImage* output, const char* input, u32 destination_width, u32 destination_height, u32 origin_width, u32 origin_height) const;
virtual void loadImageFromDXT5 (IImage* output, const char* input, u32 destination_width, u32 destination_height, u32 origin_width, u32 origin_height) const;
virtual void loadImageFromDXT1 (irr::video::IImage* output, const char* input, irr::u32 destination_width, irr::u32 destination_height, irr::u32 origin_width, irr::u32 origin_height) const;
virtual void loadImageFromDXT5 (irr::video::IImage* output, const char* input, irr::u32 destination_width, irr::u32 destination_height, irr::u32 origin_width, irr::u32 origin_height) const;
private:
enum ContainerVersion
{
UNKNOWN = -1,
TEXB0003 = 3,
TEXB0002 = 2,
TEXB0001 = 1
};
class TextureMipmap
{
public:
TextureMipmap ();
~TextureMipmap ();
/** Width of the mipmap */
irr::u32 width;
/** Height of the mipmap */
irr::u32 height;
/** If the mipmap data is compressed */
irr::u32 compression;
/** Uncompressed size of the mipmap */
irr::u32 uncompressedSize;
/** Compress size of the mipmap */
irr::u32 compressedSize;
/** Pointer to the compressed data */
char* compressedData = nullptr;
/** Pointer to the uncompressed data */
char* uncompressedData = nullptr;
/**
* Performs actual decompression of the compressed data
*/
void decompressData ();
};
class TextureContainer
{
public:
TextureContainer ();
~TextureContainer ();
/** The version of the texture container */
ContainerVersion containerVersion = ContainerVersion::UNKNOWN;
/** Real width of the texture */
irr::u32 width;
/** Real height of the texture */
irr::u32 height;
/** Texture width in memory (power of 2) */
irr::u32 textureWidth;
/** Texture height in memory (power of 2) */
irr::u32 textureHeight;
/** Texture data format */
irr::u32 format;
/** Free Image format */
irr::u32 freeimageFormat;
/** Number of mipmap levels for the texture */
irr::u32 mipmapCount;
/** List of mipmaps */
std::vector <TextureMipmap*> mipmaps;
};
/** Irrlicht context */
CContext* m_context;
/**
* Parses the container file and returns a texture ready to be used
*
* @param input The file to parse the data from
*
* @return The texture ready to be used
*/
irr::video::IImage* parseFile (irr::io::IReadFile* input) const;
/**
* Parses the container header and returns it's information
*
* @param input The file to parse the data from
*
* @return The container header data
*/
TextureContainer* parseHeader (irr::io::IReadFile* input) const;
/**
* Parses a mipmap level and returns it's information
*
* @param header The container header where this mipmap is contained
* @param input The file to parse the data from
*
* @return The mipmap info ready
*/
TextureMipmap* parseMipmap (TextureContainer* header, irr::io::IReadFile* input) const;
void BlockDecompressImageDXT1(unsigned long width, unsigned long height, const unsigned char *blockStorage, unsigned long *image) const;
void DecompressBlockDXT1(unsigned long x, unsigned long y, unsigned long width, const unsigned char *blockStorage, unsigned long *image) const;
unsigned long PackRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) const;

View File

@ -1,192 +1,180 @@
#include <WallpaperEngine/Irrlicht/Irrlicht.h>
#include "CPkgReader.h"
using namespace WallpaperEngine::Irrlicht;
CArchiveLoaderPkg::CArchiveLoaderPkg(irr::io::IFileSystem* fs)
: FileSystem(fs)
namespace WallpaperEngine::Irrlicht
{
CArchiveLoaderPkg::CArchiveLoaderPkg (CContext* context) :
m_context (context)
{
#ifdef _DEBUG
setDebugName("CArchiveLoaderWAD");
setDebugName("CArchiveLoaderWAD");
#endif
}
//! returns true if the file maybe is able to be loaded by this class
bool CArchiveLoaderPkg::isALoadableFileFormat(const irr::io::path& filename) const
{
return irr::core::hasFileExtension (filename, "pkg");
}
//! Creates an archive from the filename
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
irr::io::IFileArchive* CArchiveLoaderPkg::createArchive(const irr::io::path& filename, bool ignoreCase, bool ignorePaths) const
{
irr::io::IFileArchive *archive = nullptr;
irr::io::IReadFile* file = FileSystem->createAndOpenFile(filename);
if (file)
{
archive = createArchive (file, ignoreCase, ignorePaths);
file->drop ();
}
return archive;
}
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
irr::io::IFileArchive* CArchiveLoaderPkg::createArchive(irr::io::IReadFile* file, bool ignoreCase, bool ignorePaths) const
{
irr::io::IFileArchive *archive = nullptr;
if (file)
bool CArchiveLoaderPkg::isALoadableFileFormat(const irr::io::path& filename) const
{
file->seek (0);
archive = new CPkgReader (file, ignoreCase, ignorePaths);
return irr::core::hasFileExtension (filename, "pkg");
}
return archive;
}
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
bool CArchiveLoaderPkg::isALoadableFileFormat(irr::io::IReadFile* file) const
{
unsigned int size;
char* pointer;
file->read (&size, 4);
// the string doesnt include the null terminator
size ++;
pointer = new char [size];
memset (pointer, 0, size);
file->read (pointer, size - 1);
if (strcmp (pointer, "PKGV0002") != 0 && strcmp (pointer, "PKGV0001") != 0)
irr::io::IFileArchive* CArchiveLoaderPkg::createArchive(const irr::io::path& filename, bool ignoreCase, bool ignorePaths) const
{
irr::io::IFileArchive *archive = nullptr;
irr::io::IReadFile* file = this->m_context->getDevice ()->getFileSystem ()->createAndOpenFile(filename);
if (file)
{
archive = this->createArchive (file, ignoreCase, ignorePaths);
file->drop ();
}
return archive;
}
irr::io::IFileArchive* CArchiveLoaderPkg::createArchive(irr::io::IReadFile* file, bool ignoreCase, bool ignorePaths) const
{
irr::io::IFileArchive *archive = nullptr;
if (file)
{
file->seek (0);
archive = new CPkgReader (file, ignoreCase, ignorePaths);
}
return archive;
}
bool CArchiveLoaderPkg::isALoadableFileFormat(irr::io::IReadFile* file) const
{
unsigned int size;
char* pointer;
file->read (&size, 4);
// the string doesnt include the null terminator
size ++;
pointer = new char [size];
memset (pointer, 0, size);
file->read (pointer, size - 1);
if (strcmp (pointer, "PKGV0002") != 0 && strcmp (pointer, "PKGV0001") != 0)
{
delete [] pointer;
return false;
}
delete [] pointer;
return true;
}
//! Check to see if the loader can create archives of this type.
bool CArchiveLoaderPkg::isALoadableFileFormat(irr::io::E_FILE_ARCHIVE_TYPE fileType) const
{
return false;
}
delete [] pointer;
return true;
}
//! Check to see if the loader can create archives of this type.
bool CArchiveLoaderPkg::isALoadableFileFormat(irr::io::E_FILE_ARCHIVE_TYPE fileType) const
{
return false;
}
CPkgReader::CPkgReader (irr::io::IReadFile* file, bool ignoreCase, bool ignorePaths)
: CFileList((file ? file->getFileName() : irr::io::path("")), ignoreCase, ignorePaths), mFile(file)
{
if (this->mFile)
CPkgReader::CPkgReader (irr::io::IReadFile* file, bool ignoreCase, bool ignorePaths)
: CFileList((file ? file->getFileName() : irr::io::path("")), ignoreCase, ignorePaths), m_file(file)
{
this->mFile->grab ();
this->scanPkgHeader ();
if (this->m_file)
{
this->m_file->grab ();
this->scanPkgHeader ();
}
}
}
CPkgReader::~CPkgReader()
{
if (this->mFile)
this->mFile->drop();
}
//! get the archive type
irr::io::E_FILE_ARCHIVE_TYPE CPkgReader::getType() const
{
return irr::io::E_FILE_ARCHIVE_TYPE::EFAT_ZIP;
}
const irr::io::IFileList* CPkgReader::getFileList() const
{
return this;
}
void CPkgReader::scanPkgHeader ()
{
char* headerVersion = this->readSizedString ();
if (strcmp ("PKGV0002", headerVersion) != 0 && strcmp ("PKGV0001", headerVersion) != 0)
CPkgReader::~CPkgReader()
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Unexpected package header... Aborting load", this->mFile->getFileName ().c_str (), irr::ELL_ERROR);
if (this->m_file)
this->m_file->drop();
}
irr::io::E_FILE_ARCHIVE_TYPE CPkgReader::getType() const
{
return irr::io::E_FILE_ARCHIVE_TYPE::EFAT_ZIP;
}
const irr::io::IFileList* CPkgReader::getFileList() const
{
return this;
}
void CPkgReader::scanPkgHeader ()
{
char* headerVersion = this->readSizedString ();
if (strcmp ("PKGV0002", headerVersion) != 0 && strcmp ("PKGV0001", headerVersion) != 0)
{
delete [] headerVersion;
this->m_context->getDevice ()->getLogger ()->log (
"unexpected package header", this->m_file->getFileName ().c_str (), irr::ELL_ERROR
);
return;
}
delete [] headerVersion;
return;
irr::u32 entriesCount;
this->m_file->read (&entriesCount, 4);
for (irr::u32 i = 0; i < entriesCount; i ++)
{
char* filename = this->readSizedString ();
irr::u32 offset, length;
this->m_file->read (&offset, 4);
this->m_file->read (&length, 4);
this->addItem (filename, offset, length, false);
delete [] filename;
}
// after the header is read we have to update the actual offsets
for (irr::u32 i = 0; i < this->m_files.size (); i ++)
{
this->m_files [i].Offset += this->m_file->getPos ();
}
}
delete [] headerVersion;
unsigned int entriesCount;
this->mFile->read (&entriesCount, 4);
for (int i = 0; i < entriesCount; i ++)
char* CPkgReader::readSizedString ()
{
char* filename = this->readSizedString ();
unsigned int offset, length;
unsigned int size;
char* pointer;
this->mFile->read (&offset, 4);
this->mFile->read (&length, 4);
this->m_file->read (&size, 4);
this->addItem (filename, offset, length, false);
// the string doesnt include the null terminator
size ++;
delete [] filename;
pointer = new char [size];
memset (pointer, 0, size);
this->m_file->read (pointer, size - 1);
return pointer;
}
// after the header is read we have to update the actual offsets
for (int i = 0; i < this->Files.size (); i ++)
irr::io::IReadFile* CPkgReader::createAndOpenFile (const irr::io::path& filename)
{
this->Files [i].Offset += this->mFile->getPos ();
}
}
irr::s32 index = this->findFile (filename, false);
char* CPkgReader::readSizedString ()
{
unsigned int size;
char* pointer;
if (index != -1)
return createAndOpenFile (index);
this->mFile->read (&size, 4);
// the string doesnt include the null terminator
size ++;
pointer = new char [size];
memset (pointer, 0, size);
this->mFile->read (pointer, size - 1);
return pointer;
}
irr::io::IReadFile* CPkgReader::createAndOpenFile (const irr::io::path& filename)
{
irr::s32 index = this->findFile (filename, false);
if (index != -1)
return createAndOpenFile (index);
return nullptr;
}
irr::io::IReadFile* CPkgReader::createAndOpenFile (irr::u32 index)
{
if (index > this->Files.size ())
return nullptr;
}
const SFileListEntry entry = Files [index];
return irr::io::createLimitReadFile (entry.FullName, mFile, entry.Offset, entry.Size);
irr::io::IReadFile* CPkgReader::createAndOpenFile (irr::u32 index)
{
if (index > this->m_files.size ())
return nullptr;
const SFileListEntry entry = m_files [index];
return irr::io::createLimitReadFile (entry.FullName, m_file, entry.Offset, entry.Size);
}
}

View File

@ -2,10 +2,9 @@
#include <irrlicht/irrlicht.h>
#include <string>
#include "CContext.h"
#include "CFileList.h"
using namespace irr;
namespace WallpaperEngine::Irrlicht
{
//! Archiveloader capable of loading WAD Archives
@ -14,36 +13,36 @@ namespace WallpaperEngine::Irrlicht
public:
//! Constructor
CArchiveLoaderPkg(irr::io::IFileSystem *fs);
CArchiveLoaderPkg (CContext* context);
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".zip")
virtual bool isALoadableFileFormat(const irr::io::path &filename) const;
virtual bool isALoadableFileFormat (const irr::io::path &filename) const;
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
virtual bool isALoadableFileFormat(irr::io::IReadFile *file) const;
virtual bool isALoadableFileFormat (irr::io::IReadFile *file) const;
//! Check to see if the loader can create archives of this type.
/** Check based on the archive type.
\param fileType The archive type to check.
\return True if the archile loader supports this type, false if not */
virtual bool isALoadableFileFormat(irr::io::E_FILE_ARCHIVE_TYPE fileType) const;
virtual bool isALoadableFileFormat (irr::io::E_FILE_ARCHIVE_TYPE fileType) const;
//! Creates an archive from the filename
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
virtual irr::io::IFileArchive *
createArchive(const irr::io::path &filename, bool ignoreCase, bool ignorePaths) const;
createArchive (const irr::io::path &filename, bool ignoreCase, bool ignorePaths) const;
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
virtual irr::io::IFileArchive *createArchive(irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths) const;
virtual irr::io::IFileArchive *createArchive (irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths) const;
private:
irr::io::IFileSystem *FileSystem;
CContext* m_context;
};
class CPkgReader : public virtual irr::io::IFileArchive, virtual CFileList
@ -51,29 +50,29 @@ namespace WallpaperEngine::Irrlicht
public:
//! constructor
CPkgReader(irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths);
CPkgReader (irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths);
//! destructor
virtual ~CPkgReader();
virtual ~CPkgReader ();
//! opens a file by file name
virtual irr::io::IReadFile *createAndOpenFile(const irr::io::path &filename);
virtual irr::io::IReadFile *createAndOpenFile (const irr::io::path &filename);
//! opens a file by index
virtual irr::io::IReadFile *createAndOpenFile(unsigned int index);
virtual irr::io::IReadFile *createAndOpenFile (unsigned int index);
//! returns the list of files
virtual const IFileList *getFileList() const;
virtual const IFileList *getFileList () const;
//! get the archive type
virtual irr::io::E_FILE_ARCHIVE_TYPE getType() const;
virtual irr::io::E_FILE_ARCHIVE_TYPE getType () const;
protected:
void scanPkgHeader();
void scanPkgHeader ();
char *readSizedString();
char *readSizedString ();
irr::io::IFileSystem *mFileSystem;
irr::io::IReadFile *mFile;
CContext* m_context;
irr::io::IReadFile *m_file;
};
}

View File

@ -1,8 +0,0 @@
#include <WallpaperEngine/Irrlicht/Irrlicht.h>
namespace WallpaperEngine::Irrlicht
{
irr::video::IVideoDriver* driver = nullptr;
irr::IrrlichtDevice* device = nullptr;
irr::scene::ICameraSceneNode* camera = nullptr;
}

View File

@ -1,10 +0,0 @@
#pragma once
#include <irrlicht/irrlicht.h>
namespace WallpaperEngine::Irrlicht
{
extern irr::video::IVideoDriver* driver;
extern irr::IrrlichtDevice* device;
extern irr::scene::ICameraSceneNode* camera;
};

View File

@ -6,9 +6,6 @@
// filesystem
#include <WallpaperEngine/FileSystem/FileSystem.h>
// video engine
#include <WallpaperEngine/Irrlicht/Irrlicht.h>
// shader compiler
#include <WallpaperEngine/Render/Shaders/Compiler.h>
#include <WallpaperEngine/Core/Core.h>
@ -242,7 +239,7 @@ namespace WallpaperEngine::Render::Shaders
std::string Compiler::precompile()
{
#define BREAK_IF_ERROR if (this->m_error == true) { WallpaperEngine::Irrlicht::device->getLogger ()->log ("ERROR PRE-COMPILING SHADER", irr::ELL_ERROR); WallpaperEngine::Irrlicht::device->getLogger ()->log (this->m_errorInfo.c_str (), irr::ELL_ERROR); return ""; }
#define BREAK_IF_ERROR if (this->m_error == true) { throw std::runtime_error ("ERROR PRE-COMPILING SHADER" + this->m_errorInfo); }
// parse the shader and find #includes and such things and translate them to the correct name
// also remove any #version definition to prevent errors
std::string::const_iterator it = this->m_content.begin ();
@ -441,12 +438,6 @@ namespace WallpaperEngine::Render::Shaders
}
}
if (this->m_recursive == false)
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Compiled shader output for", this->m_file.c_str ());
WallpaperEngine::Irrlicht::device->getLogger ()->log (this->m_compiledContent.c_str ());
}
return this->m_compiledContent;
#undef BREAK_IF_ERROR
}
@ -462,8 +453,7 @@ namespace WallpaperEngine::Render::Shaders
if (combo == data.end () || defvalue == data.end ())
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Cannot parse combo information", irr::ELL_ERROR);
return;
throw std::runtime_error ("cannot parse combo information");
}
// check the combos
@ -488,7 +478,7 @@ namespace WallpaperEngine::Render::Shaders
}
else
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Cannot parse combo information, unknown type", irr::ELL_ERROR);
throw std::runtime_error ("cannot parse combo information, unknown type");
}
}
}
@ -504,7 +494,7 @@ namespace WallpaperEngine::Render::Shaders
if (material == data.end () || defvalue == data.end ())
{
if (type != "sampler2D")
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Cannot parse parameter info for ", name.c_str (), irr::ELL_ERROR);
throw std::runtime_error ("cannot parse parameter info for " + name);
return;
}

View File

@ -1,11 +1,12 @@
#include <WallpaperEngine/FileSystem/FileSystem.h>
#include "WallpaperEngine/Irrlicht/CContext.h"
#include "WallpaperEngine/Render/Shaders/Compiler.h"
#include "effect.h"
#include "WallpaperEngine/Irrlicht/Irrlicht.h"
#include "WallpaperEngine/Core/Core.h"
extern irr::f32 g_Time;
extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
namespace WallpaperEngine
{
@ -97,7 +98,7 @@ namespace WallpaperEngine
this->m_fragShader = new WallpaperEngine::Render::Shaders::Compiler (fragpath, WallpaperEngine::Render::Shaders::Compiler::Type::Type_Pixel, &this->m_combos, false);
this->m_vertShader = new WallpaperEngine::Render::Shaders::Compiler (vertpath, WallpaperEngine::Render::Shaders::Compiler::Type::Type_Vertex, &this->m_combos, false);
this->m_materialType = WallpaperEngine::Irrlicht::driver->getGPUProgrammingServices ()
this->m_materialType = IrrlichtContext->getDevice ()->getVideoDriver ()->getGPUProgrammingServices ()
->addHighLevelShaderMaterial (
this->m_vertShader->precompile ().c_str (), "main", irr::video::EVST_VS_2_0,
this->m_fragShader->precompile ().c_str (), "main", irr::video::EPST_PS_2_0,
@ -336,7 +337,7 @@ namespace WallpaperEngine
}
else
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Unknown type for combo value", name.c_str (), irr::ELL_ERROR);
IrrlichtContext->getDevice ()->getLogger ()->log ("Unknown type for combo value", name.c_str (), irr::ELL_ERROR);
}
}
}

View File

@ -5,9 +5,11 @@
#include <WallpaperEngine/object3d.h>
#include <WallpaperEngine/image.h>
#include <WallpaperEngine/Irrlicht/Irrlicht.h>
#include <WallpaperEngine/Irrlicht/CContext.h>
#include <WallpaperEngine/Core/Core.h>
extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
namespace WallpaperEngine
{
image::image (json json_data, WallpaperEngine::object* parent) : object3d (object3d::Type::Type_Material, parent)
@ -153,8 +155,8 @@ namespace WallpaperEngine
0, 1, 2, 3
};
WallpaperEngine::Irrlicht::driver->setMaterial (this->getMaterial ());
WallpaperEngine::Irrlicht::driver->drawVertexPrimitiveList (this->m_vertices, 4, indices, 1, irr::video::EVT_STANDARD, irr::scene::EPT_QUADS, irr::video::EIT_16BIT);
IrrlichtContext->getDevice ()->getVideoDriver ()->setMaterial (this->getMaterial ());
IrrlichtContext->getDevice ()->getVideoDriver ()->drawVertexPrimitiveList (this->m_vertices, 4, indices, 1, irr::video::EVT_STANDARD, irr::scene::EPT_QUADS, irr::video::EIT_16BIT);
}
}

View File

@ -6,7 +6,6 @@
#include "WallpaperEngine/FileSystem/FileSystem.h"
#include "project.h"
#include "WallpaperEngine/Irrlicht/Irrlicht.h"
namespace WallpaperEngine
{

View File

@ -1,11 +1,9 @@
//
// Created by almamu on 17/05/19.
//
#include <SDL_rwops.h>
#include <SDL_mixer.h>
#include "sound.h"
#include "WallpaperEngine/Irrlicht/Irrlicht.h"
#include "WallpaperEngine/Irrlicht/CContext.h"
extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
namespace WallpaperEngine
{
@ -31,7 +29,7 @@ namespace WallpaperEngine
{
SDL_RWops* sdlRwops = nullptr;
Mix_Music* music = nullptr;
irr::io::IReadFile* readfile = WallpaperEngine::Irrlicht::device->getFileSystem ()->createAndOpenFile ((*cur).c_str ());
irr::io::IReadFile* readfile = IrrlichtContext->getDevice ()->getFileSystem ()->createAndOpenFile ((*cur).c_str ());
int filesize = readfile->getSize ();
char* filebuffer = new char [filesize];
@ -43,7 +41,7 @@ namespace WallpaperEngine
if (music == nullptr)
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Cannot load audio", Mix_GetError (), irr::ELL_ERROR);
IrrlichtContext->getDevice ()->getLogger ()->log ("Cannot load audio", Mix_GetError (), irr::ELL_ERROR);
}
this->m_bufferReader.push_back (sdlRwops);
@ -58,7 +56,7 @@ namespace WallpaperEngine
{
if (Mix_PlayMusic ((*mixcur), -1) == -1)
{
WallpaperEngine::Irrlicht::device->getLogger ()->log ("Cannot play audio", Mix_GetError (), irr::ELL_ERROR);
IrrlichtContext->getDevice ()->getLogger ()->log ("Cannot play audio", Mix_GetError (), irr::ELL_ERROR);
}
}
}

View File

@ -2,13 +2,15 @@
#include <stdexcept>
#include <lz4.h>
#include "WallpaperEngine/Irrlicht/Irrlicht.h"
#include <WallpaperEngine/Irrlicht/CContext.h>
extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
namespace WallpaperEngine
{
texture::texture (irr::io::path& file)
{
this->m_texture = WallpaperEngine::Irrlicht::driver->getTexture (file);
this->m_texture = IrrlichtContext->getDevice ()->getVideoDriver ()->getTexture (file);
}
irr::video::ITexture* texture::getIrrTexture ()

View File

@ -1,5 +1,7 @@
#include <WallpaperEngine/Irrlicht/Irrlicht.h>
#include <WallpaperEngine/video/material.h>
#include <WallpaperEngine/Irrlicht/CContext.h>
extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
namespace WallpaperEngine
{
@ -56,8 +58,10 @@ namespace WallpaperEngine
0, 1, 2, 3
};
WallpaperEngine::Irrlicht::driver->setMaterial (m_material);
WallpaperEngine::Irrlicht::driver->drawVertexPrimitiveList (m_vertices, 4, indices, 1, irr::video::EVT_STANDARD, irr::scene::EPT_QUADS, irr::video::EIT_16BIT);
IrrlichtContext->getDevice ()->getVideoDriver ()->setMaterial (m_material);
IrrlichtContext->getDevice ()->getVideoDriver ()->drawVertexPrimitiveList (
m_vertices, 4, indices, 1, irr::video::EVT_STANDARD, irr::scene::EPT_QUADS, irr::video::EIT_16BIT
);
}
}
}

View File

@ -1,5 +1,7 @@
#include <WallpaperEngine/Irrlicht/Irrlicht.h>
#include <WallpaperEngine/video/renderer.h>
#include <WallpaperEngine/Irrlicht/CContext.h>
extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
namespace WallpaperEngine
{
@ -31,19 +33,19 @@ namespace WallpaperEngine
znear,
zfar
);
WallpaperEngine::Irrlicht::camera = WallpaperEngine::Irrlicht::device->getSceneManager ()->addCameraSceneNode (0, position, lookat);
WallpaperEngine::Irrlicht::camera->setProjectionMatrix (orthoProjection);
s_camera = IrrlichtContext->getDevice ()->getSceneManager ()->addCameraSceneNode (0, position, lookat);
s_camera->setProjectionMatrix (orthoProjection);
WallpaperEngine::Irrlicht::driver->setTransform (irr::video::ETS_PROJECTION, orthoProjection);
WallpaperEngine::Irrlicht::driver->setTransform (irr::video::ETS_VIEW, identity);
WallpaperEngine::Irrlicht::driver->setTransform (irr::video::ETS_WORLD, identity);
IrrlichtContext->getDevice ()->getVideoDriver ()->setTransform (irr::video::ETS_PROJECTION, orthoProjection);
IrrlichtContext->getDevice ()->getVideoDriver ()->setTransform (irr::video::ETS_VIEW, identity);
IrrlichtContext->getDevice ()->getVideoDriver ()->setTransform (irr::video::ETS_WORLD, identity);
}
void renderer::render ()
{
if (WallpaperEngine::Irrlicht::driver == nullptr) return;
if (IrrlichtContext->getDevice ()->getVideoDriver () == nullptr) return;
WallpaperEngine::Irrlicht::driver->beginScene(true, true, irr::video::SColor(0, 0, 0, 0));
IrrlichtContext->getDevice ()->getVideoDriver ()->beginScene(true, true, irr::video::SColor(0, 0, 0, 0));
std::vector<node*>::const_iterator cur = s_nodes.begin ();
std::vector<node*>::const_iterator end = s_nodes.end ();
@ -53,9 +55,10 @@ namespace WallpaperEngine
(*cur)->render ();
}
WallpaperEngine::Irrlicht::driver->endScene ();
IrrlichtContext->getDevice ()->getVideoDriver ()->endScene ();
}
std::vector<node*> renderer::s_nodes;
irr::scene::ICameraSceneNode* renderer::s_camera;
}
};

View File

@ -20,6 +20,7 @@ namespace WallpaperEngine
private:
static std::vector<node*> s_nodes;
static irr::scene::ICameraSceneNode* s_camera;
};
}
}