![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/GL/LineRenderer.h>
Convenience class for a shader implementing thick and stippled line rendering. More...
Convenience class for a shader implementing thick and stippled line rendering.
LineRenderer is a stateless object which you can use to render high-quality lines with custom width and stipple pattern. The rendering is configured by passing an Options instance to the render function. The default usage is to call one of renderLines(), renderLineStrip() or renderLineLoop() with a set of vertices in world space:
If your geometry is static you can optimize your render loop by calling makeVertexData() once to write the vertex data into a VBO of your choice, and then only call render() inside the render loop.
This class inherits from GL::InstanceManager so that you can request a cached instance of it from any valid OpenGL context to save on resources.
Classes | |
struct | Options |
Helper struct to encapsulate all supported rendering options. More... | |
Public Member Functions | |
void | render (const GL::VertexBuffer &vbo, Primitive primitive, const Options &options, const ViewState &viewState, const OrderIndependentTransparency *oit=nullptr) |
Renders a the given vertex buffer as connected line. | |
void | renderLines (const std::vector< vec3 > &vertices, const Options &options, const ViewState &viewState, const OrderIndependentTransparency *oit=nullptr) |
Renders a series of individual lines from the given vertices. | |
void | renderLineStrip (const std::vector< vec3 > &vertices, const Options &options, const ViewState &viewState, const OrderIndependentTransparency *oit=nullptr) |
Renders a connected line strip of the given vertices. | |
void | renderLineLoop (const std::vector< vec3 > &vertices, const Options &options, const ViewState &viewState, const OrderIndependentTransparency *oit=nullptr) |
Renders a connected line loop of the given vertices. | |
Static Public Member Functions | |
static bool | makeVertexData (const std::vector< vec3 > &vertices, Primitive primitive, GL::VertexBuffer &outputVBO) |
Converts the given vertices to a suitable internal representation and uploads them to a VertexBuffer which can then be used with render(). | |
static bool | makeVertexData (const std::vector< vec3 > &vertices, const std::vector< vec4 > &colors, Primitive primitive, GL::VertexBuffer &outputVBO) |
Converts the given vertices to a suitable internal representation and uploads them to a VertexBuffer which can then be used with render(). | |
![]() | |
static LineRenderer & | cachedInstance () |
Returns the cached instance of type T for the currently active OpenGL context. | |
|
static |
Converts the given vertices to a suitable internal representation and uploads them to a VertexBuffer which can then be used with render().
vertices | Vertices of the line in world coordinates |
primitive | Line type to render, must be Primitive::Lines , Primitive::LineLoop , or Primitive::LineStrip . |
outputVBO | Output vertex buffer into which the resulting vertex data should be written |
true
if sufficient input vertices were provided; false
if vertices does not contain enough data or primitive is invalid, in which case outputVBO will remain untouched.
|
static |
Converts the given vertices to a suitable internal representation and uploads them to a VertexBuffer which can then be used with render().
vertices | Vertices of the line in world coordinates |
colors | Optional per-vertex colors of the line to override the static render color in Options. Must either be empty or have the same size as vertices. |
primitive | Line type to render, must be Primitive::Lines , Primitive::LineLoop , or Primitive::LineStrip . |
outputVBO | Output vertex buffer into which the resulting vertex data should be written |
true
if sufficient input vertices were provided; false
if vertices does not contain enough data or primitive is invalid, in which case outputVBO will remain untouched. void render | ( | const GL::VertexBuffer & | vbo, |
Primitive | primitive, | ||
const Options & | options, | ||
const ViewState & | viewState, | ||
const OrderIndependentTransparency * | oit = nullptr ) |
Renders a the given vertex buffer as connected line.
vbo | Vertex buffer that was previously generated with makeVertexData(). |
primitive | Line type to render, must be Primitive::Lines , Primitive::LineLoop , or Primitive::LineStrip . |
options | Rendering options to use |
viewState | View and projection matrix to use |
oit | Optional order-independent transparency handling instance to use |
void renderLines | ( | const std::vector< vec3 > & | vertices, |
const Options & | options, | ||
const ViewState & | viewState, | ||
const OrderIndependentTransparency * | oit = nullptr ) |
Renders a series of individual lines from the given vertices.
vertices | Vertices of the line in world coordinates |
options | Rendering options to use |
viewState | View and projection matrix to use |
oit | Optional order-independent transparency handling instance to use GL::Primitive::Lines |
void renderLineStrip | ( | const std::vector< vec3 > & | vertices, |
const Options & | options, | ||
const ViewState & | viewState, | ||
const OrderIndependentTransparency * | oit = nullptr ) |
Renders a connected line strip of the given vertices.
vertices | Vertices of the line in world coordinates |
options | Rendering options to use |
viewState | View and projection matrix to use |
oit | Optional order-independent transparency handling instance to use |
void renderLineLoop | ( | const std::vector< vec3 > & | vertices, |
const Options & | options, | ||
const ViewState & | viewState, | ||
const OrderIndependentTransparency * | oit = nullptr ) |
Renders a connected line loop of the given vertices.
vertices | Vertices of the line in world coordinates |
options | Rendering options to use |
viewState | View and projection matrix to use |
oit | Optional order-independent transparency handling instance to use |