Quick little start up options thingy..

BlitzMax Forums/BlitzMax Beginners Area/Quick little start up options thingy..

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

It's not flashy but it does it's job. I needed something to allow me to test a variety of start up display options so I coded this little diddy. I'm sure some other noobs may find it useful. ;) Quck and dirty..just like I like my...anyway.. here it is:

(Windows Only)

'
Extern "win32"
 Function GetActiveWindow%()
End Extern
'
' Set default options
'
Global gdriver:Int = 0
Global windowed:Int = 0 
Global vsync:Int = 1    
Global depth:Int = 32   
Global res:Int = 3     
Global screenwidth:Int
Global screenheight:Int 
'
GetStartUpOptions()
'
' results...
' gdriver: 0=dx 1=ogl
' vsync: 0 = off 1 = on
' screenwidth = width of screen
' screenheight = height of screen
' depth = 16-24-32
' windowed: 0=no 1=yes
'
Function GetStartUpOptions()
 SetGraphicsDriver D3D7Max2DDriver()
 Graphics(280,150,0)
 CenterWindowWin32()
 While Not KeyHit(KEY_RETURN)
  KeyOptions()
  Cls
  ShowOptions()
  Flip
  Delay 20
 Wend
End Function
'
Function KeyOptions()
 If KeyHit(KEY_G) ; gdriver = Not gdriver
 If KeyHit(KEY_V) ; vsync = Not vsync
 If KeyHit(KEY_C)
  If depth = 16
   depth = 24
  Else 
   If depth = 24
    depth = 32
   Else
    If depth = 32 
     depth = 16
    EndIf
   EndIf
  EndIf
 EndIf
 If KeyHit(KEY_R)
  res=res+1 ; If res = 5 Then res=1
 EndIf
 If KeyHit(KEY_D) ; windowed = Not windowed 
End Function
'
Function ShowOptions()
 SetColor 0,255,0
 SetTransform 0,1,1
 SetBlend SOLIDBLEND
 Local gr$,vs$,dp$,sz$,w$
 If gdriver = 0 ; gr$ = "DirectX"
 If gdriver = 1 ; gr$ = "OpenGL"
 DrawText "(G)raphics Driver = " + gr$,20,20
 If vsync = 0 ; vs$ = "Off"
 If vsync = 1 ; vs$ = "On"
 DrawText "(V)sync = " + vs$,20,40
 If depth = 16 ; dp$ = "16 bit"
 If depth = 24 ; dp$ = "24 bit"
 If depth = 32 ; dp$ = "32 bit"
 DrawText "(C)olor Depth = " + dp$,20,60
 If res = 1 ; sz$ = "320x240"
 If res = 2 ; sz$ = "640x480"
 If res = 3 ; sz$ = "800x600"
 If res = 4 ; sz$ = "1024x768"
 DrawText "(R)esolution = " + sz$,20,80
 If windowed = 0 Then w$ = "Full Screen"
 If windowed = 1 Then w$ = "Windowed"
 DrawText "(D)isplay = " + w$,20,100
 DrawText "Press RETURN to continue.",20,120
 Select res
 Case 1
  screenwidth=320 ; screenheight=240
 Case 2
  screenwidth=640 ; screenheight=480
 Case 3
  screenwidth=800 ; screenheight=600
 Case 4
  screenwidth=1024 ; screenheight=768
 End Select
End Function
'
Function CenterWindowWin32()
 Local hwnd:Long = GetActiveWindow()
 Local desk[4]
 Local window[4]
 GetWindowRect(GetDesktopWindow(), desk) 
 GetWindowRect(hwnd, window)
 SetWindowPos(hwnd, HWND_NOTOPMOST, (desk[2] - (window[2] - window[1])) / 2, (desk[3] - (window[3] - window[0])) / 2, 0, 0, SWP_NOSIZE)	
End Function
'