Can't find uniforms

BlitzMax Forums/OpenGL Module/Can't find uniforms

Sanctus(Posted 2011) [#1]
Hey guys,

I've been trying to add shader support into my game written with normal Max2D.

I've written this extension for max2d:


I know it's very ugly but right now I only care about functionality.

So I've tested this in a separate app and it works great. I tested it in the game (only the desaturated shader) and it worked great. In the editor however it won't work at all.
Everything is set up, the max2d driver, glew, the shader is linked well but I keep getting -1 on the uniform locations and I just don't know what to do. The shader I use there is different but it doesn't matter since it won't even work with the dessaturated shader I tested in 2 other places.

Just so there is no confusion I'm gonna post the code for that shader:

Vert:
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}

Frag:
uniform sampler2D tex;
void main()
{
float4 t = texture2D(tex,gl_TexCoord[0].st);
float d = (t.r+t.g+t.b)/3.0;
gl_FragColor = float4(d,d,d,t.a);
}

Does anyone have any idea as to why this doesn't work?

I've been working with opengl for at least 5 years now and never once did I encounter such a weird thing.
Thanks a lot


col(Posted 2011) [#2]
Never mind, didnt read the post properly !!! Sorry.

Last edited 2011


Sanctus(Posted 2011) [#3]
Found it.
It didn't take me this long but I was quite busy with RL things.
If you create a shader having set the graphics on one canvas and then try to draw using that shader on another canvas you won't find the location of the uniforms.
I will check on a sollution for this.

On another note, we need a new Max2D that works the same but with shader support(both ogl and dx). It's 2011 already...
I swear that when I'll have some free time I'll start working on one and release it for free and everything.


kfprimm(Posted 2011) [#4]
Give it a shot with GLShareContexts().

That should fix it.