views:

140

answers:

0

I am able to map a single image as a texture onto the entire surface of a sphere. But when I try to map the image to a small part of the sphere by using mipmaps the image quality is very poor. What should I do to improve that? And also how do I set texture coordinates for the image on the sphere? Is there an option other than mipmaps?

I am using DeVil image library for loading images. I am generating my own sphere through coordinates.

gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, 
 GL_RGB, GL_UNSIGNED_BYTE, ilGetData() );

At present I am generating texture coordinates in this manner:

for( b = 0; b <= 90-space; b+=space){
         for( a = 0; a <= 360-space; a+=space){

         VERTEX[n].X = R * sin((a) / 180 * PI) * sin((b) / 180 * PI) - H;
         VERTEX[n].Y = R * cos((a) / 180 * PI) * sin((b) / 180 * PI) + K;
         VERTEX[n].Z = R * cos((b) / 180 * PI) - Z;
         if(b>=BS && b<=BE-space && a>=AS && a<=AE-space)
         {
             VERTEX[n].V = ((b-BS))/(2*(BE-BS));
             VERTEX[n].U = -(a-AS)/(AE-AS);

where

space=10 is the interval
      U,V are texture coordinates
      BS=70,BE=90 are angles from Y axis 
      AS=50,AE=90 are angles from Z axis
  These angles describe the region where the image is to be mapped.