Sign in to follow this  
White Scorpion

DX Newb need help with initialization

Recommended Posts

White Scorpion    148
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this