title: i want to wrap an image around a sphere in opengl
body: <p>I am developing Billiard game for which i have several balls in the table.
  to make each ball unique i tried to give numbers to them using texture. Using texture i can also show rotation of balls.</p>
  
  <p>So far i have mapped texture using SOIL in</p>
  
  <p>INIT() function ---</p>
  
  <pre><code>glGenTextures(1,&amp;texture_id);
  texture_id = SOIL_load_OGL_texture("globe.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID,  SOIL_FLAG_INVERT_Y);
  
  glBindTexture(GL_TEXTURE_2D, texture_id);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  </code></pre>
  
  <p>DISPLAY FUNCTION()</p>
  
  <pre><code>glPushMatrix();                                       // Push the current matrix stack
      glColor3f(1,1,1);
      glEnable( GL_TEXTURE_2D );
      glBindTexture( GL_TEXTURE_2D, texture_id);
  
      glEnable(GL_TEXTURE_GEN_S);
      glEnable(GL_TEXTURE_GEN_T);
      glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
      glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      glTranslatef(world.qBall.pos.x,world.qBall.pos.y,world.qBall.pos.z);  //Multiply the current matrix by a translation matrix
      glRotatef(30,1,0,0);
      glutSolidSphere  (world.qBall.radius*5,50,50); 
      glDisable(GL_TEXTURE_GEN_S);
      glDisable(GL_TEXTURE_GEN_T);
      glDisable(GL_TEXTURE_2D);
  glPopMatrix();  // Pop the current matrix stack
  </code></pre>
  
  <p>I am getting from this is whole image mapped onto visible portion of sphere and not wrapping sphere so that only parts of image are visible .
  also when i move my camera texture also rotates with it.</p>
  
  <p>So , how do i wrap my texture around sphere so that only partial image appears!.</p>