|
sub wirecube{
local ( $s ) = @_ ;
local ( @x , @y , @z , @f );
local ( $i , $j , $k );
$s = $s /2.0;
@x =(- $s ,- $s ,- $s ,- $s , $s , $s , $s , $s );
@y =(- $s ,- $s , $s , $s ,- $s ,- $s , $s , $s );
@z =(- $s , $s , $s ,- $s ,- $s , $s , $s ,- $s );
@f =(
0, 1, 2, 3,
3, 2, 6, 7,
7, 6, 5, 4,
4, 5, 1, 0,
5, 6, 2, 1,
7, 4, 0, 3,
);
for ( $i =0; $i <6; $i ++){
glBegin(GL_LINE_LOOP);
for ( $j =0; $j <4; $j ++){
$k = $f [ $i *4+ $j ];
glVertex3d( $x [ $k ], $y [ $k ], $z [ $k ]);
}
glEnd();
}
}
sub display{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glLoadIdentity();
glTranslatef(0.0, 0.0, -5.0);
glScalef(1.0, 2.0, 1.0);
wirecube(1.0);
glpFlush();
}
sub myReshape {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0,1.0,1.0,30.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity ();
}
glpOpenWindow;
glShadeModel(GL_FLAT);
myReshape();
display();
glpMainLoop;
|