Creating offscreen surfaces - help please!

Started by
2 comments, last by Destroyer 22 years, 10 months ago
Hi, I''m having trouble creating offscreen surfaces using this function I wrote. This is part of a class called Sprite (duh) and the integer mode variable is just for the settings of whether it should be created in video memory or system memory. The g_lpdd is a IDIRECTDRAW7 interface that has been initialized and it does work - trust me. The Post_Error function just calls a MessageBox function and puts the error string on the message box - and does it pretty damn well So take a look and please just tell me I did something dumb Sprite::Sprite(int xx, int yy, int wwidth, int hheight, int mode)// mode - set to DDSCAPS_VIDEOMEMORY or DDSCAPS_SYSTEMMEMORY { Sprite::x = xx; Sprite::y = yy; Sprite::width = wwidth; Sprite::height = hheight; Sprite::cur_frame = 0; memset(&g_ddsd,0,sizeof(DDSURFACEDESC2)); Sprite::s_ddsd.dwSize = sizeof(Sprite::s_ddsd); Sprite::s_ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CKSRCBLT; Sprite::s_ddsd.dwWidth = wwidth; Sprite::s_ddsd.dwHeight = hheight; Sprite::s_ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | mode; //Different modes - DDSCAPS_VIDEOMEMORY or DDSCAPS_SYSTEMMEMORY if(g_lpdd->CreateSurface(&(Sprite::s_ddsd),&(Sprite::lpddssprite),NULL)!=DD_OK) //dependant on a global - bad { Post_Error("Could not create a surface for a sprite!"); } Sprite::s_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0; Sprite::s_ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 0; DDCOLORKEY color_key = Sprite::s_ddsd.ddckCKSrcBlt; Sprite::lpddssprite->SetColorKey(DDCKEY_SRCBLT, &color_key); } Sorry about the ugly text formatting... Any help would be great Thanks, Destroyer P.S. How do you make those little boxes with code in them in your posts?
Advertisement

memset(&g_ddsd,0,sizeof(DDSURFACEDESC2));

Sprite::s_ddsd.dwSize = sizeof(Sprite::s_ddsd);


Looks to me like you''re not using the same DDSURFACEDESC in both places.

Orbitalx
Nope, s_ddsd is a DDSURFACEDESC2 and I''ve even tried changing the line as well just in case...

Still no good ! And I still don''t know why!

Thanks though...

Any other Ideas?

Thanks,

Destroyer
Whoops... I see what your saying - and hey It works!

Thanks a LOT!

Sincerely,

Destroyer

This topic is closed to new replies.

Advertisement