PDA

View Full Version : source code to plot graph in GLUT?



baburkhan
09-26-2004, 10:06 AM
can someone tell me the source code when i want to draw some graph in GLUT(openGL) and VC++ by giving it some function f(x) along x-axis and y-axis? is there any short source code available?
i need it urgent . please help me.
i am looking forward to you people.

mikael_aronsson
09-26-2004, 10:31 PM
Hi !

Well, when you have your function that calculates the x/y values it is pretty simple.

To render points:
glBegin( GL_POINTS);
glVertex2d( x,y); // this is in a loop
glEnd();

To render a "curve"
glBegin( GL_LINE_STRIP);
glVertex2d( x,y); // this is in a loop
glEnd();

Mikael