Skip to main content
gamedev.net
🔒 Locked

GL_TEXTURE_RECTANGLE_ARB problem

Started by jasonme Dec 26, 2006 at 3:54 AM 2 replies 900+ views
Original Post
jasonme
jasonme
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:

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);

and then in the display function, I rendered a quad using the following code:

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();

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:

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);

and the rendering quad code goes:

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();

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!
PinguinDude
PinguinDude
Hi,

Did you enable GL_TEXTURE_RECTANGLE_ARB before generating the texture ?
Also, what are the values of width and height ? Are they in pixel coordinates and the same as the texture's width and height ?
http://sourceforge.net/projects/pingux/ <-- you know you wanna see my 2D Engine which supports DirectX and OpenGL or insert your renderer here :)
jasonme
jasonme
Thanks for replying, I actually did use glEnable(GL_TEXTURE_RECTANGLE_ARB) before generating the texture, and the width and height are the actual width and height of the image.

I know this might be just one of my stupid mistakes, but really can't find out a way out now.

Quote:
Original post by PinguinDude
Hi,

Did you enable GL_TEXTURE_RECTANGLE_ARB before generating the texture ?
Also, what are the values of width and height ? Are they in pixel coordinates and the same as the texture's width and height ?


jasonme
jasonme
Found the problem, I thought when I comment my reshape function, it won't matter, but it will call a default one which changed my perspective view, so the texture becomes invisible. Thanks for your help!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.