DX Newb need help with initialization

Started by
4 comments, last by White Scorpion 19 years, 9 months ago
Hi everyone ! I've been starting D3D8 today with a tutorial on NeXe. I'm compiling pretty often to see if I have errors and when I have finished the following function. I had linker error. It says that there is an extern symbol ( Direct3DCreate8( ) )that is not found in Direct3DInit( ) . Here's the complete source of the functions and some stuff related to it.

#include <windows.h>
#include <d3d8.h> // DirectX 3D v8 header file
#define DEFAULT_REFRESH_RATE 0

struct WindowInfos
{
	static const int Width = 640 ;
	static const int Height = 480 ;
	static const int X = 0 ;
	static const int Y = 0 ;
	static char Title[] ;
	static char Class[] ;
	static HINSTANCE Instance ;
	static HWND Window ;
} ;

char WindowInfos::Title[] = "DirectX" ;
char WindowInfos::Class[] = "DirectX" ;
HWND WindowInfos::Window ;

IDirect3D8* Direct3D ;
IDirect3DDevice8* Device ;
HRESULT Error ;

BOOL Direct3DInit( )
{
	// Create D3D
	Direct3D = Direct3DCreate8( D3D_SDK_VERSION ) ;
	if( Direct3D == NULL )
		return FALSE ;

	// structure to hold infos on the display mode
	D3DDISPLAYMODE displayMode ;
	Error = Direct3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &displayMode ) ;
	if( FAILED( Error ) )
		return FALSE ;

	// Used to explain to Direct3D how it will present things on the screen
	D3DPRESENT_PARAMETERS presentParameters ;
	ZeroMemory( &presentParameters, sizeof( D3DPRESENT_PARAMETERS ) ) ;

	presentParameters.Windowed = TRUE ; // Not fullscreen
	presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD ;
	presentParameters.BackBufferFormat = displayMode.Format ;
	presentParameters.BackBufferHeight = displayMode.Height ;
	presentParameters.BackBufferWidth = displayMode.Width ;

	// Create the device
	Error = Direct3D->CreateDevice( D3DADAPTER_DEFAULT,		// Default display adapter
									D3DDEVTYPE_HAL,			// Hardware acceleration
									WindowInfos::Window,
									D3DCREATE_SOFTWARE_VERTEXPROCESSING,
									&presentParameters,
									&Device ) ;
	if( FAILED( Error ) )
		return FALSE ;
	return TRUE ;
}
Thanks to everyone
Advertisement
I'm not sure if this will work or not but try including d3dx8.h too.
are you linking in d3d8.lib?

"#pragma comment( lib, "d3d8.lib" )"
[size=2]aliak.net
Didn't work.
Oh didn't see the second post, thank you dude that was it.
That's pretty stupid that they don't say wich file to link in the tutorial, they just say wich headers to include.

This topic is closed to new replies.

Advertisement