我有一个程序可以画一条线,如下所示。
private void glControl1_Paint(object sender, PaintEventArgs e)
{
GL.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
GL.glColor(Color.Yellow);
GL.glBegin(GL.GL_LINES);
GL.glVertex3f(100.0f, 100.0f, 0.0f); // origin of the line
GL.glVertex3f(200.0f, 140.0f, 5.0f); // ending point of the line
GL.glEnd();
glControl1.SwapBuffers();
}
上面的方法在 Paint 事件期间被调用。
但我有另一种方法,如下所示:
private void glControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
GL.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
GL.glColor(Color.Yellow);
GL.glBegin(GL.GL_LINES);
GL.glVertex3f(100.0f, 100.0f, 0.0f); // origin of the FIRST line
GL.glVertex3f(200.0f, 140.0f, 5.0f); // ending point of the FIRST line
GL.glVertex3f(120.0f, 170.0f, 10.0f); // origin of the SECOND line
GL.glVertex3f(240.0f, 120.0f, 5.0f); // ending point of the SECOND line
GL.glEnd();
}
我想用这种方法画一些东西,但是没有用。
怎么了。
谢谢