ATI and GL_TEXTURE_RECTANGLE_ARB

Started by
5 comments, last by V-man 17 years, 6 months ago
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?
Advertisement
Upload your code/exe somewhere.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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.

Projects: Top Down City: http://mathpudding.com/

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();
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.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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()
Email devrel@ati.com with your example and code.
I would go for power of 2
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement