Thread: errors initializing D3D

  1. #1
    Hello World!
    Join Date
    Jul 2005
    Location
    Sebastopol
    Posts
    2

    errors initializing D3D

    I've created the window and I'm trying to initialize d3d in one of my projects. Here's the code I'm using:

    #include <d3d9.h>
    ...

    IDirect3D9 g_pD3D;
    if (NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
    return E_FAIL;
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
    if (FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hw nd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&g_p d3dDevice)))
    return E_FAIL;

    I have all the directories set up correctly and I get the following errors:

    main.cpp(40) : error C2259: 'IDirect3D9' : cannot instantiate abstract class
    due to following members:
    'HRESULT IDirect3D9::QueryInterface(const IID &,void ** )' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(232) : see declaration of 'IDirect3D9::QueryInterface'
    'ULONG IDirect3D9::AddRef(void)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(233) : see declaration of 'IDirect3D9::AddRef'
    'ULONG IDirect3D9::Release(void)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(234) : see declaration of 'IDirect3D9::Release'
    'HRESULT IDirect3D9::RegisterSoftwareDevice(void *)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(237) : see declaration of 'IDirect3D9::RegisterSoftwareDevice'
    'UINT IDirect3D9::GetAdapterCount(void)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(238) : see declaration of 'IDirect3D9::GetAdapterCount'
    'HRESULT IDirect3D9::GetAdapterIdentifier(UINT,DWORD,D3DADA PTER_IDENTIFIER9 *)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(239) : see declaration of 'IDirect3D9::GetAdapterIdentifier'
    'UINT IDirect3D9::GetAdapterModeCount(UINT,D3DFORMAT)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(240) : see declaration of 'IDirect3D9::GetAdapterModeCount'
    'HRESULT IDirect3D9::EnumAdapterModes(UINT,D3DFORMAT,UINT,D 3DDISPLAYMODE *)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(241) : see declaration of 'IDirect3D9::EnumAdapterModes'
    'HRESULT IDirect3D9::GetAdapterDisplayMode(UINT,D3DDISPLAYM ODE *)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(242) : see declaration of 'IDirect3D9::GetAdapterDisplayMode'
    'HRESULT IDirect3D9::CheckDeviceType(UINT,D3DDEVTYPE,D3DFOR MAT,D3DFORMAT,BOOL)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(243) : see declaration of 'IDirect3D9::CheckDeviceType'
    'HRESULT IDirect3D9::CheckDeviceFormat(UINT,D3DDEVTYPE,D3DF ORMAT,DWORD,D3DRESOURCETYPE,D3DFORMAT)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(244) : see declaration of 'IDirect3D9::CheckDeviceFormat'
    'HRESULT IDirect3D9::CheckDeviceMultiSampleType(UINT,D3DDEV TYPE,D3DFORMAT,BOOL,D3DMULTISAMPLE_TYPE,DWORD *)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(245) : see declaration of 'IDirect3D9::CheckDeviceMultiSampleType'
    'HRESULT IDirect3D9::CheckDepthStencilMatch(UINT,D3DDEVTYPE ,D3DFORMAT,D3DFORMAT,D3DFORMAT)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(246) : see declaration of 'IDirect3D9::CheckDepthStencilMatch'
    'HRESULT IDirect3D9::CheckDeviceFormatConversion(UINT,D3DDE VTYPE,D3DFORMAT,D3DFORMAT)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(247) : see declaration of 'IDirect3D9::CheckDeviceFormatConversion'
    'HRESULT IDirect3D9::GetDeviceCaps(UINT,D3DDEVTYPE,D3DCAPS9 *)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(248) : see declaration of 'IDirect3D9::GetDeviceCaps'
    'HMONITOR IDirect3D9::GetAdapterMonitor(UINT)' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(249) : see declaration of 'IDirect3D9::GetAdapterMonitor'
    'HRESULT IDirect3D9::CreateDevice(UINT,D3DDEVTYPE,HWND,DWOR D,D3DPRESENT_PARAMETERS *,IDirect3DDevice9 ** )' : pure virtual function was not defined
    C:\DXSDK\Include\d3d9.h(250) : see declaration of 'IDirect3D9::CreateDevice'
    main.cpp(41) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'IDirect3D9 *' (or there is no acceptable conversion)
    main.cpp(48) : error C2819: type 'IDirect3D9' does not have an overloaded member 'operator ->'
    C:\DXSDK\Include\d3d9.h(229) : see declaration of 'IDirect3D9'
    did you intend to use '.' instead?
    main.cpp(48) : error C2227: left of '->CreateDevice' must point to class/struct/union
    type is 'IDirect3D9'
    did you intend to use '.' instead?


    Can someone shed some light?

    BTW: I'm using the Visual C++ Toolkit.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I'm not an expert at directx but I would guess that g_pD3D should be a pointer to an IDirect3D9 object
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Please use [code][/code]Tags
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    This error
    Code:
    main.cpp(48) : error C2819: type 'IDirect3D9' does not have an overloaded member 'operator ->'
    is weird . . . you can't overload the operator ->.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. Initializing D3D Window with Options
    By Ti22 in forum Windows Programming
    Replies: 0
    Last Post: 03-22-2006, 09:14 AM
  3. Why am I getting these errors??
    By maxthecat in forum Windows Programming
    Replies: 3
    Last Post: 02-03-2006, 01:00 PM
  4. DirectX9 compile errors
    By maxthecat in forum Windows Programming
    Replies: 5
    Last Post: 01-01-2006, 10:33 PM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM