title: Camera rotation (OpenGL)
body: <p>I am having trouble with a camera class I am trying to use in my program. When I change the camera_target of the gluLookAt call, my whole terrain is rotating instead of just the camera rotating like it should.</p>
  
  <p>Here is some code from my render method:</p>
  
  <pre><code>camera-&gt;Place();
  
      ofSetColor(255, 255, 255, 255);
  
   //draw axis lines
   //x-axis
   glBegin(GL_LINES);
   glColor3f(1.0f,0.0f,0.0f);
   glVertex3f(0.0f,0.0f,0.0f);
   glVertex3f(100.0f, 0.0f,0.0f);
   glEnd();
  
   //y-axis
   glBegin(GL_LINES);
   glColor3f(0.0f,1.0f,0.0f);
   glVertex3f(0.0f,0.0f,0.0f);
   glVertex3f(0.0f, 100.0f,0.0f);
   glEnd();
  
   //z-axis
   glBegin(GL_LINES);
   glColor3f(0.0f,0.0f,1.0f);
   glVertex3f(0.0f,0.0f,0.0f);
   glVertex3f(0.0f, 0.0f,100.0f);
   glEnd();
  
   glColor3f(1,1,1);
  
   terrain-&gt;Draw();
  </code></pre>
  
  <p>And the rotate and place methods from my camera class:</p>
  
  <pre><code>void Camera::RotateCamera(float h, float v){
  hRadians += h;
  vRadians += v;
  
  cam_target.y = cam_position.y+(float)(radius*sin(vRadians));
  cam_target.x = cam_position.x+(float)(radius*cos(vRadians)*cos(hRadians));
  cam_target.z = cam_position.z+(float)(radius*cos(vRadians)*sin(hRadians));
  
  cam_up.x = cam_position.x-cam_target.x;
  cam_up.y = ABS(cam_position.y+(float)(radius*sin(vRadians+PI/2))) ;
  cam_up.z = cam_position.z-cam_target.z;
  }
  
  void Camera::Place() {
  //position, camera target, up vector
  gluLookAt(cam_position.x, cam_position.y, cam_position.z, cam_target.x, cam_target.y, cam_target.z, cam_up.x, cam_up.y, cam_up.z);
  }
  </code></pre>
  
  <p>The problem is that the whole terrain is moving around the camera, whereas the camera should just be rotating.</p>
  
  <p>Thanks for any help!</p>
  
  <p>EDIT - Found some great tutorials and taking into account the answers on here, I make a better camera class. Thanks guys</p>