Class VecBufferSequence


  • public class VecBufferSequence
    extends CompoundVecBuffer
    VecBufferSequence provides storage and retrieval of a sequence of logical VecBuffers in a single VecBuffer that expands when more capacity is needed. VecBuffers added to a VecBufferSequence by calling append(VecBuffer). This copies the specified VecBuffer's data to the VecBuffer backing the VecBufferSequence, and expands the backing VecBuffer if necessary.
    • Field Detail

      • vecCount

        protected int vecCount
    • Constructor Detail

      • VecBufferSequence

        public VecBufferSequence​(VecBuffer buffer,
                                 int capacity)
        Constructs a PackedCompoundVecBuffer with the specified backing VecBuffer and the specified initial capacity.
        Parameters:
        buffer - the backing VecBuffer.
        capacity - the PackedCompoundVecBuffer's initial capacity, in number of sub-buffers.
        Throws:
        java.lang.IllegalArgumentException - if the buffer is null, or if the capacity is less than 1.
      • VecBufferSequence

        public VecBufferSequence​(VecBuffer buffer)
        Constructs a PackedCompoundVecBuffer with the specified backing VecBuffer and the default initial capacity.
        Parameters:
        buffer - the backing VecBuffer.
        Throws:
        java.lang.IllegalArgumentException - if the buffer is null.
      • VecBufferSequence

        protected VecBufferSequence​(VecBufferSequence that,
                                    int beginIndex,
                                    int endIndex)
      • VecBufferSequence

        protected VecBufferSequence​(VecBufferSequence that,
                                    int[] indices,
                                    int offset,
                                    int length)
    • Method Detail

      • emptyVecBufferSequence

        public static VecBufferSequence emptyVecBufferSequence​(int coordsPerVec)
        Returns an empty VecBufferSequence. The returned VecBufferSequence has a size of zero and contains no sub-buffers.
        Parameters:
        coordsPerVec - the number of coordinates per logical vector.
        Returns:
        the empty VecBufferSequence.
      • subBufferSize

        public int subBufferSize​(int index)
        Returns the size in logical vectors of the VecBuffer with the specified index.
        Specified by:
        subBufferSize in class CompoundVecBuffer
        Parameters:
        index - the index for the VecBuffer who's size is returned.
        Returns:
        the size of the specified VecBuffer.
      • clear

        public void clear()
        Sets the number sub-buffers to zero. This does not free any memory associated with this CompoundVecBuffer.
        Overrides:
        clear in class CompoundVecBuffer
      • getCoordsPerVec

        public int getCoordsPerVec()
        Returns the number of coordinates per logical vector element.
        Specified by:
        getCoordsPerVec in class CompoundVecBuffer
        Returns:
        the cardinality of a logical vector element.
      • getVecBuffer

        public VecBuffer getVecBuffer()
        Returns the VecBuffer that stores this PackedCompoundVecBuffer's sub-buffers.
        Returns:
        this PackedCompoundVecBuffer's backing VecBuffer.
      • append

        public int append​(VecBuffer buffer)
        Appends the contents of the specified sub-buffer to the end of this PackedCompoundVecBuffer, incrementing the number of sub-buffers by one. The backing buffer grows to accomodate the sub-buffer if it does not already have enough capacity to hold it.
        Parameters:
        buffer - the sub-buffer to append.
        Returns:
        the sub-buffer's index.
        Throws:
        java.lang.IllegalArgumentException - if the subBuffer is null.
      • expandBufferCapacity

        protected void expandBufferCapacity​(int minCapacity)
      • bindAsNormalBuffer

        public void bindAsNormalBuffer​(DrawContext dc)
        Binds this buffer as the source of normal coordinates to use when rendering OpenGL primitives. The normal type is equal to buffer's underlying BufferWrapper GL type, the stride is 0, and the vertex data itself is this buffer's backing NIO Buffer. This buffer's vector size must be 3.
        Parameters:
        dc - the current DrawContext.
        Throws:
        java.lang.IllegalArgumentException - if the DrawContext is null, or if this buffer is not compatible as a normal buffer.
      • bindAsVertexBuffer

        public void bindAsVertexBuffer​(DrawContext dc)
        Binds this buffer as the source of vertex coordinates to use when rendering OpenGL primitives. The vertex size is equal to coordsPerVertex, the vertex type is equal to buffer's underlying BufferWrapper GL type, the stride is 0, and the normal data itself is this buffer's backing NIO Buffer. This buffer's vector size must be 2, 3, or 4.
        Parameters:
        dc - the current DrawContext.
        Throws:
        java.lang.IllegalArgumentException - if the DrawContext is null, or if this buffer is not compatible as a vertex buffer.
      • bindAsTexCoordBuffer

        public void bindAsTexCoordBuffer​(DrawContext dc)
        Binds this buffer as the source of texture coordinates to use when rendering OpenGL primitives. The texture coordinate size is equal to coordsPerVertex, the texture coordinate type is equal to buffer's underlying BufferWrapper GL type, the stride is 0, and the texture coordinate data itself is this buffer's backing NIO Buffer. This buffer's vector size must be 1, 2, 3, or 4.
        Parameters:
        dc - the current DrawContext.
        Throws:
        java.lang.IllegalArgumentException - if the DrawContext is null, or if this buffer is not compatible as a normal buffer.
      • drawArrays

        public void drawArrays​(DrawContext dc,
                               int drawMode)
        Renders getTotalBufferSize() elements from the currently bounds OpenGL coordinate buffers, beginning with element 0. The specified drawMode indicates which type of OpenGL primitives to render.
        Parameters:
        dc - the current DrawContext.
        drawMode - the type of OpenGL primtives to render.
        Throws:
        java.lang.IllegalArgumentException - if the DrawContext is null.
      • multiDrawArrays

        public void multiDrawArrays​(DrawContext dc,
                                    int drawMode)
        Renders elements from the currently bounds OpenGL coordinate buffers. This behaves exactly like drawArrays(gov.nasa.worldwind.render.DrawContext, int), except that each sub-buffer is rendered independently. The specified drawMode indicates which type of OpenGL primitives to render.
        Parameters:
        dc - the current DrawContext.
        drawMode - the type of OpenGL primtives to render.
        Throws:
        java.lang.IllegalArgumentException - if the DrawContext is null.
      • haveMultiDrawArrays

        protected boolean haveMultiDrawArrays​(DrawContext dc)