When used with a canvas and OpenGL gfx driver, GraphicsWidth() and Height() return the original size of the canvas, not the current canvas size.
GraphicsWidth(), Height() only returns
BlitzMax Forums/BlitzMax GUI Programming/GraphicsWidth(), Height() only returns Why is the Canvas size changing?
I think it is best to destroy the canvas and make a new one when you need to resize it.
I think it is best to destroy the canvas and make a new one when you need to resize it.
This works for me.
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 :)
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 :)
In the case of (at least the original) dx7 driver, the graphics context was setup as a single backbuffer the size of the primary desktop screen shared by all canvas, so in theory this is what should be being reported back as the SetViewPort command is of course useful for rendering back into images (grabpixmap instead of flip) not just to attached canvas gadgets.
I don't know about OpenGL, please post some code.
I don't know about OpenGL, please post some code.