   Initialising directx10
  I've written a few applications using directx 9 and am now teaching myself to use dx10.I'm having trouble initialising it though. Everything seems normal, the device is created, all my HRESULTS are ok, but when I come to bind the render target, it doesn't work. Before the call to OMGetRenderTargets, my renderTargetView has been populated - the pointer is non-zero -  but as soon as I try to call OMGetRenderTargets, the pointer gets set to 0, meaning it crashes as soon I try and do anything with it. I've checked a few tutorials and I seem to be doing everything in order. Here's my code:void DX10Renderer::initialise(){// create swap chainDXGI_SWAP_CHAIN_DESC scd;scd.BufferCount = 1;scd.BufferDesc.Width = m_width;scd.BufferDesc.Height = m_height;scd.BufferDesc.RefreshRate.Numerator = 60;scd.BufferDesc.RefreshRate.Denominator = 1;scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;scd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;scd.SampleDesc.Count = 1;scd.SampleDesc.Quality = 0;scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;scd.OutputWindow = m_hWnd;scd.Windowed = true;scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;scd.Flags = 0;// create deviceHRESULT result;UINT createDeviceFlags = 0;#if defined(DEBUG) || defined(_DEBUG)createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;#endifresult = D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, D3D10_SDK_VERSION, &scd, &m_swapChain, &m_d3dDevice);DXerror(result);// create render targetDXerror(m_swapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), reinterpret_cast<void**>(&m_backBuffer)));DXerror(m_d3dDevice->CreateRenderTargetView(m_backBuffer, 0, &m_renderTargetView));m_backBuffer->Release(); // need this because the call to GetBuffer adds an extra COM referencem_d3dDevice->OMGetRenderTargets(1, &m_renderTargetView, NULL);// set viewportD3D10_VIEWPORT vp;vp.Height = m_height;vp.Width = m_width;vp.MaxDepth = 1;vp.MinDepth = 0;vp.TopLeftX = 0;vp.TopLeftY = 0;m_d3dDevice->RSSetViewports(1, &vp);const FLOAT clearColour[4] = {1.0f, 1.0f, 1.0f, 1.0f};m_d3dDevice->ClearRenderTargetView(m_renderTargetView, clearColour);m_swapChain->Present(0, 0);}inline void DX10Renderer::DXerror(HRESULT hr){#if defined(DEBUG) | defined(_DEBUG)if (FAILED(hr)){std::string message(DXGetErrorDescription(hr));MessageBox(0, message.c_str(), "DirectX Error", MB_OK);}#endif}
  You don't want OMGetRenderTargets, but OMSetRenderTargets. The one you use now retrieves the currently set render target, where you want to set it to the one you created.   ;  Doh! I can't believe I didn't spot that!Thanks :-)   