Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Problems with trying to get D3DX9/10 to work in Qt
QtWS25 Last Chance

Problems with trying to get D3DX9/10 to work in Qt

Scheduled Pinned Locked Moved Game Development
2 Posts 2 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    ProgrammerAtHeart3344
    wrote on last edited by
    #1

    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")

    class CD3D10 : public QWidget
    {
    public:
    CD3D10(QWidget* parent = 0);

    ~CD3D10();

    protected:
    bool createD3D10();
    void paintEvent(QPaintEvent *);
    void resizeEvent(QResizeEvent *);

    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"

    CD3D10::CD3D10(QWidget* parent /* = 0 */)
    : QWidget(parent)
    {
    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;

    }

    void CD3D10::paintEvent(QPaintEvent *paint)
    {
    m_pD3D10Dev->ClearRenderTargetView(this->m_pRenderView,D3DXCOLOR(0.0f,0.0f,0.5f,0.3f));

    m_pD3DSwapChain->Present(0,0);

    }

    void CD3D10::resizeEvent(QResizeEvent *event)
    {

    }

    @
    hopefully someone can help me

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      As far as I know, you should override the paint event to a null function and do your rendering from another function.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved