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

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

    • Texture

      public Texture(int width, int height)
      Creates an empty texture.
    • Texture

      public Texture(Image image)
      Creates a texture based on an image.
    • Texture

      public Texture(String path, int width, int height, ByteBuffer pixels)
  • Method Details

    • bind

      public void bind()
      Description copied from interface: TextureBase
      Binds this texture.
      Specified by:
      bind in interface TextureBase
    • unbind

      public void unbind()
      Description copied from interface: TextureBase
      Unbinds this texture.
      Specified by:
      unbind in interface TextureBase
    • setParameter

      public void setParameter(int name, int value)
    • uploadData

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

      public void uploadData(int internalFormat, int width, int height, int format, ByteBuffer pixels)
      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
      pixels - Pixel data of the image
    • destroy

      public void destroy()
      Description copied from interface: TextureBase
      Removes this texture from the resource pool and deletes it.
      Specified by:
      destroy in interface Lifecycle
      Specified by:
      destroy in interface Resource
      Specified by:
      destroy in interface TextureBase
    • getId

      public int getId()
      Specified by:
      getId in interface TextureBase
    • getWidth

      public int getWidth()
      Specified by:
      getWidth in interface TextureBase
      Returns:
      The width of this texture, in pixels.
    • getHeight

      public int getHeight()
      Specified by:
      getHeight in interface TextureBase
      Returns:
      The height of this texture, in pixels.
    • getPath

      public String getPath()
      Specified by:
      getPath in interface Resource
      Specified by:
      getPath in interface TextureBase
      Returns:
      The path of the image file of this texture.
    • hasEqualLocation

      public boolean hasEqualLocation(TextureBase other)
      Description copied from interface: TextureBase
      Checks whether two textures are from the same location.
      Specified by:
      hasEqualLocation in interface TextureBase
      Parameters:
      other - Other texture
      Returns:
      True if other is equal to this texture or in the same texture array.
    • isInArray

      public boolean isInArray()
      Specified by:
      isInArray in interface TextureBase
      Returns:
      True if this texture is part of a texture array.
    • getArray

      public TextureArray getArray()
      Specified by:
      getArray in interface TextureBase
      Returns:
      The texture array this texture is part of, or null if this texture is not in a texture array.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(TextureBase other)
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • 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.