PDA

View Full Version : 2D Texture of any size



karbuckle
02-27-2002, 12:35 PM
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).]

zeckensack
02-27-2002, 12:45 PM
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-----
######## |
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).]

richardve
02-27-2002, 12:46 PM
Read this:
http://www.nvidia.com/dev_content/nvopenglspecs/GL_NV_texture_rectangle.txt

karbuckle
02-27-2002, 12:50 PM
You guys are awesome! I'll check out the document.

karbuckle
02-27-2002, 04:40 PM
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.