+ Updated .gitignore

- Removed config class as It's no longer used
+ Added a small readme with all the documentation needed up to now
+ Changed the way the application starts to take into account execution switches to allow the users to select a background without recompiling the software

Signed-off-by: Alexis Maiquez Murcia <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez Murcia 2019-04-05 16:41:33 +02:00
parent 83caa05ebf
commit e62ea3e2be
12 changed files with 157 additions and 59 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
cmake-build-debug cmake-build-debug
assets assets.zip
.idea

View File

@ -15,6 +15,6 @@ find_package(LZ4 REQUIRED)
include_directories(${X11_INCLUDE_DIR} ${IRRLICHT_INCLUDE_DIR} ${LZ4_INCLUDE_DIR} .) include_directories(${X11_INCLUDE_DIR} ${IRRLICHT_INCLUDE_DIR} ${LZ4_INCLUDE_DIR} .)
add_executable(wallengine main.cpp wallpaperengine/shaders/compiler.h wallpaperengine/shaders/compiler.cpp wallpaperengine/project.cpp wallpaperengine/project.h wallpaperengine/scene.cpp wallpaperengine/scene.h wallpaperengine/object.cpp wallpaperengine/object.h wallpaperengine/camera.cpp wallpaperengine/camera.h wallpaperengine/core.cpp wallpaperengine/core.h wallpaperengine/image.cpp wallpaperengine/image.h wallpaperengine/object3d.cpp wallpaperengine/object3d.h wallpaperengine/effect.cpp wallpaperengine/effect.h wallpaperengine/fs/utils.cpp wallpaperengine/fs/utils.h wallpaperengine/irrlicht.cpp wallpaperengine/irrlicht.h wallpaperengine/config.cpp wallpaperengine/config.h wallpaperengine/video/renderer.cpp wallpaperengine/video/renderer.h wallpaperengine/video/node.cpp wallpaperengine/video/node.h wallpaperengine/video/material.cpp wallpaperengine/video/material.h wallpaperengine/texture.cpp wallpaperengine/texture.h wallpaperengine/irr/CImageLoaderTEX.h wallpaperengine/irr/CImageLoaderTEX.cpp wallpaperengine/irr/CPkgReader.h wallpaperengine/irr/CPkgReader.cpp wallpaperengine/irr/CFileList.h wallpaperengine/irr/CFileList.cpp) add_executable(wallengine main.cpp wallpaperengine/shaders/compiler.h wallpaperengine/shaders/compiler.cpp wallpaperengine/project.cpp wallpaperengine/project.h wallpaperengine/scene.cpp wallpaperengine/scene.h wallpaperengine/object.cpp wallpaperengine/object.h wallpaperengine/camera.cpp wallpaperengine/camera.h wallpaperengine/core.cpp wallpaperengine/core.h wallpaperengine/image.cpp wallpaperengine/image.h wallpaperengine/object3d.cpp wallpaperengine/object3d.h wallpaperengine/effect.cpp wallpaperengine/effect.h wallpaperengine/fs/utils.cpp wallpaperengine/fs/utils.h wallpaperengine/irrlicht.cpp wallpaperengine/irrlicht.h wallpaperengine/video/renderer.cpp wallpaperengine/video/renderer.h wallpaperengine/video/node.cpp wallpaperengine/video/node.h wallpaperengine/video/material.cpp wallpaperengine/video/material.h wallpaperengine/texture.cpp wallpaperengine/texture.h wallpaperengine/irr/CImageLoaderTEX.h wallpaperengine/irr/CImageLoaderTEX.cpp wallpaperengine/irr/CPkgReader.h wallpaperengine/irr/CPkgReader.cpp wallpaperengine/irr/CFileList.h wallpaperengine/irr/CFileList.cpp)
target_link_libraries(wallengine ${X11_LIBRARIES} ${X11_Xxf86vm_LIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES} ${IRRLICHT_LIBRARY} ${LZ4_LIBRARY}) target_link_libraries(wallengine ${X11_LIBRARIES} ${X11_Xxf86vm_LIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${ZLIB_LIBRARIES} ${IRRLICHT_LIBRARY} ${LZ4_LIBRARY})

72
README.md Normal file
View File

@ -0,0 +1,72 @@
# 1. Disclaimer
**This is an educational project**. Our main focus is to learn how Irrlicht Engine works and provide examples of usage of as much aspects of it as possible. We are not responsible for what others do with the source code downloaded from this project.
# 2. What is this project all about?
This projects aims to reproduce the background functionality of Wallpaper Engine on Linux systems. Simple as that.
# 3. What is Wallpaper Engine?
Wallpaper Engine is a software designed by [Kristjan Skutta](https://store.steampowered.com/search/?developer=Kristjan%20Skutta&snr=1_5_9__400) that provides live wallpaper functionality to Windows Systems, allowing It's users to animate their own backgrounds and sharing their own creations. You can find more about it on their [Steam page](https://store.steampowered.com/app/431960/Wallpaper_Engine/)
# 4. Compilation requirements
- OpenGL 2.1 support
- CMake
- Irrlicht
- LZ4
- ZLIB
# 5. How to use
## 5.1. Pre-requirements
In order to properly use this software you'll need to own an actual copy of Window's Wallpaper Engine as it contains some basic assets on which most of the backgrounds are based on.
The only way to get those assets is to install the Windows version trough Steam. Luckily you don't really need a Windows OS for that. Using the Linux client should be enough to force the download.
## 5.2. Extracting needed assets
Once Wallpaper Engine is downloaded open the installation folder (usually on C:\Program Files (x86)\Steam\steamapps\common\wallpaper_engine). Here you'll see the main folders of Wallpaper Engine. The folder we're interested in is the one named "assets".
![folder](docs/images/screenshot_folder.png)
All the folders we see must be compressed in a single zip file for the project to load them:
![compression](docs/images/zip.png)
The zip must be named "assets.zip" and placed on the same folder as the directory where the project is going to be run from.
## 5.3. Compilation steps
The project is built on CMake as build engine. First we need to create the directory where the build will be stored and get into it:
```
mkdir build
cd build
```
Once the folder is created and we're in it, cmake has to generate the actual Makefiles. This can be done this way
```
cmake ..
```
Take a closer look at the CMake output, if you miss any library CMake will report the missing libraries so you can install them either trough your package manager or manually in your system.
Finally we can compile the project to generate the actual executable
```
make
```
**REMEMBER: The assets.zip file has to be at the same folder as the executable**
## 5.4. Running a background
Currently both compressed and uncompressed backgrounds are supported.
#### 5.4.1. Running compressed backgrounds
Compressed backgrounds are actually two separate files. One named "project.json" and another called "scene.pkg". These two files are important as one contains the background's information and the second one contains the needed assets for it. For the program to properly detect them we'll use the ```--pkg``` parameter, which will specify the folder where those two files are stored.
```
./wallengine --pkg folder
```
#### 5.4.2. Running uncompressed backgrounds
Uncompressed backgrounds are just plain folders including all the resources and scene information all jumbled together. At least a project.json and a scene.json must exists for the background to even start loading. For the program to properly detect them we'll use the ```--dir``` parameter, which will specify the folder where the background itself is stored.
```
./wallengine --dir folder
```
###### Example background
This was the first background to even be compatible with the software. And It's not 100% compatible yet. Both textures and shaders are properly loaded, but there are still particles missing.
![example](docs/images/example.gif)

BIN
docs/images/example.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
docs/images/zip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

View File

@ -1,10 +1,10 @@
#include <iostream> #include <iostream>
#include <irrlicht/irrlicht.h> #include <irrlicht/irrlicht.h>
#include <sstream> #include <sstream>
#include <wallpaperengine/config.h>
#include <wallpaperengine/video/renderer.h> #include <wallpaperengine/video/renderer.h>
#include <wallpaperengine/video/material.h> #include <wallpaperengine/video/material.h>
#include <wallpaperengine/irr/CPkgReader.h> #include <wallpaperengine/irr/CPkgReader.h>
#include <getopt.h>
#include "wallpaperengine/shaders/compiler.h" #include "wallpaperengine/shaders/compiler.h"
#include "wallpaperengine/project.h" #include "wallpaperengine/project.h"
@ -66,13 +66,19 @@ int init_irrlicht()
void preconfigure_wallpaper_engine () void preconfigure_wallpaper_engine ()
{ {
wp::config::path::base = wp::irrlicht::device->getFileSystem ()->getAbsolutePath ("../"); // load the assets from wallpaper engine
wp::config::path::resources = wp::config::path::base + "/res"; wp::irrlicht::device->getFileSystem ()->addFileArchive ("assets.zip", true, false);
wp::config::path::shaders = wp::config::path::resources + "/shaders";
// register custom loaders
wp::irrlicht::driver->addExternalImageLoader (new irr::video::CImageLoaderTex ());
wp::irrlicht::device->getFileSystem ()->addArchiveLoader (new CArchiveLoaderPkg (wp::irrlicht::device->getFileSystem ()));
} }
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
int mode = 0;
std::string path;
// parse the integer if it exists // parse the integer if it exists
if (argc >= 1) if (argc >= 1)
{ {
@ -81,7 +87,45 @@ int main (int argc, char* argv[])
ss >> WinID; ss >> WinID;
} }
printf ("Initializing X11 to %d\n", WinID); int option_index = 0;
static struct option long_options [] = {
{"win", required_argument, 0, 'w'},
{"pkg", required_argument, 0, 'p'},
{"dir", required_argument, 0, 'd'},
{nullptr, 0, 0, 0}
};
while (true)
{
int c = getopt_long (argc, argv, "w:p:d:", long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 'w':
if (optarg)
WinID = atoi (optarg);
break;
case 'p':
mode = 1;
path = optarg;
break;
case 'd':
mode = 2;
path = optarg;
break;
default:
break;
}
}
printf ("Initializing irrlicht to WindowID %d\n", WinID);
if (init_irrlicht()) if (init_irrlicht())
{ {
@ -90,22 +134,35 @@ int main (int argc, char* argv[])
preconfigure_wallpaper_engine (); preconfigure_wallpaper_engine ();
// do_decompress (); irr::io::path wallpaper_path;
irr::io::path _wp_engine_folder = "/home/almamu/Development/tmp/nier__automata_-_become_as_gods_edition/"; irr::io::path project_path;
irr::io::path _wp_project_file = _wp_engine_folder + "project.json"; irr::io::path scene_path;
// load the assets folder from wallpaper engine switch (mode)
wp::irrlicht::device->getFileSystem ()->addFileArchive ("../assets.zip", true, false); {
// pkg mode
case 1:
wallpaper_path = wp::irrlicht::device->getFileSystem ()->getAbsolutePath (path.c_str ());
project_path = wallpaper_path + "project.json";
scene_path = wallpaper_path + "scene.pkg";
break;
// folder mode
case 2:
wallpaper_path = wp::irrlicht::device->getFileSystem ()->getAbsolutePath (path.c_str ());
project_path = wallpaper_path + "project.json";
break;
default:
break;
}
// set our working directory // set our working directory
wp::irrlicht::device->getFileSystem ()->changeWorkingDirectoryTo (_wp_engine_folder); wp::irrlicht::device->getFileSystem ()->changeWorkingDirectoryTo (wallpaper_path);
// register custom loader
wp::irrlicht::driver->addExternalImageLoader (new irr::video::CImageLoaderTex ());
wp::irrlicht::device->getFileSystem ()->addArchiveLoader (new CArchiveLoaderPkg (wp::irrlicht::device->getFileSystem ()));
// wp::irrlicht::device->getFileSystem ()->addFileArchive (_wp_engine_folder + "scene.pkg", true, false); // add the pkg file to the lookup list // wp::irrlicht::device->getFileSystem ()->addFileArchive (_wp_engine_folder + "scene.pkg", true, false); // add the pkg file to the lookup list
wp::project* wp_project = new wp::project (_wp_project_file); wp::project* wp_project = new wp::project (project_path);
if (wp_project->getScene ()->isOrthogonal() == true) if (wp_project->getScene ()->isOrthogonal() == true)
{ {

View File

@ -1,15 +0,0 @@
//
// Created by almamu on 6/07/18.
//
#include "config.h"
namespace wp
{
namespace config
{
irr::io::path path::resources;
irr::io::path path::base;
irr::io::path path::shaders;
}
}

View File

@ -1,22 +0,0 @@
#ifndef WALLENGINE_CONFIG_H
#define WALLENGINE_CONFIG_H
#include <string>
#include <irrlicht/path.h>
namespace wp
{
namespace config
{
class path
{
public:
static irr::io::path resources;
static irr::io::path base;
static irr::io::path shaders;
};
};
}
#endif //WALLENGINE_CONFIG_H

View File

@ -3,9 +3,6 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
// system configuration
#include <wallpaperengine/config.h>
// filesystem // filesystem
#include <wallpaperengine/fs/utils.h> #include <wallpaperengine/fs/utils.h>

View File

@ -35,6 +35,14 @@ namespace wp
int size; int size;
}; };
struct ShaderParameters
{
char* variableName;
void* defaultValue;
void* range [2];
char* type;
};
/** /**
* Types of shaders * Types of shaders
*/ */
@ -191,9 +199,9 @@ namespace wp
*/ */
Type m_type; Type m_type;
/** /**
* The file resolver to be used by the compiler to load the files * Tha parameters the shader needs
*/ */
wp::fs::utils m_resolver; std::vector <ShaderParameters*> m_parameters;
}; };
} }
} }