• Advertisement

Archived

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

Switching between fullscreen and windowed

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

Hey all, I''m making some basic D3D stuff. I want to be able to have a messagebox that lets you switch from fullscreen to windowed, like in NeHe. Here''s my code:
  
// INSIDE OF WINMAIN()

	// Ask user if he or she wants to be in fullscreen mode

	if( ( MessageBox(NULL,"Would you like to run in fullscreen mode?","Fullscreen",MB_YESNO|MB_ICONQUESTION) == IDYES ) )
	{
		// Fullscreen

		FullScreen = true;
	}

	if (FullScreen)
	{
		ScreenWidth  = GetSystemMetrics( SM_CXFULLSCREEN );	// Set the width of the window

		ScreenHeight = GetSystemMetrics( SM_CYFULLSCREEN );	// Set the height of the window

		Style = WS_POPUP | WS_VISIBLE;						// Set the style of the window

	}
// Now that works, but I''m having trouble with Direct3D.NOte: Im using andy pike tutorials as a guide.


	if( FullScreen )
	{
		// Fullscreen

		d3dpp.Windowed = FALSE;					// Fullscreen

		d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;			// Use default refresh rate

		d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;	// Use a present interval on one

		d3ddm.Format = CheckDisplayMode( ScreenWidth, ScreenHeight, 16 );	// Check for a display mode

	}
// And the definition for CheckDisplayMode is...

D3DFORMAT CheckDisplayMode(UINT nWidth, UINT nHeight, UINT nDepth)
{
    UINT x;
    D3DDISPLAYMODE d3ddm;

    for(x = 0; x < g_pD3D->GetAdapterModeCount(0); x++)
    {
        g_pD3D->EnumAdapterModes(0, x, &d3ddm);
        if(d3ddm.Width == nWidth)
        {
            if(d3ddm.Height == nHeight)
            {
                if((d3ddm.Format == D3DFMT_R5G6B5) || (d3ddm.Format == D3DFMT_X1R5G5B5) || (d3ddm.Format == D3DFMT_X4R4G4B4))
                {
                    if(nDepth == 16)
                    {
                        return d3ddm.Format;
                    }
                }
                else if((d3ddm.Format == D3DFMT_R8G8B8) || (d3ddm.Format == D3DFMT_X8R8G8B8))
                {
                    if(nDepth == 32)
                    {
                        return d3ddm.Format;
                    }
                }
            }
        }
    }

    return D3DFMT_UNKNOWN;
}
  
andypike doesn''t sat much about how to use this, and I don''t really understand. So if any of you could make clear what I am doing wrong, that would be cool. In fullscreen, it says one of those windows error messages. So I know the problem is with Direct3D fullscreen. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
its a great help that you dont even tell the error message you are getting, but i am thinking it is because you are not filling the structs properly because you are just blindly copying code.

so either andy pike is maiking terrible tutorials with too much code and not enough explainations or you are not trying to understand what is presented. not trying to be mean, but you should be more specific as to the problem you are having and what is confusing you. go back and reread the tutorials, and read some other tutorials or maybe even go buy a book. obviously you are still trying to cope with the basics of d3d8 and dont understand the init process yet.

also try making a windowed app and a sperate fullscreen app. then you can easily combine the init code after you understand it.

[edited by - a person on April 20, 2002 6:21:17 PM]

Share this post


Link to post
Share on other sites
Sorry, but you should check out the tut yourself. Thanks for the last sentence though. Does anyone know of any tutorials on how to do fullscreen? I''ve looked at NeXe, DrunkenHyena, and the msdn tutorials, but none say anything about using fullscreen mode.

Share this post


Link to post
Share on other sites
Obviously you didn''t look very hard. Both MSDN and NeXe have tutorials showing both windowed and fullscreen mode. Honestly I can''t possibly imagine how you could miss them.

~CGameProgrammer( );

Share this post


Link to post
Share on other sites
I seem to have become the body of ignorance here or something. Thanks CGameProgrammer, but I figured it out this morning by looking at some other source code.

Share this post


Link to post
Share on other sites

  • Advertisement