|
void __fastcall TFormMain :: RenderGLScene ()
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
DrawObjects ();
glFlush ();
}
void __fastcall TFormMain :: DrawObjects ()
{
glBegin (GL_LINE_STRIP);
glColor3f (1.0f, 0.0f, 0.0f); // Set the current color to red
glVertex3f (0.0f, 0.0f, 0.0f);
glVertex3f (0.0f, X, 0.0f); // X is a changed value, which is read in from outside through RS232
glEnd ();
}
With the above method, there is always a straight line from 0, 0, 0 to the latest X value, how to achieve a little bit of connection, rather than the connection from the first point to the last point.
The effect I need is similar to that in the drawing software, as the mouse moves, it follows the line.
In addition, if you do not use glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); how to eliminate flicker? |
|