java.lang.Object
dev.prozilla.pine.common.system.resource.Texture
All Implemented Interfaces:
Lifecycle, Printable

public class Texture extends Object implements Lifecycle, Printable
Represents an OpenGL texture.
  • Field Details

    • id

      public final int id
      Stores the handle of the texture.
    • currentTextureId

      public static Integer currentTextureId
  • Constructor Details

    • Texture

      public Texture()
      Creates a texture.
  • Method Details

    • bind

      public void bind()
      Binds the texture.
    • unbind

      public void unbind()
    • setParameter

      public void setParameter(int name, int value)
      Sets a parameter of the texture.
      Parameters:
      name - Name of the parameter
      value - Value to set
    • uploadData

      public void uploadData(int width, int height, ByteBuffer data)
      Uploads image data with specified width and height.
      Parameters:
      width - Width of the image
      height - Height of the image
      data - Pixel data of the image
    • uploadData

      public void uploadData(int internalFormat, int width, int height, int format, ByteBuffer data)
      Uploads image data with specified internal format, width, height and image format.
      Parameters:
      internalFormat - Internal format of the image data
      width - Width of the image
      height - Height of the image
      format - Format of the image data
      data - Pixel data of the image
    • destroy

      public void destroy()
      Delete the texture.
      Specified by:
      destroy in interface Lifecycle
    • getWidth

      public int getWidth()
      Gets the texture width.
      Returns:
      Texture width
    • setWidth

      public void setWidth(int width)
      Sets the texture width.
      Parameters:
      width - The width to set
    • getHeight

      public int getHeight()
      Gets the texture height.
      Returns:
      Texture height
    • setHeight

      public void setHeight(int height)
      Sets the texture height.
      Parameters:
      height - The height to set
    • toString

      public String toString()
      Description copied from interface: Printable
      Returns a string representation of this object.
      Specified by:
      toString in interface Printable
      Overrides:
      toString in class Object
      Returns:
      String representation of this object.
    • createTexture

      public static Texture createTexture(Image image)
      Creates a texture based on an image.
      Parameters:
      image - Image
      Returns:
      Texture
    • createTexture

      public static Texture createTexture(int width, int height, ByteBuffer data)
      Creates a texture with specified width, height and data.
      Parameters:
      width - Width of the texture
      height - Height of the texture
      data - Picture Data in RGBA format
      Returns:
      Texture from the specified data
    • reset

      public static void reset()