I'm using linux... how would I go about loading BMP's for textures in linux. I mean the actual loading part, not the texture mapping, binding etc. Are there any libraries for this? I tried openil but that didn't seem to install.
Printable View
I'm using linux... how would I go about loading BMP's for textures in linux. I mean the actual loading part, not the texture mapping, binding etc. Are there any libraries for this? I tried openil but that didn't seem to install.
if you want to link to glaux, i think the function name is:
auxdibimagload
(dib = device independent bitmap)
of course, if you're rendering with OpenGL
Thanks :D
Or you can say screw BMP's large, bloated format and use an alternative format. Think about it, you have access to a million formats, thanks to the GIMP. For gaming, BMP has a lot of useless information.
I would suggest BMPs for beginners - once you learn more, however, try testing your own file format.
I tried using the auxdibimageload function, in various cases and styles... However, it is undeffined in the glaux header files. Where is it?
auxDIBImageLoad(char*FileName);
freaking cases
This is how I did it. Found most of the info from www.gamedev.net.
Textures.h
Textures.cppCode:#ifndef _TEXTURES_
#define _TEXTURES_
#include <ddraw.h>
#include <d3d.h>
#include "DXEngine.h"
class BasicTexture
{
LPDIRECTDRAWSURFACE7 Surface;
LPDIRECTDRAWSURFACE7 Texture;
public:
BasicTexture(void) {};
~BasicTexture(void);
void LoadTexture(char * filename, LPDIRECT3DDEVICE7 D3DDevice, LPDIRECTDRAW7 DirectDraw);
LPDIRECTDRAWSURFACE7 GetSurface(void) {return Surface;};
};
This sets the transparent color to bright purple and all textures are assumed to be 64x64 pixels. You can remove these constraints quite easily.Code:TileTexture::TileTexture(void)
{
Width = 64;
Height = 64;
}
HRESULT CALLBACK EnumTextures( LPDDPIXELFORMAT DDPixelFormat, LPVOID pDDDesiredPixelFormat )
{
if( DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS && DDPixelFormat->dwRGBBitCount == 16 )
{
if( DDPixelFormat->dwRGBAlphaBitMask == 1 ||
DDPixelFormat->dwRGBAlphaBitMask == 0x8000 )
{
memcpy( pDDDesiredPixelFormat, DDPixelFormat, sizeof(DDPIXELFORMAT) );
return D3DENUMRET_CANCEL;
}
}
return D3DENUMRET_OK;
}
void BasicTexture::LoadTexture(char * filename, LPDIRECT3DDEVICE7 D3DDevice, LPDIRECTDRAW7 DirectDraw)
{
DDPIXELFORMAT TexturePixelFormat;
if (FAILED(D3DDevice->EnumTextureFormats(( LPD3DENUMPIXELFORMATSCALLBACK )EnumTextures, ( void* )&TexturePixelFormat)))
{
exit(10);
};
DDSURFACEDESC2 Desc;
ZeroMemory( &Desc, sizeof( DDSURFACEDESC2 ));
Desc.dwSize = sizeof( Desc );
Desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_CKSRCBLT;
Desc.dwWidth = 64;
Desc.dwHeight = 64;
Desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
Desc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
Desc.ddpfPixelFormat = TexturePixelFormat;
Desc.ddckCKSrcBlt.dwColorSpaceHighValue = _RGB16BIT565(128,0,128);
Desc.ddckCKSrcBlt.dwColorSpaceLowValue = _RGB16BIT565(128,0,128);
DirectDraw->CreateSurface( &Desc, &Surface, 0 );
HBITMAP hBM;
BITMAP BM;
HDC hDCImage, hDC;
hBM = ( HBITMAP ) LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE | LR_CREATEDIBSECTION );
if (hBM == NULL)
{
exit(10);
};
GetObject( hBM, sizeof( BM ), &BM );
hDCImage = CreateCompatibleDC( NULL );
SelectObject( hDCImage, hBM );
if( SUCCEEDED( Surface->GetDC( &hDC )))
{
BitBlt( hDC, 0, 0, 64, 64, hDCImage, 0, 0, SRCCOPY );
Surface->ReleaseDC( hDC );
} else exit(10);
DeleteDC( hDCImage );
DeleteObject( hBM );
}
BasicTexture::~BasicTexture(void)
{
Surface->Release();
Texture->Release();
}
Silvercord: I tried that set of cases... still undefined.
Bubba: I'll see how this works.
are there any other ways or a reason why auxdibimageload still remains undefined?
You can't use what bubba is using because he's using Window's API and Directx. You could google for bitmap header format and figure out how to open the file yourself.
Since you are using linux, you have or can get GIMP which can edit .tga files. I would recommend switching to .tga. First off, the header is darn simple. Second, the targa file can store an 8 bit alpha channel.
Well it uses Windows GDI and DirectX which you are not using. Perhaps I mis-posted or didn't read your post completely. It was very late at night when I posted.
:D