I’m working on this robot project, that outputs some continuous values while the robot is moving. Currently, my code to draw these values are such below.
//Displacement of Robot glColor3f(1.0f, 0.0f, 0.0f); glLineWidth (3); glBegin(GL_LINE_STRIP); glVertex2f(0, 0); // origin of the line glVertex2f(Y_VALUE, X_VALUE); // ending point of the glEnd( ); line
So, while the robot is moving, it is constantly giving me new y-value and x-value, and I’m trying to develop a code where the current position of the robot is displayed on the computer screen. Thus, I need to figure out some type of loop that keeps creating a new glVertex2f function for every new x-value and y-value. For example
glBegin(GL_LINE_STRIP); glVertex2f(0, 0); // origin of the line glVertex2f(Y_VALUE_1, X_VALUE_1); glVertex2f(Y_VALUE_2, X_VALUE_2); glVertex2f(Y_VALUE_3, X_VALUE_3); ................................ glVertex2f(Y_VALUE_N, X_VALUE_N); glEnd( );
If I can figure this out, then the lines will be connected from the origin till the last x and y value. I will greatly appreciate any help provided. Thanks.