Basically, im using a canvas in a resizable window, but when i resize the window i want the canvas to keep its perspetive the same just scale the graphics, or in other words i want to emulate blitz+'s canvas. I wish todo this with opengl though as i dont wish to use scale/origin commands for this.
MaxGUI canvas keeping perspective.
BlitzMax Forums/BlitzMax Programming/MaxGUI canvas keeping perspective. Like this?
Strict 'virtual canvas size - 640,480 more likely... Local WIDTH=48,HEIGHT=16 SetGraphicsDriver GLMax2DDriver() Local window:TGadget=CreateWindow( "Window!",0,0,640,480 ) Local canvas:TGadget=CreateCanvas( 0,0,ClientWidth(window),ClientHeight(window),window ) SetGadgetLayout canvas,1,1,1,1 While WaitEvent()<>EVENT_WINDOWCLOSE Select EventID() Case EVENT_TIMERTICK,EVENT_GADGETPAINT 'setup code SetGraphics CanvasGraphics( canvas ) Local w#=GraphicsWidth(),h#=GraphicsHeight() SetViewport 0,0,w,h glLoadIdentity glScalef w/WIDTH,h/HEIGHT,1 'your paint code - note: viewport might not work as expected Cls For Local x=0 Until 6 SetColor Sin(x*15)*255,Cos(x*30)*255,0 DrawRect x*8,0,8,16 Next SetColor 255,255,255 DrawText "Hello!",0,0 Flip End Select Wend
Thanks mark, thats precisly what i wanted :).