Results 1 to 3 of 3

Thread: How to change the "camera" position in OpenGL - Mac OSX

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

    Question How to change the "camera" position in OpenGL - Mac OSX

    Hey guys,

    I am quite new to OpenGL but I am trying to figure out how to draw things in 3D. I am trying to write a simple program in Xcode for Mac OSX which uses OpenGL library and the NSOpenGLView class to draw OpenGL graphics. I want to figure out how to change the position of the "camera" so the object can be viewed from top, bottom, right, left, at an angle, etc. The thing that is not working for me is the glLookAt() method. Apparently it was deprecated and now I have to use GLKMatrix4MakeLookAt(); The big problem though, is that this method appears to do nothing.

    this is my method do do the basic drawing and change the position of the camera - am i doing something wrong?

    -(void) display
    {

    glClearColor(0, 0, 0, 0);
    glClear(GL_COLOR_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);


    glLoadIdentity ();

    GLKMatrix4MakeLookAt(10, 10, 10, 0.0, 0.0, 0.0, 0.5, 1.0, 0.0);

    glPushMatrix();

    // draw the cube

    glPopMatrix();
    }

    Any advice? Any help is hugely appreciated as well as any additional approaches to manipulating perspectives or rotating stuff in OpenGL or code examples of how to do this


    Thanks a lot for any feedback you guys might give.

  2. #2
    Member Contributor
    Join Date
    Oct 2011
    Posts
    73
    GLKMatrix4MakeLookAt, according to a fast check on google, returns a GLKMatrix4. It doesn't call any gl code. https://developer.apple.com/library/...rix4MakeLookAt

    So you are creating a matrix which you are not loading up anywhere. This is assuming you have the rest of your rendering setup correct and many other things not shown in your code.

    Quite honestly, you likely won't enjoy hearing this, but you should probably put on your training wheels and grab a book on the subject because it's not only OpenGL what you'll have to learn and understand to actually "draw things in 3D". The OpenGL Superbible 6th Ed. is probably a good start, but I'm sure there's many other choices.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2014
    Posts
    12
    Thank you for suggestions. can you or someone explain how to "load it up" (the matrix) if thats not too much trouble because I understand and know matrix mathematics, more generally linear algebra, but I can't really understand the syntax and what to do as far as transferring the math and matrices to code.

Similar Threads

  1. Replies: 0
    Last Post: 11-08-2017, 03:02 PM
  2. Switching between "arcball" and "fps-style" camera rotation
    By bsabiston in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-31-2017, 12:37 PM
  3. Replies: 1
    Last Post: 10-26-2012, 02:19 AM
  4. opengl & linux -- "GLTools.h"&"GLShaderManager.h"
    By ggeo1 in forum OpenGL: Linux
    Replies: 1
    Last Post: 03-07-2011, 08:39 AM
  5. beginner question about "camera" in openGL
    By ashi08104 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 02-01-2011, 07:20 PM

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