Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
Have you tried drawing the skybox before drawing the game objects? Also a screenshot would help. – Tetrad Feb 5 '11 at 19:18
up vote 4 down vote accepted

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.

share|improve this answer
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. – r2d2rigo Feb 6 '11 at 1:21
@r2d2rigo: It is a 3D skybox (cube). when I try to add translation to the skybox, I soon run out of the cube. – brainydexter Feb 6 '11 at 3:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.