Interface GeometryBuilder
- All Known Implementing Classes:
GeometryBuilder.Abstract
public interface GeometryBuilder
A builder class that assists the building of geometric data to later fill in a buffer.
The underlying buffer that this builder creates is a Java Native I/O direct float buffer,
so its contents can be easily transferred to the OpenGL context.
Buffer contents are interleaved, so the draw calls for the created buffer after OpenGL transfer should be set up using strides.
All of these methods can be called outside of the graphics thread except create().
Depending on implementation version, some methods may not be supported or available,
and will throw UnsupportedOperationException if so.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classGeometryBuilder.Abstract<GL extends OGLGraphics>Geometry builder utility class. -
Method Summary
Modifier and TypeMethodDescriptionadd(int attributeId, float... values) Adds the values for a one-component attribute.create()Creates a new buffer object bindable to theBufferTargetType.GEOMETRYtarget.intintgetOffset(int attributeId) Gets the stride offset for an attribute.intintgetWidth(int attributeId) Gets the element width for an attribute.
-
Method Details
-
add
Adds the values for a one-component attribute. Next call to this method with the same will write to the next vertex.- Parameters:
attributeId- the attribute id.values- the component values.- Returns:
- this builder.
- Throws:
IllegalArgumentException- if bad attribute id, the attribute component count is incorrect, or no more vertices for this attribute.
-
getAttributeCount
int getAttributeCount()- Returns:
- the attribute count.
-
getStrideSize
int getStrideSize()- Returns:
- the stride size.
-
getWidth
int getWidth(int attributeId) Gets the element width for an attribute.- Parameters:
attributeId- the attribute id.- Returns:
- the width for the provided attribute.
-
getOffset
int getOffset(int attributeId) Gets the stride offset for an attribute.- Parameters:
attributeId- the attribute id.- Returns:
- the offset for the provided attribute.
-
create
OGLBuffer create()Creates a new buffer object bindable to theBufferTargetType.GEOMETRYtarget.- Returns:
- the buffer created using this builder's data.
-