Well...
I found a way that it works with GLMax2D.
It's pure OpenGL.
I named the function setCenterAndZoom
and here it's an example... with Max2D Drawing
please test...
I found a way that it works with GLMax2D.
It's pure OpenGL.
I named the function setCenterAndZoom
Function setCenterAndZoom(x:Float , y:Float , Zoom:Float) Local LeftGL:Float = x - ((GraphicsWidth() / Zoom) / 2) Local RightGL:Float = x + ((GraphicsWidth() / Zoom) / 2) Local ButtomGL:Float = y + ((GraphicsHeight() / Zoom) / 2) Local TopGL:Float = y - ((GraphicsHeight() / Zoom) / 2) glMatrixMode (GL_PROJECTION) glLoadIdentity () gluOrtho2D (LeftGL, RightGL, ButtomGL,TopGL) End Function
and here it's an example... with Max2D Drawing
SuperStrict SetGraphicsDriver GLMax2DDriver() Graphics 640 , 480 Local Zoom:Float = 1.0 Local CenterX:Float = 0.0 Local CenterY:Float = 0.0 While Not KeyDown(KEY_ESCAPE) Cls setCenterAndZoom( CenterX , CenterY , Zoom ) SetColor 0 , 255 , 0 DrawOval 30 , 30 , 40 , 40 SetColor 255 , 0 , 0 DrawLine 0 , 0 , 30 , 30 If KeyDown(KEY_LEFT) Then CenterX:-1 If KeyDown(KEY_RIGHT) Then CenterX:+1 If KeyDown(KEY_UP) Then CenterY:-1 If KeyDown(KEY_DOWN) Then CenterY:+1 If KeyDown(KEY_NUMADD) Then Zoom:+ 0.1 If Zoom > 0.1 If KeyDown(KEY_NUMSUBTRACT) Then Zoom:- 0.1 End If Flip Wend Function setCenterAndZoom(x:Float , y:Float , Zoom:Float) Local LeftGL:Float = x - ((GraphicsWidth() / Zoom) / 2) Local RightGL:Float = x + ((GraphicsWidth() / Zoom) / 2) Local ButtomGL:Float = y + ((GraphicsHeight() / Zoom) / 2) Local TopGL:Float = y - ((GraphicsHeight() / Zoom) / 2) glMatrixMode (GL_PROJECTION) glLoadIdentity () gluOrtho2D (LeftGL, RightGL, ButtomGL,TopGL) End Function
please test...