skydome texture questions

In my opengl prog i’m drawing a massive sphere in my scene and giving it a clouds texture to simulate the sky and then rotating the sphere to make it look like its moving.

I have a couple of questions:

  1. On the sphere where the two ends of the texture meet there is a white line which looks stupid. I tried using glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) ; but it didn’t do anything. I had to add
    #define GL_CLAMP_TO_EDGE 0x812F as well otherwise it wouldn’t compile.

  2. My sphere has a radius of 1000.0f and so i’ve set Z far in gluPerspective to 1001.0f. Is there a better way to do this?

btw i’m this is on winXP with a radeon 9200se

1: Get a copy of glext.h . It contains constants and function pointer typedefs for everything above OpenGL 1.1 and all extensions.

2: As long as the sphere is centered at the viewpoit, it doesn’t matter what size the sphere is. Keep the far plane at whatever distance is needed to render everything except the sphere properly. Then draw the sphere first of all with no depth test, and then draw everything else. The size of the sphere doesn’t matter then, so just keep it at a size so it fits within the view volume.

Correct, the size of the sphere does not matter if you
are going to lcear the depth buffer before drawing
anything else. Setting the far plane to 1001 is what
I would do and avoid buffer clearing.

My question to you: How did you texture map the sphere
with the clouds texture? And by that I mean how did you
generate the texel coordinates. There are a few ways, some
are better than others and I have yet to find one that
I like… If you could tell us a bit about this, that
would be great.

Keep a copy of glext.h handy! And having said that,
keep a copy of the files in the “util” directory
of the MESA distribution too…

Thanks for the advice,

I’m loading textures the way that is shown in the Nehe lesson 6 tutorial and this is what my texture loading code looks like:

      AUX_RGBImageRec *TextureImage[MAX_TEXS];                                
    	textures = new GLuint[numtextures];												

        memset(TextureImage,0,sizeof(void *)*1);                                

        for( i = 0; i < numtextures; i++)										
        { 
				
                if (TextureImage[i]=LoadBMP(imagefilename))								
                { 
                        Status=TRUE;                                                    
                        glGenTextures(1, &textures[i]);                                  

                        glBindTexture(GL_TEXTURE_2D, textures[i]);						 

                        glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[i]->sizeX, TextureImage[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[i]->data);	 

                        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 
                        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);  
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) ;

                } 

                if (TextureImage[i])                                                    
                { 
                        if (TextureImage[i]->data)                                       
                        { 
                                free(TextureImage[i]->data);                            

                        } 

                        free(TextureImage[i]);                                           
                } 
        }   

And how do you generate texels (per vertex texture
coordinates)? That is where you have to be smart in
order to make the skydome look good. What do you do?

This is the dome drawing code, i’m not sure how it generates texels.

GLUquadricObj *quadratic;
glBindTexture(GL_TEXTURE_2D, textures[iTexNum]);
quadratic=gluNewQuadric();			
gluQuadricNormals(quadratic, GLU_SMOOTH);	
gluQuadricTexture(quadratic, GL_TRUE);  
gluSphere(quadratic,radius,32,32);