Class Texture

java.lang.Object
org.xjge.graphics.Texture

public final class Texture
extends java.lang.Object
Supplies the data parsed from an image file into a new two-dimensional texture object that can be used by the graphics pipeline. RBGA encoded .png is the preferred file format of this engine. OpenGL texture parameters are expected to be defined outside of this class following the texture objects initialization.
Since:
2.0.0
  • Field Summary

    Fields
    Modifier and Type Field Description
    int handle  
  • Constructor Summary

    Constructors
    Constructor Description
    Texture​(java.lang.String filename)
    Creates a new texture object from the image file specified.
    Texture​(java.lang.String filename, int target)
    Creates a new texture object from the image file specified.
  • Method Summary

    Modifier and Type Method Description
    void freeTexture()
    Frees the OpenGL texture image associated with this object.
    int getChannels()
    Obtains the amount of color channels this texture uses.
    int getHeight()
    Obtains the height of the texture.
    int getWidth()
    Obtains the width of the texture.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • handle

      public final int handle
  • Constructor Details

    • Texture

      public Texture​(java.lang.String filename, int target)
      Creates a new texture object from the image file specified. If the image file cannot be found, the engine will instead use a fallback texture in its place.
      Parameters:
      filename - the name of the file to load. Expects the file extension to be included.
      target - the OpenGL texture target. One of:
      TEXTURE_2D TEXTURE_1D_ARRAY TEXTURE_RECTANGLE TEXTURE_CUBE_MAP
      PROXY_TEXTURE_2D PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_CUBE_MAP
    • Texture

      public Texture​(java.lang.String filename)
      Creates a new texture object from the image file specified. If the image file cannot be found, the engine will instead use a fallback texture in its place.
      Parameters:
      filename - the name of the file to load. Expects the file extension to be included.
  • Method Details

    • getWidth

      public int getWidth()
      Obtains the width of the texture.
      Returns:
      the textures width in pixels
    • getHeight

      public int getHeight()
      Obtains the height of the texture.
      Returns:
      the textures height in pixels
    • getChannels

      public int getChannels()
      Obtains the amount of color channels this texture uses.
      Returns:
      the number of color components the texture image exhibits
    • freeTexture

      public void freeTexture()
      Frees the OpenGL texture image associated with this object. Should be used when a texture is no longer needed.
      See Also:
      GL11.glDeleteTextures(int)