Okay I got a couple of small bmax programs working to change the resolution to and from desktop resolution that get called from the html5 game itself (thanks grable!!). All good. The only thing I'm stumped at is how to run the WM_DISPLAYCHANGE message from within blitzmax. I tried to read up on what information there is floating around but my brain is too small to grasp how to do it in blitz.
Here's the code that switches to game resolution:
Import "display.c"
Extern "C"
Function TestDisplayMode:Int( width:Int,height:Int, bpp:Int, hz:Int=60)
Function ChangeDisplayMode:Int( width:Int=0,height:Int=0, bpp:Int=0, hz:Int=60, permanent:Int = False)
Function CurrentDisplayMode:Int( width:Int Var,height:Int Var, bpp:Int Var, hz:Int Var)
EndExtern
''''''''''''''load preferred resolutions from a text file'''''''''
Local GameExe:String
Local x:Int[4]
Local y:Int[4]
' read game resolution config file
in=ReadStream("launch.txt")
If Not In RuntimeError "Failed to open a ReadStream to file launch.txt"
GameExe=String(ReadLine(in))
x[1]=Int(ReadLine(in))
y[1]=Int(ReadLine(in))
x[2]=Int(ReadLine(in))
y[2]=Int(ReadLine(in))
x[3]=Int(ReadLine(in))
y[3]=Int(ReadLine(in))
x[4]=Int(ReadLine(in))
y[4]=Int(ReadLine(in))
CloseStream in
' write Desktop resolution to another config file
out=WriteStream("desktopres.txt")
If Not out RuntimeError "Failed to open a WriteStream to file desktopres.txt"
WriteLine out, DesktopWidth ()
WriteLine out, DesktopHeight ()
WriteLine out, DesktopDepth ()
WriteLine out, DesktopHertz ()
CloseStream out
' replace empty values with '1' to prevent fallback (necessary?)
For z = 1 To 4
If x[z] = 0 Then x[z] = 1
If y[z] = 0 Then y[z] = 1
Next
If GraphicsModeExists(x[1],y[1],0,0)
ChangeDisplayMode(x[1],y[1],DesktopDepth(),DesktopHertz (),1)
' Extern "C"
' SendMessage(HWND_BROADCAST, WM_DISPLAYCHANGE, (WPARAM)(deviceMode.dmBitsPerPel), MAKELPARAM(newWidth, newHeight));
' EndExtern
ElseIf GraphicsModeExists(x[2],y[2],0,0)
ChangeDisplayMode(x[2],y[2],DesktopDepth(),DesktopHertz (),1)
ElseIf GraphicsModeExists(x[3],y[3],0,0)
ChangeDisplayMode(x[3],y[3],DesktopDepth(),DesktopHertz (),1)
ElseIf GraphicsModeExists(x[4],y[4],0,0)
ChangeDisplayMode(x[4],y[4],DesktopDepth(),DesktopHertz (),1)
EndIf
'system_ GameExe
End
... with the commented-out WM_DISPLAYCHANGE message command nicked from some example on the internet. It would be great if anyone could help me with this :)
|