PDA

View Full Version : texture2DRect re-size problem



firegun9
06-25-2007, 09:52 AM
Hello,

I use FBO and GL_TEXTURE_RECTANGLE_ARB to generate a non-power-of-two sized texture and render it to cover the whole window. When users change the window size, I re-create a new texture with the new window size and render it to fulfill the window again.

It works flawlessly until I use shaders to render the texture. The screen looks fine when the program just launched. But if the window size is changed, the texture would get stretched, which doesn't happen without shaders. So it seems like the problem is the coordinates of textures in shaders do not update correctly.

Here are my shaders

void main(){
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
uniform sampler2DRect source;

void main()
{
gl_FragColor = texture2DRect(source, gl_TexCoord[0].st);
}
ATI mobility radeon 9600, omega 3.8.360

def
07-05-2007, 03:15 AM
Rectangular textures need un-normalized texture coordinates.

You will need to pass the screen size via uniform variables to the shader then use normalized texture coordinates and multiply them with the screen size.

Or you need to update the original texture coordinates to reflect the new screen dimensions.