#### Archived

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

# User specified resolution

This topic is 5333 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

At the moment, I am choosing the display mode for when my app switches to full screen as follows:
	// get the number of modes we have on the device
// enumerate available devices
m_pD3D->EnumAdapterModes(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, num-1, &m_display);  
Im using the assumption that the last mode is the highest resolution and bit depth. This seems to be the case and it works great, except for on my laptop where the LCD cant display the highest resolution supported. What I want to do is have a setup file where the resolution is stored. What I want to know is how do I change the above code to get the best mode in a defined resolution? --- The second question is that I currently compile with the following line of code:
	// Create the Direct3D device
//                   the card can support hardware vertex processing
D3DCREATE_HARDWARE_VERTEXPROCESSING, &m_d3dpp, &m_pd3dDevice)))
return E_FAIL;							// failure 
I would like to change it so that it will use hardware vertex processing when it is supported by the graphics card in the system, otherwise use software vertex processing. How would I do this? --- Thanks in advance. Kieran [edited by - Kieran on January 13, 2004 9:53:18 AM]

##### Share on other sites
Well,
I cant say much about your first problem as i am new to DX myself.

As for the second problem , the following code should solve it.

if( FAILED( g_pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_D3DCaps ) ) )
{
return (g_pError->HandleError( "HRESULT CRoadMaxApp::InitializeD3D()" , ERROR_TYPE_D3D ) );
}
DWORD VertexProcessing = 0;

if(m_D3DCaps.VertexProcessingCaps != 0)
VertexProcessing |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
VertexProcessing |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;

if you dont know, then first we get the D3DCAPS ffrom GetDeviceCaps() and then test the DeviceCaps for vertexprocessing. if not zero, then your system supports HARDWARE_VERTEXPROCESSING else software. Now ,use variable VertexProcessing in the foloowing code

VertexProcessing,
&m_d3dpp, &g_pD3DDevice)))

where, m_d3dpp is a D3DPRESENT_PARAMETERS structure

##### Share on other sites
I thought that EnumAdapterModes() only returned modes that would work with your configuration, but maybe they are not guaranteed to work with the monitor, just the device. Maybe CheckDeviceFormat() would work

##### Share on other sites
iron_monkey: That works great, thanks. I was just wondering, why use
|=
=
when assigning the vertex processing type? I can see that it works, but is there a reason that = isnt used?

circlesoft: On most systems, the returned modes are OK, but my laptop (possibly down to a bad monitor driver) thinks it can do higher resolutions than the monitor will handle. I looked into CheckDeviceFormat(), but thats not really what Im looking for. I simply want to enumerate at a specific resolution that I specify (via a setup file).

Thanks for the help so far!
Kieran

##### Share on other sites
Ahh okay I see.

What you need to do then is use the std library or some other file input/output library to read the info in from your file. I know that with std::ifstream it is very easy. Look around for some tutorials maybe

##### Share on other sites
Yes, but how do I get DirectX to just enumerate modes that match a certain resolution?

 After a think about it, I wont use a setup file. What I want it to do is use the resolution that is set on the desktop of the computer. So now, the question is, how do we retreive this information, and still, how do we enumerate only the modes matching that resolution?[/edit]

[edited by - Kieran on January 13, 2004 2:43:06 PM]

##### Share on other sites
I have worked it out. Very easy actually:

// go through the modes finding the correct onefor (UINT i=num; i>0; i--){	// enumerate available devices	m_pD3D->EnumAdapterModes(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, i-1, &m_display);	if (m_display.Width == 800 && m_display.Height == 600) break;}

Ive decided to go against my last post and have a setup file as it will be better if the user can change to the resolution they want.

My questions are pretty much answered now, so thanks a lot all.

One last thing though, from above, why |= and not = ?

[edited by - Kieran on January 13, 2004 2:54:48 PM]

[edited by - Kieran on January 13, 2004 2:55:45 PM]

##### Share on other sites
If anyone is interested, this is how I have loaded the resolutions from file:

	// open resolution setup file	std::ifstream inputf("setup/res.txt");	// if file not open, try other folder	if (!inputf.is_open()) 	{		// try opening file again		std::ifstream inputf("..\\setup/res.txt");			// if still not open, quit		if (!inputf.is_open()) PostQuitMessage(0);	}	// to hold width and height	UINT w, h;	inputf >> w;	inputf >> h;	// close file	inputf.close();

Then this finds the best mode at that resolution:

	// go through the modes finding the correct one	for (UINT i=num; i>0; i--)	{		// enumerate available devices		m_pD3D->EnumAdapterModes(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, i-1, &m_display);		if (m_display.Width == w && m_display.Height == h) break;	}

##### Share on other sites
Well keiran , you could use ''='' sign as well. I use this ''|='' convention only when you can assign several values to a variable such as for example dwFlags type which the values is the result of ''OR''ing individual values. I just used it y''know, since i too i am new in DX, there are so many things that can be assigned so many values by ''OR''ing them. So, i thought what if Vertex processing could have other values? So, you could OR them( if they could be ) and you will get the required result.

##### Share on other sites
That sounds sensible. Out of interest, which is the faster operation, ''|='' or ''='' ? I woulc have thought that it is ''='' as ''|='' requires a comparison between all the bits?

1. 1
2. 2
JoeJ
20
3. 3
frob
19
4. 4
5. 5

• 10
• 11
• 12
• 13
• 9
• ### Forum Statistics

• Total Topics
632206
• Total Posts
3004772

×