Original Post
Hi! I''ve been developing a third person rpg and I''ve ran into some problems with the D3D initialization. At the last function of the code below, it crashes out? Why is this? It worked fine before, but recently I saw the topic over a D3D iso engine. So, to make a long story short, I followed the code to improve my own. I had to do allot of stuff to convert it to Dx7, but I believe I did it right. I think it''s because I''m trying to add a back buffer. Before, I had an offscreen surface and I just blitted it to the primary. But, since I read the tutorial on the 3d iso engine, I saw him use the back buffer and flipping chains. What am I doing wrong exactly? Thanks for reading!
Justin Eslinger
////// PROBLEM CODE ///////
if (FAILED(DirectDrawCreateEx(NULL, (VOID**)&lpdd,
IID_IDirectDraw7, NULL)))
{
return(0);
}
if (FAILED(lpdd->SetCooperativeLevel(g_hWnd, DDSCL_ALLOWMODEX / DDSCL_FULLSCREEN / DDSCL_EXCLUSIVE /
DDSCL_ALLOWREBOOT / DDSCL_FPUSETUP )))
{
return(0);
}
if (FAILED(lpdd->SetDisplayMode( SCREEN_WIDTH,
SCREEN_HEIGHT, SCREEN_BPP,0,0)))
{
return(0);
}
memset( &ddsd,0,sizeof(DDSURFACEDESC2) );
ddsd.dwSize = sizeof(DDSURFACEDESC2);
ddsd.dwFlags = DDSD_CAPS / DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE /
DDSCAPS_COMPLEX / DDSCAPS_FLIP / DDSCAPS_3DDEVICE;
ddsd.dwBackBufferCount = 1;
if (FAILED(lpdd->CreateSurface( &ddsd, &lpddsprimary, NULL
)))
{
MessageBox(g_hWnd,"Error creating the Primary
Surface!","Engine",MB_OK);
return(0);
}
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER / DDSCAPS_3DDEVICE;
ddsd.dwBackBufferCount = 1;
if (FAILED(lpddsprimary->GetAttachedSurface(
&ddsd.ddsCaps,&lpddsback)))
{
MessageBox(g_hWnd,"Error attaching the Secondary
Surface!","Engine",MB_OK);
return(0);
};
ClipMinX = 0;
ClipMinY = 0;
ClipMaxX = SCREEN_WIDTH - 1;
ClipMaxY = SCREEN_HEIGHT - 1;
RECT ScreenRect = {0,0, SCREEN_WIDTH, SCREEN_HEIGHT};
Clipper = DD_AttachClipper(lpddsback, 1, &ScreenRect);
if (FAILED(lpdd->QueryInterface( IID_IDirect3D7, (VOID**)
&lpd3d)))
{
MessageBox(g_hWnd,"Error querying the DD
interface!","Engine",MB_OK);
return(0);
}
ddsd.dwSize = sizeof(DDSURFACEDESC2);
if (FAILED(lpd3d->CreateDevice( IID_IDirect3DHALDevice,
lpddsback, &lpd3dDev)))
{
if (FAILED(lpd3d->CreateDevice
(IID_IDirect3DRGBDevice, lpddsback,&lpd3dDev )))
{
MessageBox(g_hWnd,"Error creating D3D
Device!","Engine Problems",MB_OK);
return(0);
}
return(0);
}
////// END PROBLEM ///////