Sign in to follow this  
Osaou

DirectDraw Blt weirdness!

Recommended Posts

In short: I sometimes seem unable to blit the contents of a DirectDraw 7 surface on another ditto. No error is returned (I.E. DD_OK is returned), but the target surface in effect only gets zeroed out... or filled with black if you so will. I use the standard Blt method, and it doesn't matter how large a destination RECT I pick - the entire surface always gets blanked out. In detail: I have a surface containing whatever, that I know work fine. I can show it on the screen fine in a windowed or fullscreen, double buffered mode. No problem so far. Now I create a new surface and set its colour space with the following code (colourKey being a value other than black, 0):
DDSURFACEDESC2 surfdesc;
memset( &surfdesc,0,sizeof(surfdesc) );

surfdesc.dwSize = sizeof(surfdesc);
surfdesc.dwFlags = (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT);
surfdesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surfdesc.dwWidth = width;
surfdesc.dwHeight = height;

LPDIRECTDRAWSURFACE7 surface;
m_dd->CreateSurface( &surfdesc, &surface, NULL );

DDCOLORKEY key;
key.dwColorSpaceLowValue = colourKey;
key.dwColorSpaceHighValue = colourKey;
surface->SetColorKey( DDCKEY_SRCBLT, &key );
Error checking removed for terseness. This is the same code I use when I create a second buffer for a windowed environment. After this I fill the surface with the colourKey value and then draw the source surface content on it, like so:
DDBLTFX effects;
memset( &effects,0,sizeof(effects) );
effects.dwSize = sizeof(effects);
effects.dwFillColor = colorKey;

surface->Blt( NULL,NULL,NULL, (DDBLT_COLORFILL | DDBLT_WAIT), &effects );



RECT whole = {0,0, width,height};

surface->Blt( &whole, sourceSurface,&whole, (DDBLT_WAIT | DDBLT_KEYSRC),NULL );
Again, error checking is here removed for brevity and clarity. None of the above calls return any errors. And yet the content of surface after all this is nothing. I've been writing DirectDraw applications for a few years now and have never encountered this issue before. Do anyone have a clue as to what might be the problem here?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this