Using Tao.Freeglut and Tao.OpenGl. I tried to create some points by typing this code.
But when I run it, it show only a white windows but didn't have any points on it. Did someone know how to fix this problem.( same problem when i try to use GL_LINES with 2 points)
using Tao.Freeglut;
using Tao.OpenGl;
public static void init()
Gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
Gl.glColor3f(0.0f, 0.0f, 1.0f);
Gl.glPointSize(4);
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Glu.gluOrtho2D(0.0, 400, 0.0, 300.0);
}
public static void myDisplay()
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
Gl.glBegin(Gl.GL_POINT);
{
Gl.glVertex2i(50, 50);
Gl.glVertex2i(100, 100);
Gl.glVertex2i(100, 150);
Gl.glVertex2i(200, 200);
Gl.glVertex2i(200, 250);
Gl.glEnd();
}
Gl.glFlush();
}
static void Main()
{
Glut.glutInit();
Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
Glut.glutInitWindowPosition(50, 100);
Glut.glutInitWindowSize(400, 300);
Glut.glutCreateWindow("Test 2");
init();
Glut.glutDisplayFunc(myDisplay);
Glut.glutMainLoop();
}
Gl.glBegin(Gl.GL_POINT);
will cause a GL_INVALID_ENUM error, since GL_POINT is not a valid argument to glBegin. Check out the documentation one which draw modes are valid. You should also check for OpenGL errors at least at the end of a frame.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.