Results 1 to 2 of 2

Thread: Zooming and Preserve aspect ratio

  1. #1
    Junior Member Newbie
    Join Date
    May 2006
    Location
    Italy
    Posts
    8

    Zooming and Preserve aspect ratio

    Hi,
    thanks to some replies here I succeded in display a buffer from camera using OpenGL(Topic: "cropping" 2d texture).
    Now I'd like to perform(using OpenGl) a zoom when the user click on a certain pixel, I can get the coordinates by gluUnProject, but I don't know how to have in my window only a portion of the area zoomed.

    Another thing I'd like to do is to maintain the ratio of my buffer showing black bars on the sides, I think glOrtho could be right but I cannot understand how to use it.

    Thanks again

    Bye

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: Zooming and Preserve aspect ratio

    Orthographic projection is a "fake" 3D view without perspective depth and works fine for displaying 2D stuff like your image, i.e things don't get smaller with distance, if you look at gluPerspective you specify a "field of view" value, this is the "zoom factor" that indicates how much to show in the window, you can do this yourself with the left,right,top,bottom values in glOrtho or gluOrtho2D, this values specify how much to show of the world in your window, so by changing those values you can "zoom" in and out.

    Example, if you use -1,1,1,-1 for your left,top,right,bottom values and change this to -0.8,0.8,0.8,-0.8 you will zoom in because you display a smaller part of your world in the same window.

    Hope that helps on your way...

    Mikael

Similar Threads

  1. Adjusting aspect-ratio
    By Sagiv B in forum OpenGL ES
    Replies: 1
    Last Post: 04-18-2012, 12:00 PM
  2. gluLookAt() and Aspect Ratio
    By jonathon123 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-08-2008, 12:09 PM
  3. Aspect Ratio
    By Crilston in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-27-2005, 07:32 AM
  4. aspect ratio
    By renderz in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-29-2004, 02:45 PM
  5. Determining Aspect Ratio Constraints?
    By Pa3PyX in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-02-2002, 12:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean