PDA

View Full Version : Problem with GL_TEXTURE_RECTANGLE_NV



mop
12-16-2002, 05:59 AM
Hi,

I'm trying to use GL_TEXTURE_RECTANGLE_NV to do a background of my application.
I need to display a 1600x1200 image.

Here the code that initialize the texture:
glGenTexture (1, id);
glBindTexture (GL_TEXTURE_RECTANGLE_NV, *id);
glParameteri (GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glParameteri (GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glParameteri (GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glParameteri (GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D (GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, image);

Next in my display function:
glClearColor (0, 0, 0, 0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity ();

glDisable (GL_DEPTH);
glEnable (GL_TEXTURE_2D);
glEnable (GL_TEXTURE_RECTANGLE_NV);

glBindTexture (GL_TEXTURE_RECTANGLE_NV, *id);
glBegin (GL_QUADS);
glTexCoord2f (0, 0);
glVertex2f (0, 0);
glTexCoord2f (1, 0);
glVertex2f (1600, 0);
glTexCoord2f (1, 1);
glVertex2f (1600, 1200);
glTexCoord2f (0, 1);
glVertex2f (0, 1200);
glEnd ();

I'm working with an orthographic projection gluOrtho2D (...);

My problem is that the image isn't display, The background isn't black but the color is a mixed of brown and green.

So I've try to test with a small texture 32x24. But the problem is the same.

Could you help me ??
Do you have examples that uses rectangular texture with GL_TEXTURE_RECTANGLE_NV ??

Thanks in advance...

Philippe ;oD

jabe
12-16-2002, 06:26 AM
the texturecoords have to lie in between ([0,w], [0,h]) and not as in your code in between ([0,1], [0,1]).

regards,
jan

mop
12-17-2002, 03:38 AM
Hi,

Thank you very much for your answer, it's working fine...

So, Do you know why we must have :
"the texturecoords have to lie in between ([0,w], [0,h]) and not as in your code in between ([0,1], [0,1])." ??

Bob
12-17-2002, 06:17 AM
We read the documentation before we use it.

jabe
12-17-2002, 06:18 AM
i'm pleased to have helped you.



So, Do you know why we must have :
"the texturecoords have to lie in between ([0,w], [0,h]) and not as in your code in between ([0,1], [0,1])." ??

because it is written in the specs http://www.opengl.org/discussion_boards/ubb/smile.gif

this extensions was introduced to support NPOTD textures for movie playback and such stuff to save texture memory. movie player coders think in window coordinates. so the spec follows this logic for this kind of applications. just a thought...

regards,
jan