I need to draw a scientific graph (for example, a line or bar graph) and then render it in my application, which uses OpenGL for all display-related purposes.
What is the best way to do this?
Does anyone know of a plotting library for OpenGL?
I haven't been able to find one, and the best thing I've come up with so far is to use LibGD or PlPlot to render my image, save to PNG, and then load that same PNG as a texture for an OpenGL quad. Does anyone have any suggestions for a better way to to this, or know a library which could help with my task?
MathGL is cross-platform GPL plotting library which can use OpenGL for drawing (class mglGraphGL).
However it can produce a bitmap (or vector EPS/SVG) too. It is rather fast and don't require windows (can be run in console).
Rendering to PNG and using this as a texture is actually a reasonable way to solve your problem. If you need a "better" way, all depends on what you consider "better". If it's about scalable graphics, use the SVG output of PLPlot and render the vector shapes directly in OpenGL. If it's about avoiding intermediate files, you could extend PLPlot (LGPL licensed) to pass the data as a chunk in memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With