Sign in to follow this  

[dx8] Fullscreen troubles... [solved]

This topic is 4546 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 guys, sorry for the newb question but, this code doesn't work in fullscreen (surprised?) I get an error on the CreateDevice() call, I tried looking it up but it was some weird negative number that didn't match anything. Oh, and it doesn't work in REF either.
// Initialize D3D!!!!!! //

D3DDISPLAYMODE		d3ddm;
D3DPRESENT_PARAMETERS	d3dpp;
ZeroMemory(&d3ddm, sizeof(d3ddm));
ZeroMemory(&d3dpp, sizeof(d3dpp));


if((m_pD3D = Direct3DCreate8(D3D_SDK_VERSION))==NULL)
	return FALSE;


if( m_Windowed )	// Works
{
	if(FAILED(m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
		return FALSE;

	d3dpp.Windowed         = TRUE;
	d3dpp.SwapEffect       = D3DSWAPEFFECT_COPY_VSYNC;
	d3dpp.BackBufferFormat = d3ddm.Format;
}
else	// Make FullScreen -Doesn't work
{
	// Find the matching fullscreen display mode
	for(UINT x = 0; x < m_pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT); x++)
	{
		m_pD3D->EnumAdapterModes(0, x, &d3ddm);
		if(d3ddm.Width == m_Width)
		{
			if(d3ddm.Height == m_Height)
			{
				if((d3ddm.Format == D3DFMT_R5G6B5) || (d3ddm.Format == D3DFMT_X1R5G5B5)
					|| (d3ddm.Format == D3DFMT_X4R4G4B4))
				{
					if(m_Depth == 16)
					{
						break;	// found the right format
					}
				}
				else if((d3ddm.Format == D3DFMT_R8G8B8) || (d3ddm.Format == D3DFMT_X8R8G8B8))
				{
					if(m_Depth == 32)
					{
						break;	// found the right format
					}
				}
			}
		}// end for loop
	}

	d3dpp.Windowed				= FALSE;
	d3dpp.FullScreen_RefreshRateInHz	= D3DPRESENT_RATE_DEFAULT;
	d3dpp.FullScreen_PresentationInterval	= D3DPRESENT_INTERVAL_ONE;

	d3dpp.BackBufferCount	= 1;
	d3dpp.BackBufferWidth	= m_Width;
	d3dpp.BackBufferHeight	= m_Height;
	d3dpp.BackBufferFormat	= m_Format = d3ddm.Format;


}// end else if fullscreen


 //Create a Direct3D device.
if(FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
                               D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &m_pD3DDevice)))
	return FALSE; // enters here, it failed





I hate this bug, please squash it :) EDIT: Addled "[solved]" to title. What a newbish thread of mine :/ [Edited by - The Forgotten Mindset on July 2, 2005 12:43:43 AM]

Share this post


Link to post
Share on other sites
What are you settings the width, height, and depth too? I'm having no problem running this code (other than I seem to have a memory leak for no reason at all.)

Scratch that, I'm stupid and I was running it in windowed mode.

I get this error:
Direct3D8: (ERROR) :Invalid parameter for SwapEffect for D3DPRESENT_PARAMETERS. Must be one of D3DSWAPEFFECTS_COPY, D3DSWAPEFFECTS_COPY_VSYNC, D3DSWAPEFFECTS_DISCARD, or D3DSWAPEFFECTS_FLIP. CreateDevice/Reset Fails.

Share this post


Link to post
Share on other sites
I can tell that there is a memory leak by my debugger (I'm using the debug version of D3D.) Also, check my above post, I edited it.

I get this error:
Direct3D8: (ERROR) :Invalid parameter for SwapEffect for D3DPRESENT_PARAMETERS. Must be one of D3DSWAPEFFECTS_COPY, D3DSWAPEFFECTS_COPY_VSYNC, D3DSWAPEFFECTS_DISCARD, or D3DSWAPEFFECTS_FLIP. CreateDevice/Reset Fails.

I don't see where you are setting the swap effect for the fullscreen block. I set it to D3DSWAPEFFECT_DISCARD and it works fine (wow, check that out. The error didn't spell it correctly (they added a S just before the underscore.)

Also, you should do a double check for creating the device:

if(FAILED_TO_CREATE_HARDWARE)
{
if(FAILED_TO_CREATE_SOFTWARE)
{
D3D Doesn't exist
return error
}
software was created
}

That way people such as I that have a good graphics card but bad processor (Celeron) can take advantage of hardware.

Edit again: Can I use this code?

Share this post


Link to post
Share on other sites
Heck yeah!

Thanks, so much! How do you get those error descriptions, I've got the debug dll installed already.

This line of work gets so tedious :)

Ahh, a blank screen. I haven't seen one of those in over a month. [smile]

I'd rate you up, but I already did on my last thread :)

EDIT:

Yes, use this code to your heart's desire :) (that enumerating bit was stolen anyways [grin])

And I was going to get around to that double checking later on just so you know :)

Share this post


Link to post
Share on other sites
I'm using Microsoft Visual C++ 6, and I have the debug output set to max (in the DirectX Control Panel app). Thanks!

The first time I got a blank screen in directx I was showing it to everybody, and they were like "WTF mate?" You've been learning this stuff for 4 years and that is all you've got!? And I say "lets see you do it [grin]"

Edit: And I didn't do it for the ratings, so that doesn't matter :D Chances are you'll help me sometime down the road.

Share this post


Link to post
Share on other sites

This topic is 4546 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.

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