mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
~ Fixed pkg loading not working properly
+ Added support for PKGV0001 pkgs (look to be identical to PKGV0002 format, but needs validation) ~ Fixed segfault on vertex variable loading Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
6abd73e843
commit
24cb34145d
10
main.cpp
10
main.cpp
@ -145,23 +145,23 @@ int main (int argc, char* argv[])
|
||||
wallpaper_path = wp::irrlicht::device->getFileSystem ()->getAbsolutePath (path.c_str ());
|
||||
project_path = wallpaper_path + "project.json";
|
||||
scene_path = wallpaper_path + "scene.pkg";
|
||||
|
||||
wp::irrlicht::device->getFileSystem ()->addFileArchive (scene_path, true, false); // add the pkg file to the lookup list
|
||||
break;
|
||||
|
||||
// folder mode
|
||||
case 2:
|
||||
wallpaper_path = wp::irrlicht::device->getFileSystem ()->getAbsolutePath (path.c_str ());
|
||||
project_path = wallpaper_path + "project.json";
|
||||
|
||||
// set our working directory
|
||||
wp::irrlicht::device->getFileSystem ()->changeWorkingDirectoryTo (wallpaper_path);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// set our working directory
|
||||
wp::irrlicht::device->getFileSystem ()->changeWorkingDirectoryTo (wallpaper_path);
|
||||
|
||||
// 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 (project_path);
|
||||
|
||||
if (wp_project->getScene ()->isOrthogonal() == true)
|
||||
|
@ -216,51 +216,57 @@ namespace wp
|
||||
if (param->type == "vec4")
|
||||
{
|
||||
irr::core::vector3df* vec = (irr::core::vector3df*) defaultValue;
|
||||
irr::f32* val = new irr::f32 [4];
|
||||
|
||||
parameter->value = new irr::f32 [4];
|
||||
|
||||
(*(irr::f32**) parameter->value) [0] = vec->X;
|
||||
(*(irr::f32**) parameter->value) [1] = vec->Y;
|
||||
(*(irr::f32**) parameter->value) [2] = vec->Z;
|
||||
(*(irr::f32**) parameter->value) [3] = 0.0f;
|
||||
val [0] = vec->X;
|
||||
val [1] = vec->Y;
|
||||
val [2] = vec->Z;
|
||||
val [3] = 0.0f;
|
||||
|
||||
parameter->value = val;
|
||||
parameter->type = ParameterType::TYPE_VEC4;
|
||||
}
|
||||
else if (param->type == "vec3")
|
||||
{
|
||||
irr::core::vector3df* vec = (irr::core::vector3df*) defaultValue;
|
||||
irr::f32* val = new irr::f32 [3];
|
||||
|
||||
parameter->value = new irr::f32 [3];
|
||||
|
||||
(*(irr::f32**) parameter->value) [0] = vec->X;
|
||||
(*(irr::f32**) parameter->value) [1] = vec->Y;
|
||||
(*(irr::f32**) parameter->value) [2] = vec->Z;
|
||||
val [0] = vec->X;
|
||||
val [1] = vec->Y;
|
||||
val [2] = vec->Z;
|
||||
|
||||
parameter->value = val;
|
||||
parameter->type = ParameterType::TYPE_VEC3;
|
||||
}
|
||||
else if (param->type == "vec2")
|
||||
{
|
||||
irr::core::vector2df* vec = (irr::core::vector2df*) defaultValue;
|
||||
irr::f32* val = new irr::f32 [2];
|
||||
|
||||
parameter->value = new irr::f32 [2];
|
||||
|
||||
(*(irr::f32**) parameter->value) [0] = vec->X;
|
||||
(*(irr::f32**) parameter->value) [1] = vec->Y;
|
||||
val [0] = vec->X;
|
||||
val [1] = vec->Y;
|
||||
|
||||
parameter->value = val;
|
||||
parameter->type = ParameterType::TYPE_VEC2;
|
||||
}
|
||||
else if (param->type == "float")
|
||||
{
|
||||
parameter->value = new irr::f32;
|
||||
*(irr::f32*) parameter->value = *(irr::f32*) defaultValue;
|
||||
irr::f32* org = (irr::f32*) defaultValue;
|
||||
irr::f32* val = new irr::f32;
|
||||
|
||||
*val = *org;
|
||||
|
||||
parameter->value = val;
|
||||
parameter->type = ParameterType::TYPE_FLOAT;
|
||||
}
|
||||
else if (param->type == "int")
|
||||
{
|
||||
parameter->value = new irr::s32;
|
||||
*(irr::s32*) parameter->value = *(irr::s32*) defaultValue;
|
||||
irr::s32* org = (irr::s32*) defaultValue;
|
||||
irr::s32* val = new irr::s32;
|
||||
|
||||
*val = *org;
|
||||
|
||||
parameter->value = val;
|
||||
parameter->type = ParameterType::TYPE_INT;
|
||||
}
|
||||
else if (param->type == "sampler2D")
|
||||
|
@ -73,7 +73,7 @@ bool CArchiveLoaderPkg::isALoadableFileFormat(irr::io::IReadFile* file) const
|
||||
|
||||
file->read (pointer, size - 1);
|
||||
|
||||
if (strcmp (pointer, "PKGV0002") != 0)
|
||||
if (strcmp (pointer, "PKGV0002") != 0 && strcmp (pointer, "PKGV0001") != 0)
|
||||
{
|
||||
delete [] pointer;
|
||||
return false;
|
||||
@ -121,7 +121,7 @@ void CPkgReader::scanPkgHeader ()
|
||||
{
|
||||
char* headerVersion = this->readSizedString ();
|
||||
|
||||
if (strcmp ("PKGV0002", headerVersion) != 0)
|
||||
if (strcmp ("PKGV0002", headerVersion) != 0 && strcmp ("PKGV0001", headerVersion) != 0)
|
||||
{
|
||||
wp::irrlicht::device->getLogger ()->log ("Unexpected package header... Aborting load", this->mFile->getFileName ().c_str (), irr::ELL_ERROR);
|
||||
|
||||
@ -136,7 +136,6 @@ void CPkgReader::scanPkgHeader ()
|
||||
this->mFile->read (&entriesCount, 4);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < entriesCount; i ++)
|
||||
{
|
||||
char* filename = this->readSizedString ();
|
||||
|
@ -36,10 +36,12 @@ namespace wp
|
||||
"#define saturate(x) (clamp(x, 0.0, 1.0))\n"
|
||||
"#define texSample2D texture2D\n"
|
||||
"#define texSample2DLod texture2DLod\n"
|
||||
"#define texture2DLod texture2D\n"
|
||||
"#define atan2 atan\n"
|
||||
"#define ddx dFdx\n"
|
||||
"#define ddy(x) dFdy(-(x))\n"
|
||||
"#define GLSL 1\n\n";
|
||||
// TODO: Parse COMBO options from shaders and set at least default values
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -232,7 +234,7 @@ namespace wp
|
||||
|
||||
std::string compiler::precompile()
|
||||
{
|
||||
#define BREAK_IF_ERROR if (this->m_error == true) { wp::irrlicht::device->getLogger ()->log ("ERROR PRE-COMPILING SHADER"); wp::irrlicht::device->getLogger ()->log (this->m_errorInfo.c_str ()); return ""; }
|
||||
#define BREAK_IF_ERROR if (this->m_error == true) { wp::irrlicht::device->getLogger ()->log ("ERROR PRE-COMPILING SHADER", irr::ELL_ERROR); wp::irrlicht::device->getLogger ()->log (this->m_errorInfo.c_str (), irr::ELL_ERROR); return ""; }
|
||||
// parse the shader and find #includes and such things and translate them to the correct name
|
||||
// also remove any #version definition to prevent errors
|
||||
std::string::const_iterator it = this->m_content.begin ();
|
||||
|
Loading…
Reference in New Issue
Block a user