[Solved] 2dPath into VboMesh or Batch

Hey Embers,

Anyone know of a way to turn a 2dpath into a vbo mesh? I’m trying to make an arc/bent line into a GL_Lines VBO mesh.

I’ve not yet spotted a staight-forward approach.


gl::VboMesh::create ( Triangulator { path2d }.calcMesh() );

Seems like it might spit out triangles as opposed to lines though? Worth a try :man_shrugging:

Failing that, you could try:

gl::BatchRef PathToBatch ( const Path2d& path, float approximationScale = 1.0f )
	auto points = path.subdivide( approximationScale );
	auto verts = gl::VertBatch ( GL_LINE_STRIP );
	for ( auto& pt : points ) verts.vertex ( pt );
	return gl::Batch::create ( verts, gl::getStockShader ( gl::ShaderDef().color() ) );
1 Like

You’re a genius @lithium ! :smiley: