Changing Graphics Drivers

BlitzMax Forums/BlitzMax Programming/Changing Graphics Drivers

therevills(Posted 2009) [#1]
Hi All,

Could someone please point out why this code doesnt work:



The "driverStr" should get updated to tell you want graphics driver you are currently in, but it seems to be always set to DX7???

Thanks!


Zeke(Posted 2009) [#2]
Local driverStr$ = ""
If _max2dDriver = D3D7Max2DDriver()
	driverStr = "DX7"
Else If _max2dDriver = D3D9Max2DDriver()
	driverStr = "DX9"		
Else If _max2dDriver = GLMax2DDriver()
	driverStr = "OPENGL"		
EndIf



therevills(Posted 2009) [#3]
Cheers Zeke :)

I copied the "If D3D7Max2DDriver() Then" from Grey Alien's Framework... hmmm - Jake if you read this, does this normally work?


Zeke(Posted 2009) [#4]
D3D7Max2DDriver returns Dx7 driver and if you are using windows then this always returns something driverStr is always dx7

135rc4 (newest) is a new command :GetGraphicsDriver() which returns current graphics driver.

so driverStr$=GetGraphicsDriver().toString() returns "DirectX7" and opengl returns "OpenGL"

ToString() method is missing in D3D9Max2DDriver type so that returns some hexstring.


GfK(Posted 2009) [#5]
To clarify what Zeke said - the method you originally used is useful to determine which drivers are available - not which one is set.


therevills(Posted 2009) [#6]
Ahhhhh.... thanks the info.

I had a closer look what Jake's code was doing and what you have said makes sense now:


			'Is there a Direct3D 7 Driver installed?
			If D3D7Max2DDriver() Then			
				DebugInt=10101
				'The code can reach here even if the driver is not DirectX7 or higher I've discovered.
				If Not ccDirectXVersionIsValid() Then
					'Make sure that ccGraphicalErrors=0 otherwise this error won't show!
					ccRunTimeError("Sorry, you need DirectX V7.0 or higher!")
				Else
					DirectXVersion = ccGetDirectXVersion()
				EndIf
				DebugInt=102
				SetGraphicsDriver D3D7Max2DDriver()
'				SetGraphicsDriver D3D9Max2DDriver()
				DriverOK = 1
			Else
				'Hmm, OK, DirectX7 not present, is OpenGL available?
				DebugInt=103
				If GLMax2DDriver() Then
					DebugInt=104
					SetGraphicsDriver GLMax2DDriver() 
					DriverOK = 1
					'we'd better change the ini file!
					Driver = 1
					DebugInt=105
					IniUpdate()
				EndIf 				
			EndIf



I was having a quick play with the DX9 Driver and just quickly copied the statement without reading the rest of the code....

Thanks again


BlitzSupport(Posted 2009) [#7]
I just posted this in another thread, but it sort of belongs here I think! You can now call GetGraphicsDriver and compare against the various drivers supported by BlitzMax:

Function GraphicsDriver:String ()

	Select GetGraphicsDriver ()
		Case GLGraphicsDriver ()
			Return "OpenGL (raw)"
		Case GLMax2DDriver ()
			Return "Max2D (OpenGL)"
		Case D3D7Max2DDriver ()
			Return "Max2D (Direct3D 7)"
		Case D3D9Max2DDriver ()
			Return "Max2D (Direct3D 9)"
		Default
			Return "Unknown graphics driver!"
	EndSelect

End Function

Graphics 640, 480

Repeat
	Cls
	DrawText "Driver: " + GraphicsDriver (), 0, 0
	Flip
Until KeyHit (KEY_ESCAPE)

End



therevills(Posted 2009) [#8]
Thanks James, so if I changed my original code to be this it would have worked (although I prefer using case statements like in your example):

Function getGraphicsDriverUsingIf:String ()
	Local driverStr$ = ""
	If GetGraphicsDriver() = D3D7Max2DDriver()
		driverStr = "DX7"
	Else If GetGraphicsDriver() = D3D9Max2DDriver()
		driverStr = "DX9"		
	Else If GetGraphicsDriver() = GLMax2DDriver()
		driverStr = "OPENGL"		
	EndIf
	Return driverStr 
End Function