I am trying to make fft texture using GLSL. However, although it was created in the current version 150, thought that I wanted to rewrite it to version 120, it does not work well, I will paste the source code below, so please let me know if you know what is the cause. I am delighted.
glsl150.vert
#version 150
uniform mat4 modelViewProjectionMatrix;
in vec4 position;
in vec2 texcoord;
out vec2 vTexCoord;
void main(){
vTexCoord = texcoord;
gl_Position = modelViewProjectionMatrix * position;
}
glsl150.frag
#version 150
uniform sampler2DRect tex;
uniform float rawFft[256];
in vec2 vTexCoord;
out vec4 outputColor;
void main(){
if (vTexCoord.y < 1.0) {
int i = int(vTexCoord.x);
outputColor.r = rawFft[i];
} else {
vec2 st = vTexCoord;
st.y -= 1.0;
outputColor.r = texture(tex, st).r;
}
outputColor.a = 1.0;
}
glsl120.vert
#version 120
#extension GL_ARB_texture_rectangle : enable
void main(){
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
}
glsl120.frag
#version 120
#extension GL_ARB_texture_rectangle : enable
uniform sampler2D tex;
uniform float rawFft[256];
vec4 outputColor;
void main(){
if (gl_TexCoord[0].y < 1.0) {
int i = int(gl_TexCoord[0].x);
outputColor.r = rawFft[i];
} else {
vec2 st = gl_TexCoord[0].st;
st.y -= 1.0;
outputColor.r = texture2D(tex, st).r;
}
outputColor.a = 1.0;
gl_FragColor = outputColor;
}
I want to make the result which is out in 150 work even with 120. What is wrong?