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
  • Method Details

    • add

      GeometryBuilder add(int attributeId, float... values)
      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 the BufferTargetType.GEOMETRY target.
      Returns:
      the buffer created using this builder's data.