Skip to main content
GameDev.net gamedev.net
🔒 Locked

cannot instantiate abstract class

Started by PumpkinPieman Jan 12, 2004 at 4:05 AM 8 replies 1k views
Original Post
PumpkinPieman
PumpkinPieman
I''m not quite sure what I''m doing, but I can''t make an instance of the IDirect3D8 class ...
error C2259: ''IDirect3D8'' : cannot instantiate abstract class
        due to following members:
        ''HRESULT IDirect3D8::QueryInterface(const IID &,void ** )'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(168) : see declaration of ''IDirect3D8::QueryInterface''
        ''ULONG IDirect3D8::AddRef(void)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(169) : see declaration of ''IDirect3D8::AddRef''
        ''ULONG IDirect3D8::Release(void)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(170) : see declaration of ''IDirect3D8::Release''
        ''HRESULT IDirect3D8::RegisterSoftwareDevice(void *)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(173) : see declaration of ''IDirect3D8::RegisterSoftwareDevice''
        ''UINT IDirect3D8::GetAdapterCount(void)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(174) : see declaration of ''IDirect3D8::GetAdapterCount''
        ''HRESULT IDirect3D8::GetAdapterIdentifier(UINT,DWORD,D3DADAPTER_IDENTIFIER8 *)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(175) : see declaration of ''IDirect3D8::GetAdapterIdentifier''
        ''UINT IDirect3D8::GetAdapterModeCount(UINT)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(176) : see declaration of ''IDirect3D8::GetAdapterModeCount''
        ''HRESULT IDirect3D8::EnumAdapterModes(UINT,UINT,D3DDISPLAYMODE *)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(177) : see declaration of ''IDirect3D8::EnumAdapterModes''
        ''HRESULT IDirect3D8::GetAdapterDisplayMode(UINT,D3DDISPLAYMODE *)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(178) : see declaration of ''IDirect3D8::GetAdapterDisplayMode''
        ''HRESULT IDirect3D8::CheckDeviceType(UINT,D3DDEVTYPE,D3DFORMAT,D3DFORMAT,BOOL)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(179) : see declaration of ''IDirect3D8::CheckDeviceType''
        ''HRESULT IDirect3D8::CheckDeviceFormat(UINT,D3DDEVTYPE,D3DFORMAT,DWORD,D3DRESOURCETYPE,D3DFORMAT)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(180) : see declaration of ''IDirect3D8::CheckDeviceFormat''
        ''HRESULT IDirect3D8::CheckDeviceMultiSampleType(UINT,D3DDEVTYPE,D3DFORMAT,BOOL,D3DMULTISAMPLE_TYPE)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(181) : see declaration of ''IDirect3D8::CheckDeviceMultiSampleType''
        ''HRESULT IDirect3D8::CheckDepthStencilMatch(UINT,D3DDEVTYPE,D3DFORMAT,D3DFORMAT,D3DFORMAT)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(182) : see declaration of ''IDirect3D8::CheckDepthStencilMatch''
        ''HRESULT IDirect3D8::GetDeviceCaps(UINT,D3DDEVTYPE,D3DCAPS8 *)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(183) : see declaration of ''IDirect3D8::GetDeviceCaps''
        ''HMONITOR IDirect3D8::GetAdapterMonitor(UINT)'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(184) : see declaration of ''IDirect3D8::GetAdapterMonitor''
        ''HRESULT IDirect3D8::CreateDevice(UINT,D3DDEVTYPE,HWND,DWORD,D3DPRESENT_PARAMETERS *,IDirect3DDevice8 ** )'' : pure virtual function was not defined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(185) : see declaration of ''IDirect3D8::CreateDevice''
RenderTarget
RenderTarget
You can''t declare instances of the D3D interfaces. Call Direct3DCreate8() to get a pointer to one.

That should have been the first thing you learned in D3D. Tell me you''re not trying to do this without at least reading the preliminary docs first.

I like pie.
[sub]My spoon is too big.[/sub]
SwSh
SwSh
I know s***t about DX, but in general abstract classes (aka interfaces, so that's the 'I' in front of IDirect3D8) are not to be instantiated. Try deriving from it and defining the pure virtual functions in your derived class if you are sure you should use this class.
But I guess there is another way.

edit: nevermind, I'm slow at typing.
edit2: googling gave: http://www.andypike.com/Tutorials/DirectX8/001.asp
hope it helps.


SwSh website!

[edited by - SwSh on January 12, 2004 5:13:58 AM]


[edited by - SwSh on January 12, 2004 5:17:03 AM]
PhilHalf
PhilHalf
I think it should be a pointer to the interface, i.e.

IDirect3D8 *g_D3D;
if((g_D3D = Direct3DCreate8(D3D_SDK_VERSION)) == NULL)
{
//error

}


Or you can use LPDIRECT3D8 instead of IDirect3D8*.

Hope this helps,

PhilHalf
PumpkinPieman
PumpkinPieman
quote:
Original post by PhilHalf
I think it should be a pointer to the interface, i.e.

IDirect3D8 *g_D3D;
if((g_D3D = Direct3DCreate8(D3D_SDK_VERSION)) == NULL)
{
//error

}


Or you can use LPDIRECT3D8 instead of IDirect3D8*.

Hope this helps,

PhilHalf

I get this

WinMain.obj : error LNK2019: unresolved external symbol _Direct3DCreate8@4 referenced in function _WinMain@16
Debug/Win32APP.exe : fatal error LNK1120: 1 unresolved externals

PhilHalf
PhilHalf
You need to link in the libraries as well as include the header files.
The header file that you need is d3d8.h and the libraries are d3d8.lib and dxguid.lib. Just right click on the solution name on the Solution Explorer, select Properties, go into Linker and in the Command Line Options (I think) you need to type in the two libraries that I''ve mentioned.

Hope this helps,

PhilHalf
PumpkinPieman
PumpkinPieman
quote:
Original post by PhilHalf
You need to link in the libraries as well as include the header files.
The header file that you need is d3d8.h and the libraries are d3d8.lib and dxguid.lib. Just right click on the solution name on the Solution Explorer, select Properties, go into Linker and in the Command Line Options (I think) you need to type in the two libraries that I''ve mentioned.

Hope this helps,

PhilHalf
Yeah it does, but why exactly don''t they mention anything about dxguid.lib in the book? *Programming RolePlaying Games in DX*


PhilHalf
PhilHalf
I''m not sure you actually need dxguid.lib for the example that you gave, but it''s likely that you will use it later for other things. I know for example that you need it to use GUID_SysKeyboard with DirectInput among other things.
You could have just linked d3d8.lib. I seem to remember that Programming RPGs says that you need to link this in a small note box somewhere or something.

PhilHalf

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.