Sign in to follow this  
Boder

ATI and GL_TEXTURE_RECTANGLE_ARB

Recommended Posts

I have found a puzzling bit of behavior on my friend's ATI card. When using GL_TEXTURE_RECTANGLE_ARB, the coordinates are grabbed for the first bound texture after calling glEnable() with GL_TEXTURE_RECTANGLE_ARB. Thereafter, all textures use those coordinates rather than the proper coordinates for their size. To use the proper coordinates you have to call glDisable() with GL_TEXTURE_RECTANGLE_ARB and call glEnable() again which probably makes for a performance hit. You have to do this between binding every new Texture that uses this extension. Can I get other people with ATI cards to verify this behavior?

Share this post


Link to post
Share on other sites
i thought thats normal behavour..

read this extension, which has reference to your "GL_TEXTURE_RECTANGLE_ARB":

http://www.opengl.org/registry/specs/ARB/texture_non_power_of_two.txt

quoting:

5. How is a conventional NPOT target different from the texture
rectangle target?

STATUS: RESOLVED

RESOLUTION:
The biggest practical difference is that coventional targets use
normalized texture coordinates (ie, [0..1]) while the texture
rectangle target uses unnormalized (ie, [0..w]x[0..h]) texture
coordinates.

basicaly, you don't enable GL_TEXTURE_RECTANGLE_ARB. you use texture_non_power_of_two to have support for NPOT textures. and still don't glenable anything, it is enabled if it is in extensions string. it won't improve performance to turn it off on normal POT textures.

GL_TEXTURE_RECTANGLE_ARB will use coordinates as unnormalized and that's what your problem is.

Share this post


Link to post
Share on other sites
I made a program to test it. It has a 2x3 and a 3x4 texture and tries to draw both textures completely.

Please post to say whether the screen changes when you hold down the spacebar! Also say what your graphics card is.

Download: Texture Rectangle Test

Here is the relevant code

glDisable( GL_TEXTURE_RECTANGLE_ARB );
glEnable( GL_TEXTURE_RECTANGLE_ARB );

// draw 2x3
glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex23 );

glBegin(GL_QUADS);
glTexCoord2f(0,3); glVertex2f(50,200);
glTexCoord2f(2,3); glVertex2f(50,50);
glTexCoord2f(2,0); glVertex2f(600,50);
glTexCoord2f(0,0); glVertex2f(600,200);
glEnd();

if( GLFW_PRESS == glfwGetKey( GLFW_KEY_SPACE ) )
{
glDisable( GL_TEXTURE_RECTANGLE_ARB );
glEnable( GL_TEXTURE_RECTANGLE_ARB );
}

// draw 3x4
glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex34 );

glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2f(50,450);
glTexCoord2f(0,4); glVertex2f(50,250);
glTexCoord2f(3,4); glVertex2f(600,250);
glTexCoord2f(3,0); glVertex2f(600,450);
glEnd();

Share this post


Link to post
Share on other sites
It changes. Radeon 9700 Cat 6.9

"read this extension, which has reference to your "GL_TEXTURE_RECTANGLE_ARB": "

That's a feature of GL 2.0
All texture can have non power of 2 dimensions, can be mipmapped, etc.

Since he is using GL_ARB_texture_rectangle, it not related to NPOT.

Share this post


Link to post
Share on other sites
I need the advice of the community to proceed from here.

In order of preference:

1) Switch back to 2x textures only, using padding
+ More compatible with all cards
- Wastes texture memory (worst case 3/4 of texture memory)

2) Stay with texture rectangle and enable/disable texture rectangle between every texture

3) Use NPOT textures

4) Use Pixel buffers with glDrawPixels()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this