Problem Texturing with GL_TEXTURE_RECTANGLE

I’m drawing a quad to the screen made up of a triangle strip and have a texture on this using GL_TEXTURE_RECTANGLE, everything looks fine until I move a point on the quad(say to stretch from the corner) the texture on the quad doesn’t stretch ‘properly’, it looks as if it is stretching only 1 triangle of the triangle-stripped quad(the other side remains normal) and this effect happens even if i’m using a quad instead of a triangle strip. Is there limitations to using GL_TEXTURE_RECTANGLE in this way? obviously its not noticeable when the quad remains rectangular but is there some solution to this? I’m not using any normals for the quad but should this effect the texture anyways?

Thanks in advance

Someone else may jump right in and tell me I’m wrong but the word on the street is to avoid the GL_TEXTURE_RECTANGLE extension as its performance is ropey or the implementations out there are variable.

You would be fine using the usual GL_TEXTURE_2D even for none-square textures.

Can someone verify the veracity of that opinion?

Personally I use GL_TEXTURE_2D for all my rectangle needs except for OpenGL 1.0 hardware where a none-square texture comes out as a white rectangle.

My hardware doesn’t support non-power of 2 textures so its either this or blit my non power of 2 into a p-o-t texture with wasted space? but regarding my initial problem i guess its caused by the fact that even if you’re rendering a quad that its broken down to 2 triangles when rendering so this kind of explains why i’m not getting the behavior i expect when i stretch a point out and see that only half of it is actually being stretched(texture-wise).

I believe you will experience the same problem whether you use texture rectangles or power-of-2 textures. The problem is that when you’re moving the point, the area of the rectangle doesn’t align with the texture area anymore, meaning that splitting the quad in to two triangles causes the texture coordinate derivatives to be non-continuous in screen space.

As nico says the issue is the linear interpolation within the triangles. It is similar to the issue of perspective correction (or rather the problems you see when you don’t perspective correct).

When you grab a vertex what interpolation do you expect accross the quad? This does not have a known solution like a perspective warp, you’re applying an arbirtary 2D warp to the coordinates.

You could try fudging the homogeneous vertices based on edge length but I don’t think it will work for you. Subdiviaion of the mesh will probably give you the warp you’re looking for.

Thanks for the responses, I get whats happening now and will probably give the subdividing technique a try…another thing, is the performance and implementation of GL_TEXTURE_RECTANGLE really that sketchy that I should avoid using it as the second poster has suggested? If my hardware doesn’t support non-power-of-two textures what are my other possible options?

kingc8, actually I just tested out loading up and rendering a non-power-of-2 tex with GL_TEXTURE_2D and although it worked(my hardware supports 2.0 gl) it was horrendously slow, made my system crawl(ati firegl laptop) but when i used GL_TEXTURE_RECTANGLE everything’s fine, what gives?

This is just a sign that your hardware doesn’t support NPOT textures and dropped back to software, so you should just stick with a texture rectangle instead. :slight_smile:

If you want to know if it is hw accelerated, check the GL version, which should be 2.0 and above.
Then check to see if GL_ARB_texture_non_power_of_two exists.
If it exists : hw accelerated
If not : the driver emulates

Gf 6 and up support it.