Archived

This topic is now archived and is closed to further replies.

DirectX 8 fullscreen...

This topic is 6165 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

I have looked through the tutorials from the DirectX 8 SDK and I would like to know how to run my app in fullscreen mode. I have read Furby''s tutorial on using DX8 for 2d, but I had problems getting it to run (just the code for initializing DX8). So Furby, or anyone else out there, could you please reply to this post and take me step by step on how to set the app to fullscreen. Never cross the thin line between bravery and stupidity.

Share this post


Link to post
Share on other sites
Well, it''s a little complicated. First you obtain a pointer to a D3D Interface with Direct3DCreate8(), then you fill in a D3DPRESENT_PARAMETERS struct, and use it with the D3D Interface to create a D3D Device with CreateDevice().

That''s simple, but the problem you''ll run into is that you need to enumerate supported display modes first, because you have to set the screen pixel-format and the back-buffer pixel-format in the D3DPRESENT_PARAMETERS struct. If you set a format the adapter doesn''t support, the CreateDevice() call will fail.

Also if you want to set-up a depth buffer, the pixel-format for this has to be correct as well. In the case of a depth buffer you have to enumerate the supported depth buffer formats associated with each display mode. Set an un-supported format, and again the CreateDevice() call will fail.

The main enumeration functions are EnumAdapterModes(), GetDeviceCaps(), CheckDeviceFormat(), CheckDeviceType(), and CheckDepthStencilMatch(). You really need all these to perform reliable enumeration.

You''ll want to read ''Selecting a Device'' in the SDK which will tell you everything you want to know.

The alternative is just to find a supported mode by trial and error, but then you won''t end up with an app. that will work on a wide variety of video cards. If you want to run full-screen you really need to perform enumeration.

Share this post


Link to post
Share on other sites
I thought you didn''t need to check the present parameters in order to set it to fullscreen. I thought you had to query to see if the mode you were requesting is supported, check if hardware vertex processing is present (for better speed) and then set it.

Hey furby100, I think there might be a glitch in your tutorial. If I''m not mistaken, the CheckDeviceType function takes 5 parameters. If I have the time maybe I can go over some of your tutorial and add some more explanation, then e-mail you back.

Never cross the thin line between bravery and stupidity.

Share this post


Link to post
Share on other sites
Well, you can certainly find out if a particular mode is supported. The trouble is that the mode will be in one specific pixel-format only, so you would need to check if the mode is supported in a variety of pixel formats to guarantee finding a supported mode (my GeForce 2 for instance only supports one 16-bit pixel-format and one 32-bit pixel-format).

As well as supporting different pixel formats, some D3D Adapters will have every mode duplicated in several refresh rates. Also if you want to use depth buffering, there will probably be only a few of the 7 depth buffer format that can be used with any particular resolution, so you would have to test for each of these as well. You could end up doing a lot of checks before finding a working mode.

Plus for the sake of wide compatibility, it''s a good idea to let the program user have a choice of res/colour depth (etc).

You need to supply a completed D3DPRESENT_PARAMETERS to CreateDevice though as far as I know. I could be wrong though , i''ve only just switched to DX8 from 7.

Share this post


Link to post
Share on other sites
I figured it out with a bit of help from furby100''s tutorial. Here is the code I used:

  
//create the present parameters variable

D3DPRESENT_PARAMETERS d3dpp;
//the variable to see if it can run 5-6-5 mode

bool Mode565 =1;

// Create the D3D object, which is needed to create the D3DDevice.

if (NULL == ( lpd3d = Direct3DCreate8( D3D_SDK_VERSION )))
return E_FAIL;

//check to see if it supports 16 bit color

if (lpd3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_R5G6B5,
D3DFMT_R5G6B5, FALSE)!=D3D_OK)
{
//set Mode565 to false

Mode565 = 0;

if (lpd3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X1R5G5B5,
D3DFMT_X1R5G5B5, FALSE)!=D3D_OK)
{
MessageBox(hWnd,"Unable to find 16bit supported hardware!", "Error!", MB_OK);
return(0);
}
}
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Windowed = FALSE;
d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
if (Mode565 == true)
d3dpp.BackBufferFormat = D3DFMT_R5G6B5;
if (Mode565 == false)
d3dpp.BackBufferFormat = D3DFMT_X1R5G5B5;
d3dpp.BackBufferWidth = 800;
d3dpp.BackBufferHeight = 600;
d3dpp.BackBufferCount = 1;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
d3dpp.hDeviceWindow = hWnd;
if(lpd3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &lpd3ddevice)!= D3D_OK)
{
if(lpd3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &lpd3ddevice)!=D3D_OK)
{
MessageBox(hWnd, "Unable to do vertex processing", "Error", MB_OK);
return(0);
}
}

return S_OK;


Never cross the thin line between bravery and stupidity.

Share this post


Link to post
Share on other sites
I also forgot to mention that I am getting a wierd glitch. The mouse cursor stays as an hourglass from when its loading. Anyone know why it could do this?

Never cross the thin line between bravery and stupidity.

Share this post


Link to post
Share on other sites
I am having the same "glitch" Moe. I think I doesn''t change the cursor. If you bring in the cursor from the top it stays a regular arrow. Bring it in from the sides, and it is that resize icon. Bring it in from the corner, and it is a corner resize icon. I think there is some message that we have to put in to make it redraw the cursor. Any help anyone?
~Wave

Share this post


Link to post
Share on other sites
When that happened to me, I looked at my code for loading a cursor and found a bug in that... try something like this

WindowClass.hCursor = LoadCursor(0, IDC_ARROW);

-Domenic-
Geek^n

Share this post


Link to post
Share on other sites
Yeah, thats the glitch Wavewash. It happens in windowed mode just like you said. I eventually am going to turn the cursor off and use a textured poly but it would be nice to get this figured out. furby100, you out there?

Never cross the thin line between bravery and stupidity.

Share this post


Link to post
Share on other sites
Domenic was right. I fooled around for a few minutes and had it working fine. I guess that can be considered a glitch in the DX8 SDK tutorials.

Never cross the thin line between bravery and stupidity.

Share this post


Link to post
Share on other sites