Class OGL15Graphics

All Implemented Interfaces:
OGLVersioned
Direct Known Subclasses:
OGL20Graphics

public class OGL15Graphics extends OGL14Graphics
OpenGL 1.5 Graphics Implementation.
Author:
Matthew Tropiano
  • Constructor Details

  • Method Details

    • getVersion

      public OGLVersion getVersion()
      Specified by:
      getVersion in interface OGLVersioned
      Overrides:
      getVersion in class OGL14Graphics
      Returns:
      the version that this object or value is available for (and higher).
    • getCurrentBufferState

      protected OGLBuffer getCurrentBufferState(BufferTargetType type)
      Gets the current buffer for a binding target.
      Parameters:
      type - the binding type.
      Returns:
      the current buffer, or null if no current.
    • setCurrentBufferState

      protected void setCurrentBufferState(BufferTargetType type, OGLBuffer buffer)
      Sets the current texture for a binding target.
      Parameters:
      type - the binding type.
      buffer - the buffer to set.
    • endFrame

      protected void endFrame()
      Description copied from class: OGLGraphics
      Called on frame end - mostly does cleanup of objects that were abandoned in OpenGL.
      Overrides:
      endFrame in class OGL11Graphics
    • setFogCoordinateSource

      public void setFogCoordinateSource(FogCoordinateType coord)
      Sets the origin of the calculation of the fog coordinate value that dictates "where" in the fog it is.
      Parameters:
      coord - the coordinate type.
    • createQuery

      public OGLQuery createQuery()
      Creates a new query.
      Returns:
      a new sample query object.
      Throws:
      GraphicsException - if the object could not be created.
    • destroyQuery

      public void destroyQuery(OGLQuery query)
      Destroys a query object.
      Parameters:
      query - the query to destroy.
    • startQuery

      public void startQuery(QueryTarget queryTarget, OGLQuery query)
      Starts a new query.
      Parameters:
      queryTarget - the query target.
      query - the query object to attach results to.
      Throws:
      UnsupportedOperationException - if the provided type is unavailable in this version.
    • endQuery

      public void endQuery(QueryTarget queryTarget)
      Ends a query. Must be a started query of the same type. The query's results should be fetched after verifying that it is complete, later.
      Parameters:
      queryTarget - the query target.
      Throws:
      GraphicsException - if the query type provided waqs not started.
    • isQueryReady

      public boolean isQueryReady(OGLQuery query)
      Checks if a query's results are ready.
      Parameters:
      query - the query to check.
      Returns:
      true if this query's results are available, false otherwise.
    • getQueryResult

      public long getQueryResult(OGLQuery query)
      Gets the result of the query as a long integer. If isQueryReady(OGLQuery) is not checked beforehand, this will hold the thread until the query is finished. Depending on your OpenGL version, a 64-bit precision value may not be available.
      Parameters:
      query - the query to get the results for.
      Returns:
      the long value of the result.
    • getQueryBooleanResult

      public boolean getQueryBooleanResult(OGLQuery query)
      Gets the result of the query as a boolean. If isQueryReady(OGLQuery) is not checked beforehand, this will hold the thread until the query is finished.
      Parameters:
      query - the query to get the results for.
      Returns:
      the boolean value of the result.
    • createGeometryBuilder

      public GeometryBuilder createGeometryBuilder(int vertices, int... attributeSizes)
      Creates a new geometry builder. The internal size of the buffer (number of float elements) is vertices times the sum of all of the attribute sizes, which would house the whole object.

      This geometry builder aids in building buffer objects, and its GeometryBuilder.create() method will bind a new buffer to the BufferTargetType.GEOMETRY target, send the data, unbind the target, and return the new object.

      For example, if this is a builder of a four-vertex mesh with 3D spatial coordinates and an RGBA color, the constructor for this 4-vertex, 2 attribute builder is:

      GeometryBuilder.start(4, 3, 4)
      ...and the resultant buffer capacity is 28 (4 * (3 + 4)).
      Parameters:
      vertices - the number of individual vertices or attribute sets.
      attributeSizes - the list of attribute sizes in components.
      Returns:
      the new builder.
    • createBuffer

      public OGLBuffer createBuffer()
      Creates a new buffer object.
      Returns:
      a new, uninitialized buffer object.
      Throws:
      GraphicsException - if the object could not be created.
    • destroyBuffer

      public void destroyBuffer(OGLBuffer buffer)
      Destroys a buffer object.
      Parameters:
      buffer - the buffer to destroy.
    • getBuffer

      public OGLBuffer getBuffer(BufferTargetType type)
      Gets the currently bound buffer for a binding target.
      Parameters:
      type - the buffer binding target.
      Returns:
      the currently bound buffer, or null if no bound buffer to that target.
    • setBuffer

      public void setBuffer(BufferTargetType type, OGLBuffer buffer)
      Binds a buffer to the current context.
      Parameters:
      type - the buffer type to bind.
      buffer - the buffer to bind. Null unbinds the currently bound buffer type.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferCapacity

      public void setBufferCapacity(BufferTargetType type, DataType dataType, CachingHint cachingHint, int elements)
      Sets the capacity of the current buffer (sends no data).
      Parameters:
      type - the buffer type binding.
      dataType - the data type.
      cachingHint - the caching hint on this buffer's data.
      elements - the amount of elements of the data type.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferData

      public void setBufferData(BufferTargetType type, CachingHint cachingHint, ByteBuffer data)
      Sets the data of the current buffer.
      Parameters:
      type - the buffer type binding.
      cachingHint - the caching hint on this buffer's data.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferData

      public void setBufferData(BufferTargetType type, CachingHint cachingHint, ShortBuffer data)
      Sets the data of the current buffer.
      Parameters:
      type - the buffer type binding.
      cachingHint - the caching hint on this buffer's data.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferData

      public void setBufferData(BufferTargetType type, CachingHint cachingHint, IntBuffer data)
      Sets the data of the current buffer.
      Parameters:
      type - the buffer type binding.
      cachingHint - the caching hint on this buffer's data.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferData

      public void setBufferData(BufferTargetType type, CachingHint cachingHint, FloatBuffer data)
      Sets the data of the current buffer.
      Parameters:
      type - the buffer type binding.
      cachingHint - the caching hint on this buffer's data.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferData

      public void setBufferData(BufferTargetType type, CachingHint cachingHint, LongBuffer data)
      Sets the data of the current buffer.
      Parameters:
      type - the buffer type binding.
      cachingHint - the caching hint on this buffer's data.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferData

      public void setBufferData(BufferTargetType type, CachingHint cachingHint, DoubleBuffer data)
      Sets the data of the current buffer.
      Parameters:
      type - the buffer type binding.
      cachingHint - the caching hint on this buffer's data.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferSubData

      public void setBufferSubData(BufferTargetType type, int offset, ByteBuffer data)
      Sets a subsection of data to the current buffer.
      Parameters:
      type - the buffer type binding.
      offset - the offset into the buffer to copy.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferSubData

      public void setBufferSubData(BufferTargetType type, int offset, ShortBuffer data)
      Sets a subsection of data to the current buffer.
      Parameters:
      type - the buffer type binding.
      offset - the offset into the buffer to copy.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferSubData

      public void setBufferSubData(BufferTargetType type, int offset, IntBuffer data)
      Sets a subsection of data to the current buffer.
      Parameters:
      type - the buffer type binding.
      offset - the offset into the buffer to copy.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferSubData

      public void setBufferSubData(BufferTargetType type, int offset, FloatBuffer data)
      Sets a subsection of data to the current buffer.
      Parameters:
      type - the buffer type binding.
      offset - the offset into the buffer to copy.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferSubData

      public void setBufferSubData(BufferTargetType type, int offset, LongBuffer data)
      Sets a subsection of data to the current buffer.
      Parameters:
      type - the buffer type binding.
      offset - the offset into the buffer to copy.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setBufferSubData

      public void setBufferSubData(BufferTargetType type, int offset, DoubleBuffer data)
      Sets a subsection of data to the current buffer.
      Parameters:
      type - the buffer type binding.
      offset - the offset into the buffer to copy.
      data - the data to send.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • mapByteBuffer

      public ByteBuffer mapByteBuffer(BufferTargetType type, AccessType accessType)
      Maps the internal data of the current OGLBuffer to a local buffer for quick modification/read.

      Please note that the returned Buffer is special in how it is used by OpenGL according to the AccessType.

      Parameters:
      type - the binding target type.
      accessType - an access hint for the returned buffer.
      Returns:
      a buffer suitable for application use.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • mapShortBuffer

      public ShortBuffer mapShortBuffer(BufferTargetType type, AccessType accessType)
      Maps the internal data of the current OGLBuffer to a local buffer for quick modification/read.

      Please note that the returned Buffer is special in how it is used by OpenGL according to the AccessType.

      Parameters:
      type - the binding target type.
      accessType - an access hint for the returned buffer.
      Returns:
      a buffer suitable for application use.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • mapIntBuffer

      public IntBuffer mapIntBuffer(BufferTargetType type, AccessType accessType)
      Maps the internal data of the current OGLBuffer to a local buffer for quick modification/read.

      Please note that the returned Buffer is special in how it is used by OpenGL according to the AccessType.

      Parameters:
      type - the binding target type.
      accessType - an access hint for the returned buffer.
      Returns:
      a buffer suitable for application use.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • mapLongBuffer

      public LongBuffer mapLongBuffer(BufferTargetType type, AccessType accessType)
      Maps the internal data of the current OGLBuffer to a local buffer for quick modification/read.

      Please note that the returned Buffer is special in how it is used by OpenGL according to the AccessType.

      Parameters:
      type - the binding target type.
      accessType - an access hint for the returned buffer.
      Returns:
      a buffer suitable for application use.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • mapFloatBuffer

      public FloatBuffer mapFloatBuffer(BufferTargetType type, AccessType accessType)
      Maps the internal data of the current OGLBuffer to a local buffer for quick modification/read.

      Please note that the returned Buffer is special in how it is used by OpenGL according to the AccessType.

      Parameters:
      type - the binding target type.
      accessType - an access hint for the returned buffer.
      Returns:
      a buffer suitable for application use.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • mapDoubleBuffer

      public DoubleBuffer mapDoubleBuffer(BufferTargetType type, AccessType accessType)
      Maps the internal data of the current OGLBuffer to a local buffer for quick modification/read.

      Please note that the returned Buffer is special in how it is used by OpenGL according to the AccessType.

      Parameters:
      type - the binding target type.
      accessType - an access hint for the returned buffer.
      Returns:
      a buffer suitable for application use.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • unmapBuffer

      public boolean unmapBuffer(BufferTargetType type)
      Unmaps a buffer after it has been mapped and manipulated/read by the calling client application. Please note that the Buffer that was mapped from this OGLBuffer will be completely invalidated upon unmapping it.
      Parameters:
      type - the binding target type.
      Returns:
      true if unmap successful, false if data corruption occurred on unmap.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • unsetBuffer

      public void unsetBuffer(BufferTargetType type)
      Unbinds the current buffer from a target.
      Parameters:
      type - the binding target type.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.