Glm::lookAt crash


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


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.

So what should be done if I want to look straight up or down? No idea for a solution actually comes to my head.

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.