hi,how can i draw a transparent bitmap inopenGL by VC++?
No, blending doesn’t help.
You mean bitmap like in GDI, not glBitmap, right?
Try this: http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/006761.html
The BMP file has not alpha chanel.
Leyder, do you mean that BMPs cannot have an alpha channel? If so you are wrong. The Microsoft documentation says they can be 32-bit.
The documentation I have read says they can be 32 bit, but the “alpha” channel is not used. Yes, that mean 25% wasted space.
Not used by whom? MSPaint? If 32 bits are allowed, you can use them for an alpha channel.
Never heard of 32bit BMP’s before, but now that I checked it turns out photoshop happily will save 32bit bmp’s for you.
Humus, are you sure the alpha channel is really saved? If you open it again, is it still there? PSP7 can not save the alpha channel in BMPs. TGA and PNG works fine though.
Yup, it’s still there.
Well, if so, it’s cool. Guess I have to accept it then
However, eveywhere I look at MSDN, it says 32 bits are supported but the high byte is not used/undefined. I would be careful using it, since other programs may not read it properly if it’s not allowed by the specification (unless the specificaion has been updated recently).
You realize that whether Microsoft considers it supported or not ONLY matters if you pass these bitmaps AS BITMAP OBJECTS to the Microsoft API (i e GDI), right?
If you open a file on disk, read past a few headers, and read binary data into your application, then point at that binary data with glTexImage() and friends, there’s no way the system can “know” that that binary data came from a .bmp file, and intentionally screw you over. It’s just data. Whether you store your data in a file called *.tga (with a TGA header); *.bmp (with BITMAPINFO header); *.dds (with DDSURFACEDESC2 header) or something else is entirely not relevant, as long as you parse it yourself. Which you should be doing.
Yes, I’m aware of that. But if you open the image in another paint program, makes some modifications and save it, don’t count on finding the proper alpha channel next time you read the file.
If you only use the images with your own tools, or with other tools that has this extra “feature”, like Photoshop and alpha channel in bitmaps, then I see no problems. But not following the specification can/will cause problems when other programs comes into the picture. I mean, I can save a bitmap with the image data compressed by, say, zlib, instead of RLE compression. As long as I can decompress the data, and I don’t intend to use it in other programs, then there’s no problems. But if you need compressed data, or an alpha channel, it’s better to choose a format that is known to have this feature so other programs can handle it properly.