Hello, I have a slight problem with textures that I can’t seem to figure out on my own.
I created a sphere using gluSphere() which I then textured to look like Earth. At first it was small(1.0f radius) and it looked fine, then I decided to change my scale so each unit in the coordinate system represents 1 meter. I therefore rendered a sphere with a radius of 6371000.0 and this is where the problem comes in:
For some reason, the texture is distorted in a sense that it’s too big and only part of it is applied to the sphere. For example, whereas Antarctica normally takes up maybe 1/4 of the sphere’s side if you look at it from a 90 degree angle, it now takes up over half the sphere instead. I have tried playing with the various texture parameters but have thus far had no success with solving this problem. Any help would be greatly appreciated. Rendering code below:
EDIT: If it helps, the texture image is JPG format and is 4096x2048 in size
gluPerspective(50.0*zoomFactor, (GLfloat) w/(GLfloat) h, 2.0, 2000000000000000000000.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(18000000.0, 0.0, 0.0, 6500000.0, 0.0, 0.0, 0.0, 1.0, 0.0); glRotatef((GLfloat) rotation, 0.0, 1.0, 0.0); glLightfv(GL_LIGHT0,GL_POSITION,light_position); cout<<"rotation: "<<test<<endl; glColor3ubv(earthColor); glGenTextures(1, &texID); glBindTexture(GL_TEXTURE_2D, texID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA, w, h, 0, GL_RGBA,GL_UNSIGNED_BYTE,textura ); glEnable(GL_TEXTURE_2D); glBindTexture ( GL_TEXTURE_2D, texID); sphere = gluNewQuadric(); gluQuadricDrawStyle( sphere, GLU_FILL); gluQuadricNormals( sphere, GLU_SMOOTH); gluQuadricOrientation( sphere, GLU_OUTSIDE); gluQuadricTexture( sphere, GL_TRUE); //glColor3f(0.0, 1.0, 0.0); gluSphere( sphere, 6371000, 50, 40); //gluSphere( sphere, 0.2, 50, 40); glDisable(GL_TEXTURE_2D);
As you can see in the below image, Antarctica looks abnormally large:
And this is what it should look like: