Environment Background With OpenGL
I am programming up a basic driving game and don't know how to do a background image (like the sky).
It doesn't have to be great, how is best?
Thanks
Spinner
It doesn't have to be great, how is best?
Thanks
Spinner
A relatively large textured cube that remains centered on the viewer?
Don't even bother having it large: you can make it just big enough to have it completely in the view, but turn off the depth buffer. (be sure to draw it first)
What akb825 said, except, I'd like to add that it's easy enough to make a dynamic one using layers of textured spheres.
TomorrowPlusX Wrote:What akb825 said, except, I'd like to add that it's easy enough to make a dynamic one using layers of textured spheres.Don't you mean 'relatively easy'?
so the spheres mesh together, but then rotate so it looks like the clouds are moving? or what do you mean?
He means you can have a series of spheres that have different textures on them. That way you can add different layers to the sky, or, as you said, you can also move one sphere to create movement.
So I need to call
But then how do I create and texture the sphere?
I don't really care about a realistic sky, I just want to apply a sky texture panorama something like
![[Image: urban_sky.jpg93fe09bc-a4ce-40a8-907b-a83...dLarge.jpg]](http://files.turbosquid.com/Preview/Content_on_12_14_2004_01_46_14/urban_sky.jpg93fe09bc-a4ce-40a8-907b-a8394154d83dLarge.jpg)
I am not sure how to (or even if I need to) use gluNewQuadric
Thanks
Spinner
Code:
glDisable(GL_DEPTH_TEST);
background();
glEnable(GL_DEPTH_TEST);But then how do I create and texture the sphere?
I don't really care about a realistic sky, I just want to apply a sky texture panorama something like
![[Image: urban_sky.jpg93fe09bc-a4ce-40a8-907b-a83...dLarge.jpg]](http://files.turbosquid.com/Preview/Content_on_12_14_2004_01_46_14/urban_sky.jpg93fe09bc-a4ce-40a8-907b-a8394154d83dLarge.jpg)
I am not sure how to (or even if I need to) use gluNewQuadric
Thanks
Spinner
Code:
//global or class variable
GLUquadric *sphere;
//in initialization
sphere = gluNewQuadric();
gluQuadricTexture(sphere, GL_TRUE);
//in draw function
//bind and enable textures
//all numbers are arbitrary
gluSphere(sphere, radius, numSlices, numStacks);
//in quit function
gluDeleteQuadric(sphere);For what numbers to choose, you can choose a smallish number, like 10, for the radius. (it doesn't really matter due to the perspective, as long as it isn't cut off by the view frustum) You can also pick smallish numbers for the number of slices and stacks, since you don't need a perfect sphere. Something like 10 each should do fine. You can also put the sphere itself in a display list to speed up the drawing.
Rather than glDisable(GL_DEPTH_TEST) / glEnable(GL_DEPTH_TEST), you'll probably want glDepthMask(GL_FALSE) / glDepthMask(GL_TRUE). That way your background won't be written to the depth buffer when you draw it.
Thanks, that was just what I was after. Looks pretty good, even with a really low res texture.
I was under the impression that disabling depth testing also disabled depth writing, although this may only apply to OpenGL ES.
Sir, e^iπ + 1 = 0, hence God exists; reply!
Disabling depth testing does indeed disable writing. If you want writing but no testing, you need to enable it, but set the DepthFunc to ALWAYS. Testing with no writing uses a DepthMask of FALSE, as has been said.
akb825 Wrote:He means you can have a series of spheres that have different textures on them. That way you can add different layers to the sky, or, as you said, you can also move one sphere to create movement.
Exactly. Also, I render my stars and planets and sun as tangential textured quads. This way they can be much higher resolution than the clouds. Further, I can do per-vertex colors on the outermost sphere to create atmospheric effects, such as a horizon color biased by proximity to bright objects like the sun, so you can have a reddish tint near a sunset.
OneSadCookie Wrote:Disabling depth testing does indeed disable writing.Interesting. I had no idea.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Environment mapping | MACnus | 6 | 3,438 |
Jul 13, 2005 08:43 AM Last Post: MACnus |
|
| dynamic environment mapping | orange144 | 6 | 3,763 |
Jul 7, 2004 06:13 PM Last Post: tod_baudais |
|
| Character Environment Collision Detection | NYGhost | 1 | 2,338 |
Sep 30, 2003 09:05 AM Last Post: MacFiend |
|
| Cube Environment | PowerMacX | 3 | 2,731 |
Aug 7, 2003 09:36 PM Last Post: MattDiamond |
|

