Class OGLObject

java.lang.Object
com.blackrook.gloop.opengl.OGLObject
Direct Known Subclasses:
OGLBuffer, OGLFramebuffer, OGLProgram, OGLProgramPipeline, OGLProgramShader, OGLQuery, OGLRenderbuffer, OGLSampler, OGLSync, OGLTexture, OGLVertexArrayState

public abstract class OGLObject extends Object
Generic OpenGL object type. Since this is managed internally by OpenGL, the handles to these objects are "names" (aka integer IDs) rather than memory addresses.

Author:
Matthew Tropiano
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Allocates a new OpenGL object.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tests if this OpenAL object equals the provided one.
    boolean
     
    protected static int[]
    expand(int[] input, int targetLength)
    Utility function to expand the "undeleted" GL name pool if it is below a certain length.
    protected static long[]
    expand(long[] input, int targetLength)
    Utility function to expand the "undeleted" GL name pool if it is below a certain length.
    protected abstract void
    Destroys this object (deallocates it on OpenAL).
    final long
     
    final int
     
    int
     
    protected boolean
     
    protected void
    setLongName(long glId)
    Sets this object's long OpenGL name/id.
    protected void
    setName(int glId)
    Sets this object's OpenGL name/id.
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • OGLObject

      protected OGLObject()
      Allocates a new OpenGL object.
  • Method Details

    • setName

      protected void setName(int glId)
      Sets this object's OpenGL name/id. Set either this or the longer one.
      Parameters:
      glId - the new id.
      Throws:
      GraphicsException - if the id is zero.
    • setLongName

      protected void setLongName(long glId)
      Sets this object's long OpenGL name/id. Set either this or the shorter one.
      Parameters:
      glId - the new id.
      Throws:
      GraphicsException - if the id is zero.
    • getName

      public final int getName()
      Returns:
      this OGLObject OpenGL object id.
    • getLongName

      public final long getLongName()
      Returns:
      this OGLObject OpenGL object id.
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(OGLObject obj)
      Tests if this OpenAL object equals the provided one.
      Parameters:
      obj - the object to test.
      Returns:
      true if so, false if not.
    • isAllocated

      protected boolean isAllocated()
      Returns:
      true if allocated in OpenGL, false if not.
    • free

      protected abstract void free()
      Destroys this object (deallocates it on OpenAL). This is called by destroy().
      Throws:
      GraphicsException - if the deallocation cannot happen.
    • expand

      protected static int[] expand(int[] input, int targetLength)
      Utility function to expand the "undeleted" GL name pool if it is below a certain length.
      Parameters:
      input - the input array.
      targetLength - the target length.
      Returns:
      the array itself (input) if no expansion needed, or a new array with the contents copied if input.length < targetLength.
    • expand

      protected static long[] expand(long[] input, int targetLength)
      Utility function to expand the "undeleted" GL name pool if it is below a certain length.
      Parameters:
      input - the input array.
      targetLength - the target length.
      Returns:
      the array itself (input) if no expansion needed, or a new array with the contents copied if input.length < targetLength.
    • toString

      public String toString()
      Overrides:
      toString in class Object