Acknowledge Irrlicht of maximum screen size and ratio
-
- Posts: 115
- Joined: Mon May 17, 2010 7:42 am
Acknowledge Irrlicht of maximum screen size and ratio
Hi, anyone know how to get Irrlicht know wich is the maximum screen size on the machine the game is running in?
1) Wich method give the max Screen resolution for full screen mode (if the desktop is 800x600 but the monitor can use higher resolution, the user can choose to run the game in full screen at 1024x768 for example)
2) wich method give the actual screen resolution when running in windowed mode (you can create a 2000x2000 window on a 1024x768 desktop with irrlicht, so if you know the desktop is 1024x768 you will resize the window to a smaller size)
3) how to know if the screen uses 16:9 ration instead of 4:3 (i will use that result for showing a list of available resolutions depending on the user screen) and will this affect GUI elements? ( i tried and see no change on 3D meshes, so it seems that irrlicht has no problem related to the screen ratio. but i just started and made no testes with GUI elements)
I'm working on a graphics settings selection screen showed before the game starts.
thanks
EDIT:
i found only 1 of the method i need.. there is a list of screemodes somewhere but i really don't understand how to use it.
//! Returns current desktop screen resolution.
const core::dimension2d<u32>& CVideoModeList::getDesktopResolution() const
1) Wich method give the max Screen resolution for full screen mode (if the desktop is 800x600 but the monitor can use higher resolution, the user can choose to run the game in full screen at 1024x768 for example)
2) wich method give the actual screen resolution when running in windowed mode (you can create a 2000x2000 window on a 1024x768 desktop with irrlicht, so if you know the desktop is 1024x768 you will resize the window to a smaller size)
3) how to know if the screen uses 16:9 ration instead of 4:3 (i will use that result for showing a list of available resolutions depending on the user screen) and will this affect GUI elements? ( i tried and see no change on 3D meshes, so it seems that irrlicht has no problem related to the screen ratio. but i just started and made no testes with GUI elements)
I'm working on a graphics settings selection screen showed before the game starts.
thanks
EDIT:
i found only 1 of the method i need.. there is a list of screemodes somewhere but i really don't understand how to use it.
//! Returns current desktop screen resolution.
const core::dimension2d<u32>& CVideoModeList::getDesktopResolution() const
Re: Acknowledge Irrlicht of maximum screen size and ratio
You can get all fullscreen video modes supported using next code:Dareltibus wrote:how to get Irrlicht know wich is the maximum screen size on the machine the game is running in?
Code: Select all
video::IVideoModeList* l = device->getVideoModeList();
for (int i = 0; i < l->getVideoModeCount(); i++)
{
core::dimension2du resolution = l->getVideoModeResolution(i);
int depth = l->getVideoModeDepth(i);
// now you have resolution and depth
// ...
}
Irrlicht Documentation wrote:core::dimension2du video::IVideoModeList::getVideoModeResolution(core::dimension2du& minSize, core::dimension2du& maxSize);
Parameters:
minSize: Minimum dimensions required.
maxSize: Maximum dimensions allowed.
Returns:
Size of screen in pixels which matches the requirements. as good as possible.
you can just get current screen resolution and check its ratio:Dareltibus wrote:how to know if the screen uses 16:9 ration instead of 4:3
Code: Select all
core::dimension2du resolution = l->getDesktopResolution();
float ratio = (float)resolution.Width / resolution.Height;
if (ratio == 16.0f/9.0f)
{
// this is 16:9
}
else if (ratio == 4.0f/3.0f)
{
// this is 4:3
}
else
{
// this is some other ratio
}
Forgive me for asking, but isn't it a bit leery to directly compare floats? Or is that taken care of with overloaded operators?
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
"I'll find out if what I deleted was vital here shortly..." -d3jake
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
Yes, it's probably a bad idea to do that. A different way of comparing would be:
This way should be much safer as no floating points need to be involved.
Code: Select all
if (yRes/(xRes/4)==3) {
// 4:3
}
else if (yRes/(xRes/16)==9) {
// 16:9
}
Why floats cannot be compared ?d3jake wrote:Forgive me for asking, but isn't it a bit leery to directly compare floats? Or is that taken care of with overloaded operators?
Next code writes "true" into "c":
Code: Select all
float a = 1.f/2.f;
float b = 1000.f/2000.f;
bool c = a == b;
I didn't mention doubles.hybrid wrote:Problems would arise, if someone e.g. would write 16.0/9.0 as it would use doubles and often come to different results. Other bad things may happen with floats and doubles as well. Always be careful with such things.
Solution that i showed uses floats.
There is no problems when you use floats for converting 1-7 meaning digits integers to float to divide them and compare the result. There are problems only with doubles and when we mixing both types.
Code: Select all
float a = (float)0.000151f/0.000252f;
float b = (float)151000000/252000000;
bool c = a == b; // true
I think the issue is that even if you aren't converting, a small amount of precision difference (EG: 4.999999f is not technically 5.f.) Like slavik262, use irr::core::equals for safety.
-
- Posts: 115
- Joined: Mon May 17, 2010 7:42 am
thanks
ok thanks you all. if i get any trouble i'll ask. I love this community and you all:)