Sign in to follow this  
Nauraushaun

CreateDevice() fails when using fullscreen mode

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Direct3D9: (ERROR) :Unable to create a fullcreen device from a terminal server session. ValidatePresentParameters fails.
D3D9 Helper: IDirect3D9::CreateDevice failed: D3DERR_INVALIDCALL

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Remote login like remote desktop or any other remote service. DX fullscreen only works when logged in as a local session.

Share this post


Link to post
Share on other sites
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. =]

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