Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: gluPerspective vs. GLKMatrix4MakePerspective use in OSX OpenGL

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2014
    Posts
    12

    gluPerspective vs. GLKMatrix4MakePerspective use in OSX OpenGL

    Hello,

    I am programming a Mac OSX application in Xcode and I am running into some problems with the GL functions. I need to use the gluPerspective function to do some set up but apparently its is deprecated for osx. Xcode suggests using GLKMatrix4MakePerspective function as a substitute but even after researching the documentation I can't figure out how to use it.
    Here is a part of my code:

    glLoadIdentity();
    gluPerspective(30f,[self bounds].size.width/(GLfloat)[self bounds].size.width,1.0f,1000.0f);
    glEnable(GL_DEPTH_TEST);
    glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);

    And again, the gluPerspective is deprecated so I can't get the result i am looking for.

    If anyone who is good at this could explain it to me how to use the new function as a substitute I would be very grateful.

    Thanks in advance for any feedback.

  2. #2
    Intern Newbie
    Join Date
    Apr 2014
    Posts
    47
    The fact gluPerspective is deprecated shouldn't affect your ability to use it. It looks like you have a typo for your aspect ratio--you are dividing width by width, and not width by height. If you fix that it should work.

    gluPerspective creates a perspective projection matrix and then multiplies it onto the current selected matrix stack, while GLKMatrix4MakePerspective creates a matrix and returns it.

    You can accomplish the same effect by doing something like:
    Code :
    glMatrixMode( GL_PROJECTION ); // select our projection matrix
    glLoadIdentity();
    glMultMatrix( GLKMatrix4MakePerspective(30f,[self bounds].size.width/(GLfloat)[self bounds].size.height,1.0f,1000.0f ).m ); // << .m is the GLfloat* you are accessing
    glEnable(GL_DEPTH_TEST);
    glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
    //...etc... for model drawing
    glMatrixMode( GL_MODELVIEW );
    //...drawing, etc.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2014
    Posts
    12
    Thanks a lot. I appreciate the explanation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •