3D Font rendering in OpenGL - can JUCE help me?

For some 3D plots I’m about to build, I need to be able to draw some 3D coordinate system to plot the data in, this means I need to draw the coordinate system first and then draw my data above it (which means that the data will mask the coordinate axes for some view-positions).

While a coordinate system consisting of simple lines does not seem to be a challenging task, adding text to the axes seems to be a lot more complicated. I had a quick read on usual font rendering approaches for OpenGL that gave me a rough idea on how it could be done. However that seems like a bit of overkill for my needs. Is there any solution for this in JUCE I could re-use? I know that the GL renderer obviously can render font in the 2D plane above my 3D GL drawing, could I somehow use this renderer to draw a font placed in the 3D space under my drawings?

Or would it be a good idea to build three bitmap images for each all three axes with all text using the usual JUCE 2D drawing methods and then use them as a textures that are placed in the 3D space? Or any totally different idea?

Well, the juce font classes make it easy to get a Path object for a string of text, and you can flatten that into lines and triangulate them, but if you’re doing 3D with it then you’re on your own as far as rendering the triangles goes.

Are you referring to GlyphArrangement::createPath? Looks like a good starting point for me. However could you elaborate the “flatten that into lines” part a bit more? I‘m not quite sure if I get the correct meaning :wink:

By the way, my naive idea would be to somehow generate a bunch of vertices from the path describing the outline (if that’s somehow possible) and draw a trianglestrip between those points, but I suspect you mean something different.

All approaches I came along so far used bitmap rastered glyphs as textures

Well yes, that’s exactly what I meant. You want the PathFlatteningIterator class for that.

Thanks, the PathFlatteningIterator looks good. Now after having flattened my glyph outline, I still need to build up the list of vertices for the triangle strip that fills the space between the outlines with a scanline algorithm, or is there a more efficient way of doing this?

We don’t have anything for triangulation, you’ll have to figure that bit out for yourself :slight_smile:

Okay, I think I’ll manage to set up something that works (even if it might not be the most efficient solution) - sounds like an interesting task at the moment. Thank you for your help so far!