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 4 of 4

Thread: Glm::lookAt crash

  1. #1
    Intern Newbie
    Join Date
    Feb 2014
    Location
    Poland
    Posts
    42

    Glm::lookAt crash

    Hello

    I recently have experienced crash using glm::lookAt function. I'm not sure what is wrong, but it occurs only when I pass camera location and target both with the same Z value. For example camera location to be (0, 0, 4) and target (0, -1, 4) and to have every argument, the up vector is also (0, 1, 0).
    Is it me doing something wrong, or it's just the glm's bug? In either case, what should be done to avoid the crash?
    The error message is:
    Terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_$_construct null not valid
    Thanks.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,224
    The problem is that your "look_toward" vector is colinear with your "up" vector.

    look_toward = normalize( target - camera_loc ) = vec3( 0,-1,0 )

    With this, LookAt can't define an orthonormal coordinate frame.
    Last edited by Dark Photon; 03-03-2014 at 05:10 PM.

  3. #3
    Intern Newbie
    Join Date
    Feb 2014
    Location
    Poland
    Posts
    42
    So what should be done if I want to look straight up or down? No idea for a solution actually comes to my head.

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,224
    Pass a camera "up" vector that is pointing north, or south, or east, or ... Along the ground anyway.

    Keep in mind when you say "look straight up" you are talking about WORLD space, not EYE space. With gluLookAt, you are providing vectors in WORLD space to orient and position EYE space.

Posting Permissions

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