Zooming in 2D editor

Started by
1 comment, last by greger 22 years, 5 months ago
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
Advertisement
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/
With best regards, Mirek Czerwiñski
Thank yoy for your quick answer. Just some clarifications:

1. How? Would it help if you got my code?

2. What values?

Thanks

/greger

This topic is closed to new replies.

Advertisement