Exemplo n.º 1
0
 /**
  * Uploads the pixel data to the given texture at the specified position. This only needs to be
  * called once, after the pixel data has changed.
  *
  * @param texture the texture to modify
  * @param x the x position to place the pixel data on the texture
  * @param y the y position to place the pixel data on the texture
  */
 public void apply(Texture texture, int x, int y) {
   if (x + width > texture.getTextureWidth() || y + height > texture.getTextureHeight())
     throw new IndexOutOfBoundsException("pixel data won't fit in given texture");
   position(length());
   pixels.flip();
   int glFmt = format.getOGLType();
   final SGL GL = Renderer.get();
   texture.bind();
   GL.glTexSubImage2D(
       SGL.GL_TEXTURE_2D, 0, x, y, width, height, glFmt, SGL.GL_UNSIGNED_BYTE, pixels);
 }