Package gov.nasa.worldwind.util
Class VecBufferSequence
- java.lang.Object
-
- gov.nasa.worldwind.util.CompoundVecBuffer
-
- gov.nasa.worldwind.util.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 callingappend(VecBuffer)
. This copies the specified VecBuffer's data to the VecBuffer backing the VecBufferSequence, and expands the backing VecBuffer if necessary.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class gov.nasa.worldwind.util.CompoundVecBuffer
CompoundVecBuffer.CompoundIterator<T>, CompoundVecBuffer.CoordIterable, CompoundVecBuffer.EmptyCompoundVecBuffer, CompoundVecBuffer.LocationIterable, CompoundVecBuffer.PositionIterable, CompoundVecBuffer.ReverseCompoundIterator<T>, CompoundVecBuffer.SubBufferIterable<T>, CompoundVecBuffer.VectorIterable
-
-
Field Summary
Fields Modifier and Type Field Description protected VecBuffer
buffer
protected int
vecCount
-
Fields inherited from class gov.nasa.worldwind.util.CompoundVecBuffer
ALLOCATE_DIRECT_BUFFERS, capacity, count, DEFAULT_INITIAL_CAPACITY, lengths, offsets
-
-
Constructor Summary
Constructors Modifier Constructor Description VecBufferSequence(VecBuffer buffer)
Constructs a PackedCompoundVecBuffer with the specified backing VecBuffer and the default initial capacity.VecBufferSequence(VecBuffer buffer, int capacity)
Constructs a PackedCompoundVecBuffer with the specified backing VecBuffer and the specified initial capacity.protected
VecBufferSequence(VecBufferSequence that, int[] indices, int offset, int length)
protected
VecBufferSequence(VecBufferSequence that, int beginIndex, int endIndex)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.void
bindAsNormalBuffer(DrawContext dc)
Binds this buffer as the source of normal coordinates to use when rendering OpenGL primitives.void
bindAsTexCoordBuffer(DrawContext dc)
Binds this buffer as the source of texture coordinates to use when rendering OpenGL primitives.void
bindAsVertexBuffer(DrawContext dc)
Binds this buffer as the source of vertex coordinates to use when rendering OpenGL primitives.void
clear()
Sets the number sub-buffers to zero.protected CompoundVecBuffer
createSlice(int[] indices, int offset, int length)
protected CompoundVecBuffer
createSlice(int beginIndex, int endIndex)
protected VecBuffer
createSubBuffer(int offset, int length)
void
drawArrays(DrawContext dc, int drawMode)
RendersgetTotalBufferSize()
elements from the currently bounds OpenGL coordinate buffers, beginning with element 0.static VecBufferSequence
emptyVecBufferSequence(int coordsPerVec)
Returns an empty VecBufferSequence.protected void
expandBufferCapacity(int minCapacity)
int
getCoordsPerVec()
Returns the number of coordinates per logical vector element.VecBuffer
getVecBuffer()
Returns the VecBuffer that stores this PackedCompoundVecBuffer's sub-buffers.protected boolean
haveMultiDrawArrays(DrawContext dc)
void
multiDrawArrays(DrawContext dc, int drawMode)
Renders elements from the currently bounds OpenGL coordinate buffers.int
subBufferSize(int index)
Returns the size in logical vectors of the VecBuffer with the specified index.-
Methods inherited from class gov.nasa.worldwind.util.CompoundVecBuffer
addSubBuffer, emptyCompoundVecBuffer, expandCapacity, getCoords, getCoords, getLocations, getPositions, getReverseCoords, getReverseLocations, getReversePositions, getReverseVectors, getVectors, size, slice, slice, slice, subBuffer
-
-
-
-
Field Detail
-
vecCount
protected int vecCount
-
buffer
protected VecBuffer buffer
-
-
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 classCompoundVecBuffer
- 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 classCompoundVecBuffer
-
getCoordsPerVec
public int getCoordsPerVec()
Returns the number of coordinates per logical vector element.- Specified by:
getCoordsPerVec
in classCompoundVecBuffer
- 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.
-
createSubBuffer
protected VecBuffer createSubBuffer(int offset, int length)
- Specified by:
createSubBuffer
in classCompoundVecBuffer
-
createSlice
protected CompoundVecBuffer createSlice(int[] indices, int offset, int length)
- Specified by:
createSlice
in classCompoundVecBuffer
-
createSlice
protected CompoundVecBuffer createSlice(int beginIndex, int endIndex)
- Specified by:
createSlice
in classCompoundVecBuffer
-
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 NIOBuffer
. This buffer's vector size must be 3.- Parameters:
dc
- the currentDrawContext
.- 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)
RendersgetTotalBufferSize()
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 likedrawArrays(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)
-
-