# Sphere texture mapping - distortion strip problem

## Recommended Posts

Sword7    135

Hello folks,

I am writing a small program to display planet earth by using glDrawElements and vertex/indices array.

It normally displays planet earth but seam strip between alaska and russia land.  I think that it is a problem with texcoords or glDrawElements function call.  I tried different ways but it always display distrotion strip.  Does anyone know any working around to get rid of distrotion strip?

Look at my code below.

Thanks!

Sword7

    int    thetaExtent = extent;

int    phiExtent   = extent/2;

int    theta1      = theta0 + thetaExtent;

int    phi1        = phi0 + phiExtent;

double phiStep     = (PI) / phiExtent;

double thetaStep   = (2 * PI) / thetaExtent;

double *v = vertices;

double *t = texCoords;
for (int phi = phi0; phi <= phi1; phi += ri.step) {

for (int theta = theta0; theta < theta1; theta += ri.step) {

*v++ = sin(phi * phiStep) * cos(theta * thetaStep);

*v++ = cos(phi * phiStep);

*v++ = sin(phi * phiStep) * sin(theta * thetaStep);

*t++ = 1 - (theta * (1.0 / thetaExtent));

*t++ = phi * (1.0 / phiExtent);

}

}

uint16 *i = indices;

for (int p = 0; p < phiExtent; p++) {

for (int t = 0; t < thetaExtent; t++) {

*i++ = p * thetaExtent + t;

*i++ = p * thetaExtent + (t+1);

*i++ = (p+1) * thetaExtent + (t+1);

*i++ = (p+1) * thetaExtent + t;

}

}

glVertexPointer(3, GL_DOUBLE, 0, vertices);

glNormalPointer(GL_DOUBLE, 0, vertices);

glTexCoordPointer(2, GL_DOUBLE, 0, texCoords);

glDrawElements(GL_QUADS, nIndices, GL_UNSIGNED_SHORT, indices);