PDA

View Full Version : problem about GL_TEXTURE_RECTANGLE_NV



CGDeveloper
12-27-2004, 05:55 PM
After
glGenTextures(1, &tex);
glBindTexture(target, tex);
...
glCopyTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB, 0, 0, winX, winY, 0);
then
glColor4f(0, 0, 0, 1);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable(GL_TEXTURE_RECTANGLE_NV);
glBindTexture(GL_TEXTURE_RECTANGLE_NV, sceneTex);
glBegin(GL_QUADS);
glNormal3f(0, 0, 1);
glTexCoord2f(0, 0);
glVertex3f(-1.0f, -1.0f, 0);
glTexCoord2f(1, 0);
glVertex3f(1.0f, -1.0f, 0);
glTexCoord2f(1, 1);
glVertex3f(1.0f, 1.0f, 0);
glTexCoord2f(0, 1);
glVertex3f(-1.0f, 1.0f, 0);
glEnd();
glDisable(GL_TEXTURE_RECTANGLE_NV);
But nothing is displayed.why?

CGDeveloper
12-27-2004, 05:58 PM
Of course, i have set the modelview transform:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glTranslatef(0, 0, -4.0f);
glRotatef(xrot, 1.0f, 0, 0);
glRotatef(yrot, 0, 1.0f, 0);
Thanks for your reply.

CGDeveloper
12-27-2004, 06:12 PM
OK!I find the problem:
NPOTD textures are accessed by non-normalized texture coordinates.
So instead of thinking of the texture image lying in a [0..1]x[0..1]
range, the NPOTD texture image lies in a [0..w]x[0..h] range
http://oss.sgi.com/projects/ogl-sample/registry/NV/texture_rectangle.txt.

Korval
12-27-2004, 06:31 PM
NPOTD textures are accessed by non-normalized texture coordinates.No, they are accessed by normalized texture coordinates. Rectangle textures are accessed by un-normalized texture coordinates. There is a non-trivial difference. NPOT textures provide separate functionality from rectangle textures. NPOT simply lifts the restriction of power-of-two to normal texture formats. Rectangle textures are a completely different texture type, like cube maps or 3D textures.

Granted, more hardware supports rectangular textures than supports NPOT textures. Only the NV40 hardware (6xxx GeForces) supports NPOTs.