#include <stdio.h> 
#include <time.h> 
#include <windows.h> 
#include <gl/glut.h> 
void pixel(int x, int y, int size, GLubyte Red, GLubyte Green, GLubyte Blue) 

glPointSize(size); glBegin(GL_POINTS); 
glColor3ub(Red, Green, Blue); 
glVertex2f(x, y); 
glEnd(); glFlush(); } void drawing() 

int x,y,red,green,blue; 
srand((unsigned)time(NULL)); 
for(int i=0;i <2000;i++) 

red=rand()%255+1; 
green=rand()%255+1; 
blue=rand()%255+1; 
x=rand()%800+1; 
y=rand()%600+1; 
pixel(x, y, i%3, red, green, blue); 
/*-------------------------------这里加入Sleep(10);就会出问题!!!!!!!!!!!!!!!!不出窗口了。*/ 
} } void init_display() 

glClearColor(0.0, 0.0, 0.0, 0.0); 
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

void display() 

init_display(); drawing(); 
} void reshape(int w, int h) 

glViewport(0, 0, (GLsizei)w, (GLsizei)h); 
glMatrixMode(GL_PROJECTION); 
glLoadIdentity(); 
gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h); 
} int main(int argc, char *argv[]) 

glutInit(&argc, argv); 
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_SINGLE); 
glutInitWindowSize(800, 600); 
glutInitWindowPosition(0, 0); 
glutCreateWindow("Point"); 
glutDisplayFunc(display); 
glutReshapeFunc(reshape); 
display(); 
glutMainLoop(); 
return 0;