Zoom View

BlitzMax Forums/BlitzMax Programming/Zoom View

Haramanai(Posted 2006) [#1]
Is it possible?
I found this from here : http://www.blitzmax.com/Community/posts.php?topic=42799&hl=zoom

It's good use of OpenGL.
But when I zoom in and out the origin changes...
Also I cannot find a proper way to get coordinates using the MouseX() and MouseY().

Is there another way to do this?
Or I am just loosing my time?
Is there a probability to be impemented in Max2D?


Haramanai(Posted 2006) [#2]
?


Haramanai(Posted 2006) [#3]
Well...
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

please test...


Haramanai(Posted 2006) [#4]
I almost forgot.
Here is the function to get the global coordinates from the Mouse position on the screan.
Function getGlobalXY( x:Double Var , y:Double Var , CenterX:Double , CenterY:Double , Zoom:Double)
	x = (x / zoom) + CenterX - ((GraphicsWidth() / Zoom) / 2)
	y = (y / zoom) + CenterY - ((GraphicsHeight() / Zoom) / 2)
End Function

Also I have to tell you that DrawPixmap gives strange result.
All the other drawing commands works ok. ( and pure OpenGL drawing of curse)