mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 21:32:23 +08:00
+ created global variable storage for shaders
+ added g_Time to global variable storage - removed global g_Time from main ~ changed "shader parameters" to "shader variables" as it's a more apt naming Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
d03edb7c1e
commit
d7cf8af7ca
@ -25,18 +25,21 @@ add_executable(
|
||||
src/WallpaperEngine/Core/Core.h
|
||||
src/WallpaperEngine/Core/Core.cpp
|
||||
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp
|
||||
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloatPointer.h
|
||||
src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloatPointer.cpp
|
||||
|
||||
src/WallpaperEngine/Render/Shaders/Compiler.h
|
||||
src/WallpaperEngine/Render/Shaders/Compiler.cpp
|
||||
|
8
main.cpp
8
main.cpp
@ -18,9 +18,6 @@ enum BACKGROUND_RUN_MODE
|
||||
RUN_MODE_PACKAGE = 3
|
||||
};
|
||||
|
||||
// TODO: MOVE GLOBAL SHADER VARIABLES TO THEIR OWN CLASS
|
||||
irr::f32 g_Time = 0;
|
||||
|
||||
WallpaperEngine::Irrlicht::CContext* IrrlichtContext = nullptr;
|
||||
|
||||
void print_help (const char* route)
|
||||
@ -168,8 +165,6 @@ int main (int argc, char* argv[])
|
||||
WallpaperEngine::Render::CScene* scene = new WallpaperEngine::Render::CScene (project, IrrlichtContext);
|
||||
|
||||
irr::u32 minimumTime = 1000 / maximumFPS;
|
||||
irr::u32 currentTime = 0;
|
||||
|
||||
irr::u32 startTime = 0;
|
||||
irr::u32 endTime = 0;
|
||||
|
||||
@ -180,8 +175,7 @@ int main (int argc, char* argv[])
|
||||
if (IrrlichtContext->getDevice ()->getVideoDriver () == nullptr)
|
||||
continue;
|
||||
|
||||
currentTime = startTime = IrrlichtContext->getDevice ()->getTimer ()->getTime ();
|
||||
g_Time = currentTime / 1000.0f;
|
||||
startTime = IrrlichtContext->getDevice ()->getTimer ()->getTime ();
|
||||
|
||||
IrrlichtContext->renderFrame (scene);
|
||||
|
||||
|
@ -8,8 +8,11 @@
|
||||
#include "WallpaperEngine/Irrlicht/CImageLoaderTEX.h"
|
||||
#include "WallpaperEngine/Irrlicht/CPkgReader.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloatPointer.h"
|
||||
|
||||
#include "CContext.h"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Irrlicht;
|
||||
|
||||
CContext::CContext (std::vector<std::string> screens, bool isRootWindow) :
|
||||
@ -85,6 +88,10 @@ void CContext::initializeContext ()
|
||||
this->getDevice ()->getFileSystem ()->addArchiveLoader (
|
||||
new WallpaperEngine::Irrlicht::CArchiveLoaderPkg (this)
|
||||
);
|
||||
// register time shader variable
|
||||
this->insertShaderVariable (
|
||||
new Render::Shaders::Variables::CShaderVariableFloatPointer (&this->m_time, 1, "g_Time")
|
||||
);
|
||||
}
|
||||
|
||||
void CContext::initializeViewports (irr::SIrrlichtCreationParameters &irrlichtCreationParameters)
|
||||
@ -149,6 +156,8 @@ void CContext::initializeViewports (irr::SIrrlichtCreationParameters &irrlichtCr
|
||||
|
||||
void CContext::renderFrame (Render::CScene* scene)
|
||||
{
|
||||
this->m_time = this->getDevice ()->getTimer ()->getTime () / 1000.0f;
|
||||
|
||||
if (this->m_viewports.empty () == true)
|
||||
{
|
||||
this->getDevice ()->getVideoDriver ()->beginScene (true, true, scene->getScene ()->getClearColor ().toSColor());
|
||||
@ -172,6 +181,16 @@ void CContext::renderFrame (Render::CScene* scene)
|
||||
}
|
||||
}
|
||||
|
||||
void CContext::insertShaderVariable (Render::Shaders::Variables::CShaderVariable* variable)
|
||||
{
|
||||
this->m_globalShaderVariables.push_back (variable);
|
||||
}
|
||||
|
||||
const std::vector<Render::Shaders::Variables::CShaderVariable*>& CContext::getShaderVariables () const
|
||||
{
|
||||
return this->m_globalShaderVariables;
|
||||
}
|
||||
|
||||
irr::IrrlichtDevice* CContext::getDevice ()
|
||||
{
|
||||
return this->m_device;
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "WallpaperEngine/Render/CScene.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
|
||||
namespace WallpaperEngine::Render
|
||||
{
|
||||
class CScene;
|
||||
@ -22,6 +24,9 @@ namespace WallpaperEngine::Irrlicht
|
||||
void setDevice (irr::IrrlichtDevice* device);
|
||||
void initializeContext ();
|
||||
|
||||
void insertShaderVariable (Render::Shaders::Variables::CShaderVariable* variable);
|
||||
const std::vector<Render::Shaders::Variables::CShaderVariable*>& getShaderVariables () const;
|
||||
|
||||
void renderFrame (Render::CScene* scene);
|
||||
|
||||
irr::IrrlichtDevice* getDevice ();
|
||||
@ -36,6 +41,10 @@ namespace WallpaperEngine::Irrlicht
|
||||
|
||||
irr::IrrlichtDevice* m_device;
|
||||
|
||||
std::vector<Render::Shaders::Variables::CShaderVariable*> m_globalShaderVariables;
|
||||
|
||||
irr::f32 m_time;
|
||||
|
||||
std::vector<std::string> m_screens;
|
||||
std::vector<irr::core::recti> m_viewports;
|
||||
bool m_isRootWindow;
|
||||
|
@ -1,16 +1,18 @@
|
||||
#include "CImage.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Compiler.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloatPointer.h"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Render::Objects;
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
extern irr::f32 g_Time;
|
||||
|
||||
@ -225,7 +227,7 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
if ((*cur)->is <CShaderParameterInteger> () == true)
|
||||
if ((*cur)->is <CShaderVariableInteger> () == true)
|
||||
{
|
||||
services->setVertexShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
@ -234,10 +236,10 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
|
||||
);
|
||||
}
|
||||
else if (
|
||||
(*cur)->is <CShaderParameterFloat> () == true ||
|
||||
(*cur)->is <CShaderParameterVector2> () == true ||
|
||||
(*cur)->is <CShaderParameterVector3> () == true ||
|
||||
(*cur)->is <CShaderParameterVector4> () == true)
|
||||
(*cur)->is <CShaderVariableFloat> () == true ||
|
||||
(*cur)->is <CShaderVariableVector2> () == true ||
|
||||
(*cur)->is <CShaderVariableVector3> () == true ||
|
||||
(*cur)->is <CShaderVariableVector4> () == true)
|
||||
{
|
||||
services->setVertexShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
@ -252,7 +254,7 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
if ((*cur)->is <CShaderParameterInteger> () == true)
|
||||
if ((*cur)->is <CShaderVariableInteger> () == true)
|
||||
{
|
||||
services->setPixelShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
@ -261,10 +263,10 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
|
||||
);
|
||||
}
|
||||
else if (
|
||||
(*cur)->is <CShaderParameterFloat> () == true ||
|
||||
(*cur)->is <CShaderParameterVector2> () == true ||
|
||||
(*cur)->is <CShaderParameterVector3> () == true ||
|
||||
(*cur)->is <CShaderParameterVector4> () == true)
|
||||
(*cur)->is <CShaderVariableFloat> () == true ||
|
||||
(*cur)->is <CShaderVariableVector2> () == true ||
|
||||
(*cur)->is <CShaderVariableVector3> () == true ||
|
||||
(*cur)->is <CShaderVariableVector4> () == true)
|
||||
{
|
||||
services->setPixelShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
@ -274,8 +276,25 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
|
||||
}
|
||||
}
|
||||
|
||||
services->setVertexShaderConstant ("g_Time", &g_Time, 1);
|
||||
services->setPixelShaderConstant ("g_Time", &g_Time, 1);
|
||||
cur = this->getScene ()->getContext ()->getShaderVariables ().begin ();
|
||||
end = this->getScene ()->getContext ()->getShaderVariables ().end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
if ((*cur)->is <CShaderVariableFloatPointer> () == true)
|
||||
{
|
||||
services->setPixelShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::f32*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
services->setVertexShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::f32*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
services->setVertexShaderConstant ("g_ModelViewProjectionMatrix", worldViewProj.pointer(), 16);
|
||||
|
||||
|
@ -10,12 +10,12 @@
|
||||
#include <WallpaperEngine/Render/Shaders/Compiler.h>
|
||||
#include <WallpaperEngine/Core/Core.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders
|
||||
{
|
||||
@ -511,33 +511,33 @@ namespace WallpaperEngine::Render::Shaders
|
||||
return;
|
||||
}
|
||||
|
||||
Parameters::CShaderParameter* parameter = nullptr;
|
||||
Variables::CShaderVariable* parameter = nullptr;
|
||||
|
||||
if (type == "vec4")
|
||||
{
|
||||
parameter = new Parameters::CShaderParameterVector4 (
|
||||
parameter = new Variables::CShaderVariableVector4 (
|
||||
WallpaperEngine::Core::ato3vf (*defvalue)
|
||||
);
|
||||
}
|
||||
else if (type == "vec3")
|
||||
{
|
||||
parameter = new Parameters::CShaderParameterVector3 (
|
||||
parameter = new Variables::CShaderVariableVector3 (
|
||||
WallpaperEngine::Core::ato3vf (*defvalue)
|
||||
);
|
||||
}
|
||||
else if (type == "vec2")
|
||||
{
|
||||
parameter = new Parameters::CShaderParameterVector2 (
|
||||
parameter = new Variables::CShaderVariableVector2 (
|
||||
WallpaperEngine::Core::ato2vf (*defvalue)
|
||||
);
|
||||
}
|
||||
else if (type == "float")
|
||||
{
|
||||
parameter = new Parameters::CShaderParameterFloat ((*defvalue).get <irr::f32> ());
|
||||
parameter = new Variables::CShaderVariableFloat ((*defvalue).get <irr::f32> ());
|
||||
}
|
||||
else if (type == "int")
|
||||
{
|
||||
parameter = new Parameters::CShaderParameterInteger ((*defvalue).get <irr::s32> ());
|
||||
parameter = new Variables::CShaderVariableInteger ((*defvalue).get <irr::s32> ());
|
||||
}
|
||||
else if (type == "sampler2D")
|
||||
{
|
||||
@ -557,7 +557,7 @@ namespace WallpaperEngine::Render::Shaders
|
||||
this->m_parameters.push_back (parameter);
|
||||
}
|
||||
|
||||
Parameters::CShaderParameter* Compiler::findParameter (const std::string& identifier)
|
||||
Variables::CShaderVariable* Compiler::findParameter (const std::string& identifier)
|
||||
{
|
||||
auto cur = this->m_parameters.begin ();
|
||||
auto end = this->m_parameters.end ();
|
||||
@ -573,7 +573,7 @@ namespace WallpaperEngine::Render::Shaders
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::vector <Parameters::CShaderParameter*>& Compiler::getParameters () const
|
||||
const std::vector <Variables::CShaderVariable*>& Compiler::getParameters () const
|
||||
{
|
||||
return this->m_parameters;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders
|
||||
{
|
||||
@ -67,12 +67,12 @@ namespace WallpaperEngine::Render::Shaders
|
||||
* @param identifier The identifier to search for
|
||||
* @return The shader information
|
||||
*/
|
||||
Parameters::CShaderParameter* findParameter (const std::string& identifier);
|
||||
Variables::CShaderVariable* findParameter (const std::string& identifier);
|
||||
|
||||
/**
|
||||
* @return The list of parameters available for this shader with their default values
|
||||
*/
|
||||
const std::vector <Parameters::CShaderParameter*>& getParameters () const;
|
||||
const std::vector <Variables::CShaderVariable*>& getParameters () const;
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -207,7 +207,7 @@ namespace WallpaperEngine::Render::Shaders
|
||||
/**
|
||||
* The parameters the shader needs
|
||||
*/
|
||||
std::vector <Parameters::CShaderParameter*> m_parameters;
|
||||
std::vector <Variables::CShaderVariable*> m_parameters;
|
||||
/**
|
||||
* The combos the shader should be generated with
|
||||
*/
|
||||
|
@ -1,46 +0,0 @@
|
||||
#include "CShaderParameter.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameter::CShaderParameter (void* defaultValue, void* value, std::string type) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (value),
|
||||
m_type (std::move(type))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const void* CShaderParameter::getValue () const
|
||||
{
|
||||
if (this->m_value)
|
||||
return this->m_value;
|
||||
|
||||
return this->m_defaultValue;
|
||||
}
|
||||
|
||||
void CShaderParameter::setValue (void* value)
|
||||
{
|
||||
this->m_value = value;
|
||||
}
|
||||
|
||||
const std::string& CShaderParameter::getIdentifierName () const
|
||||
{
|
||||
return this->m_identifierName;
|
||||
}
|
||||
|
||||
const std::string& CShaderParameter::getName () const
|
||||
{
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
void CShaderParameter::setIdentifierName (std::string identifierName)
|
||||
{
|
||||
this->m_identifierName = std::move(identifierName);
|
||||
}
|
||||
|
||||
void CShaderParameter::setName (std::string name)
|
||||
{
|
||||
this->m_name = std::move(name);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#include "CShaderParameterFloat.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterFloat::CShaderParameterFloat(irr::f32 defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterFloat::setValue (irr::f32 value)
|
||||
{
|
||||
this->m_value = value;
|
||||
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderParameterFloat::getSize () const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterFloat::Type = "float";
|
@ -1,24 +0,0 @@
|
||||
#include "CShaderParameterInteger.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterInteger::CShaderParameterInteger(irr::s32 defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterInteger::setValue (irr::s32 value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderParameterInteger::getSize () const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterInteger::Type = "int";
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CShaderParameter.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterInteger : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterInteger (irr::s32 defaultValue);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
void setValue (irr::s32 value);
|
||||
|
||||
private:
|
||||
irr::s32 m_defaultValue;
|
||||
irr::s32 m_value;
|
||||
};
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#include "CShaderParameterVector2.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterVector2::CShaderParameterVector2 (const irr::core::vector2df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector2df ()),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterVector2::setValue (irr::core::vector2df value)
|
||||
{
|
||||
this->m_value = value;
|
||||
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderParameterVector2::getSize () const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterVector2::Type = "vec2";
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterVector2 : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterVector2 (const irr::core::vector2df& defaultValue);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
void setValue (irr::core::vector2df value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector2df m_defaultValue;
|
||||
irr::core::vector2df m_value;
|
||||
};
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#include "CShaderParameterVector3.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterVector3::CShaderParameterVector3 (const irr::core::vector3df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector3df ()),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterVector3::setValue (irr::core::vector3df value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderParameterVector3::getSize () const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterVector3::Type = "vec3";
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterVector3 : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterVector3 (const irr::core::vector3df& defaultValue);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
void setValue (irr::core::vector3df value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector3df m_defaultValue;
|
||||
irr::core::vector3df m_value;
|
||||
};
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#include "CShaderParameterVector4.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterVector4::CShaderParameterVector4 (const irr::core::vector3df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector3df ()),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterVector4::setValue (irr::core::vector3df value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderParameterVector4::getSize () const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterVector4::Type = "vec4";
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterVector4 : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterVector4 (const irr::core::vector3df& defaultValue);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
void setValue (irr::core::vector3df value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector3df m_defaultValue;
|
||||
irr::core::vector3df m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
#include "CShaderVariable.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
CShaderVariable::CShaderVariable (void* defaultValue, void* value, std::string type) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (value),
|
||||
m_type (std::move(type))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const void* CShaderVariable::getValue () const
|
||||
{
|
||||
if (this->m_value)
|
||||
return this->m_value;
|
||||
|
||||
return this->m_defaultValue;
|
||||
}
|
||||
|
||||
void CShaderVariable::setValue (void* value)
|
||||
{
|
||||
this->m_value = value;
|
||||
}
|
||||
|
||||
const std::string& CShaderVariable::getIdentifierName () const
|
||||
{
|
||||
return this->m_identifierName;
|
||||
}
|
||||
|
||||
const std::string& CShaderVariable::getName () const
|
||||
{
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
void CShaderVariable::setIdentifierName (std::string identifierName)
|
||||
{
|
||||
this->m_identifierName = std::move(identifierName);
|
||||
}
|
||||
|
||||
void CShaderVariable::setName (std::string name)
|
||||
{
|
||||
this->m_name = std::move(name);
|
||||
}
|
@ -2,12 +2,12 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderParameter
|
||||
class CShaderVariable
|
||||
{
|
||||
public:
|
||||
CShaderParameter (void* defaultValue, void* value, std::string type);
|
||||
CShaderVariable (void* defaultValue, void* value, std::string type);
|
||||
|
||||
template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; }
|
||||
template<class T> T* as () { assert (is <T> ()); return (T*) this; }
|
@ -0,0 +1,34 @@
|
||||
#include "CShaderVariableFloat.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
CShaderVariableFloat::CShaderVariableFloat(irr::f32 defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableFloat::CShaderVariableFloat(irr::f32 defaultValue, std::string name) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
this->setName (std::move(name));
|
||||
}
|
||||
|
||||
void CShaderVariableFloat::setValue (irr::f32 value)
|
||||
{
|
||||
this->m_value = value;
|
||||
|
||||
CShaderVariable::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderVariableFloat::getSize () const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string CShaderVariableFloat::Type = "float";
|
@ -1,15 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "CShaderParameter.h"
|
||||
#include "CShaderVariable.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderParameterFloat : public CShaderParameter
|
||||
class CShaderVariableFloat : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
CShaderParameterFloat (irr::f32 defaultValue);
|
||||
explicit CShaderVariableFloat (irr::f32 defaultValue);
|
||||
CShaderVariableFloat (irr::f32 defaultValue, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
@ -0,0 +1,26 @@
|
||||
#include "CShaderVariableFloatPointer.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
|
||||
CShaderVariableFloatPointer::CShaderVariableFloatPointer(irr::f32* value, int size) :
|
||||
m_size (size),
|
||||
CShaderVariable (value, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableFloatPointer::CShaderVariableFloatPointer(irr::f32* value, int size, std::string name) :
|
||||
m_size (size),
|
||||
CShaderVariable (value, nullptr, Type)
|
||||
{
|
||||
this->setName (std::move(name));
|
||||
}
|
||||
|
||||
const int CShaderVariableFloatPointer::getSize () const
|
||||
{
|
||||
return this->m_size;
|
||||
}
|
||||
|
||||
const std::string CShaderVariableFloatPointer::Type = "pointer";
|
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "CShaderVariable.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderVariableFloatPointer : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
CShaderVariableFloatPointer (irr::f32* value, int size);
|
||||
CShaderVariableFloatPointer (irr::f32* value, int size, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
static const std::string Type;
|
||||
private:
|
||||
int m_size;
|
||||
};
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#include "CShaderVariableInteger.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
CShaderVariableInteger::CShaderVariableInteger(irr::s32 defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableInteger::CShaderVariableInteger(irr::s32 defaultValue, std::string name) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
this->setName (std::move(name));
|
||||
}
|
||||
|
||||
void CShaderVariableInteger::setValue (irr::s32 value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderVariable::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderVariableInteger::getSize () const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string CShaderVariableInteger::Type = "int";
|
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#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);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
void setValue (irr::s32 value);
|
||||
|
||||
private:
|
||||
irr::s32 m_defaultValue;
|
||||
irr::s32 m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
#include "CShaderVariableVector2.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
CShaderVariableVector2::CShaderVariableVector2 (const irr::core::vector2df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector2df ()),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableVector2::CShaderVariableVector2 (const irr::core::vector2df& defaultValue, std::string name) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector2df ()),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
this->setName (std::move(name));
|
||||
}
|
||||
|
||||
|
||||
void CShaderVariableVector2::setValue (const irr::core::vector2df& value)
|
||||
{
|
||||
this->m_value = value;
|
||||
|
||||
CShaderVariable::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderVariableVector2::getSize () const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
const std::string CShaderVariableVector2::Type = "vec2";
|
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderVariableVector2 : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
explicit CShaderVariableVector2 (const irr::core::vector2df& defaultValue);
|
||||
CShaderVariableVector2 (const irr::core::vector2df& defaultValue, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
void setValue (const irr::core::vector2df& value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector2df m_defaultValue;
|
||||
irr::core::vector2df m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
#include "CShaderVariableVector3.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
CShaderVariableVector3::CShaderVariableVector3 (const irr::core::vector3df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector3df ()),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableVector3::CShaderVariableVector3 (const irr::core::vector3df& defaultValue, std::string name) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector3df ()),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
this->setName (name);
|
||||
}
|
||||
|
||||
void CShaderVariableVector3::setValue (const irr::core::vector3df& value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderVariable::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderVariableVector3::getSize () const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
const std::string CShaderVariableVector3::Type = "vec3";
|
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderVariableVector3 : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
explicit CShaderVariableVector3 (const irr::core::vector3df& defaultValue);
|
||||
CShaderVariableVector3 (const irr::core::vector3df& defaultValue, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
void setValue (const irr::core::vector3df& value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector3df m_defaultValue;
|
||||
irr::core::vector3df m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#include "CShaderVariableVector4.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
CShaderVariableVector4::CShaderVariableVector4 (const irr::core::vector3df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector3df ()),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
}
|
||||
|
||||
CShaderVariableVector4::CShaderVariableVector4 (const irr::core::vector3df& defaultValue, std::string name) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector3df ()),
|
||||
CShaderVariable (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
this->setName (std::move(name));
|
||||
}
|
||||
|
||||
void CShaderVariableVector4::setValue (const irr::core::vector3df& value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderVariable::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
const int CShaderVariableVector4::getSize () const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
const std::string CShaderVariableVector4::Type = "vec4";
|
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Variables
|
||||
{
|
||||
class CShaderVariableVector4 : public CShaderVariable
|
||||
{
|
||||
public:
|
||||
explicit CShaderVariableVector4 (const irr::core::vector3df& defaultValue);
|
||||
CShaderVariableVector4 (const irr::core::vector3df& defaultValue, std::string name);
|
||||
|
||||
const int getSize () const override;
|
||||
|
||||
void setValue (const irr::core::vector3df& value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector3df m_defaultValue;
|
||||
irr::core::vector3df m_value;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user