Detecting DX or GL and falling back on Failure ?

BlitzMax Forums/BlitzMax Programming/Detecting DX or GL and falling back on Failure ?

SillyPutty(Posted 2005) [#1]
Hi all

On my work pc, bmax apps cannot run in dx mode. the app crashes.

Is there a way to check if there is an error running dx mode, to fallback onto GL ?

I am sure the answer is simple, but I cannot find it anywhere. Can bmax do this out the box without any funny tweaks ? How to I assert on failure ?

Something like this would rock

pseudo



FlameDuck(Posted 2005) [#2]
Is there a way to check if there is an error running dx mode, to fallback onto GL ?
Not that I know of. Currently I'm forcing OpanGL, and allowing the user to switch to the DX renderer by using a commandline switch.


SillyPutty(Posted 2005) [#3]
ok cool, thanks FlameDuck :)

So I take it you have come across the same prob with dx on some pc's ? Apps Crashing on dx ?


TartanTangerine (was Indiepath)(Posted 2005) [#4]
YEs you could do this but it would mean fiddling with one of the modules.


Shambler(Posted 2005) [#5]
The simplest workaround I can think of is...

Open and write to a file when your app starts e.g. write a string stating which driver you are using "Running in DX mode" or "Running in OpenGL mode".

Then just before you application closes normally write over the file with "DX ran OK" or "OpenGL ran OK".

When you start your application check this file and it will tell you if your application crashed using that particular driver and if so you could create another file stating which driver should be used for this PC.


SillyPutty(Posted 2005) [#6]
That means the user has to basically run the app again, if it failed on the first run.

I wish I could trap the crash in bmax and handle it like that.

It would be nice to give the user a friendly error message.


tonyg(Posted 2005) [#7]
Surely coming soon...
DX -> GL


Robert Cummings(Posted 2005) [#8]
Exactly. It should happen gracefully and automatically.


SillyPutty(Posted 2005) [#9]
ah perfect. thanks


JazzieB(Posted 2005) [#10]
I'm sure you can do this to check which drivers are available...

If GLMax2DDriver()<>Null Then openGL=True	' check if OpenGL available
If D3D7Max2DDriver()<>Null Then directX=True	' check if DirectX available

At least, that's what I've done, but it hasn't been tested to the extent that it falls to OpenGL if DirectX isn't available.


SillyPutty(Posted 2005) [#11]
hmmm, weird, it says both are available, maybe I have poked drivers or something, I need to investigate this further. But that is a nice way that I would like to implement it.

*EDIT

Does not work :(


JazzieB(Posted 2005) [#12]
Maybe both ARE available. I assume that what I posted above returns a non-null response if a DX and/or OGL driver exists - not whether your app will run without crashing.

If the app crashes then it could be another issue, for example graphics drivers and/or DX may need updating, or the PC doesn't meet the minimum spec for your app (even if you don't yet know what that minimum is).

One thing though, you don't say how your app crashes. It may not be DX related at all, but could be something completely different - like missing files when you move to your work PC.

Also, the minimum version of DirectX required for Max2D is 7 - does your work PC meet this?


SillyPutty(Posted 2005) [#13]
yes it does, I get unhandled exceptions while trying to use the dx driver.

Funny enough I can run dx9 apps on my work pc no problem. I agree that both Are available with the above check.

I just wish I could trap the error and fallback to GL.


xlsior(Posted 2005) [#14]
Didn't BRL post a test program a while back for people to try, that was supposed to do a DX -> OpenGL fallback?

Sounds like something is in the pipeline...