title: getting a region from texture atlas with opengl using soil
body: <p>I want to map different regions of texture atlas to the different sides of a cube with opengl using soil. So far, I manage to map a single image to one of the sides of the cube : </p>
  
  <pre><code>int LoadTexture(const char*);
  
  int texID;
  
  void DrawCube(float width)
  {
      float wd2 = width / 2;
      glColor3f(0, 0, 1);
      glBegin(GL_QUADS);
  
      //front
      glTexCoord2f(0, 1);
      glVertex3f(-wd2, -wd2, wd2);
      glTexCoord2f(1, 1);
      glVertex3f(wd2, -wd2, wd2);
      glTexCoord2f(1, 0);
  
      glVertex3f(wd2, wd2, wd2);
      glTexCoord2f(0, 0);
  
      glVertex3f(-wd2, wd2, wd2);
  
      //left side..
      //right side..
      //back..
      //top..
      //bottom..
  
      glEnd();
  }
  
  int LoadTexture(const char* tex) {
      texID = SOIL_load_OGL_texture(tex, 4, 0, 0);
      if (!texID) {
          cout &lt;&lt; "Texture not loaded!\n";
  
      }
      return texID;
  }
  </code></pre>
  
  <p>And in the <code>init</code> function :</p>
  
  <pre><code>glEnable(GL_TEXTURE_2D);
  texID = LoadTexture("sas.jpg");
  glBindTexture(GL_TEXTURE_2D, texID);
  </code></pre>
  
  <p>But my question is how do I get only one sprite of the whole texture ? </p>
  
  <p>Here is the image : 
  <a href="https://i.stack.imgur.com/WSUUw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WSUUw.jpg" alt="image"></a></p>