Sign in to follow this  

Errors with DX9

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

Hi all, im trying to convert a tutorial from DX8 to DX9. So far I've done it all but 2 function parameters are still putting up a fight. Heres the code snippet that gives me the following errors:
D3DFORMAT CGame::CheckDisplayMode(UINT nWidth, UINT nHeight, UINT nDepth)
{
	UINT x;
	D3DDISPLAYMODE dm;

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

	return D3DFMT_UNKNOWN;
}


Quote:
'IDirect3D9::EnumAdapterModes' : function does not take 3 arguments 'IDirect3D9::GetAdapterModeCount' : function does not take 1 arguments
I've read the documentation but I still dont understand what I should put in the extra Format parameter. Does anyone know of a fix? (or do I have to create a whole new way to check display modes with DX9?) thanks in advance!

Share this post


Link to post
Share on other sites
From the DX9 help file:

Quote:

EnumAdapterModes Changes
The IDirect3D9::EnumAdapterModes now takes a D3DFORMAT.

HRESULT IDirect3D9::EnumAdapterModes(
UINT Adapter,
D3DFORMAT Format,
UINT Mode,
D3DDISPLAYMODE *pMode);

The format supports an expanding set of display modes. To protect applications from enumerating formats that were not invented when the application shipped, the application must tell Microsoft Direct3D the format for the display modes that should be enumerated. The resulting array of display modes will differ only by width, height, and refresh rate.

The application specifies a pixel format and the enumeration is restricted to those display modes that exactly match the format. The following is a list of the allowed formats:

D3DFMT_A1R5G5B5
D3DFMT_A2B10G10R10
D3DFMT_A8R8G8B8
D3DFMT_R5G6B5
D3DFMT_X1R5G5B5
D3DFMT_X8R8G8B8

Enumeration is equivalent for alpha and nonalpha versions of the same format. The returned Format will always be filled with the same format supplied by the application.

This method treats 565 and 555 as equivalent, and returns the correct version in the Format. The difference comes into play only when the application locks the back buffer, and there is an explicit flag that the application must set in order to accomplish this.

Quote:

UINT GetAdapterModeCount( UINT Adapter,
D3DFORMAT Format
);

Share this post


Link to post
Share on other sites
Yes I've read that plenty of times, though I'm not quite sure what to do with the information given. Does it mean that the new parameter eliminates the need to check which display mode is the right one? If so how do I use it correctly? If not...what exactly is it's purpose. Sorry that SDK explanation just doesn't cut it for me :/

Share this post


Link to post
Share on other sites
AFAICT, you need to pass one of the D3DFMT values to each of the two functions. EnumAdapterModes will then only return modes whose Format matches the one passed in.

Share this post


Link to post
Share on other sites

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