WARNING: If you run this code you'll have to "End Task" one of BlitzMax Applications that are made.
OK, the aim behind this code is to start in full-screen 800x600 32-bit, and if that fails, try in the same res in 16-bit, and if that fails, start in windowed mode.
What I have done is deliberately added + 1 to ScreenWidth when CreateGraphics is called the first two times to make a ridiculous size of 801 pixels that should fail on graphics cards thus resulting in GR being null. I know that GR is null because I added a debug stop after if GR=null.
However, this is the weird thing, the code seems to make 3 "BlitzMax Application"s that can only be seen in Task Manager. The final windowed mode is never shown properly and the repeat until loop is never entered thus you can't press escape, or run any code in fact. You have to End Task on the BlitzMax Application to get out of it.
I thought my logic was sound, make a graphics object, if it fails to create the mode, gr will be null so you can try to make another etc. I know I could check all available graphics modes and automatically make a selection (maybe I should just do this) but I don't get why this code fails so badly.
Any ideas?
Strict
Local fullscreen=1
Local screenwidth = 800
Local screenheight = 600
Local forcewindowedmode = 0
Local gr:TGraphics
If FullScreen Then
'Try 32 bit, failing that try 16 bit, failing that use windowed mode
gr = CreateGraphics (ScreenWidth+1,ScreenHeight,32,60,GRAPHICS_BACKBUFFER)
If gr = Null Then
gr = CreateGraphics (ScreenWidth+1,ScreenHeight,16,60,GRAPHICS_BACKBUFFER)
If gr = Null Then
ForceWindowedMode = 1
FullScreen = 0
'Code will continue after EndIf and call Graphics in windowed mode
EndIf
EndIf
EndIf
'No else on purpose
If FullScreen = 0 Then
gr = CreateGraphics (ScreenWidth,ScreenHeight,0,60,GRAPHICS_BACKBUFFER)
EndIf
SetGraphics gr
Repeat
Until KeyHit(KEY_ESCAPE)
|