title: Rotation around camera's axis
body: <p>I want to build proper camera transformations in OpenGL and I have a question.</p>
  
  <p>I built a simple 3D engine with without OpenGL, just to see how hard it is to make simple projection of the world onto a screen. </p>
  
  <p>In this engine I put wiewer on (0,0,0) with the eye sight on
      (1,0,0). 
  ASDW make translation of objects. 
  Mouse make rotation
      around (1,0,0),(0,1,0),(0,0,1).</p>
  
  <p>I learned a lot with programing my own 3D engine. With that knowledge I started to build a proper 3D engine based on OpenGL.</p>
  
  <p>For camera transformation in OpenGL, I made this code...</p>
  
  <p>Camera's axis define where up,right,forward translation will go.
  Rotation is made around global axis (I want to rotate objects around camera's axis) :(</p>
  
  
  
  <pre class="lang-py prettyprint-override"><code>glRotatef(camera_rot[0],1,0,0)
  glRotatef(camera_rot[1],0,1,0)
  glRotatef(camera_rot[2],0,0,1)
  
  camera_rot[0]=0
  camera_rot[1]=0
  camera_rot[2]=0
  
  glGetFloatv(GL_MODELVIEW_MATRIX, matrix)
  
  glTranslatef(
  matrix[0]*camera_tra[0],
  matrix[4]*camera_tra[0],
  matrix[8]*camera_tra[0])
  
  glTranslatef(
  matrix[1]*camera_tra[1],
  matrix[5]*camera_tra[1],
  matrix[9]*camera_tra[1])
  
  glTranslatef(
  matrix[2]*camera_tra[2],
  matrix[6]*camera_tra[2],
  matrix[10]*camera_tra[2])
  
  camera_tra[0]=0
  camera_tra[1]=0
  camera_tra[2]=0
  </code></pre>
  
  <p>It's kinda confusing why OpenGL designers didn't put camera in (0,0,0) and make translation and rotation on object not camera.</p>
  
  <p>I'm thinking to manually aplly transformation with out glTranslate or glRotation and put transformation logic from my 3D engine (that I made) to changing glVertexe cordinates.
  So every time in draw function I will change glVertexes cordinates. But if I do that the vertextes will multiply after my transformation with identical matrix (ModelView matrix), and I don't want meaningless computation in my program.</p>
  
  <p>So what should I do to fix this problem?
  How can I make the best solution for rotation around camera's axis?</p>