加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl-opengl几何变换函数

发布时间:2020-12-16 00:05:52 所属栏目:大数据 来源:网络整理
导读:#!/usr/bin/perl -wuse strict;use warnings;use OpenGL qw/ :all /;use OpenGL::Config; glutInit();glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);glutInitWindowPosition(100,100);glutInitWindowSize(400,400);glutCreateWindow("opengl");glClearColor(0,

#!/usr/bin/perl -w
use strict;
use warnings;
use OpenGL qw/ :all /;
use OpenGL::Config;   

glutInit();
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowPosition(100,100);
glutInitWindowSize(400,400);
glutCreateWindow("opengl");
glClearColor(0,255);
glClear(GL_COLOR_BUFFER_BIT);  
glMatrixMode(GL_PROJECTION);
gluOrtho2D(-100,100,-100,100);
glMatrixMode(GL_MODELVIEW);
glutDisplayFunc(&;mydis);
glutMainLoop();
return 0;

sub mydis()
{
  glClearColor(0,255);
  glClear(GL_COLOR_BUFFER_BIT); 
  glLoadIdentity();
  glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);  
  glColor3f(1,1,1);
  glBegin(GL_LINES);
  glVertex2f(-100,0);
  glVertex2f(100,0); 
  glEnd();
  glBegin(GL_LINES);
  glVertex2f(0,-100);
  glVertex2f(0,100); 
  glEnd(); 
  # 画矩形
  glColor3f(0.5,0.1,0);  
  glRecti(-50,-50,50,50);
  glFlush();
  glPushMatrix();
  #向x方向移动3.5个单位,y方向移动8.5个单位
  glColor3f(0.1,0.9);  
  glTranslatef(3.5,8.5,0);
  glRecti(-50,50);
  glFlush();  
  glPopMatrix();
  glPushMatrix();  
  #x方向放大到1.2倍,y方向放大到1.8倍
  glColor3f(0.1,0.9,0.1); 
  glScalef(1.2,1.8,1); 
  glRecti(-50,50);
  glFlush(); 
  glPopMatrix();
  glPushMatrix();   
  #x方向缩小至0.5倍,y方向缩小至0.8倍
  glColor3f(0.9,0.9); 
  glScalef(0.5,0.8,50);
  glFlush(); 
  glPopMatrix();
  glPushMatrix();  
  #二维旋转,相对于坐标原点的
  glColor3f(0.7,0.7);
  my ($x1,$y1,$x2,$y2)=(15,15,50);
  for (my $theta=5;$theta<360;$theta+=5)
  { 
	glRotatef($theta,1);#相对于z轴
    glRecti(-50,50); 
  }    
  glFlush();  
}



(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读