Jump to content
  • Advertisement
Sign in to follow this  
White Scorpion

DX Newb need help with initialization

This topic is 5097 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!