Original Post
I've been creating a DirectDraw Engine, and its worked fine on my computer, but then I tried running it on some other computers, and it wont work. Ive tracked the error down to my CreatSurface function, and well.. here take a look:
// initializes a direct draw struct, basically zeros it and sets the dwSize field
#define DDRAW_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); }
LPDIRECTDRAWSURFACE4 CDDraw_Manager::CreateSurface(int width, int height, int mem_flags, int ColorKey)
{
//////////////////////////////////////////////////////////////////////////////////////
// Purpose: This Creates am offscreen surface for CImages //
// //////////////////////////// //
// //
//////////////////////////////////////////////////////////////////////////////////////
LPDIRECTDRAWSURFACE4 lpdds; //This is just temporary - it gets return and never used again by CDDraw_Manager
//ddsd is a member of CDDraw_Manager. It is a DDSURFACEDESC2
DDRAW_INIT_STRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS / DDSD_WIDTH / DDSD_HEIGHT; //lets it know all these are valid values
ddsd.dwWidth = width;
ddsd.dwHeight = height;
//Tell it, its offscreen and to the right memory
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN / mem_flags; //this is what tells it to be created in system or VRAM. use VRAM when possible!
//create the surface - THIS IS WHAT ERRORS
if(FAILED(lpdd4->CreateSurface(&ddsd, &lpdds, NULL)))
{
ErrorMessage("Error creating offscreen surface!");
return(NULL);
}
//transparency
if(ColorKey >= 0) //this just makes sure they arent trying to make color -12323 transparent
{
DDCOLORKEY color_key;
color_key.dwColorSpaceHighValue = ColorKey;
color_key.dwColorSpaceLowValue = ColorKey;
//set key for blitting
lpdds->SetColorKey(DDCKEY_SRCBLT, &color_key);
}
//this is what we came for in the first place: the surface
return(lpdds);
}
The ErrorMessage function opens an error file, and writes to it. And on the 2 other computers I've tried running my program on, thats what has happened. Any ideas? You can download the program at www.123.net/~sourmosh/skeltest.zip if you want. I can send anyone the full source if they need it.
Thanks,
Dave
Edited by - ratman on 3/12/00 12:31:38 PM