Archived

This topic is now archived and is closed to further replies.

Bltting problem

This topic is 6032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My program was working fine until I updated it to the Directx7 interface. Now it refuses to blt and just shuts down and I can''t figure out why.

Share this post


Link to post
Share on other sites
When does it shutdown, on init, blt, flip?

Post your code so we can see where it goes wrong, or compare your init and blt routines with the SDK samples.



Demo Download: www.angelfire.com/realm/zeroone

Share this post


Link to post
Share on other sites
First of all, The window''s size you''re creating is 600x400.
You should create the window as the same size as the display (800x600 in your case). Not sure if it really matters, but still



- Goblineye Entertainment
The road to success is always under construction

Share this post


Link to post
Share on other sites
Actually I got to thinking about it more. I was having the same problem. For sanity''s sake, test all of your DD calls like this:

if ( FAILED( lpDD->CreateSurface( &ddsd2,&lpDDSPrimary,NULL ) ) )
{
return Fail( hWnd, "Couldn''t create primary surface.\n" );
}

BOOL App::Fail( HWND hwnd, char *szMsg )
{
ReleaseObjects();
OutputDebugString( szMsg );
DestroyWindow( hwnd );
return FALSE;
}

Run every thing from the debugger to get the OutputDebugString( szMsg ) output in your debug window(VC6).

If you find that the error is that one of the surfaces is not being created, most likely the case, I think you''ll need to change your ddsd settings. The requirements seem to be a little different for dx7. In the MSSDK7 documents C:\MSSDK7\doc\DirectX7\Word in the ddraw.doc file page 44 describes the requirements. Use this as a template and experiment til it works. Remember to tweek this for all surfaces you create. Oh yeah, either memset the ddsd to all 0 or use a new one for each surface. Here''s what''s working for me:

DDSURFACEDESC2 ddsd2;
#define WIDTH 800 // in pixels
#define HEIGHT 600
#define DEPTH 3 // in bytes (3bytes == 24 bits)

LPVOID lpSurface = NULL;
HLOCAL hMemHandle = NULL;


ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
ZeroMemory(&ddsd2.ddpfPixelFormat, sizeof(DDPIXELFORMAT));
ddsd2.dwSize = sizeof(ddsd2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_VIDEOMEMORY;
ddsd2.dwWidth = WIDTH;
ddsd2.dwHeight= HEIGHT;
ddsd2.lPitch = (LONG)DEPTH * WIDTH;
ddsd2.lpSurface = lpSurface;
ddsd2.dwBackBufferCount = 1;

if ( FAILED( lpDD->CreateSurface( &ddsd2,&lpDDSPrimary,NULL ) ) )
{
return Fail( hWnd, "Couldn''t create primary surface.\n" );
}

and then for a sprite surface...

DDSURFACEDESC2 ddsd2;
#define DEPTH 3 // in bytes (3bytes == 24 bits)
LPVOID lpSurface = NULL;
HLOCAL hMemHandle = NULL;


ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
ZeroMemory(&ddsd2.ddpfPixelFormat, sizeof(DDPIXELFORMAT));
ddsd2.dwSize = sizeof(ddsd2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT |
DDSD_WIDTH | DDSD_CKSRCBLT;

ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;

ddsd2.dwWidth = m_nImageWidth;
ddsd2.dwHeight= m_nImageHeight;
ddsd2.lPitch = (LONG)DEPTH * m_nImageWidth;
ddsd2.lpSurface = lpSurface;

if ( FAILED( lpDD->CreateSurface( &ddsd2, &image, NULL ) ) )
{
return Fail( "Couldn''t create off-screen surface.\n" );
}

Share this post


Link to post
Share on other sites