|
-
Dec 6th, 2004, 09:47 PM
#1
Thread Starter
PowerPoster
C++: LoadImage() Function crashing WinXP HELP!!! [HALF RESOVLED]
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;
}
Last edited by Electroman; Dec 8th, 2004 at 07:36 PM.
Reason: Added Language to tile.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Dec 6th, 2004, 10:27 PM
#2
Thread Starter
PowerPoster
Re: LoadBmp Function crashing WinXP
I set up a reporting method which tells me how it is doing while going through the CreateSurface function I posted.
I set up steps at entering, before and after loadimage(), after the surface is created, after the DC is stretched on the surface, and when the function exits.
Usually it loads 1 or 2..maybe even three bitmaps before it crashs. Problem is it always crashs on Xp, whether it be after 1 or 2 attempts at loading a bitmap.
I have gotten it to load 3 in a row once. Majority of the time it hits LoadImage() the first time and crash's.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Dec 6th, 2004, 11:39 PM
#3
Thread Starter
PowerPoster
Re: LoadImage() Function crashing WinXP HELP!!! -- CreateSurface() Code Included
http://support.microsoft.com/default...b;en-us;150147
http://support.microsoft.com/default...b;en-us;195831
The top article and the bottom article seem they could be the problem.
It also seems as this API has some problems in the NT engine of windows. As shown in those msnd articles.
Any advice?
I need something to get away from LoadImage()
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Dec 7th, 2004, 01:35 PM
#4
Thread Starter
PowerPoster
Re: LoadImage() Function crashing WinXP HELP!!! -- CreateSurface() Code Included
I really need help on this guys.
3 Windows Xp Machines all totally unrelated owned by different people are experiencing the exact same crashs on the LoadImage() function.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Dec 7th, 2004, 03:55 PM
#5
Thread Starter
PowerPoster
Re: LoadImage() Function crashing WinXP HELP!!! -- CreateSurface() Code Included
Alright, I fixed it...I think/hope forever.
This now needs further explanation I hope someone reply's.
I installed VC6, Dx7 SDK, my EzC Win32 Api library on a Windows Xp machine.
Got VC6 to compile my game on the Xp machine.
It loaded 100% fine.
So, a Win 98/ME compile fails on Xp.
An Xp compile works on Xp.
I should try an Xp compile on Win 98/ME.
Any reason why this could have happened?
I notice VC6 on XP reporting alot different like thread ids and how many my app took increased.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|