Archived

This topic is now archived and is closed to further replies.

greger

Zooming in 2D editor

Recommended Posts

greger    122
Hi there! I''m making a 2D paint program, much like MS Paint (it''s a school project, not of free will!). I can draw lines, circles and polygons. All objects drawn are saved in a linked list, so they are properly redrawn when a reshape occurs. I''ve made a zoom function which uses the mouse to draw a rectangle around the object and then zooms in: gluOrtho2D(zx1,x ,y , zy1); glViewport(x, y, zx1-x, zy1-y); where zx1,zy1 are the top-left coordinates and x,y the bottom-right coordinates of the rectangle. But when I try to draw a line after this, the lines doesn''t appear at the same position as the mouse is. Why? My coordinate system is set up with 0,0 at the top-left of the window. How do I zoom out again? Thankful for answer! /greger

Share this post


Link to post
Share on other sites
MirekCz    132
1.they don''t appear correctly because you''re (most probably, haven''t seen source..) still drawing them like you wouldn''t "zoom-in". You have to recalc mouse positions to screen positions after zooming in.
2.well save the original values before zooming-in and when you want to zoom-out just restore those values
hope it helps.

With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/

Share this post


Link to post
Share on other sites