Skip to content

WireframeGeometry

Generated geometry representing the wireframe edges of a triangle mesh.

WireframeGeometry takes an existing triangle-based geometry and expands its indexed triangle list into a line list suitable for rendering with Geometry::PrimitiveType::Lines. The source geometry's vertex attributes are shared rather than copied, while the index buffer is replaced with pairs of indices representing each unique edge of the mesh.

Because the attributes are shared, the wireframe is a live view of the source's vertices rather than a snapshot: updating the source's vertex data (for example, via BufferAttribute::SetData) updates the wireframe as well. Likewise, explicitly disposing the source's attributes invalidates any wireframes that share them.

This is useful for visual debugging (visualizing topology, silhouette edges, or bounding structures) without modifying the source geometry.

The input geometry must provide valid triangle indices. Non-indexed or non-triangle primitives are not supported and wireframe rendering is not available for instanced meshes.

cpp
auto solid = vglx::BoxGeometry::Create();
auto wireframe  = vglx::WireframeGeometry::Create(solid.get());
auto material = vglx::UnlitMaterial::Create({.color = 0xFFFFFFu});

my_scene->Add(vglx::Mesh::Create(wireframe, material));

INFO

Derives from Geometry and inherits all public properties and methods.

Construction

Constructors


WireframeGeometry()

Constructs a wireframe representation of an existing geometry.

The vertex attributes are shared with the source geometry, but the index buffer is rebuilt so that each unique triangle edge becomes a line segment. Changes to the source's vertex data are reflected in the wireframe.

cpp
WireframeGeometry::WireframeGeometry(const Geometry* geometry);
ParameterDescription
geometryPointer to the original triangle-based geometry.

Factories preferred


WireframeGeometry::Create() std::shared_ptr<WireframeGeometry>

Creates a shared instance of WireframeGeometry.

cpp
static std::shared_ptr<WireframeGeometry> WireframeGeometry::Create(const Geometry* geometry);
ParameterDescription
geometryPointer to the original triangle-based geometry.

Released under the MIT License.