Problem with init D3D

Started by
13 comments, last by TheGamerHART 20 years, 9 months ago
Now, I''m assuming DirectX.exe is the name of your application. The access violation could be anything, but I get it when I try to dereference a null pointer, deallocated memory, etc. Since the debug doesn''t say anything, it''s probably not a Direct3D problem.
Advertisement
K, I''m sure your Device was NOT created. You try to access it, but it''s not valid so *CRASH*.

.lick
Here is the code I use. It works. Maybe comparing it to yours will help you figure out what is wrong.
/// @param  pD3d            Direct3D object./// @param  hWnd            Window handle./// @param  ppDevice        Where to store the new device./// @param  zBufferFormat   Z-buffer format./// @param  adapter         Which adapter./// @param  deviceType      Device type./// @param  behavior        Behavior (see docs for CreateDevice).HRESULT CreateD3dWindowedDevice( IDirect3D9 *           pD3d,                                 HWND                   hWnd,                                 IDirect3DDevice9 * *   ppDevice,                                 D3DFORMAT              zBufferFormat   /* = D3DFMT_D24S8 */,                                 UINT                   adapter         /* = D3DADAPTER_DEFAULT*/,                                 D3DDEVTYPE             deviceType      /* = D3DDEVTYPE_HAL*/,                                 DWORD                  behavior        /* = D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE*/                               ){    HRESULT     hr;    // Get the format of the desktop    D3DDISPLAYMODE  displayMode;    hr = pD3d->GetAdapterDisplayMode( adapter, &displayMode );    if ( FAILED( hr ) )    {        return hr;    }    // Create the d3d device using the desktop format    D3DPRESENT_PARAMETERS   present;    ZeroMemory( &present, sizeof( present ) );    present.Windowed                = TRUE;    present.SwapEffect              = D3DSWAPEFFECT_DISCARD;    present.BackBufferFormat        = displayMode.Format;    present.EnableAutoDepthStencil  = ( zBufferFormat != D3DFMT_UNKNOWN );    present.AutoDepthStencilFormat  = zBufferFormat;    return pD3d->CreateDevice( adapter, deviceType, hWnd, behavior, &present, ppDevice );}


[edited by - JohnBolton on July 27, 2003 3:45:46 AM]
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
@JohnBolton

can you send me please the whole code (Creating Window, etc.)??


Regards
TheGamer
Or has someone other such kind of code??

This topic is closed to new replies.

Advertisement