title: How would I read a sprite sheet in LWJGL?
body: <p>I currently use LWJGL Textures to draw images on the screen. I would like to read Textures* from a sprite sheet. I am using slick's TextureLoader class to load the textures.</p>
  
  <p>I draw an LWJGL Shape and bind a Texture onto it.</p>
  
  <p>e.g:</p>
  
  <p>Me drawing an image:</p>
  
  <pre><code>    Texture texture = ResourceManager.loadTexture("Images/Tests/test.png");
  
      GL11.glBegin(GL11.GL_QUADS);
      {
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex2f(0, 0);
        GL11.glTexCoord2f(0, texture.getHeight());
        GL11.glVertex2f(0, height);
        GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
        GL11.glVertex2f(width,height);
        GL11.glTexCoord2f(texture.getWidth(), 0);
        GL11.glVertex2f(width,0);
      }
      GL11.glEnd();
  </code></pre>
  
  <p>I think there is a way by when calling glTexCoord2f, I could give it a sprite offset and load the sprite sheet in the texture instead,</p>
  
  <p>for example one call would be like this:</p>
  
  <pre><code>      GL11.glTexCoord2f(0+spriteXOffset, texture.getHeight()-spriteYOffset);
  </code></pre>
  
  <p>But I would really like to know if there is a simpler way, maybe extracting Textures from a single texture for example like they do in here:</p>
  
  <p><a href="https://stackoverflow.com/questions/10604824/reading-images-from-a-sprite-sheet-java">Reading images from a sprite sheet Java</a></p>
  
  <p>Just instead of BufferedImage, Texture object.</p>
  
  <p>Thank you for the help!</p>