#!/usr/bin/perl -w use strict; use warnings; use OpenGL qw/ :all /; use OpenGL::Config; #!/usr/bin/perl -w use strict; use warnings; use OpenGL qw/ :all /; use OpenGL::Config; my $a=rand(1); my $b=rand(1); my $c=1; my $look=0.1; my $lookx=0.1; my $looky=0.1; my $ispress=0; 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); glLoadIdentity(); glOrtho(-3,3,-3,3,-3,3); gluLookAt($look,$look,$look,0.0,0.0,0.0,0.0,$look,0.0); glMatrixMode(GL_MODELVIEW); glutDisplayFunc(\&mydis); glutMotionFunc(\&mymouse); glutMainLoop(); sub mydis() { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glClearColor(0,0,0,255); glClear(GL_COLOR_BUFFER_BIT); &qiu(); } sub mymouse() { my ($myx,$myy)=@_; $look=($myx+$myy)/2/400; $lookx=($myx-200)/200; $looky=(200-$myy)/200; glLoadIdentity(); gluLookAt($lookx,$looky,$look,0.0,0.0,0.0,0.0,$look,0.0); glutPostRedisplay(); print "mouse x:$myx-y:$myy-look:$look\n"; } sub qiu() { my $x; my $y; my $z; my $c=3.1415926/180; for (my $phi=-80.00;$phi<=80.00;$phi+=20.00) { my $phir=$c*$phi; my $phir20=$c*($phi+20); glBegin(GL_QUAD_STRIP); glColor3f($a,$b,$c); for (my $theta=-180.00;$theta<=180.00;$theta+=20.00) { my $thetar=$c*$theta; $x=sin($thetar)*cos($phir); $y=cos($thetar)*cos($phir); $z=sin($phir); glVertex3d($x,$y,$z); $x=sin($thetar)*cos($phir20); $y=cos($thetar)*cos($phir20); $z=sin($phir20); glVertex3d($x,$y,$z); } glEnd(); glFlush(); } }
按下鼠标按钮时,球体会随着鼠标的操作而转动
7.6 glutMotionFunc, glutPassiveMotionFunc
glutMotionFunc and glutPassiveMotionFunc set the motion and passive motion callbacks respectively for the current window.
Usage
void glutMotionFunc(void (*func)(int x, int y)); void glutPassiveMotionFunc(void (*func)(int x, int y));
Description
glutMotionFunc and glutPassiveMotionFunc set the motion and passive motion callback respectively for the current window. The motion callback for a window is called when the mouse moves within the window while one or more mouse buttons are pressed. The passive motion callback for a window is called when the mouse moves within the window while no mouse buttons are pressed.
The x and y callback parameters indicate the mouse location in window relative coordinates.
Passing NULL to glutMotionFunc or glutPassiveMotionFunc disables the generation of the mouse or passive motion callback respectively.
相关推荐
strawberry-perl-5.32.1.1-64bit.msi离线安装包(官方),可避免从官网下载速度慢的问题。 windows环境的perl安装包,不用去官网下载了,测试好用。 strawberry-perl-5.32.1.1-64bit.msi离线安装包(官方),可避免...
linux 离线安装perl-IPC-Cmd
strawberry-perl-5.32.1.1-32bit.msi离线安装包(官方),可避免从官网下载速度慢的问题。 windows环境的perl安装包,不用去官网下载了,测试好用。 strawberry-perl-5.32.1.1-32bit.msi离线安装包(官方),可避免...
ActivePerl-5.28.1 win10 x64离线安装包(官方),可避免从官网下载速度慢的问题。 ActivePerl-5.28.1 win10 x64离线安装包(官方),可避免从官网下载速度慢的问题。 ActivePerl-5.28.1 win10 x64离线安装包(官方...
perl-WWW-Curl4.17版本rpm包
Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0...
Windows Perl-5.36.0 VC2017 源码编译版 此版本是在Windows下,使用github上Perl-5.36的源码,在VC2017下编译的。
strawberry-perl-5.10.1.0.msi
Digest-Perl-MD5
perl-parent-0.225-244.el7.noarch perl-HTTP-Tiny-0.033-3.el7.noarch perl-podlators-2.5.1-3.el7.noarch perl-Pod-Perldoc-3.20-4.el7.noarch 1:perl-Pod-Escapes-1.04-286.el7.noarch perl-Text-...
刚刚下载的strawberry-perl-5.32.1.1-64bit 用于64位系统Perl 希望对你有用
perl-DBD-MySQL-4.013-3.el6.x86_64.rpm
perl-MailTools-1.53-1.noarch.rpm
perl-DBI-1.52-2.el5.i386.rpm
perl-5.16.3-297.el7.x86_64.rpm
Windows Perl-5.36.0 VC2015 源码编译版 此版本是在Windows下,使用github上Perl-5.36的源码,在VC2015下编译的。
strawberry-perl-5.32.1.1-32bit
strawberry-perl-5.32.1.1-64bit安装包 CSDN审核可能较慢,如无法下载,可以过段时间再回来看下 仅供相关爱好者交流使用,请于下载24小时内删除
perl-XML-DOM-1.44-7.el6.noarch.rpm perl-XML-DOM-1.44-7.el6.noarch.rpm
解决MYSQL在LINUXCENTOS下缺失依赖包 perl-5.10.1-141.el6_7.1.x86_64.rpm