Class GlBuffer

java.lang.Object
com.jozufozu.flywheel.backend.gl.GlObject
com.jozufozu.flywheel.backend.gl.buffer.GlBuffer
Direct Known Subclasses:
MappedGlBuffer, PersistentGlBuffer

public abstract class GlBuffer extends GlObject
  • Field Details

    • type

      protected final GlBufferType type
    • capacity

      protected long capacity
      The size (in bytes) of the buffer on the GPU.
    • growthMargin

      protected int growthMargin
      How much extra room to give the buffer when we reallocate.
  • Constructor Details

  • Method Details

    • requestPersistent

      public static GlBuffer requestPersistent(GlBufferType type)
      Request a Persistent mapped buffer.

      If Persistent buffers are supported, this will provide one. Otherwise it will fall back to a classic mapped buffer.

      Parameters:
      type - The type of buffer you want.
      Returns:
      A buffer that will be persistent if the driver supports it.
    • setGrowthMargin

      public void setGrowthMargin(int growthMargin)
    • getCapacity

      public long getCapacity()
    • getBuffer

      public MappedBuffer getBuffer()
    • getBuffer

      public abstract MappedBuffer getBuffer(long offset, long length)
    • ensureCapacity

      public boolean ensureCapacity(long size)
      Ensure that the buffer has at least enough room to store size bytes.
      Returns:
      true if the buffer grew.
    • doneForThisFrame

      public void doneForThisFrame()
      Call this after all draw calls using this buffer are complete.
    • alloc

      protected abstract void alloc(long size)
    • upload

      public abstract void upload(ByteBuffer directBuffer)
    • bind

      public void bind()
    • unbind

      public void unbind()
    • _create

      protected void _create()
    • deleteInternal

      protected void deleteInternal(int handle)
      Specified by:
      deleteInternal in class GlObject