My game has been working on all machines until late.
I decided to impliment a neat title screen, looks really good. Works on my WinMe comp just fine.
It crashing instantly upon calling my self-written LoadBMP function on a WinXp Sp2 machine. I debugged the hell out of it and I know it crash's once it hits a function which calls my LoadBmp function a few times...
Could someone look over this and tell me why Xp would not enjoy it:
PHP Code://-----------------
//Create Dx7 Surface from DC
//-----------------
LPDIRECTDRAWSURFACE7 DDSurface7::CreateSurface(LPDIRECTDRAW7 &DD, char* FileName, BOOL UseSystemMemory, int TransCol)
{
HBITMAP hbm;
BITMAP bm;
DDSURFACEDESC2 ddsd;
LPDIRECTDRAWSURFACE7 Surface;
long Width, Height;
HDC hdcPicture, hdcSurface;
DDCOLORKEY ddckColourKey;
DDPIXELFORMAT ddpf;
RECT rTemp;
//Load up the file
hbm = (HBITMAP)LoadImage(NULL, FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION );
//Size up the object
GetObject(hbm, sizeof(bm), &bm);
Width = bm.bmWidth;
Height = bm.bmHeight;
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.dwFlags = ddsd.dwFlags | DDSD_WIDTH | DDSD_HEIGHT;
if (UseSystemMemory)
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
else
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = Width;
ddsd.dwHeight = Height;
//set up our blt rect
rTemp.right = Width;
rTemp.bottom = Height;
//Create a blank surface
DD->CreateSurface(&ddsd, &Surface, NULL);
//get a new DC
hdcPicture = CreateCompatibleDC(NULL);
//point the picture to the new DC
SelectObject(hdcPicture, hbm);
Surface->GetDC(&hdcSurface);
StretchBlt(hdcSurface, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcPicture, 0, 0,
Width, Height, SRCCOPY);
Surface->ReleaseDC(hdcSurface);
//Sets our transparency--Black(1), Magenta(2)
if (TransCol==1)
{
ddckColourKey.dwColorSpaceLowValue = 0;
ddckColourKey.dwColorSpaceHighValue = 0;
Surface->SetColorKey(DDCKEY_SRCBLT, &ddckColourKey);
}
else if (TransCol==2)
{
Surface->GetPixelFormat(&ddpf);
ddckColourKey.dwColorSpaceLowValue = ddpf.dwBBitMask + ddpf.dwRBitMask;
ddckColourKey.dwColorSpaceHighValue = ddckColourKey.dwColorSpaceLowValue;
Surface->SetColorKey(DDCKEY_SRCBLT, &ddckColourKey);
}
//Clean up the DC's and STDPicture objects
DeleteDC(hdcPicture);
DeleteObject(hbm);
return Surface;
}




Reply With Quote