Magnum::GL::TransformFeedback class

Transform feedback.

Performance optimizations

The engine tracks currently bound transform feedback to avoid unnecessary calls to glBindTransformFeedback(). Transform feedback limits and implementation-defined values (such as maxSeparateComponents()) are cached, so repeated queries don't result in repeated glGet() calls. See also Context::resetState() and Context::State::TransformFeedback.

If ARB_direct_state_access (part of OpenGL 4.5) is available, functions attachBuffer() and attachBuffers() use DSA to avoid unnecessary calls to glBindTransformFeedback(). See their respective documentation for more information.

Base classes

class AbstractObject
Base for all OpenGL objects.

Public types

enum class PrimitiveMode: GLenum { Points = GL_POINTS, Lines = GL_LINES, Triangles = GL_TRIANGLES }
Transform feedback primitive mode.

Public static functions

static auto maxInterleavedComponents() -> Int
Max supported interleaved component count.
static auto maxSeparateAttributes() -> Int
Max supported separate attribute count.
static auto maxSeparateComponents() -> Int
Max supported separate component count.
static auto maxBuffers() -> Int
Max supported buffer count.
static auto maxVertexStreams() -> Int
Max supported vertex stream count.
static auto wrap(GLuint id, ObjectFlags flags = {}) -> TransformFeedback
Wrap existing OpenGL transform feedback object.

Constructors, destructors, conversion operators

TransformFeedback() explicit
Constructor.
TransformFeedback(NoCreateT) explicit noexcept
Construct without creating the underlying OpenGL object.
TransformFeedback(const TransformFeedback&) deleted
Copying is not allowed.
TransformFeedback(TransformFeedback&& other) noexcept
Move constructor.
~TransformFeedback()
Destructor.

Public functions

auto operator=(const TransformFeedback&) -> TransformFeedback& deleted
Copying is not allowed.
auto operator=(TransformFeedback&& other) -> TransformFeedback& noexcept
Move assignment.
auto id() const -> GLuint
OpenGL transform feedback ID.
auto release() -> GLuint
Release OpenGL object.
auto label() -> std::string
Transform feedback label.
auto setLabel(const std::string& label) -> TransformFeedback&
Set transform feedback label.
template<std::size_t size>
auto setLabel(const char(&label)[size]) -> TransformFeedback&
auto attachBuffer(UnsignedInt index, Buffer& buffer, GLintptr offset, GLsizeiptr size) -> TransformFeedback&
Attach range of buffer.
auto attachBuffer(UnsignedInt index, Buffer& buffer) -> TransformFeedback&
Attach buffer.
auto attachBuffers(UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers) -> TransformFeedback&
Attach ranges of buffers.
auto attachBuffers(UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers) -> TransformFeedback&
Attach buffers.
void begin(AbstractShaderProgram& shader, PrimitiveMode mode)
Begin transform feedback.
void pause()
Pause transform feedback.
void resume()
Resume transform feedback.
void end()
End transform feedback.

Enum documentation

enum class Magnum::GL::TransformFeedback::PrimitiveMode: GLenum

Transform feedback primitive mode.

Enumerators
Points

Points. If no geometry shader is present, allowed only in combination with MeshPrimitive::Points mesh primitive type. If geometry shader is present, allowed only in combination with points output primitive type.

Lines

Lines. If no geometry shader is present, allowed only in combination with MeshPrimitive::LineStrip, MeshPrimitive::LineLoop, MeshPrimitive::Lines, MeshPrimitive::LineStripAdjacency and MeshPrimitive::LinesAdjacency mesh primitive type. If geometry shader is present, allowed only in combination with line_strip output primitive type.

Triangles

Triangles. If no geometry shader is present, allowed only in combination with MeshPrimitive::TriangleStrip, MeshPrimitive::TriangleFan, MeshPrimitive::Triangles, MeshPrimitive::TriangleStripAdjacency and MeshPrimitive::TrianglesAdjacency mesh primitive type. If geometry shader is present, allowed only in commbination with triangle_strip output primitive type.

Function documentation

static Int Magnum::GL::TransformFeedback::maxInterleavedComponents()

Max supported interleaved component count.

The result is cached, repeated queries don't result in repeated OpenGL calls. If extension EXT_transform_feedback (part of OpenGL 3.0) is not available, returns 0.

static Int Magnum::GL::TransformFeedback::maxSeparateAttributes()

Max supported separate attribute count.

The result is cached, repeated queries don't result in repeated OpenGL calls. If extension EXT_transform_feedback (part of OpenGL 3.0) is not available, returns 0.

static Int Magnum::GL::TransformFeedback::maxSeparateComponents()

Max supported separate component count.

The result is cached, repeated queries don't result in repeated OpenGL calls. If extension EXT_transform_feedback (part of OpenGL 3.0) is not available, returns 0.

static Int Magnum::GL::TransformFeedback::maxBuffers()

Max supported buffer count.

The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_transform_feedback3 (part of OpenGL 4.0) is not available, returns the same value as maxSeparateAttributes().

static Int Magnum::GL::TransformFeedback::maxVertexStreams()

Max supported vertex stream count.

The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_transform_feedback3 (part of OpenGL 4.0) is not available, returns 1.

static TransformFeedback Magnum::GL::TransformFeedback::wrap(GLuint id, ObjectFlags flags = {})

Wrap existing OpenGL transform feedback object.

Parameters
id OpenGL transform feedback ID
flags Object creation flags

The id is expected to be of an existing OpenGL transform feedback object. Unlike renderbuffer created using constructor, the OpenGL object is by default not deleted on destruction, use flags for different behavior.

Magnum::GL::TransformFeedback::TransformFeedback() explicit

Constructor.

Creates new OpenGL transform feedback object. If ARB_direct_state_access (part of OpenGL 4.5) is not available, the transform feedback object is created on first use.

Magnum::GL::TransformFeedback::TransformFeedback(NoCreateT) explicit noexcept

Construct without creating the underlying OpenGL object.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.

This function can be safely used for constructing (and later destructing) objects even without any OpenGL context being active.

Magnum::GL::TransformFeedback::~TransformFeedback()

Destructor.

Deletes associated OpenGL transform feedback object.

GLuint Magnum::GL::TransformFeedback::release()

Release OpenGL object.

Releases ownership of OpenGL transform feedback object and returns its ID so it is not deleted on destruction. The internal state is then equivalent to moved-from state.

std::string Magnum::GL::TransformFeedback::label()

Transform feedback label.

The result is not cached, repeated queries will result in repeated OpenGL calls. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_debug (covered also by ANDROID_extension_pack_es31a) nor EXT_debug_label desktop or ES extension is available, this function returns empty string.

TransformFeedback& Magnum::GL::TransformFeedback::setLabel(const std::string& label)

Set transform feedback label.

Returns Reference to self (for method chaining)

Default is empty string. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_debug (covered also by ANDROID_extension_pack_es31a) nor EXT_debug_label desktop or ES extension is available, this function does nothing.

template<std::size_t size>
TransformFeedback& Magnum::GL::TransformFeedback::setLabel(const char(&label)[size])

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

TransformFeedback& Magnum::GL::TransformFeedback::attachBuffer(UnsignedInt index, Buffer& buffer, GLintptr offset, GLsizeiptr size)

Attach range of buffer.

Returns Reference to self (for method chaining)

The offset parameter must be aligned to 4 bytes. If ARB_direct_state_access (part of OpenGL 4.5) is not available, the transform feedback object is bound (if not already) and the operation is then done equivalently to Buffer::bind(Buffer::Target, UnsignedInt, GLintptr, GLsizeiptr).

TransformFeedback& Magnum::GL::TransformFeedback::attachBuffer(UnsignedInt index, Buffer& buffer)

Attach buffer.

Returns Reference to self (for method chaining)

If ARB_direct_state_access (part of OpenGL 4.5) is not available, the transform feedback object is bound (if not already) and the operation is then done equivalently to Buffer::bind(Buffer::Target, UnsignedInt).

TransformFeedback& Magnum::GL::TransformFeedback::attachBuffers(UnsignedInt firstIndex, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>> buffers)

Attach ranges of buffers.

Returns Reference to self (for method chaining)

Attches first buffer in the list to firstIndex, second to firstIndex + 1 etc. Second parameter is offset, third is size. If any buffer is nullptr, given attachment point is detached. The range of indices must respect maxBuffers() (maxSeparateComponents() in OpenGL ES or if ARB_transform_feedback3 (part of OpenGL 4.0) is not available). The offsets must be aligned to 4 bytes. All the buffers must have allocated data store. If ARB_direct_state_access (part of OpenGL 4.5) is not available, the transform feedback object is bound (if not already) and the operation is then done equivalently to Buffer::bind(Buffer::Target, UnsignedInt, std::initializer_list<std::tuple<Buffer*, GLintptr, GLsizeiptr>>).

TransformFeedback& Magnum::GL::TransformFeedback::attachBuffers(UnsignedInt firstIndex, std::initializer_list<Buffer*> buffers)

Attach buffers.

Returns Reference to self (for method chaining)

Attches first buffer in the list to firstIndex, second to firstIndex + 1 etc. If any buffer is nullptr, given index is detached. The range of indices must respect maxBuffers() (maxSeparateComponents() in OpenGL ES or if ARB_transform_feedback3 (part of OpenGL 4.0) is not available). All the buffers must have allocated data store. If ARB_direct_state_access (part of OpenGL 4.5) is not available, the transform feedback object is bound (if not already) and the operation then is done equivalently to Buffer::bind(Buffer::Target, UnsignedInt, std::initializer_list<Buffer*>).

void Magnum::GL::TransformFeedback::begin(AbstractShaderProgram& shader, PrimitiveMode mode)

Begin transform feedback.

Parameters
shader Shader from which to capture data
mode Primitive mode

When transform feedback is active, only shader given in shader and meshes with primitive type (or geometry shaders with output primitive type) compatible with mode can be used. Only one transform feedback object can be active at a time.

void Magnum::GL::TransformFeedback::pause()

Pause transform feedback.

Pausing transform feedback makes it inactive, allowing to use different shader, or starting another transform feedback.

void Magnum::GL::TransformFeedback::resume()

Resume transform feedback.

Resumes transform feedback so the next captured data are appended to already captured ones. The restrictions specified for begin() still apply after resuming. Only one transform feedback object can be active at a time.

void Magnum::GL::TransformFeedback::end()

End transform feedback.

Ends transform feedback so the captured data can be used.