D3D7Max2DDriver()

BlitzMax Forums/BlitzMax Beginners Area/D3D7Max2DDriver()

Why this code does not work?
Local driver:TD3D7Max2DDriver=D3D7Max2DDriver()
SetGraphicsDriver driver
Graphics 800, 600


Because you haven't updated to the latest version. Works fine here (1.14).

hm... version 1.14. Sync mod has did today. Recompil all modules.
Code not work...
Function D3D7GraphicsDriver:TD3D7GraphicsDriver()

	Global _done
	Global _driver:TD3D7GraphicsDriver
	
	If _done Return _driver
	If DirectDrawCreateEx
		DirectDrawEnumerate enum_devices_callback,Null
'		Print "DirectDraw found "+DDDevices.Count()+" devices."
		If PrimaryDevice
			PrimaryDevice.Init
'			Print "PrimaryDevice reslist.count()="+PrimaryDevice.reslist.Count()
			If PrimaryDevice.reslist.Count()	
				 _driver=New TD3D7GraphicsDriver
			EndIf
		EndIf
	EndIf
	_done=True
	Return _driver
End Function

I think error here:
DirectDrawEnumerate enum_devices_callback,Null


Works OK for me as well.
What error do you get?

Unhandled Exception: Attempt to acess field or method of Null object
...
Driver = null
Function enum_devices_callback(guid Ptr,desc:Byte Ptr,name:Byte Ptr,context Ptr) "win32"
	Local		device:TD3D7Device
	Local		devicedesc:Int Ptr,caps	
	
	devicedesc=Int Ptr(desc)
	caps=devicedesc[0]	
	If (caps&D3DDEVCAPS_HWRASTERIZATION)=0 Return
	device=New TD3D7Device
	device.guid=guid
	device.name=String.FromCString(name)	
	device.description=String.FromCString(desc)
	If Not primarydevice primarydevice=device
	DDDevices.AddLast device
	Return True
End Function

After this line:
If (caps&D3DDEVCAPS_HWRASTERIZATION)=0 Return

i get null in Driver...

Didn't you used to be Arkon, the BasicGL guy?

2Gabriel
No - he disappeared - account remained beside me. BasicGL I did not do.

After me comment line
'If (caps&D3DDEVCAPS_HWRASTERIZATION)=0 Return
Code became to work.

It's normal?? :)