Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: glOrtho vs glViewport for 2d zooming

  1. #1
    Guest

    glOrtho vs glViewport for 2d zooming

    I was wondering what all you opengl gurus do for 2d zooming. I've got an app that draws 2d shapes and I'm using glViewport to zoom but I'm running into integer round off problems with the viewport dimensions when I zoom in too far. I've tried scaling but I'm not too happy with this approach and I'm thinking maybe glOrtho is a better choice, i.e. keep a constant viewport and change the orthogrraphic projection parameters. Any suggestions would be much appreciated.

    I have searched the archives on this too.

    Thanks in advance!

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: glOrtho vs glViewport for 2d zooming

    I have always been happy with glScaled so far.

  3. #3
    Guest

    Re: glOrtho vs glViewport for 2d zooming

    Thanks, glScaled is definitely an option. Does it even make sense to use glViewport and glOrtho to do zoom?

  4. #4
    Guest

    Re: glOrtho vs glViewport for 2d zooming

    glOrtho make good sense in 2D.

  5. #5
    Guest

    Re: glOrtho vs glViewport for 2d zooming

    In mfc, to get scroll bars i can make the openGL viewport bigger than the mfc window. However, as I increase the viewport and keep the mfc window the same size i begin to run into round off error/resolution limits when i get the mouse position. In other words the opengl viewport gets really big making it difficult to map the mouse coords. How can this be solved?

  6. #6
    Guest

    Re: glOrtho vs glViewport for 2d zooming

    whay are you fooling with the viewport? all you need is a scale (glScale*) or a view xform (glOrtho).

    the viewport should normally be set to the window dims. dont fool with that.

  7. #7
    Guest

    Re: glOrtho vs glViewport for 2d zooming

    thanks for the reply, I'm starting to agree with you here, however, it is nice to be able to scroll across a drawing with mfc scroll bars.

  8. #8
    Guest

    Re: glOrtho vs glViewport for 2d zooming

    i agree, simon, but there a far better ways to accomplish that. a scroll is simply a translation. as a matrix operation, you could use glTranslate*(). or, for an individual vertex, you could simply offset the positions manually on the cpu, its up to you. i like the matrix stuff, because its cheap, and it affects everthing globally, automagically.

  9. #9
    Guest

    Re: glOrtho vs glViewport for 2d zooming

    I was just looking for the easy way out, big surprise eh!? If I go with glTranslate then I would have to keep track of scroll bar stuff in my code instead of letting mfc do it and the scroll bar increments would need to be scaled with zooms, that just doesn't seem very elegant. hmmm....

  10. #10
    Guest

    Re: glOrtho vs glViewport for 2d zooming

    it will allow for huge viewports, far beyond the range of a gl viewport. in my world editor, i use a system just like this to allow the user to navigate a huge 3D world, by zooming and scrolling with mouse clicks, kinda like the quake and unreal editors. i know of no better way to do this. for my texture browser, i just offset individual quads, since its very easy and fast to do, and i need a special layout.

    just think of the thumb position as being the origin in the world, and offset or translate everything relative to that. its really quite easy once you get the hang of it.

Page 1 of 2 12 LastLast

Similar Threads

  1. zooming to mouse position using glOrtho
    By danmarell in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-26-2013, 08:28 PM
  2. Q on glOrtho / zooming in orthographic projection
    By roelv in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-12-2009, 04:03 AM
  3. Artifacts during zooming (glOrtho)
    By devdept in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 05-16-2008, 08:32 AM
  4. glOrtho & glViewport
    By Cerv36 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-21-2003, 08:50 PM
  5. glOrtho, and glViewport...
    By DJKAOS in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-31-2001, 12:01 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