5

How can I render mathematical notations / expressions in Python with OpenGL?

I'm actually using pyglet however it uses OpenGL.

Such things as this:

Quadratic formula

I can't store static images as I am generating the expressions as well.

Community
  • 1
  • 1
AnnanFay
  • 9,573
  • 15
  • 63
  • 86

3 Answers3

10

I would say generate suitable latex expression, rendering it into an image, then load the image as a texture.

freespace
  • 16,529
  • 4
  • 36
  • 58
3

You can use GL_TEXTURE_RECTANGLE_ARB opengl extension to quickly load dynamicaly generated image of arbitrary size into OpenGL texture. You can look for python examples of using dynamic vector graphics with opengl at http://cairographics.org/OpenGL/, though if you want to render complex formulas you also have to look at the some appropriate system like latex.

user285176
  • 594
  • 3
  • 7
1

I don't know about the OpenGL bit. But matplotlib has a matplotlib.mathtext module for rendering a sub-set of TeX mathematical expressions.

Craig McQueen
  • 41,871
  • 30
  • 130
  • 181