perl-opengl几何变换函数
来源:互联网 发布:整型变量的数据范围 编辑:程序博客网 时间:2024/04/30 23:31
- #!/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,0,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,0,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.1,0.9);
- glTranslatef(3.5,8.5,0);
- glRecti(-50,-50,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,50,50);
- glFlush();
- glPopMatrix();
- glPushMatrix();
- #x方向缩小至0.5倍,y方向缩小至0.8倍
- glColor3f(0.9,0.9,0.9);
- glScalef(0.5,0.8,1);
- glRecti(-50,-50,50,50);
- glFlush();
- glPopMatrix();
- glPushMatrix();
- #二维旋转,相对于坐标原点的
- glColor3f(0.7,0.8,0.7);
- my ($x1,$y1,$x2,$y2)=(15,15,15,50);
- for (my $theta=5;$theta<360;$theta+=5)
- {
- glRotatef($theta,0,0,1);#相对于z轴
- glRecti(-50,-50,50,50);
- }
- glFlush();
- }
#!/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,0,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,0,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.1,0.9); glTranslatef(3.5,8.5,0); glRecti(-50,-50,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,50,50); glFlush(); glPopMatrix(); glPushMatrix(); #x方向缩小至0.5倍,y方向缩小至0.8倍 glColor3f(0.9,0.9,0.9); glScalef(0.5,0.8,1); glRecti(-50,-50,50,50); glFlush(); glPopMatrix(); glPushMatrix(); #二维旋转,相对于坐标原点的 glColor3f(0.7,0.8,0.7); my ($x1,$y1,$x2,$y2)=(15,15,15,50); for (my $theta=5;$theta<360;$theta+=5) { glRotatef($theta,0,0,1);#相对于z轴 glRecti(-50,-50,50,50); } glFlush(); }
- perl-opengl几何变换函数
- perl-opengl几何变换函数
- 【OpenGL】几何变换的常用函数
- OpenGL几何变换
- OpenGL三角形几何变换
- OpenGL几何变换详解
- OpenGL的几何变换
- OpenGL开发 几何变换:管线
- OpenGL: 用户自定义几何变换
- 实验3 OpenGL几何变换
- OpenGL ES几何变换和坐标变换
- OpenGL ES几何变换和坐标变换
- OpenGL图形变换——几何变换(世界变换)
- OpenGL变换函数说明
- 我对 OpenGL 几何变换的理解
- OpenGL学习——二维几何变换
- OpenGL学习08_几何变换
- OpenGL的几何变换-纹理贴图
- 笔记通过查询创建表
- 多线程编程2 - NSOperation
- Eclipse使用过程中出现java.lang.NoClassDefFoundError的解决方案
- JMS调用IBM MQ监听模式
- Excel 在测试中的应用(二)--添加功能键
- perl-opengl几何变换函数
- 有效的沟通非常重要
- 对象和函数
- Uva 540 Team Queue
- AWS 上 Apache httpd 服务器性能调优
- 数学杂记
- 什么是java
- Codeforces #165 div2 B Multithreading
- CSS3 图形