PDA

View Full Version : how can I make texture from non power of 2 image



doojin
01-04-2004, 05:52 PM
glu2DBuildMipmaps does that

glu2DBuildMipmaps is so slow

Is There another function which makes texture from non power of 2 image fastly?

JanHH
01-04-2004, 05:54 PM
slow??

well, write your own, it's not very complicated http://www.opengl.org/discussion_boards/ubb/wink.gif

Jan

Honk
01-04-2004, 06:08 PM
glu2DBuildMipmaps may not be the fastest way but since you only need to call it once its not a bottleneck at all.

JanHH
01-04-2004, 08:25 PM
or use an image manipulating program (such as GIMP) to rescale the texture images.

Tzupy
01-04-2004, 10:16 PM
Hi,
You can use non-power-of-two textures with the txture_rectangle extension, it's supported on both nVidia and Ati (with recent drivers, on old cards too).

01-04-2004, 10:23 PM
If you want to go fast and the non power of 2 image is on the framebuffer, use glCopyTexSubImage to update the relevant part of the texture. If the non power of 2 image is on the CPU ram, use glTexSubImage to specify what is needed.

If you need mipmaps you can use :
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,
GL_TRUE );
See http://developer.nvidia.com/object/gdc2001_automatic_mipmap.html

Of course, when you map the power of 2 texture, try to mask the not updated parts by choosing carefully the texture coordinates.

Obli
01-07-2004, 10:46 AM
Originally posted by Tzupy:
Hi,
You can use non-power-of-two textures with the txture_rectangle extension, it's supported on both nVidia and Ati (with recent drivers, on old cards too).

I was a real fan of that method however, I have it in my image management API internally to all my apps.

This thing is broken. Really, it can't be used for serious high-performance apps, it has way too much limitations unless you use a dedicated fp/vp to workaround that. The texture target change is the primary issue in my opinion.

Every time I add a feature I find myself saying "Oh %!#@, this feature will be much more complicated if I have to add support for rect textures". I have support for it since it got out. It never showed of vital importance and it always gave problems.

Really, unless ARB_n_p_o_t or whatever it's called gets supported, forget using NPOTD textures for generic purposes - simply resize them at runtime if you can.

I raccomand using the glu func (I never used it but it's already there). If you're not happy with that, implement your own.

Are you sure you really need them?

Deiussum
01-07-2004, 12:49 PM
There is also gluScaleImage if you want to scale the image to be a power of 2 w/o building full mipmaps with gluBuild2DMipMaps. Of course, you'll have to figure out what dimensions to scale to that are within a power of 2, but that would be a fairly simple task.

[This message has been edited by Deiussum (edited 01-07-2004).]