正在加载图片...
display code void display (void) / A triangle * GLfloat vertices]2]={0.0.00}{25.050.0}{50.0.00 int i, j, k; GLfloat p[2]=0,0]; / an arbitrary initial point inside traingle * glClear(GL COLOR BUFFER BID); / clear the window * glBegin(GL POINTS): / compute and plots 5000 new points * for(k=0;k<10000k++) j=rando%3: / pick a vertex at random * Compute point halfway between selected vertex and old point * p[O]=(p[0]+vertices[OJ/2.0 p[1]=(p[1]+vertices[[1)/2.0 I plot new point * glVertex2fv(p) glEndo glFlusho; clear buffers*/display code void display(void) { /* A triangle */ GLfloat vertices[3][2]={{0.0,0.0},{25.0,50.0},{50.0,0.0}}; int i, j, k; GLfloat p[2] ={0,0}; /* an arbitrary initial point inside traingle */ glClear(GL_COLOR_BUFFER_BIT); /* clear the window */ glBegin(GL_POINTS); /* compute and plots 5000 new points */ for( k=0; k<10000; k++) { j=rand()%3; /* pick a vertex at random */ /* Compute point halfway between selected vertex and old point */ p[0] = (p[0]+vertices[j][0])/2.0; p[1] = (p[1]+vertices[j][1])/2.0; /* plot new point */ glVertex2fv(p); } glEnd(); glFlush(); /* clear buffers */ } 7
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有