Hi, i got 2 problems with the shaders coding and even though i have searched the forums and the tutorials, i can't find the solution.
First problem.
In the "Shader with Parameter.cpp" example there is this part of code where a constant buffer is set in order to send a Vec2 variable from the C++ to the shader.
Code:
// PARAMETERS
/******************************************************************************/
BUFFER(ShaderWithParameterBuffer) // store parameters in custom Constant Buffer
Vec2 TextureOffset; // declare a global Vec2 parameter
BUFFER_END
/******************************************************************************/
Now the shader code compiles successfully but when i run the "02 - Shader Parameters.cpp" in Esenthel i get the error...
Code:
1>------ Build started: Project: Application 1, Configuration: Debug Win32 ------
1>Compiling...
1>Example.cpp
1>c:\esenthel\projects\_build_\application 1\source\example.cpp(102) : error C2665: 'EE::SPSet' : none of the 18 overloads could convert all the argument types
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(107): could be 'void EE::SPSet<EE::Vec2>(CChar8 *,const TYPE &)'
1> with
1> [
1> TYPE=EE::Vec2
1> ]
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(91): or 'void EE::SPSet(CChar8 *,Bool)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(92): or 'void EE::SPSet(CChar8 *,Int)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(93): or 'void EE::SPSet(CChar8 *,Flt)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(94): or 'void EE::SPSet(CChar8 *,const EE::Vec2 &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(95): or 'void EE::SPSet(CChar8 *,const EE::Vec &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(96): or 'void EE::SPSet(CChar8 *,const EE::Vec4 &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(97): or 'void EE::SPSet(CChar8 *,const EE::VecI2 &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(98): or 'void EE::SPSet(CChar8 *,const EE::VecI &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(99): or 'void EE::SPSet(CChar8 *,const EE::VecI4 &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(100): or 'void EE::SPSet(CChar8 *,const EE::Matrix3 &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(101): or 'void EE::SPSet(CChar8 *,const EE::Matrix &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(102): or 'void EE::SPSet(CChar8 *,const EE::Matrix4 &)'
1> c:\esenthel\bin\esenthelengine\graphics\shader.h(108): or 'void EE::SPSet(CChar8 *,const EE::Color &)'
1> while trying to match the argument list '(const wchar_t [14], EE::Vec2)'
1>Build log was saved at "file://c:\ESENTHEL\Projects\_Build_\Application 1\Debug\BuildLog.htm"
1>Application 1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
...pointing at the "SPSet" line below.
Code:
Bool Update()
{
if(Kb.bp(KB_ESC))return false;
CamHandle(0.1f, 1000, CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));
// set shader's custom parameter value
SPSet( "TextureOffset", Vec2(Time.time(), 0) );
return true;
}
Now SPSet seems to need a pointer to a char instead of the string "TextureOffset", so when i replace the SPSet with a char pointer it seems to work but this leads to my second problem.
Second problem.
I use single chars to transfer the values to the shader like this.
Shader Code.
Code:
// PARAMETERS
/******************************************************************************/
BUFFER(ShaderWithParameterBuffer) // store parameters in custom Constant Buffer
Vec2 t; // declare a global Vec2 parameter
BUFFER_END
/******************************************************************************/
C++ code.
Code:
cchar8 shaderData01='t';
Bool Update()
{
if(Kb.bp(KB_ESC))return false;
CamHandle(0.1f, 1000, CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));
// set shader's custom parameter value
SPSet( &shaderData01, Vec2(Time.time(), 0) );
return true;
}
Now this works and i see the texture scrolling but when i try to add a second cchar8 variable to the C++ code so that i can pass a second parameter later in the shader it seems to stop using my first parameter.
So the example below stops working.
C++ code.
Code:
cchar8 shaderData01='t';
cchar8 shaderData02='o';
Bool Update()
{
if(Kb.bp(KB_ESC))return false;
CamHandle(0.1f, 1000, CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));
// set shader's custom parameter value
SPSet( &shaderData01, Vec2(Time.time(), 0) );
return true;
}
So is there something i'm missing and i can't use string variable names like "TextureOffset" to pass variables to the shader and if the cchar8 is the solution, what should i do to pass a second parameter?
Thanks for your time.