This works for me.
SuperStrict
SetGraphicsDriver GLMax2DDriver()
Global Window:TGadget = CreateWindow("Graphics",100,100,640,480)
Global Canvas:TGadget = CreateCanvas(0,0,ClientWidth(Window),ClientHeight(Window),Window)
SetGadgetLayout(Canvas,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED)
Global timer:TTimer = CreateTimer(60)
AddHook EmitEventHook, MyHook
Repeat
WaitEvent()
Forever
Function MyHook:Object(id:Int,Data:Object,Context:Object)
Local Event:TEvent = TEvent(Data)
Select Event.id
Case EVENT_WINDOWCLOSE
End
Case EVENT_GADGETPAINT
SetGraphics CanvasGraphics(Canvas)
Cls
DrawText GraphicsWidth()+" "+GraphicsHeight(),10,10
Flip
Return Null
Case EVENT_WINDOWSIZE
SetGraphics CanvasGraphics(Canvas)
SetViewport 0,0,ClientWidth(Window),ClientHeight(Window)
RedrawGadget Canvas
Return Null
Case EVENT_TIMERTICK
RedrawGadget Canvas
Return Null
End Select
Return data
End Function
Although I'd think you'd want to use GadgetWidth() and GadgetHeight() on a canvas.
Edit: Didn't notice you were having problems with only OpenGL, so I changed the above code to use OpenGL instead of DirectX. Still works though :)
|