Re: Convert NSOpenGLView pixel coordinates to OpenGL world coordinates

  • > From within the NSOpenGLView subclass...

    - (void)reshape
    {
    NSSize  viewSize = [self bounds].size;

    glViewport( 0.0, 0.0, viewSize.width, viewSize.height
    );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluPerspective( 70.0, viewSize.width/viewSize.height,
    0.2, 100.0 );
    }

    --- David Spooner <dave...> wrote:

    >
    > What code do you use to set the projection matrix;
    > in particular, the
    > near and far distances?  How about the viewport?
    >
    > dave
    >
    > On 6-Oct-07, at 12:07 PM, Ian was here wrote:
    >
    >> The only issue that I'm having is that I'm getting
    >> some rather strange values. Such as...
    >>
    >>
    >> This is clicking on the center of the view:
    >> x: 377.000000    y: 270.000000        wx: 0.175438    wy:
    >> -0.899123
    >>
    >> Which seems OK.
    >>
    >>
    >> This is the upper-left corner:
    >> x: 41.000000    y: 582.000000 wx: -987407225.612816
    > wy:
    >> 942763954.976947
    >>
    >>
    >> And this is near the lower-right corner:
    >> x: 770.000000    y: 30.000000        wx: 0.000000    wy:
    > -1.000000
    >>
    >>
    >> There is one last step that I seem to be
    > missing...
    >>
    >
    >

          ____________________________________________________________________________________
    Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today