Problem with Graphics?

BlitzMax Forums/BlitzMax Programming/Problem with Graphics?

orgos(Posted 2006) [#1]
Strict

SetGraphicsDriver GLMax2DDriver()

Try
Graphics 640, 480, 64, 60
Catch ex:Object
RuntimeError "Unable to open a graphics context"
End Try


When i do this, or try other video setting that the video card don't support, the exception don't display. And the program break out.

In Want to notify the user that the video card don't support the game video mode.

Try with one video mode and then try whit other.


Dreamora(Posted 2006) [#2]
Graphics does not fire any error. Only IO and a few other "low level functionality" throw anything.
You will have to find that out by checking if _max2ddriver = null (at least I think this should be null when the creation breaks)


Grey Alien(Posted 2006) [#3]
well I couldn't solve this to my satisfaction either so I'm keen to hear what you come up with.


TomToad(Posted 2006) [#4]
Local GraphicsSuccess:TGraphics = TGraphics(Graphics (642,480,32))

If GraphicsSuccess
 Notify "Graphics Mode Supported"
Else
 Notify "Graphics Mode Not Supported"
End If


Don't know why I have to cast the Graphics command since it's suppose to return a TGraphics object anyway, but it works.


Grey Alien(Posted 2006) [#5]
It works on mine without the typecast. Weirdly I could have sworn I tried this a little while ago and it still make a funny little window that I couldn't get into. hmm.

OK found the thread, it's because I was looping at the end instead of just showing an error and bombing out like your code:

http://www.blitzbasic.com/Community/posts.php?topic=58443#650100


TomToad(Posted 2006) [#6]
Ok, I don't need to cast it, I just need to put the graphics parameters in parenthasis. Originally I had
Local GraphicsSuccess:TGraphics = Graphics 642,480,32

And that was what was giving me an error.


Grey Alien(Posted 2006) [#7]
yeah I had the same too, weird isn't it.


assari(Posted 2006) [#8]
The compiler in some instances cannot parse a function without parenthesis eventhough in most instances parenthesis is optional.

To be safe I always use parentheses with functions (except when I know they worked without them from experience).


Yan(Posted 2006) [#9]
The rule is:

If a function is to return a value, you *must* use the parentheses.


skidracer(Posted 2006) [#10]
You should not do this as an alternative to calling GraphicsModeExists:

If Not Graphics(640,480,60)
	Throw "chunks"
EndIf



Grey Alien(Posted 2006) [#11]
OK so GraphicsModeExists is a safer way to go, it's official. Thanks.


ImaginaryHuman(Posted 2006) [#12]
In my code I am making a list of all graphics modes with CountGraphicsModes() and then also additionally calling If GraphicsModeExists() on each mode, just to make sure.

This works most of the time unless you try to go with a fullscreen mode on a computer that doesn't support Full-screen opengl.


Grey Alien(Posted 2006) [#13]
yeah my previous mistake was doing If GraphicsModeExists and specifying a Hz, I shouldn't do that really.