PDA

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



lglabc
04-17-2003, 10: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!

HS
04-17-2003, 11:40 PM
You can expand the texture to 128x128 or you place the 100x100 image in a 128x128 texture and adjust the texture coordinates accordingly.

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

Deiussum
04-18-2003, 06: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.

lglabc
04-21-2003, 04: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).]

shinpaughp
04-21-2003, 05: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(??)

Mazy
04-21-2003, 09: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.

brute
04-22-2003, 02: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.

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

Thanks!!