Jump to content
  • Advertisement


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


Zooming in 2D editor

This topic is 6068 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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

Share this post

Link to post
Share on other sites
Thank yoy for your quick answer. Just some clarifications:

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

2. What values?



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!