Original Post
Hello experts, I've got a question about GL_TEXTURE_RECTANGLE_ARB. I'm just testing how to render a texture with target type of GL_TEXTURE_RECTANGLE_ARB, and things didn't go as I expected. After I init opengl, I setup a texture containing an image, and I create a texture using GL_TEXTURE_RECTANGLE_ARB, the codes goes like below: and then in the display function, I rendered a quad using the following code: The rendered image is even close to what I wanted. But when I try to use GL_TEXTURE_2D, things go pretty normal, and I got the image I want to render. The texture setup goes like: and the rendering quad code goes: So what's the problem with my code on GL_TEXTURE_RECTANGLE_ARB? How can I can the same render output as GL_TEXTURE_2D configuration? Thank you so much!
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texName);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texName);
glBegin(GL_QUADS);
glTexCoord2i(0,height); glVertex2i(0,0);
glTexCoord2i(width,height); glVertex2i(width,0);
glTexCoord2i(width,0); glVertex2i(width,height);
glTexCoord2i(0,0); glVertex2i(0,height);
glEnd();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_2D, texName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texName);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex2f(-1.0f, -1.0f);
glTexCoord2f(0.0, 0.0); glVertex2f(-1.0f, 1.0f);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0f, 1.0f);
glTexCoord2f(1.0, 1.0); glVertex2f(1.0f, -1.0f);
glEnd();