I have the following problem. When I create and load my shader, everything works fine. As soon I put the shader source code via 'SetShaderSource' it will not work..
If I compare both shader in debug mode, the content is almost identical. Different are only 'm_iShaderID' what is so far understood and m_bFlags (in the loaded shader to hex value 0x220 in 'SetShaderSource' shader to value 0x20). I figured out that the 0x20 cause an update of the uniform variable. The 0x200 identifies a user defined shader.
What am I doing wrong? Or did I miss something?
Her some code snippet.
this work:
AGKShader* shd = new AGKShader();
shd->LoadShader("simpleshader.vs", "simpleshader.ps");
cImage* img = new cImage("image.png"));
int i = agk::CreateObjectPlane(250, 250);
object = agk::GetObjectPtr(i);
object->SetImage(img, 0);
object->SetShader(shd);
object->SetScreenCulling(0);
object->GetMesh(0)->CheckShader();
object->SetPosition((DEVICE_WIDTH - 600) / 2, (DEVICE_HEIGHT - 600) / 2, 0);
this doesn't work ( nothing appears on the screen )
AGKShader* shd = new AGKShader();
shd->SetShaderSource(_simple_shaderv, _simple_shaderp);
cImage* img = new cImage("image.png");
int i = agk::CreateObjectPlane(250, 250);
object = agk::GetObjectPtr(i);
object->SetImage(img, 0);
object->SetShader(shd);
object->SetScreenCulling(0);
object->SetPosition((DEVICE_WIDTH - 600) / 2, (DEVICE_HEIGHT - 600) / 2, 0);
here the real simple shader source:
vs
attribute vec2 position;
attribute vec2 uv;
uniform mat4 agk_World;
uniform mat4 agk_Ortho;
varying vec2 uvVarying;
void main()
{
uvVarying = uv;
gl_Position = agk_Ortho * agk_World * vec4(position,0,1);
}
and ps
uniform sampler2D texture0;
varying vec2 uvVarying;
void main()
{
gl_FragColor = texture2D(texture0, uvVarying);
}
I hope I have described my problem understandable.