mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 05:12:25 +08:00
~ fixed a_TexCoord variable not having the correct values
- removed irrlicht functions and types from the active codebase so it's no longer required at compile time (CContext still there as the code might be still be useful) Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
291b7e364a
commit
dd76439901
@ -15,13 +15,12 @@ find_package(GLFW3 3.1 REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
find_package(GLUT REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(Irrlicht REQUIRED)
|
||||
find_package(SDL REQUIRED)
|
||||
find_package(SDL_mixer REQUIRED)
|
||||
find_package(LZ4 REQUIRED)
|
||||
find_package(FFmpeg REQUIRED)
|
||||
|
||||
include_directories(${X11_INCLUDE_DIR} ${XRANDR_INCLUDE_DIR} ${GLEW_INCLUDE_DIR} ${glfw3_INCLUDE_DIR} ${IRRLICHT_INCLUDE_DIR} ${LZ4_INCLUDE_DIR} ${SDL_INCLUDE_DIRS} ${SDL_MIXER_INCLUDE_DIRS} ${FFMPEG_INCLUDE_DIR} src include)
|
||||
include_directories(${X11_INCLUDE_DIR} ${XRANDR_INCLUDE_DIR} ${GLEW_INCLUDE_DIR} ${glfw3_INCLUDE_DIR} ${LZ4_INCLUDE_DIR} ${SDL_INCLUDE_DIRS} ${SDL_MIXER_INCLUDE_DIRS} ${FFMPEG_INCLUDE_DIR} src include)
|
||||
|
||||
add_executable(
|
||||
wallengine
|
||||
@ -90,16 +89,8 @@ add_executable(
|
||||
src/WallpaperEngine/FileSystem/FileSystem.cpp
|
||||
src/WallpaperEngine/FileSystem/FileSystem.h
|
||||
|
||||
src/WallpaperEngine/Irrlicht/CEventReceiver.h
|
||||
src/WallpaperEngine/Irrlicht/CEventReceiver.cpp
|
||||
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/Core/Types/FloatColor.h
|
||||
src/WallpaperEngine/Core/Types/IntegerColor.h
|
||||
|
||||
src/WallpaperEngine/Core/CProject.cpp
|
||||
src/WallpaperEngine/Core/CProject.h
|
||||
@ -178,4 +169,4 @@ add_executable(
|
||||
src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h
|
||||
)
|
||||
|
||||
target_link_libraries(wallengine ${X11_LIBRARIES} ${XRANDR_LIBRARIES} ${X11_Xxf86vm_LIB} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLFW3_LIBRARY} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES} ${IRRLICHT_LIBRARY} ${LZ4_LIBRARY} ${SDL_LIBRARY} ${SDL_MIXER_LIBRARIES} ${FFMPEG_LIBRARIES})
|
||||
target_link_libraries(wallengine ${X11_LIBRARIES} ${XRANDR_LIBRARIES} ${X11_Xxf86vm_LIB} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLFW3_LIBRARY} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES} ${LZ4_LIBRARY} ${SDL_LIBRARY} ${SDL_MIXER_LIBRARIES} ${FFMPEG_LIBRARIES})
|
@ -1,25 +0,0 @@
|
||||
FIND_PATH(IRRLICHT_INCLUDE_DIR irrlicht/irrlicht.h
|
||||
PATHS $ENV{IRRDIR}/include
|
||||
PATH_SUFFIXES irrlicht
|
||||
)
|
||||
|
||||
MESSAGE(STATUS "IRRLICHT_INCLUDE_DIR = ${IRRLICHT_INCLUDE_DIR}")
|
||||
|
||||
FIND_LIBRARY(IRRLICHT_LIBRARY NAMES Irrlicht
|
||||
PATHS $ENV{IRRDIR}/lib
|
||||
)
|
||||
|
||||
MESSAGE(STATUS "IRRLICHT_LIBRARY = ${IRRLICHT_LIBRARY}")
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set IRRLICHT_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IRRLICHT DEFAULT_MSG IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR)
|
||||
|
||||
IF(IRRLICHT_FOUND)
|
||||
SET(IRRLICHT_LIBRARIES ${IRRLICHT_LIBRARY})
|
||||
ELSE(IRRLICHT_FOUND)
|
||||
SET(IRRLICHT_LIBRARIES)
|
||||
ENDIF(IRRLICHT_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR)
|
@ -10,7 +10,6 @@ Wallpaper Engine is a software designed by [Kristjan Skutta](https://store.steam
|
||||
# 4. Compilation requirements
|
||||
- OpenGL 2.1 support
|
||||
- CMake
|
||||
- Irrlicht
|
||||
- LZ4
|
||||
- ZLIB
|
||||
- SDL
|
||||
@ -18,6 +17,8 @@ Wallpaper Engine is a software designed by [Kristjan Skutta](https://store.steam
|
||||
- FFmpeg
|
||||
- X11
|
||||
- Xrandr
|
||||
- GLW3
|
||||
- GLM
|
||||
|
||||
# 5. How to use
|
||||
## 5.1. Pre-requirements
|
||||
|
11
main.cpp
11
main.cpp
@ -1,5 +1,4 @@
|
||||
#include <iostream>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include <SDL_mixer.h>
|
||||
@ -12,7 +11,6 @@
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#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"
|
||||
@ -31,7 +29,6 @@ enum BACKGROUND_RUN_MODE
|
||||
RUN_MODE_PACKAGE = 3
|
||||
};
|
||||
|
||||
WallpaperEngine::Irrlicht::CContext* IrrlichtContext = nullptr;
|
||||
double g_Time;
|
||||
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
@ -218,7 +215,7 @@ int main (int argc, char* argv[])
|
||||
{
|
||||
// Mix_GetError is an alias for SDL_GetError, so calling it directly will yield the correct result
|
||||
// it doesn't matter if SDL_Init or Mix_Init failed, both report the errors through the same functions
|
||||
IrrlichtContext->getDevice ()->getLogger ()->log ("Cannot initialize SDL audio system", SDL_GetError(),irr::ELL_ERROR);
|
||||
fprintf (stderr, "Cannot initialize SDL audio system, SDL_GetError: %s", SDL_GetError ());
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -336,9 +333,9 @@ int main (int argc, char* argv[])
|
||||
throw std::runtime_error ("Unsupported wallpaper type");
|
||||
}
|
||||
|
||||
irr::u32 minimumTime = 1000 / maximumFPS;
|
||||
irr::u32 startTime = 0;
|
||||
irr::u32 endTime = 0;
|
||||
uint32_t minimumTime = 1000 / maximumFPS;
|
||||
uint32_t startTime = 0;
|
||||
uint32_t endTime = 0;
|
||||
|
||||
while (IrrlichtContext && IrrlichtContext->getDevice () && IrrlichtContext->getDevice ()->run ())
|
||||
{
|
||||
|
@ -8,15 +8,16 @@ using namespace WallpaperEngine::Assets;
|
||||
|
||||
CTexture::CTexture (void* fileData)
|
||||
{
|
||||
TextureHeader* header = this->parseHeader (static_cast <char*> (fileData));
|
||||
// ensure the header is parsed
|
||||
this->parseHeader (static_cast <char*> (fileData));
|
||||
|
||||
if (header->freeImageFormat != FREE_IMAGE_FORMAT::FIF_UNKNOWN)
|
||||
if (this->m_header->freeImageFormat != FREE_IMAGE_FORMAT::FIF_UNKNOWN)
|
||||
throw std::runtime_error ("Normal images are not supported yet");
|
||||
|
||||
GLint formatGL;
|
||||
|
||||
// detect the image format and hand it to openGL to be used
|
||||
switch (header->format)
|
||||
switch (this->m_header->format)
|
||||
{
|
||||
case TextureFormat::DXT5:
|
||||
formatGL = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
@ -31,7 +32,7 @@ CTexture::CTexture (void* fileData)
|
||||
formatGL = GL_RGBA8;
|
||||
break;
|
||||
default:
|
||||
delete header;
|
||||
delete this->m_header;
|
||||
throw std::runtime_error ("Cannot determine the texture format");
|
||||
}
|
||||
|
||||
@ -42,10 +43,10 @@ CTexture::CTexture (void* fileData)
|
||||
glBindTexture (GL_TEXTURE_2D, this->m_textureID);
|
||||
// set mipmap levels
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, header->mipmapCount - 1);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, this->m_header->mipmapCount - 1);
|
||||
|
||||
// setup texture wrapping and filtering
|
||||
if (header->flags & TextureFlags::ClampUVs)
|
||||
if (this->m_header->flags & TextureFlags::ClampUVs)
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
@ -56,7 +57,7 @@ CTexture::CTexture (void* fileData)
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
}
|
||||
|
||||
if (header->flags & TextureFlags::NoInterpolation)
|
||||
if (this->m_header->flags & TextureFlags::NoInterpolation)
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
@ -70,8 +71,8 @@ CTexture::CTexture (void* fileData)
|
||||
// TODO: USE THIS ONE
|
||||
uint32_t blockSize = (formatGL == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ? 8 : 16;
|
||||
|
||||
auto cur = header->mipmaps.begin ();
|
||||
auto end = header->mipmaps.end ();
|
||||
auto cur = this->m_header->mipmaps.begin ();
|
||||
auto end = this->m_header->mipmaps.end ();
|
||||
|
||||
for (int32_t level = 0; cur != end; cur ++, level ++)
|
||||
{
|
||||
@ -97,13 +98,16 @@ CTexture::CTexture (void* fileData)
|
||||
}
|
||||
}
|
||||
|
||||
delete header;
|
||||
// TODO: IMPLEMENT SUPPORT FOR NORMAL IMAGES
|
||||
}
|
||||
|
||||
CTexture::~CTexture ()
|
||||
{
|
||||
// TODO: FREE STUFF HERE
|
||||
if (this->getHeader () == nullptr)
|
||||
return;
|
||||
|
||||
// free the header if it was allocated
|
||||
delete this->getHeader ();
|
||||
}
|
||||
|
||||
const GLuint CTexture::getTextureID () const
|
||||
@ -111,6 +115,11 @@ const GLuint CTexture::getTextureID () const
|
||||
return this->m_textureID;
|
||||
}
|
||||
|
||||
const CTexture::TextureHeader* CTexture::getHeader () const
|
||||
{
|
||||
return this->m_header;
|
||||
}
|
||||
|
||||
CTexture::TextureMipmap::TextureMipmap ()
|
||||
{
|
||||
}
|
||||
@ -152,7 +161,7 @@ CTexture::TextureHeader::~TextureHeader ()
|
||||
delete *cur;
|
||||
}
|
||||
|
||||
CTexture::TextureHeader* CTexture::parseHeader (char* fileData)
|
||||
void CTexture::parseHeader (char* fileData)
|
||||
{
|
||||
// check the magic value on the header first
|
||||
if (memcmp (fileData, "TEXV0005", 9) != 0)
|
||||
@ -165,16 +174,16 @@ CTexture::TextureHeader* CTexture::parseHeader (char* fileData)
|
||||
// jump through the string again
|
||||
fileData += 9;
|
||||
|
||||
TextureHeader* header = new TextureHeader;
|
||||
this->m_header = new TextureHeader;
|
||||
|
||||
uint32_t* pointer = reinterpret_cast<uint32_t*> (fileData);
|
||||
|
||||
header->format = static_cast<TextureFormat>(*pointer ++);
|
||||
header->flags = static_cast<TextureFlags> (*pointer ++);
|
||||
header->textureWidth = *pointer ++;
|
||||
header->textureHeight = *pointer ++;
|
||||
header->width = *pointer ++;
|
||||
header->height = *pointer ++;
|
||||
this->m_header->format = static_cast<TextureFormat>(*pointer ++);
|
||||
this->m_header->flags = static_cast<TextureFlags> (*pointer ++);
|
||||
this->m_header->textureWidth = *pointer ++;
|
||||
this->m_header->textureHeight = *pointer ++;
|
||||
this->m_header->width = *pointer ++;
|
||||
this->m_header->height = *pointer ++;
|
||||
pointer ++; // ignore some more bytes
|
||||
|
||||
// now we're going to parse some more data that is string
|
||||
@ -185,18 +194,18 @@ CTexture::TextureHeader* CTexture::parseHeader (char* fileData)
|
||||
|
||||
if (memcmp (fileData, "TEXB0003", 9) == 0)
|
||||
{
|
||||
header->containerVersion = ContainerVersion::TEXB0003;
|
||||
this->m_header->containerVersion = ContainerVersion::TEXB0003;
|
||||
|
||||
// get back the pointer and use it
|
||||
pointer = reinterpret_cast <uint32_t*> (afterFileData);
|
||||
pointer ++;
|
||||
header->freeImageFormat = static_cast<FREE_IMAGE_FORMAT> (*pointer++);
|
||||
this->m_header->freeImageFormat = static_cast<FREE_IMAGE_FORMAT> (*pointer++);
|
||||
// set back the pointer
|
||||
fileData = reinterpret_cast <char*> (pointer);
|
||||
}
|
||||
else if(memcmp (fileData, "TEXB0002", 9) == 0)
|
||||
{
|
||||
header->containerVersion = ContainerVersion::TEXB0002;
|
||||
this->m_header->containerVersion = ContainerVersion::TEXB0002;
|
||||
|
||||
// get back the pointer and use it
|
||||
pointer = reinterpret_cast <uint32_t*> (afterFileData);
|
||||
@ -206,7 +215,7 @@ CTexture::TextureHeader* CTexture::parseHeader (char* fileData)
|
||||
}
|
||||
else if (memcmp (fileData, "TEXB0001", 9) == 0)
|
||||
{
|
||||
header->containerVersion = ContainerVersion::TEXB0001;
|
||||
this->m_header->containerVersion = ContainerVersion::TEXB0001;
|
||||
|
||||
// get back the pointer and use it
|
||||
pointer = reinterpret_cast <uint32_t*> (afterFileData);
|
||||
@ -216,20 +225,21 @@ CTexture::TextureHeader* CTexture::parseHeader (char* fileData)
|
||||
}
|
||||
else
|
||||
{
|
||||
delete header;
|
||||
delete this->m_header;
|
||||
this->m_header = nullptr;
|
||||
throw std::runtime_error ("unknown texture format type");
|
||||
}
|
||||
|
||||
if (header->format == TextureFormat::R8)
|
||||
if (this->m_header->format == TextureFormat::R8)
|
||||
{
|
||||
delete header;
|
||||
|
||||
delete this->m_header;
|
||||
this->m_header = nullptr;
|
||||
throw std::runtime_error ("R8 format is not supported yet");
|
||||
}
|
||||
else if (header->format == TextureFormat::RG88)
|
||||
else if (this->m_header->format == TextureFormat::RG88)
|
||||
{
|
||||
delete header;
|
||||
|
||||
delete this->m_header;
|
||||
this->m_header = nullptr;
|
||||
throw std::runtime_error ("RG88 format is not supported yet");
|
||||
}
|
||||
|
||||
@ -237,14 +247,12 @@ CTexture::TextureHeader* CTexture::parseHeader (char* fileData)
|
||||
pointer = reinterpret_cast <uint32_t*> (fileData);
|
||||
|
||||
// read the number of mipmaps available
|
||||
header->mipmapCount = *pointer ++;
|
||||
this->m_header->mipmapCount = *pointer ++;
|
||||
|
||||
fileData = reinterpret_cast <char*> (pointer);
|
||||
|
||||
for (uint32_t i = 0; i < header->mipmapCount; i ++)
|
||||
header->mipmaps.emplace_back (this->parseMipmap (header, &fileData));
|
||||
|
||||
return header;
|
||||
for (uint32_t i = 0; i < this->m_header->mipmapCount; i ++)
|
||||
this->m_header->mipmaps.emplace_back (this->parseMipmap (this->m_header, &fileData));
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,12 +142,14 @@ namespace WallpaperEngine::Assets
|
||||
~CTexture ();
|
||||
|
||||
const GLuint getTextureID () const;
|
||||
const TextureHeader* getHeader () const;
|
||||
|
||||
|
||||
private:
|
||||
TextureHeader* parseHeader (char* fileData);
|
||||
void parseHeader (char* fileData);
|
||||
TextureMipmap* parseMipmap (TextureHeader* header, char** fileData);
|
||||
|
||||
TextureHeader* m_header;
|
||||
GLuint m_textureID;
|
||||
};
|
||||
}
|
@ -12,7 +12,7 @@ using namespace WallpaperEngine::Assets;
|
||||
|
||||
CObject::CObject (
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
std::string type,
|
||||
const glm::vec3& origin,
|
||||
@ -177,7 +177,7 @@ const std::vector<Objects::CEffect*>& CObject::getEffects () const
|
||||
return this->m_effects;
|
||||
}
|
||||
|
||||
const std::vector<irr::u32>& CObject::getDependencies () const
|
||||
const std::vector<uint32_t>& CObject::getDependencies () const
|
||||
{
|
||||
return this->m_dependencies;
|
||||
}
|
||||
@ -196,7 +196,7 @@ void CObject::insertEffect (Objects::CEffect* effect)
|
||||
{
|
||||
this->m_effects.push_back (effect);
|
||||
}
|
||||
void CObject::insertDependency (irr::u32 dependency)
|
||||
void CObject::insertDependency (uint32_t dependency)
|
||||
{
|
||||
this->m_dependencies.push_back (dependency);
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "Core.h"
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/CEffect.h"
|
||||
@ -28,7 +26,7 @@ namespace WallpaperEngine::Core
|
||||
template<class T> bool is () { return this->m_type == T::Type; }
|
||||
|
||||
const std::vector<Objects::CEffect*>& getEffects () const;
|
||||
const std::vector<irr::u32>& getDependencies () const;
|
||||
const std::vector<uint32_t>& getDependencies () const;
|
||||
const int getId () const;
|
||||
|
||||
const glm::vec3& getOrigin () const;
|
||||
@ -40,7 +38,7 @@ namespace WallpaperEngine::Core
|
||||
protected:
|
||||
CObject (
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
std::string type,
|
||||
const glm::vec3& origin,
|
||||
@ -49,18 +47,18 @@ namespace WallpaperEngine::Core
|
||||
);
|
||||
|
||||
void insertEffect (Objects::CEffect* effect);
|
||||
void insertDependency (irr::u32 dependency);
|
||||
void insertDependency (uint32_t dependency);
|
||||
private:
|
||||
std::string m_type;
|
||||
|
||||
bool m_visible;
|
||||
irr::u32 m_id;
|
||||
uint32_t m_id;
|
||||
std::string m_name;
|
||||
glm::vec3 m_origin;
|
||||
glm::vec3 m_scale;
|
||||
glm::vec3 m_angles;
|
||||
|
||||
std::vector<Objects::CEffect*> m_effects;
|
||||
std::vector<irr::u32> m_dependencies;
|
||||
std::vector<uint32_t> m_dependencies;
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "CWallpaper.h"
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
#include "WallpaperEngine/Core/Projects/CProperty.h"
|
||||
|
@ -10,23 +10,23 @@ using namespace WallpaperEngine::Core::Types;
|
||||
CScene::CScene (
|
||||
CContainer* container,
|
||||
Scenes::CCamera* camera,
|
||||
irr::video::SColorf ambientColor,
|
||||
FloatColor ambientColor,
|
||||
bool bloom,
|
||||
irr::f64 bloomStrength,
|
||||
irr::f64 bloomThreshold,
|
||||
double bloomStrength,
|
||||
double bloomThreshold,
|
||||
bool cameraFade,
|
||||
bool cameraParallax,
|
||||
irr::f64 cameraParallaxAmount,
|
||||
irr::f64 cameraParallaxDelay,
|
||||
irr::f64 cameraParallaxMouseInfluence,
|
||||
double cameraParallaxAmount,
|
||||
double cameraParallaxDelay,
|
||||
double cameraParallaxMouseInfluence,
|
||||
bool cameraPreview,
|
||||
bool cameraShake,
|
||||
irr::f64 cameraShakeAmplitude,
|
||||
irr::f64 cameraShakeRoughness,
|
||||
irr::f64 cameraShakeSpeed,
|
||||
double cameraShakeAmplitude,
|
||||
double cameraShakeRoughness,
|
||||
double cameraShakeSpeed,
|
||||
FloatColor clearColor,
|
||||
Scenes::CProjection* orthogonalProjection,
|
||||
irr::video::SColorf skylightColor) :
|
||||
FloatColor skylightColor) :
|
||||
CWallpaper (Type),
|
||||
m_container (container),
|
||||
m_camera (camera),
|
||||
@ -66,14 +66,14 @@ CScene* CScene::fromFile (const std::string& filename, CContainer* container)
|
||||
auto bloomthreshold_it = jsonFindRequired (*general_it, "bloomthreshold", "General section must have bloom threshold");
|
||||
auto camerafade_it = jsonFindRequired (*general_it, "camerafade", "General section must have camera fade");
|
||||
auto cameraparallax = jsonFindDefault <bool> (*general_it, "cameraparallax", true);
|
||||
auto cameraparallaxamount = jsonFindDefault <irr::f64> (*general_it, "cameraparallaxamount", 1.0f);
|
||||
auto cameraparallaxdelay = jsonFindDefault <irr::f64> (*general_it, "cameraparallaxdelay", 0.0f);
|
||||
auto cameraparallaxmouseinfluence = jsonFindDefault <irr::f64> (*general_it, "cameraparallaxmouseinfluence", 1.0f);
|
||||
auto cameraparallaxamount = jsonFindDefault <double> (*general_it, "cameraparallaxamount", 1.0f);
|
||||
auto cameraparallaxdelay = jsonFindDefault <double> (*general_it, "cameraparallaxdelay", 0.0f);
|
||||
auto cameraparallaxmouseinfluence = jsonFindDefault <double> (*general_it, "cameraparallaxmouseinfluence", 1.0f);
|
||||
auto camerapreview = jsonFindDefault <bool> (*general_it, "camerapreview", false);
|
||||
auto camerashake = jsonFindDefault <bool> (*general_it, "camerashake", false);
|
||||
auto camerashakeamplitude = jsonFindDefault <irr::f64> (*general_it, "camerashakeamplitude", 0.0f);
|
||||
auto camerashakeroughness = jsonFindDefault <irr::f64> (*general_it, "camerashakeroughness", 0.0f);
|
||||
auto camerashakespeed = jsonFindDefault <irr::f64> (*general_it, "camerashakespeed", 0.0f);
|
||||
auto camerashakeamplitude = jsonFindDefault <double> (*general_it, "camerashakeamplitude", 0.0f);
|
||||
auto camerashakeroughness = jsonFindDefault <double> (*general_it, "camerashakeroughness", 0.0f);
|
||||
auto camerashakespeed = jsonFindDefault <double> (*general_it, "camerashakespeed", 0.0f);
|
||||
auto clearcolor_it = jsonFindRequired (*general_it, "clearcolor", "General section must have clear color");
|
||||
auto orthogonalprojection_it = jsonFindRequired (*general_it, "orthogonalprojection", "General section must have orthogonal projection info");
|
||||
auto skylightcolor_it = jsonFindRequired (*general_it, "skylightcolor", "General section must have skylight color");
|
||||
@ -81,7 +81,7 @@ CScene* CScene::fromFile (const std::string& filename, CContainer* container)
|
||||
CScene* scene = new CScene (
|
||||
container,
|
||||
Scenes::CCamera::fromJSON (*camera_it),
|
||||
WallpaperEngine::Core::atoSColorf (*ambientcolor_it),
|
||||
WallpaperEngine::Core::aToColorf(*ambientcolor_it),
|
||||
*bloom_it,
|
||||
*bloomstrength_it,
|
||||
*bloomthreshold_it,
|
||||
@ -95,9 +95,9 @@ CScene* CScene::fromFile (const std::string& filename, CContainer* container)
|
||||
camerashakeamplitude,
|
||||
camerashakeroughness,
|
||||
camerashakespeed,
|
||||
WallpaperEngine::Core::aToColor (*clearcolor_it),
|
||||
WallpaperEngine::Core::aToColorf(*clearcolor_it),
|
||||
Scenes::CProjection::fromJSON (*orthogonalprojection_it),
|
||||
WallpaperEngine::Core::atoSColorf (*skylightcolor_it)
|
||||
WallpaperEngine::Core::aToColorf(*skylightcolor_it)
|
||||
);
|
||||
|
||||
auto cur = (*objects_it).begin ();
|
||||
@ -135,7 +135,7 @@ const Scenes::CCamera* CScene::getCamera () const
|
||||
return this->m_camera;
|
||||
}
|
||||
|
||||
const irr::video::SColorf &CScene::getAmbientColor() const
|
||||
const FloatColor &CScene::getAmbientColor() const
|
||||
{
|
||||
return this->m_ambientColor;
|
||||
}
|
||||
@ -145,12 +145,12 @@ const bool CScene::isBloom () const
|
||||
return this->m_bloom;
|
||||
}
|
||||
|
||||
const irr::f64 CScene::getBloomStrength () const
|
||||
const double CScene::getBloomStrength () const
|
||||
{
|
||||
return this->m_bloomStrength;
|
||||
}
|
||||
|
||||
const irr::f64 CScene::getBloomThreshold () const
|
||||
const double CScene::getBloomThreshold () const
|
||||
{
|
||||
return this->m_bloomThreshold;
|
||||
}
|
||||
@ -165,17 +165,17 @@ const bool CScene::isCameraParallax () const
|
||||
return this->m_cameraParallax;
|
||||
}
|
||||
|
||||
const irr::f64 CScene::getCameraParallaxAmount () const
|
||||
const double CScene::getCameraParallaxAmount () const
|
||||
{
|
||||
return this->m_cameraParallaxAmount;
|
||||
}
|
||||
|
||||
const irr::f64 CScene::getCameraParallaxDelay () const
|
||||
const double CScene::getCameraParallaxDelay () const
|
||||
{
|
||||
return this->m_cameraParallaxDelay;
|
||||
}
|
||||
|
||||
const irr::f64 CScene::getCameraParallaxMouseInfluence () const
|
||||
const double CScene::getCameraParallaxMouseInfluence () const
|
||||
{
|
||||
return this->m_cameraParallaxMouseInfluence;
|
||||
}
|
||||
@ -190,17 +190,17 @@ const bool CScene::isCameraShake () const
|
||||
return this->m_cameraShake;
|
||||
}
|
||||
|
||||
const irr::f64 CScene::getCameraShakeAmplitude () const
|
||||
const double CScene::getCameraShakeAmplitude () const
|
||||
{
|
||||
return this->m_cameraShakeAmplitude;
|
||||
}
|
||||
|
||||
const irr::f64 CScene::getCameraShakeRoughness () const
|
||||
const double CScene::getCameraShakeRoughness () const
|
||||
{
|
||||
return this->m_cameraShakeRoughness;
|
||||
}
|
||||
|
||||
const irr::f64 CScene::getCameraShakeSpeed () const
|
||||
const double CScene::getCameraShakeSpeed () const
|
||||
{
|
||||
return this->m_cameraShakeSpeed;
|
||||
}
|
||||
@ -215,7 +215,7 @@ const Scenes::CProjection* CScene::getOrthogonalProjection () const
|
||||
return this->m_orthogonalProjection;
|
||||
}
|
||||
|
||||
const irr::video::SColorf& CScene::getSkylightColor () const
|
||||
const FloatColor& CScene::getSkylightColor () const
|
||||
{
|
||||
return this->m_skylightColor;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "CObject.h"
|
||||
#include "CWallpaper.h"
|
||||
|
||||
@ -25,23 +23,23 @@ namespace WallpaperEngine::Core
|
||||
|
||||
const std::vector<CObject*>& getObjects () const;
|
||||
|
||||
const irr::video::SColorf& getAmbientColor() const;
|
||||
const FloatColor& getAmbientColor() const;
|
||||
const bool isBloom() const;
|
||||
const irr::f64 getBloomStrength() const;
|
||||
const irr::f64 getBloomThreshold() const;
|
||||
const double getBloomStrength() const;
|
||||
const double getBloomThreshold() const;
|
||||
const bool isCameraFade() const;
|
||||
const bool isCameraParallax() const;
|
||||
const irr::f64 getCameraParallaxAmount() const;
|
||||
const irr::f64 getCameraParallaxDelay() const;
|
||||
const irr::f64 getCameraParallaxMouseInfluence() const;
|
||||
const double getCameraParallaxAmount() const;
|
||||
const double getCameraParallaxDelay() const;
|
||||
const double getCameraParallaxMouseInfluence() const;
|
||||
const bool isCameraPreview() const;
|
||||
const bool isCameraShake() const;
|
||||
const irr::f64 getCameraShakeAmplitude() const;
|
||||
const irr::f64 getCameraShakeRoughness() const;
|
||||
const irr::f64 getCameraShakeSpeed() const;
|
||||
const double getCameraShakeAmplitude() const;
|
||||
const double getCameraShakeRoughness() const;
|
||||
const double getCameraShakeSpeed() const;
|
||||
const FloatColor& getClearColor() const;
|
||||
const Scenes::CProjection* getOrthogonalProjection() const;
|
||||
const irr::video::SColorf& getSkylightColor() const;
|
||||
const FloatColor& getSkylightColor() const;
|
||||
const Scenes::CCamera* getCamera () const;
|
||||
|
||||
protected:
|
||||
@ -50,23 +48,23 @@ namespace WallpaperEngine::Core
|
||||
CScene (
|
||||
CContainer* container,
|
||||
Scenes::CCamera* camera,
|
||||
irr::video::SColorf ambientColor,
|
||||
FloatColor ambientColor,
|
||||
bool bloom,
|
||||
irr::f64 bloomStrength,
|
||||
irr::f64 bloomThreshold,
|
||||
double bloomStrength,
|
||||
double bloomThreshold,
|
||||
bool cameraFade,
|
||||
bool cameraParallax,
|
||||
irr::f64 cameraParallaxAmount,
|
||||
irr::f64 cameraParallaxDelay,
|
||||
irr::f64 cameraParallaxMouseInfluence,
|
||||
double cameraParallaxAmount,
|
||||
double cameraParallaxDelay,
|
||||
double cameraParallaxMouseInfluence,
|
||||
bool cameraPreview,
|
||||
bool cameraShake,
|
||||
irr::f64 cameraShakeAmplitude,
|
||||
irr::f64 cameraShakeRoughness,
|
||||
irr::f64 cameraShakeSpeed,
|
||||
double cameraShakeAmplitude,
|
||||
double cameraShakeRoughness,
|
||||
double cameraShakeSpeed,
|
||||
FloatColor clearColor,
|
||||
Scenes::CProjection* orthogonalProjection,
|
||||
irr::video::SColorf skylightColor
|
||||
FloatColor skylightColor
|
||||
);
|
||||
|
||||
static const std::string Type;
|
||||
@ -79,23 +77,23 @@ namespace WallpaperEngine::Core
|
||||
Scenes::CCamera* m_camera;
|
||||
|
||||
// data from general section on the json
|
||||
irr::video::SColorf m_ambientColor;
|
||||
FloatColor m_ambientColor;
|
||||
bool m_bloom;
|
||||
irr::f64 m_bloomStrength;
|
||||
irr::f64 m_bloomThreshold;
|
||||
double m_bloomStrength;
|
||||
double m_bloomThreshold;
|
||||
bool m_cameraFade;
|
||||
bool m_cameraParallax;
|
||||
irr::f64 m_cameraParallaxAmount;
|
||||
irr::f64 m_cameraParallaxDelay;
|
||||
irr::f64 m_cameraParallaxMouseInfluence;
|
||||
double m_cameraParallaxAmount;
|
||||
double m_cameraParallaxDelay;
|
||||
double m_cameraParallaxMouseInfluence;
|
||||
bool m_cameraPreview;
|
||||
bool m_cameraShake;
|
||||
irr::f64 m_cameraShakeAmplitude;
|
||||
irr::f64 m_cameraShakeRoughness;
|
||||
irr::f64 m_cameraShakeSpeed;
|
||||
double m_cameraShakeAmplitude;
|
||||
double m_cameraShakeRoughness;
|
||||
double m_cameraShakeSpeed;
|
||||
FloatColor m_clearColor;
|
||||
Scenes::CProjection* m_orthogonalProjection;
|
||||
irr::video::SColorf m_skylightColor;
|
||||
FloatColor m_skylightColor;
|
||||
|
||||
std::vector<CObject*> m_objects;
|
||||
};
|
||||
|
@ -1,15 +1,17 @@
|
||||
#include "CVideo.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
|
||||
CVideo::CVideo (
|
||||
const irr::io::path& filename) :
|
||||
std::string filename) :
|
||||
CWallpaper (Type),
|
||||
m_filename (filename)
|
||||
m_filename (std::move(filename))
|
||||
{
|
||||
}
|
||||
|
||||
const irr::io::path CVideo::getFilename ()
|
||||
const std::string& CVideo::getFilename ()
|
||||
{
|
||||
return this->m_filename;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "Core.h"
|
||||
#include "CWallpaper.h"
|
||||
|
||||
@ -19,15 +17,15 @@ namespace WallpaperEngine::Core
|
||||
{
|
||||
public:
|
||||
CVideo (
|
||||
const irr::io::path& filename
|
||||
std::string filename
|
||||
);
|
||||
|
||||
const irr::io::path getFilename ();
|
||||
const std::string& getFilename ();
|
||||
|
||||
protected:
|
||||
friend class CWallpaper;
|
||||
|
||||
const irr::io::path m_filename;
|
||||
const std::string m_filename;
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
|
@ -1,61 +1,8 @@
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include "Core.h"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
irr::core::vector3df Core::ato3vf(const char *str)
|
||||
{
|
||||
irr::f32 x = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
|
||||
irr::f32 y = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
|
||||
irr::f32 z = irr::core::fast_atof (str, &str);
|
||||
|
||||
return irr::core::vector3df (x, y, z);
|
||||
}
|
||||
|
||||
irr::core::vector2df Core::ato2vf (const char *str)
|
||||
{
|
||||
irr::f32 x = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
|
||||
irr::f32 y = irr::core::fast_atof (str, &str);
|
||||
|
||||
return irr::core::vector2df (x, y);
|
||||
}
|
||||
|
||||
irr::core::vector3df Core::ato3vf (const std::string& str)
|
||||
{
|
||||
return Core::ato3vf (str.c_str ());
|
||||
}
|
||||
|
||||
irr::core::vector2df Core::ato2vf (const std::string& str)
|
||||
{
|
||||
return Core::ato2vf (str.c_str ());
|
||||
}
|
||||
|
||||
irr::video::SColorf Core::atoSColorf (const char *str)
|
||||
{
|
||||
irr::core::vector3df vector = Core::ato3vf (str);
|
||||
|
||||
return irr::video::SColorf (
|
||||
vector.X,
|
||||
vector.Y,
|
||||
vector.Z
|
||||
);
|
||||
}
|
||||
|
||||
irr::video::SColorf Core::atoSColorf (const std::string& str)
|
||||
{
|
||||
return Core::atoSColorf (str.c_str ());
|
||||
}
|
||||
|
||||
irr::video::SColor Core::atoSColor (const char *str)
|
||||
{
|
||||
irr::f32 r = irr::core::strtoul10 (str, &str); while (*str == ' ') str ++;
|
||||
irr::f32 g = irr::core::strtoul10 (str, &str); while (*str == ' ') str ++;
|
||||
irr::f32 b = irr::core::strtoul10 (str, &str);
|
||||
|
||||
return irr::video::SColor (255, r, g, b);
|
||||
}
|
||||
|
||||
glm::vec3 Core::aToVector3 (const char* str)
|
||||
{
|
||||
float x = strtof (str, const_cast <char**> (&str)); while (*str == ' ') str ++;
|
||||
@ -83,12 +30,7 @@ glm::vec2 Core::aToVector2 (const std::string& str)
|
||||
return Core::aToVector2 (str.c_str ());
|
||||
}
|
||||
|
||||
irr::video::SColor Core::atoSColor (const std::string& str)
|
||||
{
|
||||
return Core::atoSColor (str.c_str ());
|
||||
}
|
||||
|
||||
FloatColor Core::aToColor (const char* str)
|
||||
FloatColor Core::aToColorf (const char* str)
|
||||
{
|
||||
float r = strtof (str, const_cast<char **>(&str)); while (*str == ' ') str ++;
|
||||
float g = strtof (str, const_cast<char **>(&str)); while (*str == ' ') str ++;
|
||||
@ -97,9 +39,23 @@ FloatColor Core::aToColor (const char* str)
|
||||
return {r, g, b, 1.0f};
|
||||
}
|
||||
|
||||
FloatColor Core::aToColor (const std::string& str)
|
||||
FloatColor Core::aToColorf (const std::string& str)
|
||||
{
|
||||
return aToColor (str.c_str ());
|
||||
return aToColorf(str.c_str());
|
||||
}
|
||||
|
||||
IntegerColor Core::aToColori (const char* str)
|
||||
{
|
||||
uint8_t r = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10)); while (*str == ' ') str ++;
|
||||
uint8_t g = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10)); while (*str == ' ') str ++;
|
||||
uint8_t b = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10));
|
||||
|
||||
return {r, g, b, 255};
|
||||
}
|
||||
|
||||
IntegerColor Core::aToColori (const std::string& str)
|
||||
{
|
||||
return aToColori(str.c_str());
|
||||
}
|
||||
|
||||
nlohmann::json::iterator Core::jsonFindRequired (nlohmann::json& data, const char *key, const char *notFoundMsg)
|
||||
@ -128,11 +84,11 @@ template <typename T> T Core::jsonFindDefault (nlohmann::json& data, const char
|
||||
|
||||
template bool Core::jsonFindDefault (nlohmann::json& data, const char *key, bool defaultValue);
|
||||
template std::string Core::jsonFindDefault (nlohmann::json& data, const char *key, std::string defaultValue);
|
||||
template irr::s16 Core::jsonFindDefault (nlohmann::json& data, const char *key, irr::s16 defaultValue);
|
||||
template irr::u16 Core::jsonFindDefault (nlohmann::json& data, const char *key, irr::u16 defaultValue);
|
||||
template irr::s32 Core::jsonFindDefault (nlohmann::json& data, const char *key, irr::s32 defaultValue);
|
||||
template irr::u32 Core::jsonFindDefault (nlohmann::json& data, const char *key, irr::u32 defaultValue);
|
||||
template irr::s64 Core::jsonFindDefault (nlohmann::json& data, const char *key, irr::s64 defaultValue);
|
||||
template irr::u64 Core::jsonFindDefault (nlohmann::json& data, const char *key, irr::u64 defaultValue);
|
||||
template irr::f32 Core::jsonFindDefault (nlohmann::json& data, const char *key, irr::f32 defaultValue);
|
||||
template irr::f64 Core::jsonFindDefault (nlohmann::json& data, const char *key, irr::f64 defaultValue);
|
||||
template int16_t Core::jsonFindDefault (nlohmann::json& data, const char *key, int16_t defaultValue);
|
||||
template uint16_t Core::jsonFindDefault (nlohmann::json& data, const char *key, uint16_t defaultValue);
|
||||
template int32_t Core::jsonFindDefault (nlohmann::json& data, const char *key, int32_t defaultValue);
|
||||
template uint32_t Core::jsonFindDefault (nlohmann::json& data, const char *key, uint32_t defaultValue);
|
||||
template int64_t Core::jsonFindDefault (nlohmann::json& data, const char *key, int64_t defaultValue);
|
||||
template uint64_t Core::jsonFindDefault (nlohmann::json& data, const char *key, uint64_t defaultValue);
|
||||
template float Core::jsonFindDefault (nlohmann::json& data, const char *key, float defaultValue);
|
||||
template double Core::jsonFindDefault (nlohmann::json& data, const char *key, double defaultValue);
|
@ -1,38 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
|
||||
#include "WallpaperEngine/Core/Types/FloatColor.h"
|
||||
#include "WallpaperEngine/Core/Types/IntegerColor.h"
|
||||
|
||||
namespace WallpaperEngine::Core
|
||||
{
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
irr::core::vector3df ato3vf (const char *str);
|
||||
irr::core::vector2df ato2vf (const char *str);
|
||||
|
||||
irr::core::vector3df ato3vf (const std::string& str);
|
||||
irr::core::vector2df ato2vf (const std::string& str);
|
||||
|
||||
irr::video::SColorf atoSColorf (const char *str);
|
||||
irr::video::SColorf atoSColorf (const std::string& str);
|
||||
|
||||
irr::video::SColor atoSColor (const char *str);
|
||||
irr::video::SColor atoSColor (const std::string& str);
|
||||
|
||||
glm::vec3 aToVector3 (const char* str);
|
||||
glm::vec2 aToVector2 (const char* str);
|
||||
|
||||
glm::vec3 aToVector3 (const std::string& str);
|
||||
glm::vec2 aToVector2 (const std::string& str);
|
||||
|
||||
FloatColor aToColor (const char* str);
|
||||
FloatColor aToColor (const std::string& str);
|
||||
FloatColor aToColorf (const char* str);
|
||||
FloatColor aToColorf (const std::string& str);
|
||||
|
||||
IntegerColor aToColori (const char* str);
|
||||
IntegerColor aToColori (const std::string& str);
|
||||
|
||||
nlohmann::json::iterator jsonFindRequired (nlohmann::json& data, const char *key, const char *notFoundMsg);
|
||||
template <typename T> T jsonFindDefault (nlohmann::json& data, const char *key, T defaultValue);
|
||||
|
@ -153,7 +153,7 @@ void CEffect::constantsFromJSON (json::const_iterator constants_it, Core::Object
|
||||
|
||||
if ((*cur).is_number_float () == true)
|
||||
{
|
||||
constant = new Effects::Constants::CShaderConstantFloat ((*cur).get <irr::f32> ());
|
||||
constant = new Effects::Constants::CShaderConstantFloat ((*cur).get <float> ());
|
||||
}
|
||||
else if ((*cur).is_number_integer () == true)
|
||||
{
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CFBO.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h"
|
||||
|
@ -10,7 +10,7 @@ using namespace WallpaperEngine::Core::Objects;
|
||||
CImage::CImage (
|
||||
Images::CMaterial* material,
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale,
|
||||
@ -28,7 +28,7 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
|
||||
json data,
|
||||
CContainer* container,
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale,
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Images/CMaterial.h"
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
@ -23,7 +21,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
json data,
|
||||
CContainer* container,
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale,
|
||||
@ -38,7 +36,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
CImage (
|
||||
Images::CMaterial* material,
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale,
|
||||
|
@ -1,14 +1,12 @@
|
||||
#include "CParticle.h"
|
||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects;
|
||||
|
||||
CParticle* CParticle::fromFile (
|
||||
const std::string& filename,
|
||||
CContainer* container,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale)
|
||||
@ -66,9 +64,9 @@ CParticle* CParticle::fromFile (
|
||||
}
|
||||
|
||||
CParticle::CParticle (
|
||||
irr::u32 starttime,
|
||||
irr::u32 maxcount,
|
||||
irr::u32 id,
|
||||
uint32_t starttime,
|
||||
uint32_t maxcount,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale):
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Particles/CControlPoint.h"
|
||||
#include "WallpaperEngine/Core/Objects/Particles/CEmitter.h"
|
||||
#include "WallpaperEngine/Core/Objects/Particles/CInitializer.h"
|
||||
@ -21,7 +19,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
static CParticle* fromFile (
|
||||
const std::string& filename,
|
||||
CContainer* container,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale
|
||||
@ -33,9 +31,9 @@ namespace WallpaperEngine::Core::Objects
|
||||
|
||||
protected:
|
||||
CParticle (
|
||||
irr::u32 starttime,
|
||||
irr::u32 maxcount,
|
||||
irr::u32 id,
|
||||
uint32_t starttime,
|
||||
uint32_t maxcount,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale
|
||||
@ -46,8 +44,8 @@ namespace WallpaperEngine::Core::Objects
|
||||
|
||||
static const std::string Type;
|
||||
private:
|
||||
irr::u32 m_starttime;
|
||||
irr::u32 m_maxcount;
|
||||
uint32_t m_starttime;
|
||||
uint32_t m_maxcount;
|
||||
std::vector<Particles::CControlPoint*> m_controlpoints;
|
||||
std::vector<Particles::CEmitter*> m_emitters;
|
||||
std::vector<Particles::CInitializer*> m_initializers;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/CObject.h"
|
||||
#include "CSound.h"
|
||||
|
||||
@ -7,7 +5,7 @@ using namespace WallpaperEngine::Core::Objects;
|
||||
|
||||
CSound::CSound (
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale,
|
||||
@ -19,7 +17,7 @@ CSound::CSound (
|
||||
WallpaperEngine::Core::CObject* CSound::fromJSON (
|
||||
json data,
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale,
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
#include "WallpaperEngine/Core/CObject.h"
|
||||
|
||||
@ -17,7 +15,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
static CObject* fromJSON (
|
||||
json data,
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale,
|
||||
@ -30,7 +28,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
protected:
|
||||
CSound (
|
||||
bool visible,
|
||||
irr::u32 id,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& scale,
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
|
||||
CBind::CBind (std::string name, irr::u32 index) :
|
||||
CBind::CBind (std::string name, uint32_t index) :
|
||||
m_name (std::move(name)),
|
||||
m_index (index)
|
||||
{
|
||||
@ -23,7 +23,7 @@ const std::string& CBind::getName () const
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
const irr::u32& CBind::getIndex () const
|
||||
const uint32_t& CBind::getIndex () const
|
||||
{
|
||||
return this->m_index;
|
||||
}
|
@ -2,8 +2,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
@ -15,13 +13,13 @@ namespace WallpaperEngine::Core::Objects::Effects
|
||||
public:
|
||||
static CBind* fromJSON (json data);
|
||||
|
||||
CBind (std::string name, irr::u32 index);
|
||||
CBind (std::string name, uint32_t index);
|
||||
|
||||
const std::string& getName () const;
|
||||
const irr::u32& getIndex () const;
|
||||
const uint32_t& getIndex () const;
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
irr::u32 m_index;
|
||||
uint32_t m_index;
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
|
||||
CFBO::CFBO (std::string name, irr::f32 scale, std::string format) :
|
||||
CFBO::CFBO (std::string name, float scale, std::string format) :
|
||||
m_name (std::move(name)),
|
||||
m_scale (scale),
|
||||
m_format(std::move(format))
|
||||
@ -29,7 +29,7 @@ const std::string& CFBO::getName () const
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
const irr::f32& CFBO::getScale () const
|
||||
const float& CFBO::getScale () const
|
||||
{
|
||||
return this->m_scale;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
@ -12,17 +11,17 @@ namespace WallpaperEngine::Core::Objects::Effects
|
||||
class CFBO
|
||||
{
|
||||
public:
|
||||
CFBO (std::string name, irr::f32 scale, std::string format);
|
||||
CFBO (std::string name, float scale, std::string format);
|
||||
|
||||
static CFBO* fromJSON (json data);
|
||||
|
||||
const std::string& getName () const;
|
||||
const irr::f32& getScale () const;
|
||||
const float& getScale () const;
|
||||
const std::string& getFormat () const;
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
irr::f32 m_scale;
|
||||
float m_scale;
|
||||
std::string m_format;
|
||||
};
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
#include "CShaderConstant.h"
|
||||
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "CShaderConstant.h"
|
||||
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "CShaderConstant.h"
|
||||
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "CMaterial.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Images/Materials/CPass.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CBind.h"
|
||||
|
||||
|
@ -12,7 +12,7 @@ CControlPoint* CControlPoint::fromJSON (json data)
|
||||
|
||||
if (offset_it != data.end ())
|
||||
{
|
||||
controlpoint->setOffset (WallpaperEngine::Core::ato3vf (*offset_it));
|
||||
controlpoint->setOffset (WallpaperEngine::Core::aToVector3 (*offset_it));
|
||||
}
|
||||
|
||||
if (flags_it != data.end ())
|
||||
@ -23,29 +23,29 @@ CControlPoint* CControlPoint::fromJSON (json data)
|
||||
return controlpoint;
|
||||
}
|
||||
|
||||
CControlPoint::CControlPoint (irr::u32 id, irr::u32 flags) :
|
||||
CControlPoint::CControlPoint (uint32_t id, uint32_t flags) :
|
||||
m_id (id),
|
||||
m_flags (flags),
|
||||
m_offset (irr::core::vector3df ())
|
||||
m_offset (glm::vec3 ())
|
||||
{
|
||||
}
|
||||
|
||||
void CControlPoint::setOffset (const irr::core::vector3df& offset)
|
||||
void CControlPoint::setOffset (const glm::vec3& offset)
|
||||
{
|
||||
this->m_offset = offset;
|
||||
}
|
||||
|
||||
void CControlPoint::setFlags (irr::u32 flags)
|
||||
void CControlPoint::setFlags (uint32_t flags)
|
||||
{
|
||||
this->m_flags = flags;
|
||||
}
|
||||
|
||||
const irr::core::vector3df& CControlPoint::getOffset () const
|
||||
const glm::vec3& CControlPoint::getOffset () const
|
||||
{
|
||||
return this->m_offset;
|
||||
}
|
||||
|
||||
const irr::u32 CControlPoint::getFlags () const
|
||||
const uint32_t CControlPoint::getFlags () const
|
||||
{
|
||||
return this->m_flags;
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles
|
||||
@ -13,16 +11,16 @@ namespace WallpaperEngine::Core::Objects::Particles
|
||||
public:
|
||||
static CControlPoint* fromJSON (json data);
|
||||
|
||||
const irr::core::vector3df& getOffset () const;
|
||||
const irr::u32 getFlags () const;
|
||||
const glm::vec3& getOffset () const;
|
||||
const uint32_t getFlags () const;
|
||||
protected:
|
||||
CControlPoint (irr::u32 id, irr::u32 flags = 0);
|
||||
CControlPoint (uint32_t id, uint32_t flags = 0);
|
||||
|
||||
void setOffset (const irr::core::vector3df& offset);
|
||||
void setFlags (irr::u32 flags);
|
||||
void setOffset (const glm::vec3& offset);
|
||||
void setFlags (uint32_t flags);
|
||||
private:
|
||||
irr::u32 m_id;
|
||||
irr::u32 m_flags;
|
||||
irr::core::vector3df m_offset;
|
||||
uint32_t m_id;
|
||||
uint32_t m_flags;
|
||||
glm::vec3 m_offset;
|
||||
};
|
||||
};
|
||||
|
@ -13,24 +13,24 @@ CEmitter* CEmitter::fromJSON (json data)
|
||||
auto rate_it = jsonFindRequired (data, "rate", "Particle emitter must have a rate");
|
||||
|
||||
return new CEmitter (
|
||||
WallpaperEngine::Core::ato3vf (*directions_it),
|
||||
WallpaperEngine::Core::aToVector3 (*directions_it),
|
||||
*distancemax_it,
|
||||
*distancemin_it,
|
||||
(id_it == data.end () ? 0 : (irr::u32) (*id_it)),
|
||||
(id_it == data.end () ? 0 : (uint32_t) (*id_it)),
|
||||
*name_it,
|
||||
WallpaperEngine::Core::ato3vf (*origin_it),
|
||||
WallpaperEngine::Core::aToVector3 (*origin_it),
|
||||
*rate_it
|
||||
);
|
||||
}
|
||||
|
||||
CEmitter::CEmitter (
|
||||
const irr::core::vector3df& directions,
|
||||
irr::u32 distancemax,
|
||||
irr::u32 distancemin,
|
||||
irr::u32 id,
|
||||
const glm::vec3& directions,
|
||||
uint32_t distancemax,
|
||||
uint32_t distancemin,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const irr::core::vector3df& origin,
|
||||
irr::f64 rate):
|
||||
const glm::vec3& origin,
|
||||
double rate):
|
||||
m_directions (directions),
|
||||
m_distancemax (distancemax),
|
||||
m_distancemin (distancemin),
|
||||
@ -47,27 +47,27 @@ const std::string& CEmitter::getName () const
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
const irr::u32 CEmitter::getDistanceMax () const
|
||||
const uint32_t CEmitter::getDistanceMax () const
|
||||
{
|
||||
return this->m_distancemax;
|
||||
}
|
||||
|
||||
const irr::u32 CEmitter::getDistanceMin () const
|
||||
const uint32_t CEmitter::getDistanceMin () const
|
||||
{
|
||||
return this->m_distancemin;
|
||||
}
|
||||
|
||||
const irr::core::vector3df& CEmitter::getDirections () const
|
||||
const glm::vec3& CEmitter::getDirections () const
|
||||
{
|
||||
return this->m_directions;
|
||||
}
|
||||
|
||||
const irr::core::vector3df& CEmitter::getOrigin () const
|
||||
const glm::vec3& CEmitter::getOrigin () const
|
||||
{
|
||||
return this->m_origin;
|
||||
}
|
||||
|
||||
const irr::f64 CEmitter::getRate () const
|
||||
const double CEmitter::getRate () const
|
||||
{
|
||||
return this->m_rate;
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles
|
||||
@ -14,28 +12,28 @@ namespace WallpaperEngine::Core::Objects::Particles
|
||||
static CEmitter* fromJSON (json data);
|
||||
|
||||
const std::string& getName () const;
|
||||
const irr::u32 getDistanceMax () const;
|
||||
const irr::u32 getDistanceMin () const;
|
||||
const irr::core::vector3df& getDirections () const;
|
||||
const irr::core::vector3df& getOrigin () const;
|
||||
const irr::f64 getRate () const;
|
||||
const uint32_t getDistanceMax () const;
|
||||
const uint32_t getDistanceMin () const;
|
||||
const glm::vec3& getDirections () const;
|
||||
const glm::vec3& getOrigin () const;
|
||||
const double getRate () const;
|
||||
protected:
|
||||
CEmitter (
|
||||
const irr::core::vector3df& directions,
|
||||
irr::u32 distancemax,
|
||||
irr::u32 distancemin,
|
||||
irr::u32 id,
|
||||
const glm::vec3& directions,
|
||||
uint32_t distancemax,
|
||||
uint32_t distancemin,
|
||||
uint32_t id,
|
||||
std::string name,
|
||||
const irr::core::vector3df& origin,
|
||||
irr::f64 rate
|
||||
const glm::vec3& origin,
|
||||
double rate
|
||||
);
|
||||
private:
|
||||
irr::core::vector3df m_directions;
|
||||
irr::u32 m_distancemax;
|
||||
irr::u32 m_distancemin;
|
||||
irr::u32 m_id;
|
||||
glm::vec3 m_directions;
|
||||
uint32_t m_distancemax;
|
||||
uint32_t m_distancemin;
|
||||
uint32_t m_id;
|
||||
std::string m_name;
|
||||
irr::core::vector3df m_origin;
|
||||
irr::f64 m_rate;
|
||||
glm::vec3 m_origin;
|
||||
double m_rate;
|
||||
};
|
||||
};
|
||||
|
@ -15,7 +15,7 @@ CInitializer* CInitializer::fromJSON (json data)
|
||||
{
|
||||
auto id_it = data.find ("id");
|
||||
auto name_it = jsonFindRequired (data, "name", "Particle's initializer must have a name");
|
||||
irr::u32 id = ((id_it == data.end ()) ? 0 : (irr::u32) (*id_it));
|
||||
uint32_t id = ((id_it == data.end ()) ? 0 : (uint32_t) (*id_it));
|
||||
|
||||
if (*name_it == "lifetimerandom")
|
||||
{
|
||||
@ -56,7 +56,7 @@ CInitializer* CInitializer::fromJSON (json data)
|
||||
}
|
||||
|
||||
|
||||
CInitializer::CInitializer (irr::u32 id, std::string name) :
|
||||
CInitializer::CInitializer (uint32_t id, std::string name) :
|
||||
m_id (id),
|
||||
m_name (std::move(name))
|
||||
{
|
||||
@ -68,7 +68,7 @@ const std::string& CInitializer::getName () const
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
const irr::u32 CInitializer::getId () const
|
||||
const uint32_t CInitializer::getId () const
|
||||
{
|
||||
return this->m_id;
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles
|
||||
@ -14,11 +12,11 @@ namespace WallpaperEngine::Core::Objects::Particles
|
||||
static CInitializer* fromJSON (json data);
|
||||
|
||||
const std::string& getName () const;
|
||||
const irr::u32 getId () const;
|
||||
const uint32_t getId () const;
|
||||
protected:
|
||||
CInitializer (irr::u32 id, std::string name);
|
||||
CInitializer (uint32_t id, std::string name);
|
||||
private:
|
||||
irr::u32 m_id;
|
||||
uint32_t m_id;
|
||||
std::string m_name;
|
||||
};
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||
|
||||
CAlphaRandom* CAlphaRandom::fromJSON (json data, irr::u32 id)
|
||||
CAlphaRandom* CAlphaRandom::fromJSON (json data, uint32_t id)
|
||||
{
|
||||
auto min_it = jsonFindRequired (data, "min", "Alpharandom initializer must have a minimum value");
|
||||
auto max_it = jsonFindRequired (data, "max", "Alpharandom initializer must have a maximum value");
|
||||
@ -10,19 +10,19 @@ CAlphaRandom* CAlphaRandom::fromJSON (json data, irr::u32 id)
|
||||
return new CAlphaRandom (id, *min_it, *max_it);
|
||||
}
|
||||
|
||||
CAlphaRandom::CAlphaRandom (irr::u32 id, irr::f64 min, irr::f64 max) :
|
||||
CAlphaRandom::CAlphaRandom (uint32_t id, double min, double max) :
|
||||
CInitializer (id, "alpharandom"),
|
||||
m_min (min),
|
||||
m_max (max)
|
||||
{
|
||||
}
|
||||
|
||||
const irr::f64 CAlphaRandom::getMinimum () const
|
||||
const double CAlphaRandom::getMinimum () const
|
||||
{
|
||||
return this->m_min;
|
||||
}
|
||||
|
||||
const irr::f64 CAlphaRandom::getMaximum () const
|
||||
const double CAlphaRandom::getMaximum () const
|
||||
{
|
||||
return this->m_max;
|
||||
}
|
@ -4,23 +4,21 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
class CAlphaRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
const irr::f64 getMinimum () const;
|
||||
const irr::f64 getMaximum () const;
|
||||
const double getMinimum () const;
|
||||
const double getMaximum () const;
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CAlphaRandom* fromJSON (json data, irr::u32 id);
|
||||
static CAlphaRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CAlphaRandom (irr::u32 id, irr::f64 min, irr::f64 max);
|
||||
CAlphaRandom (uint32_t id, double min, double max);
|
||||
private:
|
||||
irr::f64 m_max;
|
||||
irr::f64 m_min;
|
||||
double m_max;
|
||||
double m_min;
|
||||
};
|
||||
};
|
||||
|
@ -2,32 +2,32 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||
|
||||
CAngularVelocityRandom* CAngularVelocityRandom::fromJSON (json data, irr::u32 id)
|
||||
CAngularVelocityRandom* CAngularVelocityRandom::fromJSON (json data, uint32_t id)
|
||||
{
|
||||
auto min_it = jsonFindRequired (data, "min", "Angularvelocityrandom initializer must have a minimum value");
|
||||
auto max_it = jsonFindRequired (data, "max", "Angularvelocityrandom initializer must have a maximum value");
|
||||
|
||||
return new CAngularVelocityRandom (
|
||||
id,
|
||||
WallpaperEngine::Core::ato3vf (*min_it),
|
||||
WallpaperEngine::Core::ato3vf (*max_it)
|
||||
WallpaperEngine::Core::aToVector3 (*min_it),
|
||||
WallpaperEngine::Core::aToVector3 (*max_it)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
CAngularVelocityRandom::CAngularVelocityRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max) :
|
||||
CAngularVelocityRandom::CAngularVelocityRandom (uint32_t id, glm::vec3 min, glm::vec3 max) :
|
||||
CInitializer (id, "angularvelocityrandom"),
|
||||
m_min (min),
|
||||
m_max (max)
|
||||
{
|
||||
}
|
||||
|
||||
const irr::core::vector3df& CAngularVelocityRandom::getMinimum () const
|
||||
const glm::vec3& CAngularVelocityRandom::getMinimum () const
|
||||
{
|
||||
return this->m_min;
|
||||
}
|
||||
|
||||
const irr::core::vector3df& CAngularVelocityRandom::getMaximum () const
|
||||
const glm::vec3& CAngularVelocityRandom::getMaximum () const
|
||||
{
|
||||
return this->m_max;
|
||||
}
|
@ -4,23 +4,21 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
class CAngularVelocityRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
const irr::core::vector3df& getMinimum () const;
|
||||
const irr::core::vector3df& getMaximum () const;
|
||||
const glm::vec3& getMinimum () const;
|
||||
const glm::vec3& getMaximum () const;
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CAngularVelocityRandom* fromJSON (json data, irr::u32 id);
|
||||
static CAngularVelocityRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CAngularVelocityRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max);
|
||||
CAngularVelocityRandom (uint32_t id, glm::vec3 min, glm::vec3 max);
|
||||
private:
|
||||
irr::core::vector3df m_max;
|
||||
irr::core::vector3df m_min;
|
||||
glm::vec3 m_max;
|
||||
glm::vec3 m_min;
|
||||
};
|
||||
};
|
||||
|
@ -2,32 +2,32 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||
|
||||
CColorRandom* CColorRandom::fromJSON (json data, irr::u32 id)
|
||||
CColorRandom* CColorRandom::fromJSON (json data, uint32_t id)
|
||||
{
|
||||
auto min_it = jsonFindRequired (data, "min", "Colorrandom initializer must have a minimum value");
|
||||
auto max_it = jsonFindRequired (data, "max", "Colorrandom initializer must have a maximum value");
|
||||
|
||||
return new CColorRandom (
|
||||
id,
|
||||
WallpaperEngine::Core::atoSColor (*min_it),
|
||||
WallpaperEngine::Core::atoSColor (*max_it)
|
||||
WallpaperEngine::Core::aToColori (*min_it),
|
||||
WallpaperEngine::Core::aToColori (*max_it)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
CColorRandom::CColorRandom (irr::u32 id, irr::video::SColor min, irr::video::SColor max) :
|
||||
CColorRandom::CColorRandom (uint32_t id, IntegerColor min, IntegerColor max) :
|
||||
CInitializer (id, "colorrandom"),
|
||||
m_min (min),
|
||||
m_max (max)
|
||||
{
|
||||
}
|
||||
|
||||
const irr::video::SColor& CColorRandom::getMinimum () const
|
||||
const IntegerColor& CColorRandom::getMinimum () const
|
||||
{
|
||||
return this->m_min;
|
||||
}
|
||||
|
||||
const irr::video::SColor& CColorRandom::getMaximum () const
|
||||
const IntegerColor& CColorRandom::getMaximum () const
|
||||
{
|
||||
return this->m_max;
|
||||
}
|
@ -4,23 +4,23 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
class CColorRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
const irr::video::SColor& getMinimum () const;
|
||||
const irr::video::SColor& getMaximum () const;
|
||||
const IntegerColor& getMinimum () const;
|
||||
const IntegerColor& getMaximum () const;
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CColorRandom* fromJSON (json data, irr::u32 id);
|
||||
static CColorRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CColorRandom (irr::u32 id, irr::video::SColor min, irr::video::SColor max);
|
||||
CColorRandom (uint32_t id, IntegerColor min, IntegerColor max);
|
||||
private:
|
||||
irr::video::SColor m_max;
|
||||
irr::video::SColor m_min;
|
||||
IntegerColor m_max;
|
||||
IntegerColor m_min;
|
||||
};
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||
|
||||
CLifeTimeRandom* CLifeTimeRandom::fromJSON (json data, irr::u32 id)
|
||||
CLifeTimeRandom* CLifeTimeRandom::fromJSON (json data, uint32_t id)
|
||||
{
|
||||
auto min_it = jsonFindRequired (data, "min", "Lifetimerandom initializer must have a minimum value");
|
||||
auto max_it = jsonFindRequired (data, "max", "Lifetimerandom initializer must have a maximum value");
|
||||
@ -11,19 +11,19 @@ CLifeTimeRandom* CLifeTimeRandom::fromJSON (json data, irr::u32 id)
|
||||
}
|
||||
|
||||
|
||||
CLifeTimeRandom::CLifeTimeRandom (irr::u32 id, irr::u32 min, irr::u32 max) :
|
||||
CLifeTimeRandom::CLifeTimeRandom (uint32_t id, uint32_t min, uint32_t max) :
|
||||
CInitializer (id, "lifetimerandom"),
|
||||
m_min (min),
|
||||
m_max (max)
|
||||
{
|
||||
}
|
||||
|
||||
const irr::u32 CLifeTimeRandom::getMinimum () const
|
||||
const uint32_t CLifeTimeRandom::getMinimum () const
|
||||
{
|
||||
return this->m_min;
|
||||
}
|
||||
|
||||
const irr::u32 CLifeTimeRandom::getMaximum () const
|
||||
const uint32_t CLifeTimeRandom::getMaximum () const
|
||||
{
|
||||
return this->m_max;
|
||||
}
|
@ -4,23 +4,21 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
class CLifeTimeRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
const irr::u32 getMinimum () const;
|
||||
const irr::u32 getMaximum () const;
|
||||
const uint32_t getMinimum () const;
|
||||
const uint32_t getMaximum () const;
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CLifeTimeRandom* fromJSON (json data, irr::u32 id);
|
||||
static CLifeTimeRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CLifeTimeRandom (irr::u32 id, irr::u32 min, irr::u32 max);
|
||||
CLifeTimeRandom (uint32_t id, uint32_t min, uint32_t max);
|
||||
private:
|
||||
irr::u32 m_max;
|
||||
irr::u32 m_min;
|
||||
uint32_t m_max;
|
||||
uint32_t m_min;
|
||||
};
|
||||
};
|
||||
|
@ -4,21 +4,21 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||
|
||||
CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id)
|
||||
CRotationRandom* CRotationRandom::fromJSON (json data, uint32_t id)
|
||||
{
|
||||
auto min_it = data.find ("minVector");
|
||||
auto max_it = data.find ("max");
|
||||
|
||||
irr::core::vector3df minVector = irr::core::vector3df ();
|
||||
irr::core::vector3df maxVector = irr::core::vector3df ();
|
||||
irr::f64 minNumber = 0.0f;
|
||||
irr::f64 maxNumber = 0.0f;
|
||||
glm::vec3 minVector = glm::vec3 ();
|
||||
glm::vec3 maxVector = glm::vec3 ();
|
||||
double minNumber = 0.0f;
|
||||
double maxNumber = 0.0f;
|
||||
bool isMinVector = false;
|
||||
bool isMaxVector = false;
|
||||
|
||||
if (min_it != data.end () && min_it->is_string ())
|
||||
{
|
||||
minVector = WallpaperEngine::Core::ato3vf (*min_it);
|
||||
minVector = WallpaperEngine::Core::aToVector3 (*min_it);
|
||||
isMinVector = true;
|
||||
}
|
||||
else if (min_it != data.end () && min_it->is_number ())
|
||||
@ -29,7 +29,7 @@ CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id)
|
||||
|
||||
if (max_it != data.end () && max_it->is_string ())
|
||||
{
|
||||
maxVector = WallpaperEngine::Core::ato3vf (*max_it);
|
||||
maxVector = WallpaperEngine::Core::aToVector3 (*max_it);
|
||||
isMaxVector = true;
|
||||
}
|
||||
else if(max_it != data.end () && max_it->is_number ())
|
||||
@ -42,12 +42,12 @@ CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id)
|
||||
}
|
||||
|
||||
CRotationRandom::CRotationRandom (
|
||||
irr::u32 id,
|
||||
irr::core::vector3df minVector,
|
||||
irr::f64 minNumber,
|
||||
uint32_t id,
|
||||
glm::vec3 minVector,
|
||||
double minNumber,
|
||||
bool isMinimumVector,
|
||||
irr::core::vector3df maxVector,
|
||||
irr::f64 maxNumber,
|
||||
glm::vec3 maxVector,
|
||||
double maxNumber,
|
||||
bool isMaximumVector
|
||||
) :
|
||||
CInitializer (id, "rotationrandom"),
|
||||
@ -60,22 +60,22 @@ CRotationRandom::CRotationRandom (
|
||||
{
|
||||
}
|
||||
|
||||
const irr::core::vector3df CRotationRandom::getMinimumVector () const
|
||||
const glm::vec3 CRotationRandom::getMinimumVector () const
|
||||
{
|
||||
return this->m_minVector;
|
||||
}
|
||||
|
||||
const irr::core::vector3df CRotationRandom::getMaximumVector () const
|
||||
const glm::vec3 CRotationRandom::getMaximumVector () const
|
||||
{
|
||||
return this->m_maxVector;
|
||||
}
|
||||
|
||||
const irr::f64 CRotationRandom::getMinimumNumber () const
|
||||
const double CRotationRandom::getMinimumNumber () const
|
||||
{
|
||||
return this->m_minNumber;
|
||||
}
|
||||
|
||||
const irr::f64 CRotationRandom::getMaximumNumber () const
|
||||
const double CRotationRandom::getMaximumNumber () const
|
||||
{
|
||||
return this->m_maxNumber;
|
||||
}
|
||||
|
@ -3,17 +3,16 @@
|
||||
#include "WallpaperEngine/Core/Objects/Particles/CInitializer.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
class CRotationRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
const irr::core::vector3df getMinimumVector () const;
|
||||
const irr::core::vector3df getMaximumVector () const;
|
||||
const irr::f64 getMinimumNumber () const;
|
||||
const irr::f64 getMaximumNumber () const;
|
||||
const glm::vec3 getMinimumVector () const;
|
||||
const glm::vec3 getMaximumVector () const;
|
||||
const double getMinimumNumber () const;
|
||||
const double getMaximumNumber () const;
|
||||
|
||||
const bool isMinimumVector () const;
|
||||
const bool isMinimumNumber () const;
|
||||
@ -23,22 +22,22 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CRotationRandom* fromJSON (json data, irr::u32 id);
|
||||
static CRotationRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CRotationRandom (
|
||||
irr::u32 id,
|
||||
irr::core::vector3df minVector,
|
||||
irr::f64 minNumber,
|
||||
uint32_t id,
|
||||
glm::vec3 minVector,
|
||||
double minNumber,
|
||||
bool isMinimumVector,
|
||||
irr::core::vector3df maxVector,
|
||||
irr::f64 maxNumber,
|
||||
glm::vec3 maxVector,
|
||||
double maxNumber,
|
||||
bool isMaximumVector
|
||||
);
|
||||
private:
|
||||
irr::core::vector3df m_maxVector;
|
||||
irr::f64 m_maxNumber;
|
||||
irr::core::vector3df m_minVector;
|
||||
irr::f64 m_minNumber;
|
||||
glm::vec3 m_maxVector;
|
||||
double m_maxNumber;
|
||||
glm::vec3 m_minVector;
|
||||
double m_minNumber;
|
||||
|
||||
bool m_isMinimumVector;
|
||||
bool m_isMaximumVector;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||
|
||||
CSizeRandom* CSizeRandom::fromJSON (json data, irr::u32 id)
|
||||
CSizeRandom* CSizeRandom::fromJSON (json data, uint32_t id)
|
||||
{
|
||||
auto min_it = jsonFindRequired (data, "min", "Sizerandom initializer must have a minimum value");
|
||||
auto max_it = jsonFindRequired (data, "max", "Sizerandom initializer must have a maximum value");
|
||||
@ -10,19 +10,19 @@ CSizeRandom* CSizeRandom::fromJSON (json data, irr::u32 id)
|
||||
return new CSizeRandom (id, *min_it, *max_it);
|
||||
}
|
||||
|
||||
CSizeRandom::CSizeRandom (irr::u32 id, irr::u32 min, irr::u32 max) :
|
||||
CSizeRandom::CSizeRandom (uint32_t id, uint32_t min, uint32_t max) :
|
||||
CInitializer (id, "sizerandom"),
|
||||
m_min (min),
|
||||
m_max (max)
|
||||
{
|
||||
}
|
||||
|
||||
const irr::u32 CSizeRandom::getMinimum () const
|
||||
const uint32_t CSizeRandom::getMinimum () const
|
||||
{
|
||||
return this->m_min;
|
||||
}
|
||||
|
||||
const irr::u32 CSizeRandom::getMaximum () const
|
||||
const uint32_t CSizeRandom::getMaximum () const
|
||||
{
|
||||
return this->m_max;
|
||||
}
|
@ -4,23 +4,21 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
class CSizeRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
const irr::u32 getMinimum () const;
|
||||
const irr::u32 getMaximum () const;
|
||||
const uint32_t getMinimum () const;
|
||||
const uint32_t getMaximum () const;
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CSizeRandom* fromJSON (json data, irr::u32 id);
|
||||
static CSizeRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CSizeRandom (irr::u32 id, irr::u32 min, irr::u32 max);
|
||||
CSizeRandom (uint32_t id, uint32_t min, uint32_t max);
|
||||
private:
|
||||
irr::u32 m_max;
|
||||
irr::u32 m_min;
|
||||
uint32_t m_max;
|
||||
uint32_t m_min;
|
||||
};
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||
|
||||
CTurbulentVelocityRandom* CTurbulentVelocityRandom::fromJSON (json data, irr::u32 id)
|
||||
CTurbulentVelocityRandom* CTurbulentVelocityRandom::fromJSON (json data, uint32_t id)
|
||||
{
|
||||
json::const_iterator phasemax_it = data.find ("phasemax");
|
||||
json::const_iterator scale_it = data.find ("scale");
|
||||
@ -48,8 +48,8 @@ CTurbulentVelocityRandom* CTurbulentVelocityRandom::fromJSON (json data, irr::u3
|
||||
}
|
||||
|
||||
|
||||
CTurbulentVelocityRandom::CTurbulentVelocityRandom (irr::u32 id,
|
||||
irr::f64 phasemax, irr::f64 scale, irr::f64 timescale, irr::u32 speedmin, irr::u32 speedmax) :
|
||||
CTurbulentVelocityRandom::CTurbulentVelocityRandom (uint32_t id,
|
||||
double phasemax, double scale, double timescale, uint32_t speedmin, uint32_t speedmax) :
|
||||
CInitializer (id, "turbulentvelocityrandom"),
|
||||
m_phasemax (phasemax),
|
||||
m_scale (scale),
|
||||
@ -60,27 +60,27 @@ CTurbulentVelocityRandom::CTurbulentVelocityRandom (irr::u32 id,
|
||||
}
|
||||
|
||||
|
||||
irr::f64 CTurbulentVelocityRandom::getPhaseMax ()
|
||||
double CTurbulentVelocityRandom::getPhaseMax ()
|
||||
{
|
||||
return this->m_phasemax;
|
||||
}
|
||||
|
||||
irr::f64 CTurbulentVelocityRandom::getScale ()
|
||||
double CTurbulentVelocityRandom::getScale ()
|
||||
{
|
||||
return this->m_scale;
|
||||
}
|
||||
|
||||
irr::f64 CTurbulentVelocityRandom::getTimeScale ()
|
||||
double CTurbulentVelocityRandom::getTimeScale ()
|
||||
{
|
||||
return this->m_timescale;
|
||||
}
|
||||
|
||||
irr::u32 CTurbulentVelocityRandom::getMinimumSpeed ()
|
||||
uint32_t CTurbulentVelocityRandom::getMinimumSpeed ()
|
||||
{
|
||||
return this->m_speedmin;
|
||||
}
|
||||
|
||||
irr::u32 CTurbulentVelocityRandom::getMaximumSpeed ()
|
||||
uint32_t CTurbulentVelocityRandom::getMaximumSpeed ()
|
||||
{
|
||||
return this->m_speedmax;
|
||||
}
|
||||
|
@ -3,31 +3,30 @@
|
||||
#include "WallpaperEngine/Core/Objects/Particles/CInitializer.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
class CTurbulentVelocityRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
irr::f64 getPhaseMax ();
|
||||
irr::f64 getScale ();
|
||||
irr::f64 getTimeScale ();
|
||||
irr::u32 getMinimumSpeed ();
|
||||
irr::u32 getMaximumSpeed ();
|
||||
double getPhaseMax ();
|
||||
double getScale ();
|
||||
double getTimeScale ();
|
||||
uint32_t getMinimumSpeed ();
|
||||
uint32_t getMaximumSpeed ();
|
||||
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CTurbulentVelocityRandom* fromJSON (json data, irr::u32 id);
|
||||
static CTurbulentVelocityRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CTurbulentVelocityRandom (irr::u32 id,
|
||||
irr::f64 phasemax, irr::f64 scale, irr::f64 timescale, irr::u32 speedmin, irr::u32 speedmax);
|
||||
CTurbulentVelocityRandom (uint32_t id,
|
||||
double phasemax, double scale, double timescale, uint32_t speedmin, uint32_t speedmax);
|
||||
private:
|
||||
irr::f64 m_phasemax;
|
||||
irr::f64 m_scale;
|
||||
irr::f64 m_timescale;
|
||||
irr::u32 m_speedmin;
|
||||
irr::u32 m_speedmax;
|
||||
double m_phasemax;
|
||||
double m_scale;
|
||||
double m_timescale;
|
||||
uint32_t m_speedmin;
|
||||
uint32_t m_speedmax;
|
||||
};
|
||||
};
|
||||
|
@ -2,32 +2,32 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
|
||||
|
||||
CVelocityRandom* CVelocityRandom::fromJSON (json data, irr::u32 id)
|
||||
CVelocityRandom* CVelocityRandom::fromJSON (json data, uint32_t id)
|
||||
{
|
||||
auto min_it = jsonFindRequired (data, "min", "Velocityrandom initializer must have a minimum value");
|
||||
auto max_it = jsonFindRequired (data, "max", "Velocityrandom initializer must have a maximum value");
|
||||
|
||||
return new CVelocityRandom (
|
||||
id,
|
||||
WallpaperEngine::Core::ato3vf (*min_it),
|
||||
WallpaperEngine::Core::ato3vf (*max_it)
|
||||
WallpaperEngine::Core::aToVector3 (*min_it),
|
||||
WallpaperEngine::Core::aToVector3 (*max_it)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
CVelocityRandom::CVelocityRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max) :
|
||||
CVelocityRandom::CVelocityRandom (uint32_t id, glm::vec3 min, glm::vec3 max) :
|
||||
CInitializer (id, "velocityrandom"),
|
||||
m_min (min),
|
||||
m_max (max)
|
||||
{
|
||||
}
|
||||
|
||||
const irr::core::vector3df& CVelocityRandom::getMinimum () const
|
||||
const glm::vec3& CVelocityRandom::getMinimum () const
|
||||
{
|
||||
return this->m_min;
|
||||
}
|
||||
|
||||
const irr::core::vector3df& CVelocityRandom::getMaximum () const
|
||||
const glm::vec3& CVelocityRandom::getMaximum () const
|
||||
{
|
||||
return this->m_max;
|
||||
}
|
@ -4,23 +4,21 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
class CVelocityRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
const irr::core::vector3df& getMinimum () const;
|
||||
const irr::core::vector3df& getMaximum () const;
|
||||
const glm::vec3& getMinimum () const;
|
||||
const glm::vec3& getMaximum () const;
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CVelocityRandom* fromJSON (json data, irr::u32 id);
|
||||
static CVelocityRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CVelocityRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max);
|
||||
CVelocityRandom (uint32_t id, glm::vec3 min, glm::vec3 max);
|
||||
private:
|
||||
irr::core::vector3df m_max;
|
||||
irr::core::vector3df m_min;
|
||||
glm::vec3 m_max;
|
||||
glm::vec3 m_min;
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "CProperty.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Projects
|
||||
|
@ -8,18 +8,18 @@ CPropertyColor* CPropertyColor::fromJSON (json data, const std::string& name)
|
||||
auto text = data.find ("type");
|
||||
|
||||
return new CPropertyColor (
|
||||
WallpaperEngine::Core::atoSColor (*value),
|
||||
WallpaperEngine::Core::aToColori (*value),
|
||||
name,
|
||||
*text
|
||||
);
|
||||
}
|
||||
|
||||
const irr::video::SColor& CPropertyColor::getValue () const
|
||||
const IntegerColor& CPropertyColor::getValue () const
|
||||
{
|
||||
return this->m_color;
|
||||
}
|
||||
|
||||
CPropertyColor::CPropertyColor (irr::video::SColor color, const std::string& name, const std::string& text) :
|
||||
CPropertyColor::CPropertyColor (IntegerColor color, const std::string& name, const std::string& text) :
|
||||
CProperty (name, Type, text),
|
||||
m_color (color)
|
||||
{
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "CProperty.h"
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
@ -9,19 +7,20 @@
|
||||
namespace WallpaperEngine::Core::Projects
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
class CPropertyColor : public CProperty
|
||||
{
|
||||
public:
|
||||
static CPropertyColor* fromJSON (json data, const std::string& name);
|
||||
|
||||
const irr::video::SColor& getValue () const;
|
||||
const IntegerColor& getValue () const;
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
CPropertyColor (irr::video::SColor color, const std::string& name, const std::string& text);
|
||||
CPropertyColor (IntegerColor color, const std::string& name, const std::string& text);
|
||||
|
||||
irr::video::SColor m_color;
|
||||
IntegerColor m_color;
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Scenes
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Scenes;
|
||||
|
||||
CProjection::CProjection (irr::u32 width, irr::u32 height) :
|
||||
CProjection::CProjection (uint32_t width, uint32_t height) :
|
||||
m_width (width),
|
||||
m_height (height)
|
||||
{
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Scenes
|
||||
|
28
src/WallpaperEngine/Core/Types/IntegerColor.h
Normal file
28
src/WallpaperEngine/Core/Types/IntegerColor.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
namespace WallpaperEngine::Core::Types
|
||||
{
|
||||
class IntegerColor
|
||||
{
|
||||
public:
|
||||
IntegerColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a) :
|
||||
r(r), g(g), b(b), a(a) { }
|
||||
|
||||
/**
|
||||
* The red color
|
||||
*/
|
||||
uint8_t r;
|
||||
/**
|
||||
* The green color
|
||||
*/
|
||||
uint8_t g;
|
||||
/**
|
||||
* The blue color
|
||||
*/
|
||||
uint8_t b;
|
||||
/**
|
||||
* The alpha
|
||||
*/
|
||||
uint8_t a;
|
||||
};
|
||||
}
|
@ -3,33 +3,8 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// engine includes
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
|
||||
std::string FileSystem::loadFullFile (const irr::io::path& file)
|
||||
{
|
||||
std::cout << file.c_str() << std::endl;
|
||||
irr::io::IReadFile* reader = IrrlichtContext->getDevice ()->getFileSystem ()->createAndOpenFile (file);
|
||||
|
||||
if (reader == nullptr)
|
||||
throw std::runtime_error ("Cannot open file " + std::string (file.c_str ()) + " for reading");
|
||||
|
||||
char* filedata = new char [reader->getSize () + 1];
|
||||
memset (filedata, 0, reader->getSize () + 1);
|
||||
|
||||
reader->read (filedata, reader->getSize ());
|
||||
reader->drop ();
|
||||
|
||||
std::string content = filedata;
|
||||
delete [] filedata;
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string FileSystem::loadFullFile (const std::string& file, WallpaperEngine::Assets::CContainer* containers)
|
||||
{
|
||||
uint32_t length = 0;
|
||||
|
@ -12,14 +12,6 @@
|
||||
|
||||
namespace WallpaperEngine::FileSystem
|
||||
{
|
||||
/**
|
||||
* Loads a full file into an std::string
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
std::string loadFullFile (const irr::io::path& file);
|
||||
|
||||
/**
|
||||
* Loads a full file into an std::string
|
||||
*
|
||||
|
@ -5,9 +5,6 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CImageLoaderTEX.h"
|
||||
#include "WallpaperEngine/Irrlicht/CPkgReader.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloatPointer.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2Pointer.h"
|
||||
|
||||
@ -165,8 +162,8 @@ void CContext::initializeViewports (irr::SIrrlichtCreationParameters &irrlichtCr
|
||||
void CContext::renderFrame (Render::CWallpaper* wallpaper)
|
||||
{
|
||||
this->m_time = this->getDevice ()->getTimer ()->getTime () / 1000.0f;
|
||||
this->m_pointerPosition.X = this->m_eventReceiver->getPosition ().X / (irr::f32) this->getDevice ()->getVideoDriver ()->getScreenSize ().Width;
|
||||
this->m_pointerPosition.Y = this->m_eventReceiver->getPosition ().Y / (irr::f32) this->getDevice ()->getVideoDriver ()->getScreenSize ().Height;
|
||||
this->m_pointerPosition.X = this->m_eventReceiver->getPosition ().X / (float) this->getDevice ()->getVideoDriver ()->getScreenSize ().Width;
|
||||
this->m_pointerPosition.Y = this->m_eventReceiver->getPosition ().Y / (float) this->getDevice ()->getVideoDriver ()->getScreenSize ().Height;
|
||||
|
||||
if (this->m_viewports.empty () == true)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ namespace WallpaperEngine::Irrlicht
|
||||
|
||||
std::vector<Render::Shaders::Variables::CShaderVariable*> m_globalShaderVariables;
|
||||
|
||||
irr::f32 m_time;
|
||||
float m_time;
|
||||
irr::core::vector2df m_pointerPosition;
|
||||
|
||||
std::vector<std::string> m_screens;
|
||||
|
@ -1,20 +0,0 @@
|
||||
#include "CEventReceiver.h"
|
||||
|
||||
using namespace WallpaperEngine::Irrlicht;
|
||||
|
||||
bool CEventReceiver::OnEvent(const irr::SEvent &event)
|
||||
{
|
||||
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == irr::EMIE_MOUSE_MOVED)
|
||||
{
|
||||
this->m_position.X = event.MouseInput.X;
|
||||
this->m_position.Y = event.MouseInput.Y;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const irr::core::position2di& CEventReceiver::getPosition () const
|
||||
{
|
||||
return this->m_position;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Irrlicht
|
||||
{
|
||||
class CEventReceiver : public irr::IEventReceiver
|
||||
{
|
||||
public:
|
||||
// This is the one method that we have to implement
|
||||
bool OnEvent(const irr::SEvent& event) override;
|
||||
|
||||
const irr::core::position2di& getPosition () const;
|
||||
|
||||
private:
|
||||
irr::core::position2di m_position;
|
||||
};
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "CFileList.h"
|
||||
|
||||
using namespace WallpaperEngine::Irrlicht;
|
||||
static const irr::io::path emptyFileListEntry;
|
||||
|
||||
CFileList::CFileList (const irr::io::path& path, bool ignoreCase, bool ignorePaths) :
|
||||
m_ignorePaths (ignorePaths),
|
||||
m_ignoreCase (ignoreCase),
|
||||
m_path(path)
|
||||
{
|
||||
this->m_path.replace ('\\', '/');
|
||||
}
|
||||
|
||||
CFileList::~CFileList ()
|
||||
{
|
||||
this->m_files.clear ();
|
||||
}
|
||||
|
||||
irr::u32 CFileList::getFileCount () const
|
||||
{
|
||||
return this->m_files.size ();
|
||||
}
|
||||
|
||||
void CFileList::sort ()
|
||||
{
|
||||
this->m_files.sort ();
|
||||
}
|
||||
|
||||
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 irr::io::path& CFileList::getFullFileName (irr::u32 index) const
|
||||
{
|
||||
return (index < this->m_files.size ()) ? this->m_files [index].FullName : emptyFileListEntry;
|
||||
}
|
||||
|
||||
//! 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;
|
||||
|
||||
// remove trailing slash
|
||||
if (entry.Name.lastChar () == '/')
|
||||
{
|
||||
entry.IsDirectory = true;
|
||||
entry.Name [entry.Name.size ()-1] = 0;
|
||||
entry.Name.validate ();
|
||||
}
|
||||
|
||||
if (this->m_ignoreCase)
|
||||
entry.Name.make_lower ();
|
||||
|
||||
entry.FullName = entry.Name;
|
||||
|
||||
irr::core::deletePathFromFilename (entry.Name);
|
||||
|
||||
if (this->m_ignorePaths)
|
||||
entry.FullName = entry.Name;
|
||||
|
||||
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.
|
||||
irr::u32 CFileList::getID (irr::u32 index) const
|
||||
{
|
||||
return (index < this->m_files.size ()) ? this->m_files [index].ID : 0;
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
irr::s32 CFileList::findFile (const irr::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 () == '/')
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
//! Returns the base path of the file list
|
||||
const irr::io::path& CFileList::getPath () const
|
||||
{
|
||||
return m_path;
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Irrlicht
|
||||
{
|
||||
//! An entry in a list of files, can be a folder or a file.
|
||||
struct SFileListEntry
|
||||
{
|
||||
//! 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. */
|
||||
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. */
|
||||
irr::io::path FullName;
|
||||
|
||||
//! The size of the file in bytes
|
||||
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. */
|
||||
irr::u32 ID;
|
||||
|
||||
//! FileOffset inside an archive
|
||||
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
|
||||
{
|
||||
if (IsDirectory != other.IsDirectory)
|
||||
return false;
|
||||
|
||||
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
|
||||
{
|
||||
if (IsDirectory != other.IsDirectory)
|
||||
return IsDirectory;
|
||||
|
||||
return FullName.lower_ignore_case (other.FullName);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Implementation of a file list
|
||||
class CFileList : public irr::io::IFileList
|
||||
{
|
||||
public:
|
||||
|
||||
// CFileList methods
|
||||
|
||||
//! Constructor
|
||||
/** \param path The path of this file archive */
|
||||
CFileList (const irr::io::path& path, bool ignoreCase, bool ignorePaths);
|
||||
|
||||
//! Destructor
|
||||
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.
|
||||
\param isDirectory True if this is a directory rather than a file.
|
||||
\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 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 ();
|
||||
|
||||
//! Returns the amount of files in the filelist.
|
||||
virtual irr::u32 getFileCount () const;
|
||||
|
||||
//! Gets the name of a file in the list, based on an index.
|
||||
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 irr::io::path& getFullFileName (irr::u32 index) const;
|
||||
|
||||
//! Returns the ID of a file in the file list, based on an index.
|
||||
virtual irr::u32 getID (irr::u32 index) const;
|
||||
|
||||
//! Returns true if the file is a directory
|
||||
virtual bool isDirectory (irr::u32 index) const;
|
||||
|
||||
//! Returns the size of a file
|
||||
virtual irr::u32 getFileSize (irr::u32 index) const;
|
||||
|
||||
//! Returns the offest of a file
|
||||
virtual irr::u32 getFileOffset (irr::u32 index) const;
|
||||
|
||||
//! Searches for a file or folder within the list, returns the index
|
||||
virtual irr::s32 findFile (const irr::io::path& filename, bool isFolder) const;
|
||||
|
||||
//! Returns the base path of the file list
|
||||
virtual const irr::io::path& getPath () const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Ignore paths when adding or searching for files
|
||||
bool m_ignorePaths;
|
||||
|
||||
//! Ignore case when adding or searching for files
|
||||
bool m_ignoreCase;
|
||||
|
||||
//! Path to the file list
|
||||
irr::io::path m_path;
|
||||
|
||||
//! List of files
|
||||
irr::core::array<SFileListEntry> m_files;
|
||||
};
|
||||
}
|
||||
|
@ -1,780 +0,0 @@
|
||||
#include "CImageLoaderTEX.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <lz4.h>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace WallpaperEngine::Irrlicht;
|
||||
|
||||
namespace WallpaperEngine::Irrlicht
|
||||
{
|
||||
CImageLoaderTex::TextureMipmap::TextureMipmap ()
|
||||
{
|
||||
}
|
||||
|
||||
CImageLoaderTex::TextureMipmap::~TextureMipmap ()
|
||||
{
|
||||
if (this->compression == 1)
|
||||
delete this->compressedData;
|
||||
|
||||
delete this->uncompressedData;
|
||||
}
|
||||
|
||||
void CImageLoaderTex::TextureMipmap::decompressData ()
|
||||
{
|
||||
if (this->compression == 1)
|
||||
{
|
||||
this->uncompressedData = new char [this->uncompressedSize];
|
||||
|
||||
int result = LZ4_decompress_safe (
|
||||
this->compressedData, this->uncompressedData,
|
||||
this->compressedSize, this->uncompressedSize
|
||||
);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
throw std::runtime_error ("Cannot decompress texture data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CImageLoaderTex::TextureContainer::TextureContainer () :
|
||||
freeimageFormat (FREE_IMAGE_FORMAT::FIF_UNKNOWN)
|
||||
{
|
||||
}
|
||||
|
||||
CImageLoaderTex::TextureContainer::~TextureContainer ()
|
||||
{
|
||||
auto cur = this->mipmaps.begin ();
|
||||
auto end = this->mipmaps.end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
delete *cur;
|
||||
}
|
||||
}
|
||||
|
||||
CImageLoaderTex::CImageLoaderTex (CContext* context) :
|
||||
m_context (context)
|
||||
{
|
||||
}
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
//! based on the file extension (e.g. ".tga")
|
||||
bool CImageLoaderTex::isALoadableFileExtension (const irr::io::path &filename) const
|
||||
{
|
||||
return irr::core::hasFileExtension (filename, "tex");
|
||||
}
|
||||
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
bool CImageLoaderTex::isALoadableFileFormat (irr::io::IReadFile *file) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CImageLoaderTex::TextureContainer* CImageLoaderTex::parseHeader (irr::io::IReadFile* input) const
|
||||
{
|
||||
char buffer [1024];
|
||||
|
||||
if (input->read (buffer, 9) != 9 || memcmp (buffer, "TEXV0005", 9) != 0)
|
||||
{
|
||||
throw std::runtime_error ("unexpected container type");
|
||||
}
|
||||
|
||||
if (input->read (buffer, 9) != 9 || memcmp (buffer, "TEXI0001", 9) != 0)
|
||||
{
|
||||
throw std::runtime_error ("unexpected sub-container type");
|
||||
}
|
||||
|
||||
TextureContainer* header = new TextureContainer;
|
||||
|
||||
input->read (&header->format, 4);
|
||||
input->seek (4, true); // ignore bytes
|
||||
input->read (&header->textureWidth, 4);
|
||||
input->read (&header->textureHeight, 4);
|
||||
input->read (&header->width, 4);
|
||||
input->read (&header->height, 4);
|
||||
input->seek (4, true); // ignore bytes
|
||||
input->read (buffer, 9);
|
||||
|
||||
if (memcmp (buffer, "TEXB0003", 9) == 0)
|
||||
{
|
||||
header->containerVersion = ContainerVersion::TEXB0003;
|
||||
|
||||
input->seek (4, true);
|
||||
input->read (&header->freeimageFormat, 4);
|
||||
}
|
||||
else if (memcmp (buffer, "TEXB0002", 9) == 0)
|
||||
{
|
||||
header->containerVersion = ContainerVersion::TEXB0002;
|
||||
|
||||
input->seek (4, true);
|
||||
}
|
||||
else if (memcmp (buffer, "TEXB0001", 9) == 0)
|
||||
{
|
||||
header->containerVersion = ContainerVersion::TEXB0001;
|
||||
|
||||
input->seek (4, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete header;
|
||||
|
||||
throw std::runtime_error ("Unknown container type");
|
||||
}
|
||||
|
||||
if (header->format == TextureFormat::A8)
|
||||
{
|
||||
delete header;
|
||||
|
||||
throw std::runtime_error ("A8 format not supported yet");
|
||||
}
|
||||
|
||||
if (header->format == TextureFormat::RA88)
|
||||
{
|
||||
delete header;
|
||||
|
||||
throw std::runtime_error ("RA88 format not supported yet");
|
||||
}
|
||||
|
||||
input->read (&header->mipmapCount, 4);
|
||||
|
||||
for (irr::u32 i = 0; i < header->mipmapCount; i ++)
|
||||
{
|
||||
header->mipmaps.push_back (
|
||||
this->parseMipmap (header, input)
|
||||
);
|
||||
}
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
CImageLoaderTex::TextureMipmap* CImageLoaderTex::parseMipmap(TextureContainer* header, irr::io::IReadFile* input) const
|
||||
{
|
||||
TextureMipmap* mipmap = new TextureMipmap ();
|
||||
|
||||
input->read (&mipmap->width, 4);
|
||||
input->read (&mipmap->height, 4);
|
||||
|
||||
if (header->containerVersion == ContainerVersion::TEXB0002 ||
|
||||
header->containerVersion == ContainerVersion::TEXB0003)
|
||||
{
|
||||
input->read (&mipmap->compression, 4);
|
||||
input->read (&mipmap->uncompressedSize, 4);
|
||||
}
|
||||
|
||||
input->read (&mipmap->compressedSize, 4);
|
||||
|
||||
// TODO: BETTER POSITION FOR THIS
|
||||
if (mipmap->compression == 0)
|
||||
{
|
||||
// this might be better named as mipmap_bytes_size instead of compressed_size
|
||||
// as in uncompressed files this variable actually holds the file length
|
||||
mipmap->uncompressedSize = mipmap->compressedSize;
|
||||
}
|
||||
|
||||
mipmap->uncompressedData = new char [mipmap->uncompressedSize];
|
||||
|
||||
if (mipmap->compression == 1)
|
||||
{
|
||||
mipmap->compressedData = new char [mipmap->compressedSize];
|
||||
|
||||
input->read (mipmap->compressedData, mipmap->compressedSize);
|
||||
|
||||
mipmap->decompressData ();
|
||||
}
|
||||
else
|
||||
{
|
||||
input->read (mipmap->uncompressedData, mipmap->uncompressedSize);
|
||||
}
|
||||
|
||||
return mipmap;
|
||||
}
|
||||
|
||||
irr::video::IImage* CImageLoaderTex::parseFile (irr::io::IReadFile* input) const
|
||||
{
|
||||
irr::video::IImage *image = nullptr;
|
||||
TextureContainer* header = nullptr;
|
||||
TextureMipmap* mipmap = nullptr;
|
||||
|
||||
if (input == nullptr)
|
||||
return nullptr;
|
||||
|
||||
header = this->parseHeader (input);
|
||||
mipmap = *header->mipmaps.begin ();
|
||||
|
||||
if (header->freeimageFormat == FREE_IMAGE_FORMAT::FIF_UNKNOWN)
|
||||
{
|
||||
image = this->m_context->getDevice ()->getVideoDriver ()->createImage (
|
||||
irr::video::ECF_A8R8G8B8, irr::core::dimension2d<irr::u32> (header->width, header->height)
|
||||
);
|
||||
|
||||
if (image == nullptr)
|
||||
{
|
||||
delete header;
|
||||
|
||||
throw std::runtime_error ("cannot create destination image");
|
||||
}
|
||||
|
||||
switch (header->format)
|
||||
{
|
||||
case TextureFormat::ARGB8888:
|
||||
this->loadImageFromARGB8Data (
|
||||
image, mipmap->uncompressedData, header->width, header->height, mipmap->width
|
||||
);
|
||||
break;
|
||||
case TextureFormat::DXT5:
|
||||
this->loadImageFromDXT5 (
|
||||
image, mipmap->uncompressedData, header->width, header->height, mipmap->width, mipmap->height
|
||||
);
|
||||
break;
|
||||
case TextureFormat::DXT1:
|
||||
this->loadImageFromDXT1 (
|
||||
image, mipmap->uncompressedData, header->width, header->height, mipmap->width, mipmap->height
|
||||
);
|
||||
break;
|
||||
case TextureFormat::DXT3:
|
||||
delete header;
|
||||
|
||||
throw std::runtime_error ("DXT3 textures not supported yet");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// generate a memory file for irrlicht to load the proper one as free image files
|
||||
// that are used by wallpaperengine are usually supported formats in irrlicht
|
||||
// TODO: FIND A WAY TO CALL THE PROPER LOADER DIRECTLY INSTEAD OF GENERATING A FILE?
|
||||
char tmpname [TMP_MAX];
|
||||
|
||||
std::tmpnam (tmpname);
|
||||
std::string filename = tmpname;
|
||||
irr::io::IReadFile* file = nullptr;
|
||||
|
||||
switch (header->freeimageFormat)
|
||||
{
|
||||
case FREE_IMAGE_FORMAT::FIF_BMP:
|
||||
filename += ".bmp";
|
||||
break;
|
||||
case FREE_IMAGE_FORMAT::FIF_PNG:
|
||||
filename += ".png";
|
||||
break;
|
||||
case FREE_IMAGE_FORMAT::FIF_JPEG:
|
||||
filename += ".jpg";
|
||||
break;
|
||||
case FREE_IMAGE_FORMAT::FIF_GIF:
|
||||
filename += ".gif";
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error ("Unsupported free image extension");
|
||||
}
|
||||
|
||||
// create a copy of the file information for the filesystem module of irrlicht
|
||||
// this will be freed automatically by irrlicht so we can freely delete the container
|
||||
// data from memory without leaking memory
|
||||
char* filebuffer = new char [mipmap->uncompressedSize];
|
||||
|
||||
memcpy (filebuffer, mipmap->uncompressedData, mipmap->uncompressedSize);
|
||||
|
||||
file = this->m_context->getDevice ()->getFileSystem ()->createMemoryReadFile (
|
||||
filebuffer, mipmap->uncompressedSize, filename.c_str (), true
|
||||
);
|
||||
|
||||
if (file == nullptr)
|
||||
{
|
||||
delete [] filebuffer;
|
||||
delete header;
|
||||
|
||||
throw std::runtime_error ("cannot create temporal memory file");
|
||||
}
|
||||
|
||||
image = this->m_context->getDevice ()->getVideoDriver ()->createImageFromFile (file);
|
||||
|
||||
if (image == nullptr)
|
||||
{
|
||||
// this takes care of freeing filebuffer
|
||||
file->drop ();
|
||||
|
||||
delete header;
|
||||
|
||||
throw std::runtime_error ("cannot create destination image");
|
||||
}
|
||||
}
|
||||
|
||||
// delete container info as it's not needed anymore
|
||||
delete header;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
// load in the image data
|
||||
irr::video::IImage *CImageLoaderTex::loadImage (irr::io::IReadFile *input) const
|
||||
{
|
||||
try
|
||||
{
|
||||
return this->parseFile (input);
|
||||
}
|
||||
catch (std::runtime_error ex)
|
||||
{
|
||||
this->m_context->getDevice ()->getLogger ()->log (
|
||||
ex.what (), input->getFileName ().c_str (), irr::ELL_ERROR
|
||||
);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CImageLoaderTex::loadImageFromARGB8Data (irr::video::IImage* output, const char* input, irr::u32 width, irr::u32 height, irr::u32 mipmap_width) const
|
||||
{
|
||||
irr::u32 bytesPerPixel = output->getBytesPerPixel ();
|
||||
char *imagedata = (char *) output->lock ();
|
||||
|
||||
for (irr::u32 y = 0; y < height; y ++)
|
||||
{
|
||||
irr::u32 baseDestination = y * output->getPitch ();
|
||||
irr::u32 baseOrigin = y * (mipmap_width * 4);
|
||||
|
||||
for (irr::u32 x = 0; x < width; x ++)
|
||||
{
|
||||
imagedata [baseDestination + (x * bytesPerPixel) + 2] = input [baseOrigin + (x * 4) + 0]; // r
|
||||
imagedata [baseDestination + (x * bytesPerPixel) + 1] = input [baseOrigin + (x * 4) + 1]; // g
|
||||
imagedata [baseDestination + (x * bytesPerPixel) + 0] = input [baseOrigin + (x * 4) + 2]; // b
|
||||
imagedata [baseDestination + (x * bytesPerPixel) + 3] = input [baseOrigin + (x * 4) + 3]; // a
|
||||
}
|
||||
}
|
||||
|
||||
output->unlock ();
|
||||
}
|
||||
|
||||
void CImageLoaderTex::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
|
||||
{
|
||||
char* decompressedBuffer = new char [origin_width * origin_height * 4];
|
||||
|
||||
this->BlockDecompressImageDXT1 (origin_width, origin_height, (const unsigned char*) input, (unsigned long*) decompressedBuffer);
|
||||
this->loadImageFromARGB8Data (output, decompressedBuffer, destination_width, destination_height, origin_width);
|
||||
|
||||
delete [] decompressedBuffer;
|
||||
}
|
||||
|
||||
void CImageLoaderTex::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
|
||||
{
|
||||
char* decompressedBuffer = new char [origin_width * origin_height * 4];
|
||||
|
||||
this->BlockDecompressImageDXT5 (origin_width, origin_height, (const unsigned char*) input, (unsigned long*) decompressedBuffer);
|
||||
this->loadImageFromARGB8Data (output, decompressedBuffer, destination_width, destination_height, origin_width);
|
||||
|
||||
delete [] decompressedBuffer;
|
||||
}
|
||||
|
||||
void CImageLoaderTex::loadImageFromDXT3 (irr::video::IImage* output, const char* input, irr::u32 destination_width, irr::u32 destination_height, irr::u32 origin_width, irr::u32 origin_height) const
|
||||
{
|
||||
char* decompressedBuffer = new char [origin_width * origin_height * 4];
|
||||
|
||||
this->BlockDecompressImageDXT3 (origin_width, origin_height, (const unsigned char*) input, (unsigned long*) decompressedBuffer);
|
||||
this->loadImageFromARGB8Data (output, decompressedBuffer, destination_width, destination_height, origin_width);
|
||||
|
||||
delete [] decompressedBuffer;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// The following code is a slightly modified version of this repository
|
||||
// https://github.com/Benjamin-Dobell/s3tc-dxt-decompression
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Benjamin Dobell, Glass Echidna
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// unsigned long PackRGBA(): Helper method that packs RGBA channels into a single 4 byte pixel.
|
||||
//
|
||||
// unsigned char r: red channel.
|
||||
// unsigned char g: green channel.
|
||||
// unsigned char b: blue channel.
|
||||
// unsigned char a: alpha channel.
|
||||
|
||||
unsigned long CImageLoaderTex::PackRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a) const
|
||||
{
|
||||
return r | (g << 8) | (b << 16) | (a << 24);
|
||||
}
|
||||
|
||||
// void DecompressBlockDXT1(): Decompresses one block of a DXT1 texture and stores the resulting pixels at the appropriate offset in 'image'.
|
||||
//
|
||||
// unsigned long x: x-coordinate of the first pixel in the block.
|
||||
// unsigned long y: y-coordinate of the first pixel in the block.
|
||||
// unsigned long width: width of the texture being decompressed.
|
||||
// unsigned long height: height of the texture being decompressed.
|
||||
// const unsigned char *blockStorage: pointer to the block to decompress.
|
||||
// unsigned long *image: pointer to image where the decompressed pixel data should be stored.
|
||||
|
||||
void CImageLoaderTex::DecompressBlockDXT1 (unsigned long x, unsigned long y, unsigned long width, const unsigned char *blockStorage, unsigned long *image) const
|
||||
{
|
||||
unsigned short color0 = *reinterpret_cast<const unsigned short *>(blockStorage);
|
||||
unsigned short color1 = *reinterpret_cast<const unsigned short *>(blockStorage + 2);
|
||||
|
||||
unsigned long temp;
|
||||
|
||||
temp = (color0 >> 11) * 255 + 16;
|
||||
unsigned char r0 = (unsigned char)((temp/32 + temp)/32);
|
||||
temp = ((color0 & 0x07E0) >> 5) * 255 + 32;
|
||||
unsigned char g0 = (unsigned char)((temp/64 + temp)/64);
|
||||
temp = (color0 & 0x001F) * 255 + 16;
|
||||
unsigned char b0 = (unsigned char)((temp/32 + temp)/32);
|
||||
|
||||
temp = (color1 >> 11) * 255 + 16;
|
||||
unsigned char r1 = (unsigned char)((temp/32 + temp)/32);
|
||||
temp = ((color1 & 0x07E0) >> 5) * 255 + 32;
|
||||
unsigned char g1 = (unsigned char)((temp/64 + temp)/64);
|
||||
temp = (color1 & 0x001F) * 255 + 16;
|
||||
unsigned char b1 = (unsigned char)((temp/32 + temp)/32);
|
||||
|
||||
unsigned long code = *reinterpret_cast<const unsigned long *>(blockStorage + 4);
|
||||
|
||||
for (int j=0; j < 4; j++)
|
||||
{
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
unsigned long finalColor = 0;
|
||||
unsigned char positionCode = (code >> 2*(4*j+i)) & 0x03;
|
||||
|
||||
if (color0 > color1)
|
||||
{
|
||||
switch (positionCode)
|
||||
{
|
||||
case 0:
|
||||
finalColor = PackRGBA (r0, g0, b0, 255);
|
||||
break;
|
||||
case 1:
|
||||
finalColor = PackRGBA (r1, g1, b1, 255);
|
||||
break;
|
||||
case 2:
|
||||
finalColor = PackRGBA ((2*r0+r1)/3, (2*g0+g1)/3, (2*b0+b1)/3, 255);
|
||||
break;
|
||||
case 3:
|
||||
finalColor = PackRGBA ((r0+2*r1)/3, (g0+2*g1)/3, (b0+2*b1)/3, 255);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (positionCode)
|
||||
{
|
||||
case 0:
|
||||
finalColor = PackRGBA (r0, g0, b0, 255);
|
||||
break;
|
||||
case 1:
|
||||
finalColor = PackRGBA (r1, g1, b1, 255);
|
||||
break;
|
||||
case 2:
|
||||
finalColor = PackRGBA ((r0+r1)/2, (g0+g1)/2, (b0+b1)/2, 255);
|
||||
break;
|
||||
case 3:
|
||||
finalColor = PackRGBA (0, 0, 0, 255);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reinterpret_cast <irr::u32*> (image) [(y + j) * width + x + i] = finalColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void BlockDecompressImageDXT1(): Decompresses all the blocks of a DXT1 compressed texture and stores the resulting pixels in 'image'.
|
||||
//
|
||||
// unsigned long width: Texture width.
|
||||
// unsigned long height: Texture height.
|
||||
// const unsigned char *blockStorage: pointer to compressed DXT1 blocks.
|
||||
// unsigned long *image: pointer to the image where the decompressed pixels will be stored.
|
||||
|
||||
void CImageLoaderTex::BlockDecompressImageDXT1(unsigned long width, unsigned long height, const unsigned char *blockStorage, unsigned long *image) const
|
||||
{
|
||||
unsigned long blockCountX = (width + 3) / 4;
|
||||
unsigned long blockCountY = (height + 3) / 4;
|
||||
unsigned long blockWidth = (width < 4) ? width : 4;
|
||||
unsigned long blockHeight = (height < 4) ? height : 4;
|
||||
|
||||
for (unsigned long j = 0; j < blockCountY; j++)
|
||||
{
|
||||
for (unsigned long i = 0; i < blockCountX; i++)
|
||||
DecompressBlockDXT1(i*4, j*4, width, blockStorage + i * 8, image);
|
||||
|
||||
blockStorage += blockCountX * 8;
|
||||
}
|
||||
}
|
||||
|
||||
// void DecompressBlockDXT3(): Decompresses one block of a DXT3 texture and stores the resulting pixels at the appropriate offset in 'image'.
|
||||
//
|
||||
// unsigned long x: x-coordinate of the first pixel in the block.
|
||||
// unsigned long y: y-coordinate of the first pixel in the block.
|
||||
// unsigned long width: width of the texture being decompressed.
|
||||
// unsigned long height: height of the texture being decompressed.
|
||||
// const unsigned char *blockStorage: pointer to the block to decompress.
|
||||
// unsigned long *image: pointer to image where the decompressed pixel data should be stored.
|
||||
|
||||
void CImageLoaderTex::DecompressBlockDXT3(unsigned long x, unsigned long y, unsigned long width, const unsigned char *blockStorage, unsigned long *image) const
|
||||
{
|
||||
unsigned short color0 = *reinterpret_cast <const unsigned short *>(blockStorage + 8);
|
||||
unsigned short color1 = *reinterpret_cast <const unsigned short *>(blockStorage + 10);
|
||||
|
||||
unsigned long temp;
|
||||
|
||||
temp = (color0 >> 11) * 255 + 16;
|
||||
unsigned char r0 = (unsigned char)((temp/32 + temp)/32);
|
||||
temp = ((color0 & 0x07E0) >> 5) * 255 + 32;
|
||||
unsigned char g0 = (unsigned char)((temp/64 + temp)/64);
|
||||
temp = (color0 & 0x001F) * 255 + 16;
|
||||
unsigned char b0 = (unsigned char)((temp/32 + temp)/32);
|
||||
|
||||
temp = (color1 >> 11) * 255 + 16;
|
||||
unsigned char r1 = (unsigned char)((temp/32 + temp)/32);
|
||||
temp = ((color1 & 0x07E0) >> 5) * 255 + 32;
|
||||
unsigned char g1 = (unsigned char)((temp/64 + temp)/64);
|
||||
temp = (color1 & 0x001F) * 255 + 16;
|
||||
unsigned char b1 = (unsigned char)((temp/32 + temp)/32);
|
||||
|
||||
unsigned long code = *reinterpret_cast <const unsigned long *>(blockStorage + 12);
|
||||
unsigned long long alphaCode = *reinterpret_cast <const unsigned long long *>(blockStorage);
|
||||
|
||||
for (int j=0; j < 4; j++)
|
||||
{
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
unsigned long finalColor = 0;
|
||||
unsigned char positionCode = (code >> 2*(4*j+i)) & 0x03;
|
||||
// per StackOverflow this creates an even distribution of alphas between 0 and 255
|
||||
unsigned char finalAlpha = 17 * (alphaCode >> 4*(4*j+i) & 0x0F);
|
||||
|
||||
if (color0 > color1)
|
||||
{
|
||||
switch (positionCode)
|
||||
{
|
||||
case 0:
|
||||
finalColor = PackRGBA (r0, g0, b0, finalAlpha);
|
||||
break;
|
||||
case 1:
|
||||
finalColor = PackRGBA (r1, g1, b1, finalAlpha);
|
||||
break;
|
||||
case 2:
|
||||
finalColor = PackRGBA ((2*r0+r1)/3, (2*g0+g1)/3, (2*b0+b1)/3, finalAlpha);
|
||||
break;
|
||||
case 3:
|
||||
finalColor = PackRGBA ((r0+2*r1)/3, (g0+2*g1)/3, (b0+2*b1)/3, finalAlpha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (positionCode)
|
||||
{
|
||||
case 0:
|
||||
finalColor = PackRGBA (r0, g0, b0, finalAlpha);
|
||||
break;
|
||||
case 1:
|
||||
finalColor = PackRGBA (r1, g1, b1, finalAlpha);
|
||||
break;
|
||||
case 2:
|
||||
finalColor = PackRGBA ((r0+r1)/2, (g0+g1)/2, (b0+b1)/2, finalAlpha);
|
||||
break;
|
||||
case 3:
|
||||
finalColor = PackRGBA (0, 0, 0, finalAlpha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reinterpret_cast <irr::u32*>(image)[(y + j)*width + x + i] = finalColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void BlockDecompressImageDXT3(): Decompresses all the blocks of a DXT3 compressed texture and stores the resulting pixels in 'image'.
|
||||
//
|
||||
// unsigned long width: Texture width.
|
||||
// unsigned long height: Texture height.
|
||||
// const unsigned char *blockStorage: pointer to compressed DXT3 blocks.
|
||||
// unsigned long *image: pointer to the image where the decompressed pixels will be stored.
|
||||
|
||||
void CImageLoaderTex::BlockDecompressImageDXT3(unsigned long width, unsigned long height, const unsigned char *blockStorage, unsigned long *image) const
|
||||
{
|
||||
unsigned long blockCountX = (width + 3) / 4;
|
||||
unsigned long blockCountY = (height + 3) / 4;
|
||||
unsigned long blockWidth = (width < 4) ? width : 4;
|
||||
unsigned long blockHeight = (height < 4) ? height : 4;
|
||||
for (unsigned long j = 0; j < blockCountY; j++)
|
||||
{
|
||||
for (unsigned long i = 0; i < blockCountX; i++)
|
||||
DecompressBlockDXT3 (i*4, j*4, width, blockStorage + i * 16, image);
|
||||
blockStorage += blockCountX * 16;
|
||||
}
|
||||
}
|
||||
|
||||
// void DecompressBlockDXT5(): Decompresses one block of a DXT5 texture and stores the resulting pixels at the appropriate offset in 'image'.
|
||||
//
|
||||
// unsigned long x: x-coordinate of the first pixel in the block.
|
||||
// unsigned long y: y-coordinate of the first pixel in the block.
|
||||
// unsigned long width: width of the texture being decompressed.
|
||||
// unsigned long height: height of the texture being decompressed.
|
||||
// const unsigned char *blockStorage: pointer to the block to decompress.
|
||||
// unsigned long *image: pointer to image where the decompressed pixel data should be stored.
|
||||
|
||||
void CImageLoaderTex::DecompressBlockDXT5(unsigned long x, unsigned long y, unsigned long width, const unsigned char *blockStorage, unsigned long *image) const
|
||||
{
|
||||
unsigned char alpha0 = *reinterpret_cast<const unsigned char *>(blockStorage);
|
||||
unsigned char alpha1 = *reinterpret_cast<const unsigned char *>(blockStorage + 1);
|
||||
|
||||
const unsigned char *bits = blockStorage + 2;
|
||||
unsigned long alphaCode1 = bits[2] | (bits[3] << 8) | (bits[4] << 16) | (bits[5] << 24);
|
||||
unsigned short alphaCode2 = bits[0] | (bits[1] << 8);
|
||||
|
||||
unsigned short color0 = *reinterpret_cast<const unsigned short *>(blockStorage + 8);
|
||||
unsigned short color1 = *reinterpret_cast<const unsigned short *>(blockStorage + 10);
|
||||
|
||||
unsigned long temp;
|
||||
|
||||
temp = (color0 >> 11) * 255 + 16;
|
||||
unsigned char r0 = (unsigned char)((temp/32 + temp)/32);
|
||||
temp = ((color0 & 0x07E0) >> 5) * 255 + 32;
|
||||
unsigned char g0 = (unsigned char)((temp/64 + temp)/64);
|
||||
temp = (color0 & 0x001F) * 255 + 16;
|
||||
unsigned char b0 = (unsigned char)((temp/32 + temp)/32);
|
||||
|
||||
temp = (color1 >> 11) * 255 + 16;
|
||||
unsigned char r1 = (unsigned char)((temp/32 + temp)/32);
|
||||
temp = ((color1 & 0x07E0) >> 5) * 255 + 32;
|
||||
unsigned char g1 = (unsigned char)((temp/64 + temp)/64);
|
||||
temp = (color1 & 0x001F) * 255 + 16;
|
||||
unsigned char b1 = (unsigned char)((temp/32 + temp)/32);
|
||||
|
||||
unsigned long code = *reinterpret_cast<const unsigned long *>(blockStorage + 12);
|
||||
|
||||
for (int j=0; j < 4; j++)
|
||||
{
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
int alphaCodeIndex = 3*(4*j+i);
|
||||
int alphaCode;
|
||||
|
||||
if (alphaCodeIndex <= 12)
|
||||
{
|
||||
alphaCode = (alphaCode2 >> alphaCodeIndex) & 0x07;
|
||||
}
|
||||
else if (alphaCodeIndex == 15)
|
||||
{
|
||||
alphaCode = (alphaCode2 >> 15) | ((alphaCode1 << 1) & 0x06);
|
||||
}
|
||||
else // alphaCodeIndex >= 18 && alphaCodeIndex <= 45
|
||||
{
|
||||
alphaCode = (alphaCode1 >> (alphaCodeIndex - 16)) & 0x07;
|
||||
}
|
||||
|
||||
unsigned char finalAlpha;
|
||||
if (alphaCode == 0)
|
||||
{
|
||||
finalAlpha = alpha0;
|
||||
}
|
||||
else if (alphaCode == 1)
|
||||
{
|
||||
finalAlpha = alpha1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alpha0 > alpha1)
|
||||
{
|
||||
finalAlpha = ((8-alphaCode)*alpha0 + (alphaCode-1)*alpha1)/7;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alphaCode == 6)
|
||||
finalAlpha = 0;
|
||||
else if (alphaCode == 7)
|
||||
finalAlpha = 255;
|
||||
else
|
||||
finalAlpha = ((6-alphaCode)*alpha0 + (alphaCode-1)*alpha1)/5;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long finalColor = 0;
|
||||
unsigned char positionCode = (code >> 2 * (4 * j + i)) & 0x03;
|
||||
|
||||
if (color0 > color1)
|
||||
{
|
||||
switch (positionCode)
|
||||
{
|
||||
case 0:
|
||||
finalColor = PackRGBA (r0, g0, b0, finalAlpha);
|
||||
break;
|
||||
case 1:
|
||||
finalColor = PackRGBA (r1, g1, b1, finalAlpha);
|
||||
break;
|
||||
case 2:
|
||||
finalColor = PackRGBA ((2*r0+r1)/3, (2*g0+g1)/3, (2*b0+b1)/3, finalAlpha);
|
||||
break;
|
||||
case 3:
|
||||
finalColor = PackRGBA ((r0+2*r1)/3, (g0+2*g1)/3, (b0+2*b1)/3, finalAlpha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (positionCode)
|
||||
{
|
||||
case 0:
|
||||
finalColor = PackRGBA (r0, g0, b0, finalAlpha);
|
||||
break;
|
||||
case 1:
|
||||
finalColor = PackRGBA (r1, g1, b1, finalAlpha);
|
||||
break;
|
||||
case 2:
|
||||
finalColor = PackRGBA ((r0 + r1) / 2, (g0 + g1) / 2, (b0 + b1) / 2, finalAlpha);
|
||||
break;
|
||||
case 3:
|
||||
finalColor = PackRGBA (0, 0, 0, finalAlpha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reinterpret_cast <irr::u32*> (image) [(y + j) * width + x + i] = finalColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void BlockDecompressImageDXT5(): Decompresses all the blocks of a DXT5 compressed texture and stores the resulting pixels in 'image'.
|
||||
//
|
||||
// unsigned long width: Texture width.
|
||||
// unsigned long height: Texture height.
|
||||
// const unsigned char *blockStorage: pointer to compressed DXT5 blocks.
|
||||
// unsigned long *image: pointer to the image where the decompressed pixels will be stored.
|
||||
|
||||
void CImageLoaderTex::BlockDecompressImageDXT5(unsigned long width, unsigned long height, const unsigned char *blockStorage, unsigned long *image) const
|
||||
{
|
||||
unsigned long blockCountX = (width + 3) / 4;
|
||||
unsigned long blockCountY = (height + 3) / 4;
|
||||
unsigned long blockWidth = (width < 4) ? width : 4;
|
||||
unsigned long blockHeight = (height < 4) ? height : 4;
|
||||
|
||||
for (unsigned long j = 0; j < blockCountY; j++)
|
||||
{
|
||||
for (unsigned long i = 0; i < blockCountX; i++)
|
||||
DecompressBlockDXT5(i*4, j*4, width, blockStorage + i * 16, image);
|
||||
|
||||
blockStorage += blockCountX * 16;
|
||||
}
|
||||
}
|
||||
};
|
@ -1,183 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include "CContext.h"
|
||||
|
||||
namespace WallpaperEngine::Irrlicht
|
||||
{
|
||||
//! Surface Loader for PNG files
|
||||
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 irr::io::path& filename) const;
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
||||
|
||||
//! creates a surface from the file
|
||||
virtual irr::video::IImage* loadImage(irr::io::IReadFile* input) 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 (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;
|
||||
virtual void loadImageFromDXT3 (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 : int
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
TEXB0003 = 3,
|
||||
TEXB0002 = 2,
|
||||
TEXB0001 = 1
|
||||
};
|
||||
|
||||
enum TextureFormat : int
|
||||
{
|
||||
ARGB8888,
|
||||
RA88,
|
||||
A8,
|
||||
DXT5,
|
||||
DXT1,
|
||||
DXT3 = -1
|
||||
};
|
||||
|
||||
// extracted from the free image library
|
||||
enum FREE_IMAGE_FORMAT : int
|
||||
{
|
||||
FIF_UNKNOWN = -1,
|
||||
FIF_BMP = 0,
|
||||
FIF_ICO = 1,
|
||||
FIF_JPEG = 2,
|
||||
FIF_JNG = 3,
|
||||
FIF_KOALA = 4,
|
||||
FIF_LBM = 5,
|
||||
FIF_IFF = FIF_LBM,
|
||||
FIF_MNG = 6,
|
||||
FIF_PBM = 7,
|
||||
FIF_PBMRAW = 8,
|
||||
FIF_PCD = 9,
|
||||
FIF_PCX = 10,
|
||||
FIF_PGM = 11,
|
||||
FIF_PGMRAW = 12,
|
||||
FIF_PNG = 13,
|
||||
FIF_PPM = 14,
|
||||
FIF_PPMRAW = 15,
|
||||
FIF_RAS = 16,
|
||||
FIF_TARGA = 17,
|
||||
FIF_TIFF = 18,
|
||||
FIF_WBMP = 19,
|
||||
FIF_PSD = 20,
|
||||
FIF_CUT = 21,
|
||||
FIF_XBM = 22,
|
||||
FIF_XPM = 23,
|
||||
FIF_DDS = 24,
|
||||
FIF_GIF = 25,
|
||||
FIF_HDR = 26,
|
||||
FIF_FAXG3 = 27,
|
||||
FIF_SGI = 28,
|
||||
FIF_EXR = 29,
|
||||
FIF_J2K = 30,
|
||||
FIF_JP2 = 31,
|
||||
FIF_PFM = 32,
|
||||
FIF_PICT = 33,
|
||||
FIF_RAW = 34,
|
||||
FIF_WEBP = 35,
|
||||
FIF_JXR = 36
|
||||
};
|
||||
|
||||
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 */
|
||||
TextureFormat format;
|
||||
/** Free Image format */
|
||||
FREE_IMAGE_FORMAT 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;
|
||||
void BlockDecompressImageDXT3(unsigned long width, unsigned long height, const unsigned char *blockStorage, unsigned long *image) const;
|
||||
void DecompressBlockDXT3(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;
|
||||
void BlockDecompressImageDXT5(unsigned long width, unsigned long height, const unsigned char *blockStorage, unsigned long *image) const;
|
||||
void DecompressBlockDXT5(unsigned long x, unsigned long y, unsigned long width, const unsigned char *blockStorage, unsigned long *image) const;
|
||||
};
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
#include "CPkgReader.h"
|
||||
|
||||
namespace WallpaperEngine::Irrlicht
|
||||
{
|
||||
bool isPkgHeaderVersionValid(char* version)
|
||||
{
|
||||
return strcmp ("PKGV0007", version) == 0 ||
|
||||
strcmp ("PKGV0002", version) == 0 ||
|
||||
strcmp ("PKGV0001", version) == 0 ||
|
||||
strcmp ("PKGV0008", version) == 0 ||
|
||||
strcmp ("PKGV0009", version) == 0 ||
|
||||
strcmp ("PKGV0004", version) == 0 ||
|
||||
strcmp ("PKGV0005", version) == 0 ||
|
||||
strcmp ("PKGV0006", version) == 0;
|
||||
}
|
||||
|
||||
CArchiveLoaderPkg::CArchiveLoaderPkg (CContext* context) :
|
||||
m_context (context)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CArchiveLoaderPKG");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CArchiveLoaderPkg::isALoadableFileFormat(const irr::io::path& filename) const
|
||||
{
|
||||
return irr::core::hasFileExtension (filename, "pkg");
|
||||
}
|
||||
|
||||
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 (this->m_context, 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 (isPkgHeaderVersionValid (pointer) == false)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
CPkgReader::CPkgReader (CContext* context, irr::io::IReadFile* file, bool ignoreCase, bool ignorePaths)
|
||||
: CFileList((file ? file->getFileName() : irr::io::path("")), ignoreCase, ignorePaths),
|
||||
m_file(file),
|
||||
m_context (context)
|
||||
{
|
||||
if (this->m_file)
|
||||
{
|
||||
this->m_file->grab ();
|
||||
this->scanPkgHeader ();
|
||||
}
|
||||
}
|
||||
|
||||
CPkgReader::~CPkgReader()
|
||||
{
|
||||
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 (isPkgHeaderVersionValid (headerVersion) == false)
|
||||
{
|
||||
delete [] headerVersion;
|
||||
|
||||
this->m_context->getDevice ()->getLogger ()->log (
|
||||
"unexpected package header", this->m_file->getFileName ().c_str (), irr::ELL_ERROR
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
delete [] headerVersion;
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
|
||||
char* CPkgReader::readSizedString ()
|
||||
{
|
||||
unsigned int size;
|
||||
char* pointer;
|
||||
|
||||
this->m_file->read (&size, 4);
|
||||
|
||||
// the string doesnt include the null terminator
|
||||
size ++;
|
||||
|
||||
pointer = new char [size];
|
||||
memset (pointer, 0, size);
|
||||
|
||||
this->m_file->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->m_files.size ())
|
||||
return nullptr;
|
||||
|
||||
const SFileListEntry entry = m_files [index];
|
||||
return irr::io::createLimitReadFile (entry.FullName, m_file, entry.Offset, entry.Size);
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
#pragma once
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <string>
|
||||
|
||||
#include "CContext.h"
|
||||
#include "CFileList.h"
|
||||
|
||||
namespace WallpaperEngine::Irrlicht
|
||||
{
|
||||
//! Archiveloader capable of loading WAD Archives
|
||||
class CArchiveLoaderPkg : public irr::io::IArchiveLoader
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
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;
|
||||
|
||||
//! 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;
|
||||
|
||||
//! 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;
|
||||
|
||||
//! 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;
|
||||
|
||||
//! 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;
|
||||
|
||||
private:
|
||||
CContext* m_context;
|
||||
};
|
||||
|
||||
class CPkgReader : public virtual irr::io::IFileArchive, virtual CFileList
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CPkgReader (CContext* context, irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths);
|
||||
|
||||
//! destructor
|
||||
virtual ~CPkgReader ();
|
||||
|
||||
//! opens a file by file name
|
||||
virtual irr::io::IReadFile *createAndOpenFile (const irr::io::path &filename);
|
||||
|
||||
//! opens a file by index
|
||||
virtual irr::io::IReadFile *createAndOpenFile (unsigned int index);
|
||||
|
||||
//! returns the list of files
|
||||
virtual const IFileList *getFileList () const;
|
||||
|
||||
//! get the archive type
|
||||
virtual irr::io::E_FILE_ARCHIVE_TYPE getType () const;
|
||||
|
||||
protected:
|
||||
void scanPkgHeader ();
|
||||
|
||||
char *readSizedString ();
|
||||
|
||||
CContext* m_context;
|
||||
irr::io::IReadFile *m_file;
|
||||
};
|
||||
}
|
@ -19,7 +19,7 @@ CCamera::CCamera (CScene* scene, const Core::Scenes::CCamera* camera) :
|
||||
|
||||
CCamera::~CCamera ()
|
||||
{
|
||||
this->m_sceneCamera->remove ();
|
||||
|
||||
}
|
||||
|
||||
const glm::vec3& CCamera::getCenter () const
|
||||
|
@ -33,7 +33,6 @@ namespace WallpaperEngine::Render
|
||||
glm::mat4 m_projection;
|
||||
glm::mat4 m_lookat;
|
||||
const Core::Scenes::CCamera* m_camera;
|
||||
irr::scene::ICameraSceneNode* m_sceneCamera;
|
||||
CScene* m_scene;
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/CObject.h"
|
||||
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include "WallpaperEngine/Render/CWallpaper.h"
|
||||
#include "WallpaperEngine/Render/CObject.h"
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
namespace WallpaperEngine::Render
|
||||
{
|
||||
class CCamera;
|
||||
@ -33,7 +31,7 @@ namespace WallpaperEngine::Render
|
||||
|
||||
private:
|
||||
CCamera* m_camera;
|
||||
irr::u32 m_nextId;
|
||||
uint32_t m_nextId;
|
||||
std::vector<CObject*> m_objects;
|
||||
};
|
||||
}
|
||||
|
@ -141,16 +141,19 @@ void CVideo::getNextFrame ()
|
||||
|
||||
void CVideo::writeFrameToImage ()
|
||||
{
|
||||
/*
|
||||
* TODO: REWRITE THIS
|
||||
uint8_t* frameData = m_videoFrameRGB->data[0];
|
||||
if (frameData == nullptr)
|
||||
return;
|
||||
|
||||
irr::u32 imgWidth = m_frameImage->getDimension().Width;
|
||||
irr::u32 imgHeight = m_frameImage->getDimension().Height;
|
||||
uint32_t imgWidth = m_frameImage->getDimension().Width;
|
||||
uint32_t imgHeight = m_frameImage->getDimension().Height;
|
||||
|
||||
unsigned char* data = (unsigned char*)m_frameImage->lock ();
|
||||
memcpy (data, frameData, imgWidth * imgHeight * 3);
|
||||
m_frameImage->unlock ();
|
||||
*/
|
||||
}
|
||||
|
||||
void CVideo::restartStream ()
|
||||
|
@ -1,13 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/CVideo.h"
|
||||
|
||||
#include "WallpaperEngine/Render/CWallpaper.h"
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <libavcodec/avcodec.h>
|
||||
@ -45,8 +41,5 @@ namespace WallpaperEngine::Render
|
||||
SwsContext* m_swsCtx = nullptr;
|
||||
uint8_t* m_buffer = nullptr;
|
||||
int m_videoStream = -1, m_audioStream = -1;
|
||||
|
||||
irr::video::IImage* m_frameImage;
|
||||
irr::video::ITexture* m_frameTexture;
|
||||
};
|
||||
};
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
@ -8,7 +7,6 @@
|
||||
#include "WallpaperEngine/Core/CScene.h"
|
||||
#include "WallpaperEngine/Core/CVideo.h"
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
#include "WallpaperEngine/Assets/CContainer.h"
|
||||
|
||||
using namespace WallpaperEngine::Assets;
|
||||
|
@ -1,9 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Objects/CImage.h"
|
||||
#include "WallpaperEngine/Render/Objects/Effects/CFBO.h"
|
||||
#include "WallpaperEngine/Render/Objects/Effects/CPass.h"
|
||||
|
@ -33,6 +33,16 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
throw std::runtime_error ("Only centered images are supported for now!");
|
||||
}
|
||||
|
||||
// load image from the .tex file
|
||||
uint32_t textureSize = 0;
|
||||
|
||||
// get the first texture on the first pass (this one represents the image assigned to this object)
|
||||
void* textureData = this->getScene ()->getContainer ()->readTexture (
|
||||
(*(*this->m_image->getMaterial ()->getPasses ().begin ())->getTextures ().begin ()), &textureSize
|
||||
);
|
||||
// now generate our opengl texture
|
||||
this->m_texture = new CTexture (textureData);
|
||||
|
||||
// build a list of vertices, these might need some change later (or maybe invert the camera)
|
||||
GLfloat data [] = {
|
||||
xleft, ytop, 0.0f,
|
||||
@ -56,14 +66,30 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
|
||||
memcpy (this->m_passesVertexList, data1, sizeof (data1));
|
||||
|
||||
// generate correct width and height for the texCoord data
|
||||
float width = 1.0f;
|
||||
float height = 1.0f;
|
||||
|
||||
// calculate the correct texCoord limits for the texture based on the texture screen size and real size
|
||||
if (this->getTexture ()->getHeader ()->textureWidth != this->getTexture ()->getHeader ()->width ||
|
||||
this->getTexture ()->getHeader ()->textureHeight != this->getTexture ()->getHeader ()->height)
|
||||
{
|
||||
uint32_t x = 1;
|
||||
uint32_t y = 1;
|
||||
|
||||
while (x < this->getImage ()->getSize ().x) x <<= 1;
|
||||
while (y < this->getImage ()->getSize ().y) y <<= 1;
|
||||
|
||||
width = this->getImage ()->getSize ().x / x;
|
||||
height = this->getImage ()->getSize ().y / y;
|
||||
}
|
||||
|
||||
GLfloat data2 [] = {
|
||||
0.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f
|
||||
width, 0.0f,
|
||||
0.0f, height,
|
||||
0.0f, height,
|
||||
width, 0.0f,
|
||||
width, height
|
||||
};
|
||||
|
||||
memcpy (this->m_texCoordList, data2, sizeof (data2));
|
||||
@ -82,15 +108,6 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
glBindBuffer (GL_ARRAY_BUFFER, this->m_texCoordBuffer);
|
||||
glBufferData (GL_ARRAY_BUFFER, sizeof (this->m_texCoordList), this->m_texCoordList, GL_STATIC_DRAW);
|
||||
|
||||
uint32_t textureSize = 0;
|
||||
|
||||
// get the first texture on the first pass (this one represents the image assigned to this object)
|
||||
void* textureData = this->getScene ()->getContainer ()->readTexture (
|
||||
(*(*this->m_image->getMaterial ()->getPasses ().begin ())->getTextures ().begin ()), &textureSize
|
||||
);
|
||||
// now generate our opengl texture
|
||||
this->m_texture = new CTexture (textureData);
|
||||
|
||||
// generate the main material used to render the image
|
||||
this->m_material = new Effects::CMaterial (this, this->m_image->getMaterial ());
|
||||
|
||||
@ -148,10 +165,9 @@ void CImage::render ()
|
||||
std::cout << std::flush;
|
||||
}
|
||||
|
||||
/*
|
||||
void CImage::generateMaterial (irr::video::ITexture* resultTexture)
|
||||
{
|
||||
// TODO: REWRITE THIS
|
||||
/*
|
||||
this->m_irrlichtMaterial.setTexture (0, resultTexture);
|
||||
this->m_irrlichtMaterial.MaterialType = irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
this->m_irrlichtMaterial.setFlag (irr::video::EMF_LIGHTING, false);
|
||||
@ -210,9 +226,9 @@ void CImage::generateMaterial (irr::video::ITexture* resultTexture)
|
||||
vertex.c_str (), "main", irr::video::EVST_VS_2_0,
|
||||
fragment.c_str (), "main", irr::video::EPST_PS_2_0,
|
||||
this, irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL, 0, irr::video::EGSL_DEFAULT
|
||||
);*/
|
||||
);
|
||||
}
|
||||
/*
|
||||
|
||||
void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, int32_t userData)
|
||||
{
|
||||
irr::s32 g_Texture0 = 0;
|
||||
@ -229,6 +245,12 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
|
||||
services->setVertexShaderConstant ("g_ModelViewProjectionMatrix", worldViewProj.pointer(), 16);
|
||||
}
|
||||
*/
|
||||
|
||||
const CTexture* CImage::getTexture () const
|
||||
{
|
||||
return this->m_texture;
|
||||
}
|
||||
|
||||
const Core::Objects::CImage* CImage::getImage () const
|
||||
{
|
||||
return this->m_image;
|
||||
|
@ -39,13 +39,12 @@ namespace WallpaperEngine::Render::Objects
|
||||
const GLuint* getVertexBuffer () const;
|
||||
const GLuint* getPassVertexBuffer () const;
|
||||
const GLuint* getTexCoordBuffer () const;
|
||||
const CTexture* getTexture () const;
|
||||
|
||||
protected:
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
void generateMaterial (irr::video::ITexture* resultTexture);
|
||||
|
||||
CTexture* m_texture;
|
||||
GLfloat m_vertexList [6 * 3];
|
||||
GLfloat m_passesVertexList [6 * 3];
|
||||
@ -60,7 +59,5 @@ namespace WallpaperEngine::Render::Objects
|
||||
|
||||
std::vector<CEffect*> m_effects;
|
||||
Effects::CMaterial* m_material;
|
||||
irr::video::SMaterial m_irrlichtMaterial;
|
||||
irr::video::SMaterial m_irrlichtMaterialInvert;
|
||||
};
|
||||
}
|
||||
|
@ -14,17 +14,12 @@ CFBO::CFBO (Core::Objects::Effects::CFBO* fbo, const Core::Objects::CImage* imag
|
||||
context->getDevice ()->getVideoDriver ()->addRenderTargetTexture (size, this->getName ().c_str ());*/
|
||||
}
|
||||
|
||||
const irr::video::ITexture* CFBO::getTexture () const
|
||||
{
|
||||
return this->m_texture;
|
||||
}
|
||||
|
||||
const std::string& CFBO::getName () const
|
||||
{
|
||||
return this->m_fbo->getName ();
|
||||
}
|
||||
|
||||
const irr::f32& CFBO::getScale () const
|
||||
const float& CFBO::getScale () const
|
||||
{
|
||||
return this->m_fbo->getScale ();
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CFBO.h"
|
||||
#include "WallpaperEngine/Core/Objects/CImage.h"
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Objects::Effects
|
||||
{
|
||||
class CFBO
|
||||
@ -14,12 +10,11 @@ namespace WallpaperEngine::Render::Objects::Effects
|
||||
public:
|
||||
CFBO (Core::Objects::Effects::CFBO* fbo, const Core::Objects::CImage* image);
|
||||
|
||||
const irr::video::ITexture* getTexture () const;
|
||||
const std::string& getName () const;
|
||||
const irr::f32& getScale () const;
|
||||
const float& getScale () const;
|
||||
const std::string& getFormat () const;
|
||||
|
||||
private:
|
||||
irr::video::ITexture* m_texture;
|
||||
const Core::Objects::Effects::CFBO* m_fbo;
|
||||
};
|
||||
};
|
||||
|
@ -98,7 +98,7 @@ void CMaterial::render (GLuint drawTo, GLuint inputTexture)
|
||||
for (; mainCur != mainEnd; mainCur ++)
|
||||
{
|
||||
// set the proper render target
|
||||
driver->setRenderTarget ((*mainCur)->getOutputTexture (), true, true, irr::video::SColor (0, 0, 0, 0));
|
||||
driver->setRenderTarget ((*mainCur)->getOutputTexture (), true, true, IntegerColor (0, 0, 0, 0));
|
||||
// set the material
|
||||
driver->setMaterial ((*mainCur)->getMaterial ());
|
||||
// draw it
|
||||
@ -110,7 +110,7 @@ void CMaterial::render (GLuint drawTo, GLuint inputTexture)
|
||||
|
||||
// render last pass' output into our output
|
||||
// set the proper render target
|
||||
driver->setRenderTarget (this->getOutputTexture (), true, true, irr::video::SColor (0, 0, 0, 0));
|
||||
driver->setRenderTarget (this->getOutputTexture (), true, true, IntegerColor (0, 0, 0, 0));
|
||||
// set the material
|
||||
driver->setMaterial (this->m_outputMaterial);
|
||||
// draw it
|
||||
|
@ -1,12 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Images/CMaterial.h"
|
||||
#include "WallpaperEngine/Core/Objects/CEffect.h"
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Objects/Effects/CPass.h"
|
||||
#include "WallpaperEngine/Render/Objects/CEffect.h"
|
||||
|
||||
|
@ -287,7 +287,7 @@ void CPass::OnSetConstants (irr::video::IMaterialRendererServices *services, int
|
||||
{
|
||||
services->setVertexShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::f32*) (*cur)->getValue (),
|
||||
(float*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
}
|
||||
@ -314,7 +314,7 @@ void CPass::OnSetConstants (irr::video::IMaterialRendererServices *services, int
|
||||
{
|
||||
services->setPixelShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::f32*) (*cur)->getValue (),
|
||||
(float*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
}
|
||||
@ -329,12 +329,12 @@ void CPass::OnSetConstants (irr::video::IMaterialRendererServices *services, int
|
||||
{
|
||||
services->setPixelShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::f32*) (*cur)->getValue (),
|
||||
(float*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
services->setVertexShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::f32*) (*cur)->getValue (),
|
||||
(float*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
}
|
||||
@ -350,16 +350,16 @@ void CPass::OnSetConstants (irr::video::IMaterialRendererServices *services, int
|
||||
char rotation [20];
|
||||
char translation [23];
|
||||
|
||||
irr::f32 textureRotation [4] = { image->getAngles ().X, image->getAngles ().Y, image->getAngles ().Z, image->getAngles ().Z };
|
||||
float textureRotation [4] = { image->getAngles ().X, image->getAngles ().Y, image->getAngles ().Z, image->getAngles ().Z };
|
||||
|
||||
for (int index = 0; textureCur != textureEnd; textureCur ++, index ++)
|
||||
{
|
||||
// TODO: CHECK THESE VALUES, DOCUMENTATION SAYS THAT FIRST TWO ELEMENTS SHOULD BE WIDTH AND HEIGHT
|
||||
// TODO: BUT IN REALITY THEY DO NOT SEEM TO BE THAT, NOT HAVING SUPPORT FOR ATTRIBUTES DOESN'T HELP EITHER
|
||||
irr::f32 textureResolution [4] = {
|
||||
float textureResolution [4] = {
|
||||
1.0, -1.0, 1.0, 1.0
|
||||
};
|
||||
irr::f32 textureTranslation [2] = {
|
||||
float textureTranslation [2] = {
|
||||
0, 0
|
||||
};
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
#include "WallpaperEngine/Render/Objects/Effects/CMaterial.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Compiler.h"
|
||||
@ -11,6 +9,7 @@
|
||||
|
||||
namespace WallpaperEngine::Render::Objects::Effects
|
||||
{
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
class CMaterial;
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
@ -565,10 +564,10 @@ namespace WallpaperEngine::Render::Shaders
|
||||
}
|
||||
else if (type == "float")
|
||||
{
|
||||
irr::f32 value = 0;
|
||||
float value = 0;
|
||||
|
||||
if (constant == this->m_constants.end ())
|
||||
value = (*defvalue).get <irr::f32> ();
|
||||
value = (*defvalue).get <float> ();
|
||||
else if ((*constant).second->is <CShaderConstantFloat> () == true)
|
||||
value = *(*constant).second->as <CShaderConstantFloat> ()->getValue ();
|
||||
else if ((*constant).second->is <CShaderConstantInteger> () == true)
|
||||
|
@ -1,21 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include "WallpaperEngine/Assets/CContainer.h"
|
||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||
|
||||
/**
|
||||
|
@ -4,14 +4,14 @@
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
CShaderVariableFloat::CShaderVariableFloat(irr::f32 defaultValue) :
|
||||
CShaderVariableFloat::CShaderVariableFloat(float defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableFloat::CShaderVariableFloat(irr::f32 defaultValue, std::string name) :
|
||||
CShaderVariableFloat::CShaderVariableFloat(float defaultValue, std::string name) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
@ -19,7 +19,7 @@ CShaderVariableFloat::CShaderVariableFloat(irr::f32 defaultValue, std::string na
|
||||
this->setName (std::move(name));
|
||||
}
|
||||
|
||||
void CShaderVariableFloat::setValue (irr::f32 value)
|
||||
void CShaderVariableFloat::setValue (float value)
|
||||
{
|
||||
this->m_value = value;
|
||||
|
||||
|
@ -2,24 +2,22 @@
|
||||
|
||||
#include "CShaderVariable.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderVariableFloat : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
explicit CShaderVariableFloat (irr::f32 defaultValue);
|
||||
CShaderVariableFloat (irr::f32 defaultValue, std::string name);
|
||||
explicit CShaderVariableFloat (float defaultValue);
|
||||
CShaderVariableFloat (float defaultValue, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
void setValue (irr::f32 value);
|
||||
void setValue (float value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::f32 m_defaultValue;
|
||||
irr::f32 m_value;
|
||||
float m_defaultValue;
|
||||
float m_value;
|
||||
};
|
||||
}
|
||||
|
@ -5,12 +5,12 @@
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
|
||||
CShaderVariableFloatPointer::CShaderVariableFloatPointer(irr::f32* value) :
|
||||
CShaderVariableFloatPointer::CShaderVariableFloatPointer(float* value) :
|
||||
CShaderVariable (value, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableFloatPointer::CShaderVariableFloatPointer(irr::f32* value, std::string name) :
|
||||
CShaderVariableFloatPointer::CShaderVariableFloatPointer(float* value, std::string name) :
|
||||
CShaderVariable (value, nullptr, Type)
|
||||
{
|
||||
this->setName (std::move(name));
|
||||
|
@ -2,15 +2,13 @@
|
||||
|
||||
#include "CShaderVariable.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderVariableFloatPointer : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
explicit CShaderVariableFloatPointer (irr::f32* value);
|
||||
CShaderVariableFloatPointer (irr::f32* value, std::string name);
|
||||
explicit CShaderVariableFloatPointer (float* value);
|
||||
CShaderVariableFloatPointer (float* value, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
|
@ -4,14 +4,14 @@
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
CShaderVariableInteger::CShaderVariableInteger(irr::s32 defaultValue) :
|
||||
CShaderVariableInteger::CShaderVariableInteger(int32_t defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableInteger::CShaderVariableInteger(irr::s32 defaultValue, std::string name) :
|
||||
CShaderVariableInteger::CShaderVariableInteger(int32_t defaultValue, std::string name) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
@ -19,7 +19,7 @@ CShaderVariableInteger::CShaderVariableInteger(irr::s32 defaultValue, std::strin
|
||||
this->setName (std::move(name));
|
||||
}
|
||||
|
||||
void CShaderVariableInteger::setValue (irr::s32 value)
|
||||
void CShaderVariableInteger::setValue (int32_t value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderVariable::setValue (&this->m_value);
|
||||
|
@ -2,24 +2,22 @@
|
||||
|
||||
#include "CShaderVariable.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderVariableInteger : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
explicit CShaderVariableInteger (irr::s32 defaultValue);
|
||||
CShaderVariableInteger (irr::s32 defaultValue, std::string name);
|
||||
explicit CShaderVariableInteger (int32_t defaultValue);
|
||||
CShaderVariableInteger (int32_t defaultValue, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
void setValue (irr::s32 value);
|
||||
void setValue (int32_t value);
|
||||
|
||||
private:
|
||||
irr::s32 m_defaultValue;
|
||||
irr::s32 m_value;
|
||||
int32_t m_defaultValue;
|
||||
int32_t m_value;
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
|
@ -5,12 +5,12 @@
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
|
||||
CShaderVariableVector2Pointer::CShaderVariableVector2Pointer(irr::core::vector2df* value) :
|
||||
CShaderVariableVector2Pointer::CShaderVariableVector2Pointer(glm::vec2* value) :
|
||||
CShaderVariable (value, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableVector2Pointer::CShaderVariableVector2Pointer(irr::core::vector2df* value, std::string name) :
|
||||
CShaderVariableVector2Pointer::CShaderVariableVector2Pointer(glm::vec2* value, std::string name) :
|
||||
CShaderVariable (value, nullptr, Type)
|
||||
{
|
||||
this->setName (std::move(name));
|
||||
|
@ -1,16 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
#include "CShaderVariable.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderVariableVector2Pointer : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
CShaderVariableVector2Pointer (irr::core::vector2df* value);
|
||||
CShaderVariableVector2Pointer (irr::core::vector2df* value, std::string name);
|
||||
CShaderVariableVector2Pointer (glm::vec2* value);
|
||||
CShaderVariableVector2Pointer (glm::vec2* value, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user