欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

perl-opengl立方体

程序员文章站 2022-04-29 13:23:02
...
#!/usr/bin/perl -w
use strict;
use warnings;
use OpenGL qw/ :all /;
use OpenGL::Config;   


my @mypoints;
@mypoints=([0,0,0],[0,50,0],[50,0,0],[50,50,0],[0,0,50],[0,50,50],[50,0,50],[50,50,50]);
glutInit();
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowPosition(100,100);
glutInitWindowSize(400,400);
glutCreateWindow("my  OpenGL program");
glClearColor(0,0,0,255);
glClear(GL_COLOR_BUFFER_BIT);  
glMatrixMode(GL_PROJECTION);
glOrtho(-100,100,-100,100,-100,100);
glMatrixMode(GL_MODELVIEW);
glutDisplayFunc(\&mydis);
glutMainLoop();
return 0;

sub mydis()
{
  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
  gluLookAt(-1,-1,-5,0,0,0,5,0,0);
  glColor3f(255,255,0);  
  &quad(6,2,3,7);
  &quad(5,1,0,4);
  &quad(7,3,1,5);
  &quad(4,0,2,6);
  &quad(2,0,1,3);
  &quad(7,5,4,6); 
  glFlush();
}

sub quad()
{
  my @ptn=@_;
  glBegin(GL_QUADS);
  glVertex3i(@{$mypoints[$ptn[0]]});
  glVertex3i(@{$mypoints[$ptn[1]]});
  glVertex3i(@{$mypoints[$ptn[2]]});
  glVertex3i(@{$mypoints[$ptn[3]]});
  glEnd(); 
}

 


perl-opengl立方体
            
    
    博客分类: 脚本语言
 

 

  • perl-opengl立方体
            
    
    博客分类: 脚本语言
  • 大小: 1.9 KB