What is the best way to draw 3d text with pyopengl, preferably with modern opengl ?
There seem to be quite a few examples, but mostly in old-style opengl and not for python
- First you need a text outline which requires a font.
On windows you can use WinGDI fonts by creating a dummy context, selecting a created font on it and getting outlines of every character. For Truetype you load glyphs into the face and simply access their outlines.
- For the front & back face of your 3D text, you need to convert the outlines/contours to triangles. Either use the good old GLU tesselator, the relative new tesselation shader of OpenGL 4 or a geometry library like CGAL. Then simply draw the triangles for the front and again with some additional depth for the back.
- For the sides you simply span rectangles behind outline segments/lines with height equal to your wished text depth - these are your text sides. You can simply use a depth vector and transform everything afterwards or calculate the orthogonal vector with 2 segments.
You notice that this all can be expensive, so don't hesitate to cache as much as possible.
I referenced to C sources because i'm more familiar with these, but i bet there're python equivalents to port my explanations.