Package arc.graphics

Class GLTexture

java.lang.Object
arc.graphics.GLTexture
All Implemented Interfaces:
Disposable
Direct Known Subclasses:
Cubemap, Texture, TextureArray

public abstract class GLTexture extends Object implements Disposable
Class representing an OpenGL texture by its target and handle. Keeps track of its state like the TextureFilter and TextureWrap. Also provides some (protected) static methods to create TextureData and upload image data.
  • Field Details

    • glTarget

      public final int glTarget
      The target of this texture, used when binding the texture, e.g. GL_TEXTURE_2D
    • width

      public int width
      Do not change. This is read-only and only set after texture data is loaded.
    • height

      public int height
      Do not change. This is read-only and only set after texture data is loaded.
    • glHandle

      protected int glHandle
    • minFilter

      protected Texture.TextureFilter minFilter
    • magFilter

      protected Texture.TextureFilter magFilter
    • uWrap

      protected Texture.TextureWrap uWrap
    • vWrap

      protected Texture.TextureWrap vWrap
  • Constructor Details

    • GLTexture

      public GLTexture(int glTarget)
      Generates a new OpenGL texture with the specified target.
    • GLTexture

      public GLTexture(int glTarget, int glHandle)
  • Method Details

    • uploadImageData

      protected static void uploadImageData(int target, TextureData data)
    • uploadImageData

      public static void uploadImageData(int target, TextureData data, int miplevel)
    • getDepth

      public abstract int getDepth()
      Returns:
      the depth of the texture in pixels
    • bind

      public void bind()
      Binds this texture. The texture will be bound to the currently active texture unit specified via GL20.glActiveTexture(int).
    • bind

      public void bind(int unit)
      Binds the texture to the given texture unit. Sets the currently active texture unit via GL20.glActiveTexture(int).
      Parameters:
      unit - the unit (0 to MAX_TEXTURE_UNITS).
    • getMinFilter

      public Texture.TextureFilter getMinFilter()
      Returns:
      The Texture.TextureFilter used for minification.
    • getMagFilter

      public Texture.TextureFilter getMagFilter()
      Returns:
      The Texture.TextureFilter used for magnification.
    • getUWrap

      public Texture.TextureWrap getUWrap()
      Returns:
      The Texture.TextureWrap used for horizontal (U) texture coordinates.
    • getVWrap

      public Texture.TextureWrap getVWrap()
      Returns:
      The Texture.TextureWrap used for vertical (V) texture coordinates.
    • getTextureObjectHandle

      public int getTextureObjectHandle()
      Returns:
      The OpenGL handle for this texture.
    • unsafeSetWrap

      public void unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v)
      Sets the Texture.TextureWrap for this texture on the u and v axis. Assumes the texture is bound and active!
      Parameters:
      u - the u wrap
      v - the v wrap
    • unsafeSetWrap

      public void unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v, boolean force)
      Sets the Texture.TextureWrap for this texture on the u and v axis. Assumes the texture is bound and active!
      Parameters:
      u - the u wrap
      v - the v wrap
      force - True to always set the values, even if they are the same as the current values.
    • setWrap

      public void setWrap(Texture.TextureWrap wrap)
    • setWrap

      public void setWrap(Texture.TextureWrap u, Texture.TextureWrap v)
      Sets the Texture.TextureWrap for this texture on the u and v axis. This will bind this texture!
      Parameters:
      u - the u wrap
      v - the v wrap
    • unsafeSetFilter

      public void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)
      Sets the Texture.TextureFilter for this texture for minification and magnification. Assumes the texture is bound and active!
      Parameters:
      minFilter - the minification filter
      magFilter - the magnification filter
    • unsafeSetFilter

      public void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter, boolean force)
      Sets the Texture.TextureFilter for this texture for minification and magnification. Assumes the texture is bound and active!
      Parameters:
      minFilter - the minification filter
      magFilter - the magnification filter
      force - True to always set the values, even if they are the same as the current values.
    • setFilter

      public void setFilter(Texture.TextureFilter filter)
    • setFilter

      public void setFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)
      Sets the Texture.TextureFilter for this texture for minification and magnification. This will bind this texture!
      Parameters:
      minFilter - the minification filter
      magFilter - the magnification filter
    • dispose

      public void dispose()
      Description copied from interface: Disposable
      Releases all resources of this object.
      Specified by:
      dispose in interface Disposable