View Full Version : help! what's the simplest way to generate an XY plot using openGL/glut?
12-14-2005, 05:25 AM
given a set of x,y coordinates, what is the simplest way to plot the data? I want to be able to just plot the points and then I want to be able to draw a curve through the points. Thanks
12-14-2005, 07:31 AM
To plot 2d points you may use glVertex2i(x,y).
glEnd();Drawing points very simple like above code, but you are not asking this, do you?
12-14-2005, 07:57 AM
OK... next question... When I create a window, the origin (0,0) is at the center. All points I need to plot will be in the first quadrant (positive x, positive y). Is there a way to shift the view or something to only show the first quadrant?
Look up glOrtho. It creates a projection matrix and you can use it map any part of the coordinate system to your window.
12-14-2005, 08:35 AM
If the resolution of your rendering window is 400x300, set your projection matrix with:
gluOrtho2D(0, 400, 0, 300);
This gives you Quadrant 1 only. The origin (0,0) is the lower-left corner and (399,299) would be the top-right corner.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.