I am rotating the camera around itself (when the camera is located at (0,0,0)) using the following:
glRotatef(x_camera_angle, 1.0, 0.0, 0.0);
glRotatef(y_camera_angle, 0.0, 1.0, 0.0);
I wish to move the camera in the direction its looking, and to move objects according to the camera direction (for example, to move object to the camera and away from camera).
I've tried achieving this using the modelview matrix as specified in here: https://stackoverflow.com/a/16137191/3362159 , but this doesn't seem to work. For example, I tried moving the camera forward (according to its direction) using the following code:
glTranslatef(front[0] * units_forward, front[1] * units_forward, front[2] * units_forward);
where "front" is the matrix specified in the answer. The camera doesn't move forward, It moves differently depending on its direction.
What am I doing wrong? Any help would be appreciated.