1) I''ve heard some complaints from a few people about the bitmap loading of Lathe''s book. I recommend the LoadBitMap functions of the MS SDK DD Example3 except you LOADFROMFILE
I just modified DD Example 3 and it makes no difference what bit format you use. They use ddutil.cpp ddutil.h ddutil2.h. Check it out.
2) Also LaMothe''s code does not address the 565 problem with 16bit surfaces and vidcards
3) Search also in the GameDev forums(using the GameDev search button) for the exact same problem.
//----------------------------------------------------------
// Global variables
//----------------------------------------------------------
LPDIRECTDRAW4 g_pDD; // DirectDraw object
LPDIRECTDRAWSURFACE4 g_pDDSPrimary;// DirectDraw primary surface
LPDIRECTDRAWSURFACE4 g_pDDSBack; // DirectDraw back surface
LPDIRECTDRAWSURFACE4 g_pDDSOne; // Offscreen surface 1
LPDIRECTDRAWSURFACE4 g_pDDSTwo; // Offscreen surface 2
LPDIRECTDRAWSURFACE4 g_pDDSHexMap; // JT surface
LPDIRECTDRAWSURFACE4 g_pDDSHexBackGround; // JT surface
LPDIRECTDRAWSURFACE4 g_pDDSText; // JT surface
LPDIRECTDRAWSURFACE4 g_pDDSHexTiles; // JT surface
LPDIRECTDRAWPALETTE g_pDDPal; // The primary surface palette
BOOL g_bActive; // Is application active?
LPDIRECTSOUND g_pDS = NULL;
;
int g_x;
int g_y;
//-----------------------------------------------------------------------------
// Name: InitSurfaces(void)
// Desc: This function reads the bitmap file FRNTBACK.BMP and stores half of it
// in offscreen surface 1 and the other half in offscreen surface 2.
// Globals: g_pDDSOne, g_pDDSTwo, g_pDDSHexMap, g_pDDSText, g_pDDSHexMapBackground
//-----------------------------------------------------------------------------
BOOL InitSurfaces(void)
{
HBITMAP hbm;
HBITMAP working;
HBITMAP combatsource;
// Load our bitmap resource.
hbm = (HBITMAP) LoadImage(GetModuleHandle(NULL), "frntback.bmp", IMAGE_BITMAP, 0,
0, LR_LOADFROMFILE / LR_CREATEDIBSECTION);
if (hbm == NULL) return FALSE;
DDCopyBitmap(g_pDDSOne, hbm, 0, 0, 640, 480);
DDCopyBitmap(g_pDDSTwo, hbm, 0, 480, 640, 480);
DeleteObject(hbm);
working = (HBITMAP) LoadImage(GetModuleHandle(NULL), "pcscreen.bmp", IMAGE_BITMAP, 0,
0, LR_LOADFROMFILE / LR_CREATEDIBSECTION);
DDCopyBitmap(g_pDDSText, working, 0, 0, 640, 480);
DeleteObject(working);
combatsource = (HBITMAP) LoadImage(GetModuleHandle(NULL), "combat.bmp", IMAGE_BITMAP, 0,
0, LR_LOADFROMFILE / LR_CREATEDIBSECTION);
DDCopyBitmap(g_pDDSHexMap, combatsource, 0, 0, 640, 480);
DeleteObject(combatsource);
combatsource = (HBITMAP) LoadImage(GetModuleHandle(NULL), "hextile.bmp", IMAGE_BITMAP, 0,
0, LR_LOADFROMFILE / LR_CREATEDIBSECTION);
DDCopyBitmap(g_pDDSHexTiles, combatsource, 0, 0, 640, 480);
DeleteObject(combatsource);
DDSetColorKey(g_pDDSTwo, RGB(0,0,0));
DDSetColorKey(g_pDDSHexMap, RGB(255,255,255));
DDSetColorKey(g_pDDSHexTiles, RGB(255,255,255));
DDSetColorKey(g_pDDSHexBackGround, RGB(255,255,255));
DDSetColorKey(g_pDDSText, RGB(255,255,255));
if (hbm == NULL) return FALSE;
return TRUE;
}
ZoomBoy
A 2D RPG with skills, weapons, and adventure.
See my character editor, Tile editor and diary at
Check out my web-site