title: Move according to camera direction
body: <p>I am rotating the camera around itself (when the camera is located at (0,0,0)) using the following:</p>
  
  <pre><code>glRotatef(x_camera_angle, 1.0, 0.0, 0.0);
  glRotatef(y_camera_angle, 0.0, 1.0, 0.0);
  </code></pre>
  
  <p>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).</p>
  
  <p>I've tried achieving this using the modelview matrix as specified in here: <a href="https://stackoverflow.com/a/16137191/3362159">https://stackoverflow.com/a/16137191/3362159</a> , but this doesn't seem to work. For example, I tried moving the camera forward (according to its direction) using the following code:</p>
  
  <pre><code>glTranslatef(front[0] * units_forward, front[1] * units_forward, front[2] * units_forward);
  </code></pre>
  
  <p>where "front" is the matrix specified in the answer. The camera doesn't move forward, It moves differently depending on its direction.</p>
  
  <p>What am I doing wrong? Any help would be appreciated.</p>