CreateDevice() fails when using fullscreen mode

Started by
8 comments, last by Nauraushaun 13 years, 4 months ago
Hello there,
I'm attempting to get my program to run full screen instead of windowed, but when I set the PresentParameters windowed attribute to FALSE, CreateDevice() fails. I turned on some debugging to find that it seems to be my PresentParameters being wrongly initialized, though it works fine for windowed mode.
I've looked at many examples and no one seems to be having the same errors. What's more, there seems to be nothing wrong with my parameters, so I've given up and asked here.

Here's my initialization:

Present_Parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;   // Dealing with animation (see doc).	Present_Parameters.BackBufferCount = 1;                  // Number of back buffers.	Present_Parameters.EnableAutoDepthStencil = TRUE;        // Check documentation.	Present_Parameters.AutoDepthStencilFormat = D3DFMT_D16;  // Check documentation.	Present_Parameters.BackBufferFormat = D3DFMT_X8R8G8B8;	Present_Parameters.Flags = 0;	Present_Parameters.hDeviceWindow = hwnd;	Present_Parameters.MultiSampleQuality = 0;	Present_Parameters.MultiSampleType = D3DMULTISAMPLE_NONE;	Present_Parameters.PresentationInterval = 0;


I have also set the relevant fullscreen parameters, like so:
Present_Parameters.Windowed = FALSE;               // Window mode (fullscreen).		Present_Parameters.BackBufferWidth = 1920;		Present_Parameters.BackBufferHeight = 1080;		Present_Parameters.FullScreen_RefreshRateInHz = 60;


Any help would be appreciated, thanks.
Advertisement
In ur DirectX/Tools folder is a programm called D3DCaps Viewer.
Get sure ur Card supports what u want.

For example my card supports in
"D3DFMT_X8R8G8B8 (Fullscreen)" only 2 different Backbuffer Formats.

"D3DFMT_X8R8G8B8 (Windowed)" supports 6 different Backbuffer Formats.

There are Functions like "CheckDeviceType" etc for the Direct3D - Object which can be used to check out what the card suppords.
For u i would suggest u just check out what ur card supports and use it.

Good Luck
I was getting same error as yours. Then i've found these codes that will solve your entire problem.

D3DPRESENT_PARAMETERS d3dpp;		ZeroMemory(&d3dpp, sizeof(d3dpp));								d3dpp.Windowed = FALSE;    // program fullscreen, not windowed		d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // discard old frames		d3dpp.hDeviceWindow = hWnd;    // set the window to be used by Direct3D		d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;    // set the back buffer format to 32-bit		d3dpp.BackBufferWidth = 800;    // set the width of the buffer		d3dpp.BackBufferHeight = 600;    // set the height of the buffer		d3dpp.EnableAutoDepthStencil = true;		d3dpp.AutoDepthStencilFormat = D3DFMT_D16;				pDirect3D->CreateDevice(D3DADAPTER_DEFAULT,								D3DDEVTYPE_HAL,								hWnd,								D3DCREATE_HARDWARE_VERTEXPROCESSING,								&d3dpp,								&pDirect3DDevice);
Quote:Original post by KanTeH
In ur DirectX/Tools folder is a programm called D3DCaps Viewer.
Get sure ur Card supports what u want.

For example my card supports in
"D3DFMT_X8R8G8B8 (Fullscreen)" only 2 different Backbuffer Formats.

"D3DFMT_X8R8G8B8 (Windowed)" supports 6 different Backbuffer Formats.

There are Functions like "CheckDeviceType" etc for the Direct3D - Object which can be used to check out what the card suppords.
For u i would suggest u just check out what ur card supports and use it.

Good Luck

I had a poke around in the caps viewer, and found that my card also only supports two backbuffer formats on fullscreen. But I still don't quite understand. I'm using one of the formats that it supports, why isn't it working?

I've also got this:
if(FAILED(m_Direct3D_Object->CheckDeviceFormat(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,DisplayMode.Format,D3DUSAGE_RENDERTARGET,D3DRTYPE_SURFACE,D3DFMT_A8R8G8B8)))	{		MessageBox(NULL,"Device format is unaccepatble for full screen mode","Sorry",MB_OK);		return false;	}

But it never posts the message, even though it doesn't work.

Baris YILMAZ, that code is more or less what I have :
[Edited by - Nauraushaun on December 6, 2010 3:51:56 PM]
What does Debug Runtime tell you?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Direct3D9: (ERROR) :Unable to create a fullcreen device from a terminal server session. ValidatePresentParameters fails.
D3D9 Helper: IDirect3D9::CreateDevice failed: D3DERR_INVALIDCALL
Quote:Original post by Nauraushaun
Direct3D9: (ERROR) :Unable to create a fullcreen device from a terminal server session. ValidatePresentParameters fails.
Well there's your problem. You can't create a fullscreen device from a terminal server session, because Direct3D can't take exclusive mode.
Oh, I see. I don't really understand though. How do I fix this? Just what is a terminal server session?
Remote login like remote desktop or any other remote service. DX fullscreen only works when logged in as a local session.
Oh I could've guessed that. I almost always program through remote desktop to take advantage of my desktop's bigger resolution. It works perfectly when logged in locally.

Thanks everyone for your help. =]

This topic is closed to new replies.

Advertisement