2D Texture of any size

Well I’ve given up on glDrawPixels() to be fastest enough for my needs and have implemented drawing a bitmap using textures and it is MUCH faster (even in the MS Software driver mode) – the good news.

However, I need to be able to handle an image of any given size and as you all know the function glTexImage2D() only supports widths and heights that are factors of 2. I have searched the discussion forums and have read that you can get around this problem, but I still don’t completely understand the entire process to accomplish this.

Do I still need to load the image with glTexImage2D() with sizes that meet the factor of 2 limitation? In other words, do I resize the image leaving the extra space empty (or black), and then use glVertex2D() to display only the area of interest?

Thanks again for everyone’s help.

[This message has been edited by karbuckle (edited 02-27-2002).]

Basically, yes. Then you need to fool around with your texture coordinates

if T denotes texture coordinates and the big rectangle is the whole texture with # denoting the area of interest, it should look like this:

######## |
T######T |
| |
| |
| |

This way the image will be stretched out to the vertices.

[This message has been edited by zeckensack (edited 02-27-2002).]

[This message has been edited by zeckensack (edited 02-27-2002).]

[This message has been edited by zeckensack (edited 02-27-2002).]

Read this:

You guys are awesome! I’ll check out the document.

While the functionality of the NV_texture_rectangle described in the document listed above is very cool – I would imagine this has limited availability. Anyone coding for an end user with unknown hardware wouldn’t be able to rely on having the NV_texture_rectangle. I’ll certainly keep this one in mind since it makes working with non-power-of-two dimensioned textures much simpiler.