DIrectX10 Error

Started by
2 comments, last by Tordin 12 years, 10 months ago
I'm trying to learn DirectX10 and am starting to build a basic framework. Only thing is that it keeps failing on the part below:


if( FAILED( d3d->InitDevice(window->GetHwnd()) ) )
{
MessageBox(window->GetHwnd(), "error", "", MB_OK);
d3d->Cleanup();
return 0;
}


and here....I know it's failing right after D3D10CreateDeviceAndSwapChain but is there anything else that anyone sees is wrong. I just started yesterday so I need some pointers.

HRESULT hr = S_OK;

//get the height/width of the client window
RECT rc;
GetClientRect( hwnd, &rc );
UINT width = rc.right - rc.left;
UINT height = rc.bottom - rc.top;

//swap chain and desc
ZeroMemory( &sd, sizeof( sd ) );
sd.BufferCount = 2;
sd.BufferDesc.Width = width;
sd.BufferDesc.Height = height;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hwnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;

//creating the device and swap chain
hr = D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &sd, &swapchain, &device);

if( FAILED( hr ) )
return hr;

//setting the backbuffer to the swap chain
hr = swapchain->GetBuffer( 0, __uuidof( ID3D10Texture2D ), ( LPVOID* )&backBuffer );
if( FAILED( hr ) )
return hr;

hr = device->CreateRenderTargetView(backBuffer, 0, &renderTarget);
backBuffer->Release();
if( FAILED( hr ) )
return hr;

//Create the depth/stencil buffer - set render target
depthDesc.ArraySize = sizeof(D3D10_TEXTURE2D_DESC);
depthDesc.BindFlags = D3D10_BIND_DEPTH_STENCIL;
depthDesc.Width = width;
depthDesc.Height = height;
depthDesc.CPUAccessFlags = 0;
depthDesc.Usage = D3D10_USAGE_DEFAULT;
depthDesc.MipLevels = 0;
depthDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
depthDesc.MiscFlags = 0;

hr = device->CreateTexture2D(&depthDesc, NULL , &depthStencil);
if( FAILED( hr ) )
return hr;

hr = device->CreateDepthStencilView(depthStencil, NULL, &dsView);
if( FAILED( hr ) )
return hr;

device->OMSetRenderTargets(1, &renderTarget, dsView);

//viewport
vp.TopLeftX = 0;
vp.TopLeftY = 0;
vp.Width = width;
vp.Height = height;
vp.MaxDepth = 1;
vp.MinDepth = 0;
device->RSSetViewports(1, &vp);

return S_OK;

[size="5"]http://innercirclegames.freeforums.org
Email me at: innercirclegames@hotmail.com
Advertisement
try setting, BufferUsage = DXGI_USAGE_BACK_BUFFER

and remember to add, D3D10_CREATE_DEVICE_DEBUG to [font=CourierNew, monospace][size=2]D3D10CreateDeviceAndSwapChain's [/font]Flags to get debug errors/warnings on your output window.

dark-hammer engine - http://www.hmrengine.com

What is you GFX card? Is it DX10 capable?
Add your .exe to the debug program.

the debug program will output all the info on what went wrong in the output window in MSVS.

you can find the debug program in the ;
Microsoft DirectX SDK (June 2010)\Utilities\bin\x86\dxcpl.exe

start that and add your program, and force the debug on.
"There will be major features. none to be thought of yet"

This topic is closed to new replies.

Advertisement