+ added vector3 support for shader constants (looks like strings were vector3 after all)

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2019-09-10 15:01:59 +02:00
parent 4358e7c173
commit 318a99d5ca
5 changed files with 53 additions and 1 deletions

View File

@ -102,6 +102,8 @@ add_executable(
src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.cpp src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.cpp
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h src/WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.cpp src/WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.cpp
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantVector3.h
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantVector3.cpp
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h src/WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.cpp src/WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.cpp

View File

@ -2,10 +2,13 @@
#include <utility> #include <utility>
#include "WallpaperEngine/Core/Core.h"
#include "WallpaperEngine/Core/Objects/CImage.h" #include "WallpaperEngine/Core/Objects/CImage.h"
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h" #include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h" #include "WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h"
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantVector3.h"
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h" #include "WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h"
#include "WallpaperEngine/FileSystem/FileSystem.h" #include "WallpaperEngine/FileSystem/FileSystem.h"
using namespace WallpaperEngine; using namespace WallpaperEngine;
@ -136,7 +139,7 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
} }
else if ((*constantCur).is_string () == true) else if ((*constantCur).is_string () == true)
{ {
throw std::runtime_error ("String constants not supported yet"); constant = new Effects::CShaderConstantVector3 (WallpaperEngine::Core::ato3vf (*constantCur));
} }
else else
{ {

View File

@ -0,0 +1,17 @@
#include "CShaderConstantVector3.h"
using namespace WallpaperEngine::Core::Objects::Effects;
CShaderConstantVector3::CShaderConstantVector3 (irr::core::vector3df value) :
CShaderConstant (Type),
m_value (value)
{
}
irr::core::vector3df* CShaderConstantVector3::getValue ()
{
return &this->m_value;
}
const std::string CShaderConstantVector3::Type = "vector3";

View File

@ -0,0 +1,21 @@
#pragma once
#include "CShaderConstant.h"
#include <string>
#include <irrlicht/irrlicht.h>
namespace WallpaperEngine::Core::Objects::Effects
{
class CShaderConstantVector3 : public CShaderConstant
{
public:
CShaderConstantVector3 (irr::core::vector3df value);
irr::core::vector3df* getValue ();
static const std::string Type;
protected:
irr::core::vector3df m_value;
};
}

View File

@ -13,6 +13,7 @@
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h" #include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h" #include "WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h"
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h" #include "WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h"
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantVector3.h"
using namespace WallpaperEngine; using namespace WallpaperEngine;
@ -194,6 +195,10 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass, Cor
{ {
pixelVar->as <CShaderVariableInteger> ()->setValue (*(*cur).second->as <CShaderConstantInteger> ()->getValue ()); pixelVar->as <CShaderVariableInteger> ()->setValue (*(*cur).second->as <CShaderConstantInteger> ()->getValue ());
} }
else if (pixelVar->is <CShaderVariableVector3> () && (*cur).second->is <CShaderConstantVector3> ())
{
pixelVar->as <CShaderVariableVector3> ()->setValue (*(*cur).second->as <CShaderConstantVector3> ()->getValue ());
}
} }
if (vertexVar) if (vertexVar)
@ -206,6 +211,10 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass, Cor
{ {
vertexVar->as <CShaderVariableInteger> ()->setValue (*(*cur).second->as <CShaderConstantInteger> ()->getValue ()); vertexVar->as <CShaderVariableInteger> ()->setValue (*(*cur).second->as <CShaderConstantInteger> ()->getValue ());
} }
else if (vertexVar->is <CShaderVariableVector3> () && (*cur).second->is <CShaderConstantVector3> ())
{
vertexVar->as <CShaderVariableVector3> ()->setValue (*(*cur).second->as <CShaderConstantVector3> ()->getValue ());
}
} }
} }
} }