Norris's picture

Rectangular texture lookup in GLSL 1.2

Hi !
I try to learn more about shaders and post-processing under OpenGL 2 and GLSL.
So, I have learn to use a FrameBuffer and rendering a full-screen quad with the color texture

binded. This works fine; I can see my textured quad and now I try to add a simple shader to

access this texture.
I first tried to just change the "glFragColor" in my fragment shader just for checking that it's

working, that's ok.But I can't access the texels of the texture.The render is always black.

I tried to send the texture by uniform, without success.
This is my code in the Rendering method (sorry, this is VB):

'...setup for 3D rendering...
'...code for "render to texture" in a fbo...
'...setup for 2D rendering...
Dim sceneTexLoc As Integer = GL.GetUniformLocation(_MyShaderProg, "sceneTexture")
GL.Uniform1(sceneTexLoc, 0)
GL.BindTexture(TextureTarget.Texture2D, _FullScreenTex)
GL.BindTexture(TextureTarget.Texture2D, 0)

and for the fragment shader:

#version 120
uniform sampler2D sceneTexture;
void main(void)
  vec3 color = vec3(1.0, 0.0, 0.0);
  vec2 uv = gl_TexCoord[0].xy;
  color = texture2D(sceneTexture, uv).rgb;
  gl_FragColor = vec4(color, 1.0);

Because this is a full-screen texture, so, rectangular and NPOT, could it be a problem for texture lookup in a fragment shader with conventional commands ?

For the moment, I just try to show the texture like before, but without effect and via GLSL.
Thanks for your help !


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Norris's picture

I got my error.
I just forgot to unbind my shader program after drawing. Sorry for that stupid post.