View Full Version : How can I use an 100*100 bitmap for mapping?

04-17-2003, 11:51 PM
I think OpenGL can use 128*128 bitmap for mapping, but now I must use the 100*100 picture for my goal, and I don't want to use gluScaleImage() to shrink the picture.
Please tell me the method,thanks!

04-18-2003, 12:40 AM
You can expand the texture to 128x128 or you place the 100x100 image in a 128x128 texture and adjust the texture coordinates accordingly.

04-18-2003, 06:01 AM
use mipmaping - then you can use textures of any width and height

04-18-2003, 07:03 AM
Originally posted by Vlasko:
use mipmaping - then you can use textures of any width and height

Only partly true. If you use gluBuild2DMipMaps, it will resize the images to be dimensions with a power of 2. So you can pass in any size image, but the end result will still be textures with dimensions that are a power of 2.

04-21-2003, 05:52 PM
Thanks for your help!
But my friends tell me that the D3D can map any size of picture easily! So why OpenGL need to shrink the picture to fit??

[This message has been edited by lglabc (edited 04-21-2003).]

04-21-2003, 06:40 PM
If you have an nVidia card you could use the GL_NV_texture_rectangle extension. I think I remember reading about similar ATI extnsion(??)

04-21-2003, 10:57 PM
I think d3dx:s imageloader does he same trick as gluBuildMipMap, that is, it resizes the texture to the nearest higher ^2 factor on load.. so if you send in a 100*100, the gfxcard will recieve a 128*128 filtered image.

04-22-2003, 03:50 AM
You can do it another way if you want to keep your texture exactly 100x100.
Allocate a texture 128x128 in size passing NULL for the pixel data.
Now do a glTexSubImage2D(0,0,100,100,....,data); to put your data into this larger texture.
Finally use texture coordinates such as
{0,0 100/128,0 100/128,100/128 0,100/128} to correctly index to your larger texture.
This should give you your required 100x100 texture data exactly.

04-22-2003, 08:33 PM
ok, I'll try these methods!