The Sky

I want a texture for the background sky instead of
glClearColor(0,1,1,0) //cyan
How can this be done?

Do a search on this board for skyboxes. It has been discussed very many times, so everything you need to know should be readily available.

You need to make a skybox or half a sphere, and then apply a ‘sky’ texure to it.

Or if angle doesn’t change much, i.e. up and down, you could create a huge quad in the distance and then apple a sky texture to it. That sounds tacky and dirty to implement. Do a search on 3d skybox in google. You might get some useful hits.
Thats how i get insight into stuff i need for my programming. For example i’m donig some research into collision detection for spheres and i found some great sites with detailed information about collision detection and tidbits of code which you can use.

oops, i was typing my post before the prior post was up. Cool! i can look around here for skybox algorithms too!

It’s a quite ewasy task :

build a box, apply to it 6 textures (maybe create them with software like bryce) so that they are a 90° camera view perpendicular to each box plane. (it is possible to do it also with only one texture but this will be “advanced stuff”, and another good hint is to create more than one box at time)

then make the box(es) rotate, but NOT translate with the current camera, draw them with glDepthMask disabled and you are done.

rIO.sK http://www.spinningkids.org/rio

Or (I stand corrected, rIO and DFrey), translate the skybox to follow the camera’s translation. Like this:

gluLookAt( ex, ey, ez, cx, cy, cz, ux, uy, uz );
glPushMatrix();
glTranslatef( ex, ey, ez );
DrawSkyBox();
glPopMatrix();

[This message has been edited by Jambolo (edited 03-24-2002).]

You can do it either way. Either draw the skybox with only a rotation matrix set, then translate and draw everything else (which is the method I prefer as then the size of the box is independent of what follows), or you can use your approach and rotate the box then translate it, but then the box must really be bigger than anything else that gets drawn.

Originally posted by DFrey:
You can do it either way. Either draw the skybox with only a rotation matrix set, then translate and draw everything else (which is the method I prefer as then the size of the box is independent of what follows), or you can use your approach and rotate the box then translate it, but then the box must really be bigger than anything else that gets drawn.

As long as it is drawn before anything else (with depth write and depth test turned off) it doesn’t matter how big it is, right?
But that means that the depth buffer still has to be cleared. Is there a faster way? You could draw a really big box with depth write on, but there could be problems since it doesn’t match the far clipping plane.

[This message has been edited by Jambolo (edited 03-24-2002).]