load unregular bitmap (vb)
Hi,
There are quite a few tutorials on using OpenGL with VB. But every tutorial used regular (i mean same width and heigt and it must be a power of 2) bitmaps.
Now I found some interesting c++ code which displays a md2 file with a texture map. But this bitmap file was sized 432x142. The texture is created with glubuild2dmipmaps, which has (among other) a parameter "bitmap-data".
Now how do I fill this bitmap-data? How can I load a 432x142 bitmap in Visual Basic, so that I can pass it to glubuild2dmipmaps? So I need some function like auxdibimageload()
in vb.
Thanks
ClassifiedOne
[edited by - ClassifiedOne on February 9, 2003 1:00:09 PM]
glubuildmipmaps first rescales the image to a power of 2 size
perhaps use devil (openil) for loading images
http://openil.sourceforge.net
http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
perhaps use devil (openil) for loading images
http://openil.sourceforge.net
http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
Well, loading a bitmap yourself and making it a texture with gluBuild2DMipmaps (if that's what you're asking for, I'm not 100% that it is) in VB is simple. Code below...
This code assumes that the file is a 24-bit bitmap (hence GLubyte), but you can modify it a little to open files of all bitsizes...
EDIT: Stupid source box ...
Coding Stuff -> [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff -> [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]
[edited by - iNsAn1tY on February 9, 2003 11:26:07 PM]
Dim BitmapHeader As BITMAPFILEHEADERDim BitmapInfo As BITMAPINFOHEADERDim BitmapBits() As GLubyteDim BitmapBitsize As Long ' Open the file to begin with...Open "C:\MyBitmap.bmp" For Binary As #1 ' Get the file's header and info...Get #1, , BitmapHeaderGet #1, , BitmapInfo ' Calculate the size of the image...BitmapBitsize = ((BitmapInfo.biHeight * BitmapInfo.biWidth) * (BitmapInfo.biBitCount / 8)) - 1 ' Allocate some space for the image...ReDim BitmapBits(BitmapBitsize) ' Read in the bitmap's bits...Get #1, , BitmapBits ' Generate a new texture object, then' bind it so that we can use it...glGenTextures 1, uiTexObjectglBindTexture glTexture2D, uiTexObject ' Set up any texture parameters (note' the fourth parameter)...glTexParameteri glTexture2D, tpnTextureWrapS, GL_REPEATglTexParameteri glTexture2D, tpnTextureWrapT, GL_REPEATglTexParameteri glTexture2D, tpnTextureMagFilter, GL_LINEARglTexParameteri glTexture2D, tpnTextureMinFilter, GL_LINEAR_MIPMAP_LINEARglTexEnvi tetTextureEnv, tenTextureEnvMode, tepModulate ' "Define" the texture...gluBuild2DMipmaps glTexture2D, 3, BitmapInfo.biWidth, BitmapInfo.biHeight, _ tiBGRExt, GL_UNSIGNED_BYTE, ByVal VarPtr(BitmapBits(0)) ' Don't forget to close the file...Close #1
This code assumes that the file is a 24-bit bitmap (hence GLubyte), but you can modify it a little to open files of all bitsizes...
EDIT: Stupid source box ...
Coding Stuff -> [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff -> [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]
[edited by - iNsAn1tY on February 9, 2003 11:26:07 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement