Jump to content
  • Advertisement
Sign in to follow this  

OpenGL proper rotations for skybox

This topic is 3196 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there. I'm new to OpenGL and 3D graphics in general. I have a very simple scene with a skybox being rendered in the background. I'm trying to render the skybox after the rest of the scene with depth testing so it's behind everything else. The thing I'm having trouble with is making sure that the correct rotations are performed when drawing the skybox without any translations. Currently my code looks something like this:

if(xmove != 0) {
    camera.Strafe(xmove * speed);


glScalef(scale, scale, scale);

// draw scene


The camera class is based on some code I found by googling. It keeps track of up, right, view and position vectors. Do I do glLoadIdentity in RenderSky then work out what rotations to apply based on the camera state (if so, how?) or is there a better/easier way? Thanks in advance.

Share this post

Link to post
Share on other sites
Well, the skybox is centered at the camera but doesn't rotate.
Thus you need to apply rotations only with translation set to 0.

glLoadIdentity + redoing the transformations is a reasonable approach.
You also could use glPushMatrix() + glPopMatrix() after the camera rotations have been applied and before the sky is rendered.

Another approach would be to get the current camera transformation matrix and just set the translation part to 0. This would require you to set the matrices with glLoadMatrix and calculate them yourself, but since glPushMatrix and the like are/will be deprecated, you might consider going down that road.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!