PDA

View Full Version : Weird GL_TEXTURE_RECTANGLE_ARB behaviour



Hylke Donker
09-12-2006, 10:55 AM
Hello,
I have a really strange problem with my GL_TEXTURE_RECTANGLE_ARB texture.
When my initial image for my texture is completly white, my program seems to work fine, except for the fact that the texture is white instead of black.
However, when my initial image for my texture is black my complete screen remains black. Even when I remove my texture-rendering related code, it still shows a blackscreen.
I find this quite odd since, I can't find anything in my code that could possible cause strange behaviour.
Here's my code(with a black texture):

INIT CODE:

glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(1, &TextureIndex);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, TextureIndex);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

GLubyte BlackImage[width()][height()][4]; // RGBA image
for(int i = 0;i < width();i++)
{
for(int j = 0;j < height();j++)
{
for(uint k = 0;k < 4;k++)
BlackImage[i][j][k] = 0;
}
}
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width(), height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, BlackImage);


RENDER CODE:
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, TextureIndex);
glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, 0, width()-1, height()-1);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glTexCoord2d(0.0, 0.0); glVertex2f(-2.0, -2.0);
glTexCoord2f(width(), 0.0); glVertex2f(2.0, -2.0);
glTexCoord2f(width(), height()); glVertex2f(2.0, 2.0);
glTexCoord2f(0.0, height()); glVertex2f(-2.0, 2.0);
glEnd();
[..]I hope somebody can help me with this strange thing.
Thanks in advance,
Hylke

Komat
09-12-2006, 11:19 AM
Can you say more about what behaviour you expected with the black texture?

Which part of the code did you removed during "when I remove my texture-rendering related code"? As long as the texture target is enabled (glEnable(GL_TEXTURE_RECTANGLE_ARB)), the texture influences the output image (unless the shaders are in use). The texture rectangle target has higher priority than the GL_TEXTURE_2D target so if both are enabled for single unit, the GL_TEXTURE_RECTANGLE_ARB texture will be used instead of the GL_TEXTURE_2D texture (again unless the shaders are used).