I'm trying to display a picture in an openGL environment. The picture's origninal dimensions are 3648x2432, and I want to display it with a 256x384 image. The problem is, 384 is not a power of 2, and when I try to display it, it looks stretched. How can I fix that?
+2
A:
You can resize your texture so it is a power of two (skew your texture so that when it is mapped onto the object it looks correct).
Albert
2008-12-12 16:46:22
I am under the impression that textures are always a power of two because the hardware would use the same amount of resources anyways. But I could be incorrect.
Albert
2008-12-12 16:47:42
Yes, this is incorrect in modern hardware.
unwind
2008-12-15 10:13:52
+3
A:
There's three ways of doing this that I know of -
- The one Albert suggested (resize it until it fits).
- Subdivide the texture into 2**n-sized rectangles, and piece them together in some way.
- See if you can use
GL_ARB_texture_non_power_of_two
. It's probably best to avoid it though, since it looks like it's an Xorg-specific extension.
Ant P.
2008-12-12 16:54:08
A:
ARB_texture_rectangle
is probably what you're looking for. It lets you bind to GL_TEXTURE_RECTANGLE_ARB
instead of GL_TEXTURE_2D
, and you can load an image with non power-of-2 dimensions. Be aware that your texture coordinates will range from [0..w]x[0..h] instead of [0..1]x[0..1].
Jay Conrod
2008-12-12 17:01:57
A:
If GL_EXT_texture_rectangle is true then use GL_TEXTURE_RECTANGLE_EXT for the first param in glEnable() and GLBindTexture() calls.
Mark Thalman
2008-12-23 20:08:17