Problem with init D3D
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.
K, I''m sure your Device was NOT created. You try to access it, but it''s not valid so *CRASH*.
.lick
.lick
Here is the code I use. It works. Maybe comparing it to yours will help you figure out what is wrong.
[edited by - JohnBolton on July 27, 2003 3:45:46 AM]
/// @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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement