I am trying to get a skybox rendered correctly in my first person shooter game. I have the skybox cube rendering using GL_TEXTURE_CUBE_MAP. I author the cube with extents of -1 and 1 along X,Y and Z.

However, I can't wrap my head around the camera transformations that I need to apply to get it right. My render loop looks something like this:

  • mp_Camera->ApplyTransform() :: Takes the current player transformation and inverts it and pushes that on the modelview stack.
  • Draw GameObjects
  • Draw Skybox

DrawSkybox does the following:


// draw the cube here with extents


Do I need to translate the skybox by the translation of the camera ? (btw, that didn't help either)

EDIT: I forgot to mention: It looks like a small cube with unit extents. Also, I can strafe in/out of the cube. Screenshot: Skybox as seen when stepped back in space

  • \$\begingroup\$ Have you tried drawing the skybox before drawing the game objects? Also a screenshot would help. \$\endgroup\$
    – Tetrad
    Feb 5, 2011 at 19:18

1 Answer 1


What you want to do is construct a matrix with only the rotation of the camera, and use that for the camera's world matrix, render the skybox there (i.e., as if the camera is at 0,0,0), and then render the other geometry with the camera's real position.

  • 1
    \$\begingroup\$ You can still add a little translation (your world translation * 0.001f, or some other appropiate scale) to simulate that you are travelling along the world. This works best if you are adding a 3d skybox. \$\endgroup\$
    – r2d2rigo
    Feb 6, 2011 at 1:21
  • \$\begingroup\$ @r2d2rigo: It is a 3D skybox (cube). when I try to add translation to the skybox, I soon run out of the cube. \$\endgroup\$ Feb 6, 2011 at 3:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .