Sign in to follow this  
thekiwimaddog

Full Screen Crash Dual Desktop D3D

Recommended Posts

Hi everyone! I have a problem with my code when running full screen. I have no problems when I have a single monitor setup. But when I try to go full screen with a dual desktop it crashes. I'm not trying to go full screen on both monitors just the primary. I can get it to work if I set the resolution in windows of the second monitor to that which the first monitor will be set to when going full screen. Is there any extra options I need to set when accounting for dual desktops? Many Thanks David
bool InitialiseDX(HWND hWnd)
{
	m_d3dObject=Direct3DCreate9(D3D_SDK_VERSION);
	if (!m_d3dObject)
	{
		CUtility::DebugString("Could not create Direct3D object\n");
		return false;
	}
	 D3DDISPLAYMODE d3ddm;
	m_d3dObject->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm);
	memset(&presParams,0,sizeof(presParams));
	if(Windowed)//Windows Mode
	{
		presParams.Windowed=TRUE;
		presParams.BackBufferFormat=D3DFMT_UNKNOWN;
	}
	else//FullScreen
	{
		presParams.Windowed=FALSE;
		presParams.BackBufferHeight = YRES;
		presParams.BackBufferWidth = XRES;
		presParams.BackBufferFormat=D3DFMT_X8R8G8B8;
	}
	presParams.FullScreen_RefreshRateInHz = 0;
	presParams.SwapEffect=D3DSWAPEFFECT_DISCARD;
	if(TripleBuffer)
		presParams.BackBufferCount=2;//Triple Buffering:2
	else
		presParams.BackBufferCount=1;//Default Double Buffer:1

	if(VSync)
		presParams.PresentationInterval=D3DPRESENT_INTERVAL_ONE;//VSync On:D3DPRESENT_INTERVAL_ONE
	else
		presParams.PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE;//VSync Off:D3DPRESENT_INTERVAL_IMMEDIATE

	presParams.EnableAutoDepthStencil = TRUE;
	presParams.AutoDepthStencilFormat =  D3DFMT_D16;
	//Anti Aliasing
	DWORD total;
	if(SUCCEEDED(m_d3dObject->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,d3ddm.Format,true,D3DMULTISAMPLE_NONMASKABLE,&total)))
	{
		presParams.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE;
		if(AntiAliasing)
			presParams.MultiSampleQuality = total - 1;//Used for detecting max AA
		else
			presParams.MultiSampleQuality = 0;//Disabled
	}

	//Create Object Device
	HRESULT hr=m_d3dObject->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,
		D3DCREATE_HARDWARE_VERTEXPROCESSING, &presParams, &m_d3dDevice);
	if (CUtility::FailedHr(hr))
	{
		// It may be that the machine cannot support vertex processing in hardware so try software instead
		hr=m_d3dObject->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,
			D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presParams, &m_d3dDevice);
		if (CUtility::FailedHr(hr))
		{
			CUtility::DebugString("Could not create Direct3D device\n");
			return false;
		}
	}
	//Setup The Scene
	InitScene();
return true;
}

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