GraphicsDriversAvail()

BlitzMax Forums/BlitzMax Programming/GraphicsDriversAvail()

GfK(Posted 2007) [#1]
Hello.

Is there a way of determining which graphics drivers are available, other than setting them and watching your PC crash and burn when OpenGL isn't supported??

I'm currently using DX by default, with an option to switch to GL. All works nicely but I've had to add a recovery option (via a commandline switch) for occasions when GL has been set but is not available (resulting in a crash).


Gabriel(Posted 2007) [#2]
Doesn't Graphics return Null if it knows for a fact that it couldn't initiate correctly? I thought that was added a while back for requests just like this.

Of course, knowing for a fact that it failed and failing in general are two quite different things, but for anything more than that, I just set a flag when the engine shuts down properly, and if that hasn't been set I pop up a "the game terminated abnormally last time you ran, would you like to run in safe mode?" and if they say yes, switch drivers.

As a second backup, I check the length of time the game has been running and if it's less than a couple of seconds, same deal, next time it runs, "the game terminated abnormally, yadda yadda.." It's not perfect, but I think it covers me fairly well.


bradford6(Posted 2007) [#3]
Function GLGraphicsDriver:TGLGraphicsDriver()
Returns An OpenGL graphics driver.
Description Get OpenGL graphics driver.
Information The returned driver can be used with SetGraphicsDriver.

something like:

if not GLGraphicsDriver then "OpenGL=no go"


GfK(Posted 2007) [#4]
Interesting... I'll try that later.


jkrankie(Posted 2007) [#5]
So to clarify, would this work as i think it should?

if not GLMax2DDriver()
SetGraphicsDriver D3D7Max2DDriver()
else
SetGraphicsDriver GLMax2DDriver()
end if

Cheers
Charlie


bradford6(Posted 2007) [#6]
try this. Just prints what is selected.
If Not GLMax2DDriver()
	Print " No OpenGL Driver. Setting to: SetGraphicsDriver D3D7Max2DDriver()"
Else
	Print "SetGraphicsDriver GLMax2DDriver()"
End If


I can't test this since all 5 of my PC's have OpenGL drivers. could try the reverse on a MAC though

If Not D3D7Max2DDriver()
	Print " No D3D Driver setting to: SetGraphicsDriver GLMax2DDriver()"
Else
	Print "setting to: SetGraphicsDriver D3D7Max2DDriver()"
End If



GfK(Posted 2007) [#7]
Just tried this - doesn't work.

Says GL is available on my test PC when I know for a fact that it isn't.


jkrankie(Posted 2007) [#8]
that's a shame.from what i've found on machines i've tested Bullet Candy on, it tends to fail when you call graphics, could you do a similar test with that? eg

SetGraphicsDriver GLMax2DDriver()
if not graphics 640,480,32,60
SetGraphicsDriver D3D7Max2DDriver()
graphics 640,480,32,60
end if

Cheers
Charlie


jkrankie(Posted 2007) [#9]
This compiles on my PC, but i know it has a GL driver so i can't test to see if it works properly:



could someone please test this.

Cheers
Charlie


bradford6(Posted 2007) [#10]
Local GDriver:TMax2DDriver

GDriver = GLMax2DDriver()
	If GDriver = Null	' If there is no OpenGL Driver available on this system
		GDriver = D3D7Max2DDriver()	' then get the D3D driver
			SetGraphicsDriver(GDriver)		' and set it
			Print Gdriver.Tostring()		' and print it
			For drivers:Int = 0 To CountGraphicsModes() -1		' and print available modes
				GetGraphicsMode( drivers,width,height,depth,hertz )
				Print width+" "+height+" "+depth+" "+hertz
			Next
	
	Else			' but if there is an OpenGL Driver	
		SetGraphicsDriver(GDriver)		' set and print modes
		Print GDriver.Tostring()
		For drivers:Int = 0 To CountGraphicsModes() -1
			GetGraphicsMode( drivers,width,height,depth,hertz )
			Print width+" "+height+" "+depth+" "+hertz
		Next
	EndIf
	



or if you want a function that is aligned with the topic:
GraphicsDriversAvail(GL:TMax2DDriver , D3D:TMax2DDriver)

Print GL.tostring()
Print D3D.Tostring()

SetGraphicsDriver GL
SetGraphicsDriver D3D

Function	GraphicsDriversAvail(GLmax2d:TMax2DDriver Var , DXmax2d:TMax2DDriver Var)
	GLmax2d = GLMax2DDriver()
	DXmax2d = D3D7Max2DDriver()
End Function