[fixed]Detect if supports resolution in fullscreen

Community Forums/General Help/[fixed]Detect if supports resolution in fullscreen

Ravl(Posted 2013) [#1]
Hi,

When I start my game I want to check if the pc supports: 1280 x 768 resolution (in fullscreen), otherwise I will start it in 1024 x 768.

How should I do this?


GfK(Posted 2013) [#2]
Could you put your resolution setting code in a Try/Catch block? It might work.


Kryzon(Posted 2013) [#3]
It depends on what operating system you're in, and what language you're using.
If I'm not mistaken, you're using BlitzMax.

You can rely on GraphicsModes() from BRL.graphics.

PS: If you don't know any of the available modes, the safest resolution to start your game with is the current desktop resolution. In Windows you can get that with GetDeviceCaps() (example usage in this thread, remembering that the parameter BITSPIXEL = 12 for retrieving the color depth).


GfK(Posted 2013) [#4]
You can rely on GraphicsModes() from BRL.graphics.
Is that a typo? Because you can't rely on that at all.

All it does is query the display drivers, and if they aren't the correct drivers, or generic drivers, you could get all sorts of resolutions returned that your hardware just doesn't support.


therevills(Posted 2013) [#5]
I normally do something like this:

SuperStrict

Global game:TGame = New TGame
game.Main()

Type TGame
	Field screenWidth:Int = 6000
	Field screenHeight:Int = 7680
	Field o:TOval = New TOval

	Method Main()
		SetUpGraphics()
		Repeat
			Update()
			Draw()
		Until AppTerminate() Or KeyHit(KEY_ESCAPE)
	EndMethod

	Method SetUpGraphics()
		Local g:TGraphics = Null
		g = SetResolution(screenWidth, screenHeight)
		If g = Null Then
			screenWidth = 800
			screenHeight = 600
			g = SetResolution(screenWidth, screenHeight)
		EndIf
	EndMethod
	
	Method SetResolution:TGraphics(w:Int, h:Int)
		If GraphicsModeExists(w, h, 32) Then
			Return Graphics(w, h, 32, 60)
		Else
			Return Null
		EndIf
	EndMethod
	
	Method Update()
		o.Update()
	EndMethod 
	
	Method Draw()
		Cls
			DrawText "Resolution = " + screenWidth + "," + screenHeight, 10, 10
			o.Draw()
		Flip
	EndMethod
EndType

Type TOval
	Field x:Float, y:Float, w:Int = 10, h:Int = 10
	Field dx:Float = 3, dy:Float = 3
	
	Method Update()
		x:+dx
		y:+dy
		If x > game.screenWidth dx = -dx
		If x < 0 dx = -dx
		If y > game.screenHeight dy = -dy
		If y < 0 dy = -dy
	EndMethod
	
	Method Draw()
		DrawOval x - w / 2, y - h / 2, w, h
	EndMethod
EndType



Kryzon(Posted 2013) [#6]
All it does is query the display drivers, and if they aren't the correct drivers, or generic drivers, you could get all sorts of resolutions returned that your hardware just doesn't support.

Hi. If they aren't the correct drivers, then the system is configured incorrectly and your (or any) application should not be expected to behave correctly.

When you install your drivers correctly (for instance, you have an ATI graphics card and you download and install the drivers for it), the display driver becomes that of the graphics card.
GraphicsModes() from BlitzMax will query this driver, so it will retrieve supported modes from the graphics card.

Since there are a lot of permutations (the same resolution but different frequencies, bit depths etc.), there can be hundreds of possible modes.


Yasha(Posted 2013) [#7]
Indeed, it seems odd to design a game for the case of a system that hasn't been set up to return correct data. If you can't rely on that, you can't rely on anything.

Besides, if you can't trust the graphics driver, where else are you going to get this kind of information?


GfK(Posted 2013) [#8]
If they aren't the correct drivers, then the system is configured incorrectly and your (or any) application should not be expected to behave correctly.


Indeed, it seems odd to design a game for the case of a system that hasn't been set up to return correct data
It really isn't as simple as that.

I could be wrong but I think Ravl is in the casual games market. Most of the target audience wouldn't know a display driver if they fell over one. And those are the type of people you need to cater for and you cannot ever rely on their systems being correctly set up, or even what you'd call "modern".

So, forget about them completely, right? Well, no. Those people will still download your game, then write bad reviews and complain when it crashes, which other people will read and that *will* hurt sales. You cannot just brush the problem aside as "operator error", even when that's exactly what it is.


Ravl(Posted 2013) [#9]
Hello,

As always you helped me again. Thanks for all this information.
"GraphicsModeExists" is what I needed.

Yes, my market is Windows Casual Gaming and I need to handle this issue proper.

My game is designed to work on 1280 x 768 and 1024 x 768 only, Fullscreen or window mode.

if the user has a very old pc and does not support 1280 than I go 1024. Everyone supports 1024 :D


Ravl(Posted 2013) [#10]
well, it sucks.

yesterday worked, but now on my home machine when I try to switch to fullscreen or if i start the game in fullscreen the game window is minized. only the music is playing in the background.

how the hack could this happening?

i am using something like this:

	If GraphicsModeExists(1280, 768, 32, 60)
		Graphics 1280, 768, 32, 60
		myGlobals.difX = 0
	Else
		Graphics(1024, 768, 32, 60)
		myGlobals.difX = 128
	End If



GfK(Posted 2013) [#11]
Not sure but I would not specify 60Hz all the time, for two reasons. First, if someone's using a CRT monitor they could be running at 85Hz+ to eliminate flicker, and your game dropping back to 60 is going to give them nasty headaches. Second, I've seen hardware that doesn't even claim to operate at 60Hz - instead you get 59Hz or something.

In the latter case, I'm not sure what would happen if you specified 60, and the nearest the system had was 59. Would it adapt, or just fail?


Ravl(Posted 2013) [#12]
same issue Gfk.

i even tried to let 0. no change.

But, i just discovered I used GLMax2DDriver instead of D3D9Max2DDriver

For the Windows version I will use D3D9Max2DDriver but that's still strange..

Btw, any idea how should I proper set the hertz?


GfK(Posted 2013) [#13]
I just omit the hertz parameter completely. It's my understanding that by doing this, it will use whatever the system default is set to.


Ravl(Posted 2013) [#14]
good to know. it's my first game FOR WINDOWS written in bmax. the last one which was only for macos was much easier to handle..

thanks again


Kryzon(Posted 2013) [#15]
If you want to support almost all hardware configurations that may run your game, don't hardcode anything: give the user the flexibility to choose the configuration he wants.

Limiting resolution choices to 1280x768 and 1024x768 certainly goes against this kind of philosophy.

You should make a configuration application.
When the user runs your game for the first time, you quit the game and forcibly run the configuration application.
The user will choose things such as the driver (giving him the choice of driver with OpenGL, Dx7, Dx9, col's Dx11 etc.), the available graphics modes under the driver chosen (supporting ALL resolutions available for his hardware, even ones as low as 320x200 - more on that below) etc.
When the user saves the settings for the first time, you write an INI, XML, text etc. file that stores these settings and the next time the game is run, you read this file (instead of running the configuration application everytime - you just needed it for the first time).



If the user wants to change the settings again, he just has to go to the game's folder and execute it. Your installation software can offer the user the choice to not only create a desktop shortcut for your game, but also a desktop shortcut for the configuration application (note these are optional as well).

Regarding the resolution support. If you're using pixel measurements in your game (for the location of objects etc.), you should convert those to proportional or percentage values instead, relative to the screen - this way the same layout will work for any resolution in existence.
An object placed at the bottom middle of the screen has the coordinate pair [0.5, 1.0]. When you're rendering the object or checking for collisions etc. you just transform these relative coordinates to absolute pixel coordinates by doing [0.5 * GraphicsWidth, 1.0 * GraphicsHeight]


*(Posted 2013) [#16]
Another thing that getting the graphics modes from the driver don't tell ya is if the monitor supports that resolution, its best to have a try at changing it and do a 15 second counter that if the user don't click on ok it reverts back to the default.


GfK(Posted 2013) [#17]
Another thing that getting the graphics modes from the driver don't tell ya is if the monitor supports that resolution
Yep, and this is exactly what I was saying about display drivers. Most Average Joes don't know the first thing about drivers and would not even think to check that the correct monitor driver is installed. I'd wager that a very high percentage are still using generic monitor drivers, which will claim to support all manner of resolutions. And that's what you need to watch out for.


Ravl(Posted 2013) [#18]
@Kryzon: unfortunately casual games portal forbid me to make a form like that. the game exe must start the game directly in fullscreen mode :)


*(Posted 2013) [#19]
Rawi: in that case just include maxgui in the game and set the rest to the DesktopWidth(), DesktopHeight(), and DesktopDepth() :)


Ravl(Posted 2013) [#20]
@EdzUp[GD]:

thanks but I that will not help me..I think. I do not need to set the resolution to the user's pc. my game which is a point and click 2D game it's made for these 2 resolutions. I need to stick to one of them.

I can't just use any resolution and then scale the whole game..