?Win32
Extern "win32"
Function UpdateWindow(hwnd)
Function RedrawWindow(hwnd,updaterect:Int Ptr,region,flags)
End Extern
Const RDW_INVALIDATE=$1
Const RDW_UPDATENOW=$100
Const RDW_FRAME=$400
Global _graphicshwnd,_currgraphics:TGraphics
Global _useogl=True
Function Graphics:TGraphics(width,height,depth=0,hertz=60,flags=0)
_currgraphics=brl.Graphics.Graphics(width,height,depth,hertz,flags)
_graphicshwnd=GetActiveWindow()
Local style=GetWindowLongA(_graphicshwnd,GWL_STYLE)
SetWindowLongA _graphicshwnd,GWL_STYLE,style|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
RedrawWindow _graphicshwnd,Null,Null,RDW_INVALIDATE|RDW_UPDATENOW|RDW_FRAME
AddHook FlipHook,ScaleGraphics,Null
Return _currgraphics
End Function
Function SetGraphicsDriver(driver:TGraphicsDriver,defaultFlags=GRAPHICS_BACKBUFFER)
Select driver
Case GLGraphicsDriver(),GLMax2DDriver()
_useogl=True
Default
_useogl=False
End Select
brl.Graphics.SetGraphicsDriver driver,defaultFlags
End Function
Function ScaleGraphics:Object(id,data:Object,context:Object)
Local rect[4]
GetClientRect _graphicshwnd,rect
Local gwidth,gheight,gdepth,ghertz,gflags
_currgraphics.GetSettings gwidth,gheight,gdepth,ghertz,gflags
If _useogl
glMatrixMode GL_PROJECTION
glLoadIdentity
glOrtho 0,gwidth,gheight,0,-1,1
glMatrixMode GL_MODELVIEW
glViewport 0,0,rect[2]-rect[0],rect[3]-rect[1]
Else
Local viewport:D3DVIEWPORT7=New D3DVIEWPORT7
viewport.dwX=0
viewport.dwY=0
viewport.dwWidth=rect[2]-rect[0]
viewport.dwHeight=rect[3]-rect[1]
viewport.dvMinZ=0.0
viewport.dvMaxZ=1.0
D3D7Max2DDriver().device.SetViewport(viewport)
Local depth=2
Local matrix#[]=[2.0/gwidth,0.0,0.0,0.0,0.0,-2.0/gheight,0.0,0.0,0.0,0.0,2.0/depth,0.0,-1-(1.0/gwidth),1+(1.0/gheight),1.0,1.0]
D3D7Max2DDriver().device.SetTransform(D3DTS_PROJECTION,matrix)
EndIf
Return data
End Function
?
That will allow the OpenGL to emulate Blitz3D's scalable window. All you have to do is copy and paste it into the bottom of you source file. I attempted to get the D3D7 driver to work but couldn't.