I have a problem with my fragment shader. I want to get the size of a texture (which is loaded from an image).
I know that it is possible to use textureSize(sampler) to get an ivec2 which contains the texture size. But i don't know why this isn't working (it doesn't compile):
#version 120
uniform sampler2D tex;
float textureSize;
float texelSize;
void main()
{
textureSize = textureSize(tex).x;//first line
//textureSize = 512.0;//if i set the above line as comment and use this one the shader compiles.
texelSize = 1.0 / textureSize;
vec4 color = texture2D(tex,gl_TexCoord[0].st);
gl_FragColor = color * gl_Color;
}
ShaderInfoLog
or something like that, and if you have a fairly modern (4.x) system, you should have some version ofdebug_output
extension (which should be preferred, as it's much nicer to use, configurable and gives overall better information). – Shultzsampler2D
. – Shultz