View Full Version : Graphs using OpenGL?

09-29-2002, 06:55 PM
I need to develop a few graphs using OpenGL on Windows using Visual C++. Examples are usual X-Y graph, 2D and 3D Waterfall graph. All the OpenGL samples I have seen so far model some object or other. I have not seen any graphing sample.

Is it possible to plot graphs using OpenGL?
If there are any samples, pls point me to them.

Thanks in Advance,

09-29-2002, 07:33 PM
i don't know any tutorials, but you will need to do something like this...

//put your data points here in glVertex2f(x,y) calls


//put your data points here in glVertex2f(x,y) for connected line graph

draw your axes with GL_LINES.
there is also glRect() for doing filled rectangles and stuff (bar graphs?).

3D contour graphs you could do with GL_LINE_STRIP, walking the data points along one axis, incrementing along the other. if you want proper occlusion of background lines this will get a little tricky and you will have to enable depth-testing, draw the contours as filled polygons in the background color, then draw the actual contours as visible lines using glPolygonOffset() etc.

get the Red Book (open GL programming guide) and read thru it - it should become obvious how to do graphs using openGL this way.

beware - fonts and text labels are harder. use the GLUT toolkit to make life easier.

[This message has been edited by vshader (edited 09-29-2002).]