Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problems w/ Initialization (Kinda big)

Started by BlackScar Mar 9, 2000 at 7:13 PM 3 replies 700+ views
Original Post
BlackScar
BlackScar
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 ///////
~-=-=-=-=-=-=~~Justin Eslinger~~.."BlackScar"..~~-=-=-=-=-=-=~
Cloxs
Cloxs
Look at the source code that he provided, and you may be able to solve your problem - I know it helped solve mine.
Nytegard
Nytegard
Try changing:

if (FAILED(lpd3d->CreateDevice( IID_IDirect3DHALDevice,
lpddsback, &lpd3dDev)))

to

if (FAILED(lpd3d->CreateDevice( IID_IDirect3DRGBDevice,
lpddsback, &lpd3dDev)))

Or, if you want, click here to download some stripped code from the Direct 3D Enumeration tutorial. Since technically Microsoft wrote this, and I''m infringing on their copyright, it will only be up for a little while.
BlackScar
BlackScar
I added this code below to replace this line at the top :
--------
if (FAILED(DirectDrawCreateEx(NULL, (VOID**)&lpdd,
IID_IDirectDraw7, NULL)))
{
return(0);
}
--------

And now I get an error here :

------------
if (FAILED(lpdd->QueryInterface( IID_IDirect3D7, (LPVOID *)
&lpd3d)))
{
MessageBox(g_hWnd,"Error querying the DD
interface!","Engine",MB_OK);
return(0);
}
-------------

The change I made went with the tutorial... but now I get a new error.

Justin Eslinger

///// New code //
LPDIRECTDRAW lpddTemp = NULL;

if (FAILED(DirectDrawCreate(NULL,&lpddTemp,NULL)))
{
MessageBox(g_hWnd, "Unable to get DD 1", "Engine
Problems", MB_OK);
return(0);
};

if (FAILED(lpddTemp->QueryInterface
IID_IDirectDraw7,(LPVOID *)&lpdd)))
{
MessageBox(g_hWnd, "Can''t get the lastest version",
"Engine", MB_OK);
return(0);
};

/// End new code //
~-=-=-=-=-=-=~~Justin Eslinger~~.."BlackScar"..~~-=-=-=-=-=-=~

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.