diff --git a/src/WallpaperEngine/Core/CProject.cpp b/src/WallpaperEngine/Core/CProject.cpp index 4ab0831..9f214e5 100644 --- a/src/WallpaperEngine/Core/CProject.cpp +++ b/src/WallpaperEngine/Core/CProject.cpp @@ -18,26 +18,28 @@ CProject* CProject::fromFile (const irr::io::path& filename) { json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)); - auto title = jsonFindRequired (content, "title", "Project title missing"); - auto type = jsonFindRequired (content, "type", "Project type missing"); - auto file = jsonFindRequired (content, "file", "Project's main file missing"); + std::string title = *jsonFindRequired (content, "title", "Project title missing"); + std::string type = *jsonFindRequired (content, "type", "Project type missing"); + std::string file = *jsonFindRequired (content, "file", "Project's main file missing"); auto general = content.find ("general"); CWallpaper* wallpaper; - if (strcmp ((*type).get ().c_str (), "scene") == 0) + std::transform (type.begin (), type.end (), type.begin (), tolower); + + if (type == "scene") { - wallpaper = CScene::fromFile ((*file).get ().c_str ()); + wallpaper = CScene::fromFile (file.c_str ()); } - else if (strcmp ((*type).get ().c_str (), "video") == 0) + else if (type == "video") { - wallpaper = new CVideo ((*file).get ().c_str ()); + wallpaper = new CVideo (file.c_str ()); } else throw std::runtime_error ("Unsupported wallpaper type"); CProject* project = new CProject ( - *title, - *type, + title, + type, wallpaper ); diff --git a/src/WallpaperEngine/Core/Core.cpp b/src/WallpaperEngine/Core/Core.cpp index dda3578..4de590a 100644 --- a/src/WallpaperEngine/Core/Core.cpp +++ b/src/WallpaperEngine/Core/Core.cpp @@ -63,9 +63,11 @@ irr::video::SColor Core::atoSColor (const std::string& str) nlohmann::json::iterator Core::jsonFindRequired (nlohmann::json& data, const char *key, const char *notFoundMsg) { auto value = data.find (key); + if (value == data.end ()) { throw std::runtime_error (notFoundMsg); } + return value; } diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp index 82a8c62..a03efc3 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp @@ -6,38 +6,96 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers; CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id) { - auto min_it = data.find ("min"); + auto min_it = data.find ("minVector"); auto max_it = data.find ("max"); - irr::core::vector3df min = irr::core::vector3df (); - irr::core::vector3df max = irr::core::vector3df (); + irr::core::vector3df minVector = irr::core::vector3df (); + irr::core::vector3df maxVector = irr::core::vector3df (); + irr::f64 minNumber = 0.0f; + irr::f64 maxNumber = 0.0f; + bool isMinVector = false; + bool isMaxVector = false; - if (min_it != data.end ()) + if (min_it != data.end () && min_it->is_string ()) { - min = WallpaperEngine::Core::ato3vf (*min_it); + minVector = WallpaperEngine::Core::ato3vf (*min_it); + isMinVector = true; + } + else if (min_it != data.end () && min_it->is_number ()) + { + minNumber = *min_it; + isMinVector = false; } - if (max_it != data.end ()) + if (max_it != data.end () && max_it->is_string ()) { - max = WallpaperEngine::Core::ato3vf (*max_it); + maxVector = WallpaperEngine::Core::ato3vf (*max_it); + isMaxVector = true; + } + else if(max_it != data.end () && max_it->is_number ()) + { + maxNumber = *max_it; + isMaxVector = false; } - return new CRotationRandom (id, min, max); + return new CRotationRandom (id, minVector, minNumber, isMinVector, maxVector, maxNumber, isMaxVector); } -CRotationRandom::CRotationRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max) : +CRotationRandom::CRotationRandom ( + irr::u32 id, + irr::core::vector3df minVector, + irr::f64 minNumber, + bool isMinimumVector, + irr::core::vector3df maxVector, + irr::f64 maxNumber, + bool isMaximumVector +) : CInitializer (id, "rotationrandom"), - m_min (min), - m_max (max) + m_minVector (minVector), + m_maxVector (maxVector), + m_minNumber (minNumber), + m_maxNumber (maxNumber), + m_isMinimumVector (isMinimumVector), + m_isMaximumVector (isMaximumVector) { } -const irr::core::vector3df CRotationRandom::getMinimum () const +const irr::core::vector3df CRotationRandom::getMinimumVector () const { - return this->m_min; + return this->m_minVector; } -const irr::core::vector3df CRotationRandom::getMaximum () const +const irr::core::vector3df CRotationRandom::getMaximumVector () const { - return this->m_max; + return this->m_maxVector; +} + +const irr::f64 CRotationRandom::getMinimumNumber () const +{ + return this->m_minNumber; +} + +const irr::f64 CRotationRandom::getMaximumNumber () const +{ + return this->m_maxNumber; +} + +const bool CRotationRandom::isMinimumVector () const +{ + return this->m_isMinimumVector == true; +} + +const bool CRotationRandom::isMinimumNumber () const +{ + return this->m_isMinimumVector == false; +} + +const bool CRotationRandom::isMaximumVector () const +{ + return this->m_isMaximumVector == true; +} + +const bool CRotationRandom::isMaximumNumber () const +{ + return this->m_isMaximumVector == false; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h index 1875bd1..e3aed7f 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h @@ -10,16 +10,37 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers class CRotationRandom : CInitializer { public: - const irr::core::vector3df getMinimum () const; - const irr::core::vector3df getMaximum () const; + const irr::core::vector3df getMinimumVector () const; + const irr::core::vector3df getMaximumVector () const; + const irr::f64 getMinimumNumber () const; + const irr::f64 getMaximumNumber () const; + + const bool isMinimumVector () const; + const bool isMinimumNumber () const; + const bool isMaximumVector () const; + const bool isMaximumNumber () const; + protected: friend class CInitializer; static CRotationRandom* fromJSON (json data, irr::u32 id); - CRotationRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max); + CRotationRandom ( + irr::u32 id, + irr::core::vector3df minVector, + irr::f64 minNumber, + bool isMinimumVector, + irr::core::vector3df maxVector, + irr::f64 maxNumber, + bool isMaximumVector + ); private: - irr::core::vector3df m_max; - irr::core::vector3df m_min; + irr::core::vector3df m_maxVector; + irr::f64 m_maxNumber; + irr::core::vector3df m_minVector; + irr::f64 m_minNumber; + + bool m_isMinimumVector; + bool m_isMaximumVector; }; }; diff --git a/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp b/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp index d5e518e..f99cb2f 100644 --- a/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp +++ b/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp @@ -205,7 +205,25 @@ namespace WallpaperEngine::Irrlicht header = this->parseHeader (input); mipmap = *header->mipmaps.begin (); - if (header->freeimageFormat == FREE_IMAGE_FORMAT::FIF_UNKNOWN) + // relevant shaders are currently drawing these masks opaque; return a transparent image instead + if ( + input->getFileName ().find ("materials/flowmask.tex") != std::string::npos || + input->getFileName ().find ("godrays_downsample2_mask") != std::string::npos || + input->getFileName ().find ("materials/util/white.tex") != std::string::npos + ) + { + this->m_context->getDevice ()->getLogger ()->log ( + "LOAD TEX: Skipping broken mask", input->getFileName ().c_str (), irr::ELL_INFORMATION + ); + + irr::u32 width = header->width; + irr::u32 height = header->height; + + image = this->m_context->getDevice ()->getVideoDriver ()->createImage ( + irr::video::ECF_A8R8G8B8, irr::core::dimension2d (width, height) + ); + } + else if (header->freeimageFormat == FREE_IMAGE_FORMAT::FIF_UNKNOWN) { image = this->m_context->getDevice ()->getVideoDriver ()->createImage ( irr::video::ECF_A8R8G8B8, irr::core::dimension2d (header->width, header->height) @@ -337,10 +355,10 @@ namespace WallpaperEngine::Irrlicht for (irr::u32 x = 0; x < width; x ++) { - imagedata [baseDestination + (x * bytesPerPixel) + 2] = input [baseOrigin + ((width - x) * 4) + 0]; // r - imagedata [baseDestination + (x * bytesPerPixel) + 1] = input [baseOrigin + ((width - x) * 4) + 1]; // g - imagedata [baseDestination + (x * bytesPerPixel) + 0] = input [baseOrigin + ((width - x) * 4) + 2]; // b - imagedata [baseDestination + (x * bytesPerPixel) + 3] = input [baseOrigin + ((width - x) * 4) + 3]; // alpha + 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 } } @@ -367,6 +385,16 @@ namespace WallpaperEngine::Irrlicht 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 @@ -401,9 +429,9 @@ namespace WallpaperEngine::Irrlicht // 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 + unsigned long CImageLoaderTex::PackRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a) const { - return ((r << 24) | (g << 16) | (b << 8) | a); + 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'. @@ -415,7 +443,7 @@ namespace WallpaperEngine::Irrlicht // 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 + 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(blockStorage); unsigned short color1 = *reinterpret_cast(blockStorage + 2); @@ -443,23 +471,23 @@ namespace WallpaperEngine::Irrlicht for (int i=0; i < 4; i++) { unsigned long finalColor = 0; - unsigned char positionCode = (code >> 2*(4*j+i)) & 0x03; + unsigned char positionCode = (code >> 2*(4*j+i)) & 0x03; if (color0 > color1) { switch (positionCode) { case 0: - finalColor = PackRGBA(r0, g0, b0, 255); + finalColor = PackRGBA (r0, g0, b0, 255); break; case 1: - finalColor = PackRGBA(r1, g1, b1, 255); + finalColor = PackRGBA (r1, g1, b1, 255); break; case 2: - finalColor = PackRGBA((2*r0+r1)/3, (2*g0+g1)/3, (2*b0+b1)/3, 255); + 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); + finalColor = PackRGBA ((r0+2*r1)/3, (g0+2*g1)/3, (b0+2*b1)/3, 255); break; } } @@ -468,22 +496,21 @@ namespace WallpaperEngine::Irrlicht switch (positionCode) { case 0: - finalColor = PackRGBA(r0, g0, b0, 255); + finalColor = PackRGBA (r0, g0, b0, 255); break; case 1: - finalColor = PackRGBA(r1, g1, b1, 255); + finalColor = PackRGBA (r1, g1, b1, 255); break; case 2: - finalColor = PackRGBA((r0+r1)/2, (g0+g1)/2, (b0+b1)/2, 255); + finalColor = PackRGBA ((r0+r1)/2, (g0+g1)/2, (b0+b1)/2, 255); break; case 3: - finalColor = PackRGBA(0, 0, 0, 255); + finalColor = PackRGBA (0, 0, 0, 255); break; } } - if (x + i < width) - image[(y + j)*width + (x + i)] = finalColor; + reinterpret_cast (image) [(y + j) * width + x + i] = finalColor; } } } @@ -504,11 +531,118 @@ namespace WallpaperEngine::Irrlicht 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); + 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 (blockStorage + 8); + unsigned short color1 = *reinterpret_cast (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 (blockStorage + 12); + unsigned long long alphaCode = *reinterpret_cast (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 (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. @@ -594,27 +728,47 @@ namespace WallpaperEngine::Irrlicht } } - unsigned char colorCode = (code >> 2*(4*j+i)) & 0x03; + unsigned long finalColor = 0; + unsigned char positionCode = (code >> 2 * (4 * j + i)) & 0x03; - unsigned long finalColor; - switch (colorCode) + if (color0 > color1) { - 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; + 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; + } } - if (x + i < width) - image[(y + j)*width + (x + i)] = finalColor; + reinterpret_cast (image) [(y + j) * width + x + i] = finalColor; } } } @@ -635,7 +789,9 @@ namespace WallpaperEngine::Irrlicht 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); + for (unsigned long i = 0; i < blockCountX; i++) + DecompressBlockDXT5(i*4, j*4, width, blockStorage + i * 16, image); + blockStorage += blockCountX * 16; } } diff --git a/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.h b/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.h index 4a3504f..5c8756d 100644 --- a/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.h +++ b/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.h @@ -27,9 +27,9 @@ namespace WallpaperEngine::Irrlicht 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 + enum ContainerVersion : int { UNKNOWN = -1, TEXB0003 = 3, @@ -37,6 +37,60 @@ namespace WallpaperEngine::Irrlicht 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: @@ -80,9 +134,9 @@ namespace WallpaperEngine::Irrlicht /** Texture height in memory (power of 2) */ irr::u32 textureHeight; /** Texture data format */ - irr::u32 format; + TextureFormat format; /** Free Image format */ - irr::u32 freeimageFormat; + FREE_IMAGE_FORMAT freeimageFormat; /** Number of mipmap levels for the texture */ irr::u32 mipmapCount; /** List of mipmaps */ @@ -120,62 +174,10 @@ namespace WallpaperEngine::Irrlicht 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; - - enum TextureFormat - { - ARGB8888, - RA88, - A8, - DXT5, - DXT3, - DXT1 - }; - - // extracted from the free image library - enum FREE_IMAGE_FORMAT - { - 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 - }; }; } diff --git a/src/WallpaperEngine/Irrlicht/CPkgReader.cpp b/src/WallpaperEngine/Irrlicht/CPkgReader.cpp index 3db54af..2c565b7 100644 --- a/src/WallpaperEngine/Irrlicht/CPkgReader.cpp +++ b/src/WallpaperEngine/Irrlicht/CPkgReader.cpp @@ -62,7 +62,8 @@ namespace WallpaperEngine::Irrlicht if ( strcmp ("PKGV0007", pointer) != 0 && strcmp ("PKGV0002", pointer) != 0 && - strcmp ("PKGV0001", pointer) != 0) + strcmp ("PKGV0001", pointer) != 0 && + strcmp ("PKGV0008", pointer) != 0) { delete [] pointer; return false; @@ -113,7 +114,8 @@ namespace WallpaperEngine::Irrlicht if ( strcmp ("PKGV0007", headerVersion) != 0 && strcmp ("PKGV0002", headerVersion) != 0 && - strcmp ("PKGV0001", headerVersion) != 0) + strcmp ("PKGV0001", headerVersion) != 0 && + strcmp ("PKGV0008", headerVersion) != 0) { delete [] headerVersion; diff --git a/src/WallpaperEngine/Render/Objects/CImage.cpp b/src/WallpaperEngine/Render/Objects/CImage.cpp index 6936e99..162d71b 100644 --- a/src/WallpaperEngine/Render/Objects/CImage.cpp +++ b/src/WallpaperEngine/Render/Objects/CImage.cpp @@ -30,25 +30,45 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) : m_passes (0) { // TODO: INITIALIZE NEEDED EFFECTS AND PROPERLY CALCULATE THESE? - irr::f32 xright = this->m_image->getOrigin ().X; - irr::f32 xleft = -this->m_image->getOrigin ().X; - irr::f32 ztop = this->m_image->getOrigin ().Y; - irr::f32 zbottom = -this->m_image->getOrigin ().Y; + irr::f32 xsize = this->m_image->getSize ().X; + irr::f32 ysize = this->m_image->getSize ().Y; + irr::f32 xscale = this->m_image->getScale ().X; + irr::f32 yscale = this->m_image->getScale ().Y; + + if (xsize == 0.0f || ysize == 0.0f) + { + xsize = 1920.0f; + ysize = 1080.0f; + + this->getScene ()->getContext ()->getDevice ()->getLogger ()->log ( + "Initializing xsise and ysize as default values 1920 and 1080", + this->getImage ()->getName ().c_str () + ); + } + + // take the orthogonal projection into account + irr::f32 scene_width = this->getScene ()->getScene ()->getOrthogonalProjection ()->getWidth (); + irr::f32 scene_height = this->getScene ()->getScene ()->getOrthogonalProjection ()->getHeight (); + + irr::f32 xright = -scene_width / 2.0f + this->m_image->getOrigin ().X + xsize * xscale / 2.0f; + irr::f32 xleft = -scene_width / 2.0f + this->m_image->getOrigin ().X - xsize * xscale / 2.0f; + irr::f32 ytop = -scene_height / 2.0f + this->m_image->getOrigin ().Y + ysize * yscale / 2.0f; + irr::f32 ybottom = -scene_height / 2.0f + this->m_image->getOrigin ().Y - ysize * yscale / 2.0f; irr::f32 z = this->m_image->getOrigin ().Z; // top left - this->m_vertex [0].Pos = irr::core::vector3df (xleft, ztop, z); + this->m_vertex [0].Pos = irr::core::vector3df (xleft, ytop, z); // top right - this->m_vertex [1].Pos = irr::core::vector3df (xright, ztop, z); + this->m_vertex [1].Pos = irr::core::vector3df (xright, ytop, z); // bottom right - this->m_vertex [2].Pos = irr::core::vector3df (xright, zbottom, z); + this->m_vertex [2].Pos = irr::core::vector3df (xright, ybottom, z); // bottom left - this->m_vertex [3].Pos = irr::core::vector3df (xleft, zbottom, z); + this->m_vertex [3].Pos = irr::core::vector3df (xleft, ybottom, z); - this->m_vertex [1].TCoords = irr::core::vector2df (1.0f, 0.0f); this->m_vertex [0].TCoords = irr::core::vector2df (0.0f, 0.0f); - this->m_vertex [3].TCoords = irr::core::vector2df (0.0f, 1.0f); + this->m_vertex [1].TCoords = irr::core::vector2df (1.0f, 0.0f); this->m_vertex [2].TCoords = irr::core::vector2df (1.0f, 1.0f); + this->m_vertex [3].TCoords = irr::core::vector2df (0.0f, 1.0f); this->m_vertex [0].Color = irr::video::SColor (255, 255, 255, 255); this->m_vertex [1].Color = irr::video::SColor (255, 255, 255, 255);