problems with trying to get D3DX9/10 to work in Qt
I’m trying to get D3D9/10/10…..ect to work in Qt4 but it wont create the window at all, it gives an access violation when runned the device must not b e getti ng cvreated….:-( here’s my code.
- header:
- #ifndef CD3D10_H
- #define CD3D10_H
- #include <QWidget>
- #include <D3D10.h>
- #include <DXGI.h>
- #include <D3DX10.h>
- #pragma comment(lib,"d3d10.lib")
- #pragma comment(lib,"d3dx10.lib")
- {
- public:
- ~CD3D10();
- protected:
- bool createD3D10();
- private:
- ID3D10Device* m_pD3D10Dev;
- IDXGISwapChain* m_pD3DSwapChain;
- ID3D10RenderTargetView* m_pRenderView;
- DXGI_SWAP_CHAIN_DESC m_pSwapChainDesc;
- ID3D10Texture2D* m_pBackBuffer;
- D3D10_VIEWPORT m_pViewport;
- IDXGIAdapter* m_pAdapter;
- };
- #endif
- source:
- #include "CD3D10.h"
- {
- this->createD3D10();
- }
- CD3D10::~CD3D10()
- {
- this->m_pD3D10Dev->Release();
- this->m_pD3DSwapChain->Release();
- }
- bool CD3D10::createD3D10()
- {
- ZeroMemory(&this->m_pSwapChainDesc,sizeof(DXGI_SWAP_CHAIN_DESC));
- m_pSwapChainDesc.BufferCount = 1;
- m_pSwapChainDesc.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
- m_pSwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
- m_pSwapChainDesc.OutputWindow = this->winId();
- m_pSwapChainDesc.SampleDesc.Count = 1;
- m_pSwapChainDesc.SampleDesc.Quality = 0;
- m_pSwapChainDesc.Windowed = true;
- HRESULT hr = D3D10CreateDeviceAndSwapChain(NULL,
- D3D10_DRIVER_TYPE_HARDWARE,
- NULL,
- 0,D3D10_SDK_VERSION,
- &this->m_pSwapChainDesc,
- &m_pD3DSwapChain,
- &m_pD3D10Dev
- );
- if(FAILED(hr))
- {
- MessageBoxA(NULL,"Blah, Blah","",MB_OK);
- return false;
- }
- ID3D10Texture2D* buffer;
- m_pD3DSwapChain->GetBuffer(0,__uuidof(ID3D10Texture2D),(LPVOID*)&buffer);
- m_pD3D10Dev->CreateRenderTargetView(buffer,NULL,&this->m_pRenderView);
- buffer->Release();
- m_pD3D10Dev->OMGetRenderTargets(1,&this->m_pRenderView,NULL);
- ZeroMemory(&m_pViewport,sizeof(D3D10_VIEWPORT));
- m_pViewport.TopLeftX = 0;
- m_pViewport.TopLeftY = 0;
- m_pViewport.Width = 800;
- m_pViewport.Height = 600;
- m_pD3D10Dev->RSSetViewports(0,&this->m_pViewport);
- return true;
- }
- {
- m_pD3D10Dev->ClearRenderTargetView(this->m_pRenderView,D3DXCOLOR(0.0f,0.0f,0.5f,0.3f));
- m_pD3DSwapChain->Present(0,0);
- }
- {
- }
hopefully someone can help me
1 reply
You must log in to post a reply. Not a member yet? Register here!
