Sign in to follow this  
Daniel Miller

About to explode.

Recommended Posts

Where can I find some information on full-screen development using Managed DirectX? Unless I am missing something, the MSDN docs are of little (to no) help. I searched in the FAQ of this forum, and found one link for Managed DirectX, but it uses windowed mode. Should I be looking at the unmanaged docs instead? The lack of information for Managed DX is frustrating.

Share this post


Link to post
Share on other sites
Quote:
Original post by Daniel Miller
Where can I find some information on full-screen development using Managed DirectX?

What sort of information are you looking for? The actual graphical effects and features should be pretty much the same for windowed/fullscreen, it's just the initialisation stage that differs.

If it's a code issue, have you checked what the SDK samples do? they're usually a good reference.

Quote:
Original post by Daniel Miller
The lack of information for Managed DX is frustrating.

Let Microsoft know [smile] - They always seem to be fairly open to constructive critiscm. If you can explain to them what you're trying to find, the fact you tried X-Y-Z to find it, and how/where you'd like to find the information. You never know - they might well take your thoughts into consideration...[attention]

Sorry I can't be of more help
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
... just the initialisation stage that differs ...


Yep, that is it.

I keep getting D3DERR_INVALIDVALL when creating a device. I check the display formats beforehand, so I think it has to do with some presentation parameters that I am omitting. However, nowhere in the docs are those explained in any detail. Will a browse throught the unmanaged docs help, or is the information exclusive to each?

edit: Yes, I just may send them some feedback, though I'm sure the reason they don't have what I'm looking for is becuase of the amazing amount of work it would take, not because they think no one wants it.


edit2: I know there is a PresentParamters page on MSDN, but it really doesn't explain what you need and when/why you need it.

Share this post


Link to post
Share on other sites
Well if you can't find the necessary documentation, I'd hit the sample code.

Load up one (or more) of the basic samples and see how they do their windowed-mode code, given that it was written by the guys at Microsoft you'd hope they got it right [grin]

Jack

Share this post


Link to post
Share on other sites
I personally would first check out the unmanaged docs, since the information there is describing essentially the same thing. Constants and types will have slightly different names, but it's pretty easy to translate most things from the unmanaged to the managed.

If that doesn't help, then I'd try to see some sample code, whether written by Microsoft, or found elsewhere online. See what they did to successfully create a fullscreen window.

If that fails, post some of your code here. Plenty of us have made many of the same mistakes far too many times, and might spot something rather quickly.

Share this post


Link to post
Share on other sites
I have looked through them, but windowed code doesn't share that much in terms of initialization with fullscreen (or so it seems to me; I don't know anything though [grin]).

No matter what I try, I get an error on initialization. I checked to see if the formats I use are supported. They are. I have tried using settings so low that any computer should be able to run it (software everything, 640x480, etc.) and it still won't work. There are also things that I don't understand: when checking to see if a format is supported, you provide both front and back buffer formats, but I don't see where you set the front buffer format when creating the device.

If someone has some simple sample code, or a link to a good tutorial, that would be fantastic. I have searched MSDN, this site, and Google, and everything I have found skims over fullscreen initialization.

Share this post


Link to post
Share on other sites
I haven't done much in C# yet, but here's a wee bit of code I pulled out of a test program of mine. Maybe something in here will help.
if (Windowed)
{
PresentParameters PParams = new PresentParameters();
PParams.EnableAutoDepthStencil = true;
PParams.AutoDepthStencilFormat = DepthFormat.D16;
PParams.DeviceWindow = this;
PParams.MultiSample = MultiSampleType.None;
PParams.MultiSampleQuality = 0;
PParams.PresentFlag = PresentFlag.None;
PParams.BackBufferCount = 1;
PParams.BackBufferWidth = BackbufferWidth;
PParams.BackBufferHeight = BackbufferHeight;
PParams.Windowed = true;
PParams.BackBufferFormat = Format.Unknown;
PParams.FullScreenRefreshRateInHz = 0;
PParams.PresentationInterval = PresentInterval.Immediate;
PParams.SwapEffect = SwapEffect.Copy;

mDevice = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, PParams);
}
else
{
if (Heads == 1)
{
PresentParameters PParams = new PresentParameters();
PParams.EnableAutoDepthStencil = true;
PParams.AutoDepthStencilFormat = DepthFormat.D16;
PParams.DeviceWindow = this;
PParams.MultiSample = MultiSampleType.None;
PParams.MultiSampleQuality = 0;
PParams.PresentFlag = PresentFlag.None;
PParams.BackBufferCount = 1;
PParams.BackBufferWidth = BackbufferWidth;
PParams.BackBufferHeight = BackbufferHeight;
PParams.Windowed = false;
PParams.BackBufferFormat = BackbufferFormat;
PParams.FullScreenRefreshRateInHz = RefreshRate;
PParams.PresentationInterval = PresentInterval.One;
PParams.SwapEffect = SwapEffect.Discard;

mDevice = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, PParams);
}
else
{
PresentParameters[] PParamArray = new PresentParameters[Heads];
mForms = new Form[Heads];

for (int i = 0; i < Heads; ++i)
{
PParamArray[i] = new PresentParameters();
mForms[i] = new Form();
mForms[i].Visible = true;
PParamArray[i].EnableAutoDepthStencil = true;
PParamArray[i].AutoDepthStencilFormat = DepthFormat.D16;
PParamArray[i].DeviceWindow = mForms[i];
PParamArray[i].MultiSample = MultiSampleType.None;
PParamArray[i].MultiSampleQuality = 0;
PParamArray[i].PresentFlag = PresentFlag.None;
PParamArray[i].BackBufferCount = 1;
PParamArray[i].BackBufferWidth = BackbufferWidth;
PParamArray[i].BackBufferHeight = BackbufferHeight;
PParamArray[i].Windowed = false;
PParamArray[i].BackBufferFormat = BackbufferFormat;
PParamArray[i].FullScreenRefreshRateInHz = RefreshRate;
PParamArray[i].PresentationInterval = PresentInterval.One;
PParamArray[i].SwapEffect = SwapEffect.Discard;
}

mDevice = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing | CreateFlags.AdapterGroupDevice, PParamArray);
}
}

Share this post


Link to post
Share on other sites
EDIT: Agony's too quick! [smile]

This is native DX, so not quite what you want - but for reference purposes this is what my engine uses to toggle between fullscreen and windowed. It's all done before the CreateDevice() call:

Common initialisation code used whatever mode:
ZeroMemory( &pp, sizeof( pp ) );		
pp.Windowed = bWindowed;
pp.AutoDepthStencilFormat = D3DFMT_D16;
pp.EnableAutoDepthStencil = true;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
pp.BackBufferCount = bTripleBuffer ? 2 : 1;
pp.PresentationInterval = bVSync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;



Branch executed if using windowed mode:
pD3D9->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &CurrMode );
pp.BackBufferFormat = CurrMode.Format;
pp.BackBufferWidth = iScreenWidth;
pp.BackBufferHeight = iScreenHeight;



Branch executed if using fullscreen mode:
pp.BackBufferWidth = iScreenWidth;
pp.BackBufferHeight = iScreenHeight;
switch ( iScreenDepth ) {
case 32:
pp.BackBufferFormat = D3DFMT_X8R8G8B8;
break;

case 24:
pp.BackBufferFormat = D3DFMT_R8G8B8;
break;

case 16:
pp.BackBufferFormat = D3DFMT_R5G6B5;
break;

default:
pp.BackBufferFormat = CurrMode.Format;
break;
}



hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by DrunkenHyena
If the call is failing there should be a good reason for it and the debug runtime is happy to tell you what it is.

I'd recommend you read the Forum FAQ on debugging D3D apps.


I will look at that, thanks a lot. [smile]

[Edited by - Daniel Miller on June 28, 2005 5:37:59 PM]

Share this post


Link to post
Share on other sites
I just set up the debugger as DH said because the provided code wasn't working, and I got the following error:

Quote:
The application was compiled against and will only work with D3D_SDK_VERSION (32), but the currently installed runtime is version (31).

Ugh.

Could this be because I, at one point, installed the June update of the SDK, but currently have an older version installed (I was required to use it to work on a much larger application)?

edit: I noticed that another one of my programs that used to work shows that now, too. Still, it may be that this problem wasn't fatal to that program, but is to this one (but if run in Debug mode DX will break no matter what).

edit2: I have the 2003 summer update. :
I will uninstall and get the new version (and hope I won't need to use the older one again [grin]). Please work...

[Edited by - Daniel Miller on June 28, 2005 5:46:21 PM]

Share this post


Link to post
Share on other sites
Okay, I got the new DirectX SDK installed, and...

It seems I have to compile my program in Release mode to get any DX debugger information? Is this normal? D3D output is on high, and it is set for Debug mode.

In release mode, this is what I am told:

Quote:
Direct3D9: (ERROR) :Invalid value for BackBufferFormat. ValidatePresentParameters fails.


However, take a look at my code:


...

if (!Direct3D.Manager.CheckDeviceType(Direct3D.Manager.Adapters.Default.Adapter,
Direct3D.DeviceType.Hardware, Format.X8R8G8B8, Format.X8R8G8B8, false))
//Look at the formats used: X8R8G8B8
{
throw new Exception("Can't support formats.");
}

...

presentParams.BackBufferFormat = Direct3D.Format.X8B8G8R8;
//See how I use the same format here?
//Should I be setting the front buffer format somewhere?
//I don't know how, and the code that you guys provided didn't do it either.

...

d3dDevice = new Direct3D.Device(0, Direct3D.DeviceType.Hardware,
this, CreateFlags.HardwareVertexProcessing, presentParams);


Share this post


Link to post
Share on other sites
It would have helped if you could have listed all the presentParams that you are using for switching to fullscreen. However, the following bit should work because it's using the current desktop values for the back buffer format:


PresentParameters presentParams = new PresentParameters();
presentParams.SwapEffect = SwapEffect.Discard;

Format current = Manager.Adapters[0].CurrentDisplayMode.Format;

if (Manager.CheckDeviceType(0, DeviceType.Hardware, current, current, false))
{
// Perfect, this is valid
presentParams.Windowed = false;
presentParams.BackBufferFormat = current;
presentParams.BackBufferCount = 1;
presentParams.BackBufferWidth = ScreenWidth; //specify the width and
presentParams.BackBufferHeight = ScreenHeight; //height somewhere
}
else
presentParams.Windowed = true;

device = new Direct3D.Device(0, Direct3D.DeviceType.Hardware,
this, CreateFlags.HardwareVertexProcessing, presentParams);



If the above works then try setting the backbuffer format specifically to the one you want and repeat. It could also be that the backbuffer format is not supported for the resolution you are trying to set it to?

Share this post


Link to post
Share on other sites
Well, the first thing that I notice is that you're checking to see if the RGB type is supported, but then you're trying to set it to a BGR type, where the color components are reversed in order. Might just be a typo. Try X8R8G8B8 instead of X8B8G8R8.

Share this post


Link to post
Share on other sites
Quote:
Original post by Agony
Well, the first thing that I notice is that you're checking to see if the RGB type is supported, but then you're trying to set it to a BGR type, where the color components are reversed in order. Might just be a typo. Try X8R8G8B8 instead of X8B8G8R8.


Agony, how on earth did you see that!? I would never have caught that, and that was the problem! Sorry for bothering you all, I will now remeber to check the order of the color formats. That's what scrolling through the intellisense list will do to you! [grin]


edit: Why is it that you don't get DirectX's debug spew when your program is compiled in debug mode? I have to compile in release before I get any info (D3D is in debug mode with output on high).

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