#!/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.
相关推荐
`perl-IPC-Cmd`是Perl的一个模块,它提供了执行外部命令并捕获其输出的功能。离线安装Perl模块在没有互联网连接或者安全策略限制的环境下尤其重要。下面我们将详细介绍如何在Linux上离线安装`perl-IPC-Cmd`,以及...
- perl-DBI:Perl 数据库接口模块,是 perl-DBD-MySQL 所依赖的基础模块。 - perl-IO-Compress:Perl 的压缩和解压缩库。 - perl-DBD-MySQL:MySQL 数据库驱动模块,用于 Perl 连接 MySQL 数据库。 - perl-Compress-...
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...
3. 使用`rpm`命令逐个安装这些包,按照依赖关系顺序安装,通常从perl-Digest-1.17开始,然后是perl-Digest-SHA,接着是perl-local-lib,最后是perl-CPAN。运行以下命令: ``` sudo rpm -ivh perl-Digest-1.17-245....
strawberry-perl-5.32.1.1-32bit.msi离线安装包(官方),可避免从官网下载速度慢的问题。 windows环境的perl安装包,不用去官网下载了,测试好用。 strawberry-perl-5.32.1.1-32bit.msi离线安装包(官方),可避免...
《Digest-Perl-MD5:Perl中的MD5哈希库》 Digest-Perl-MD5是Perl编程语言中用于处理MD5(Message-Digest Algorithm 5)哈希算法的一个模块。MD5是一种广泛使用的加密散列函数,设计者是Ronald Rivest。它产生一个...
strawberry-perl-5.32.1.1-64bit.msi离线安装包(官方),可避免从官网下载速度慢的问题。 windows环境的perl安装包,不用去官网下载了,测试好用。 strawberry-perl-5.32.1.1-64bit.msi离线安装包(官方),可避免...
ActivePerl-5.28.1 win10 x64离线安装包(官方),可避免从官网下载速度慢的问题。 ActivePerl-5.28.1 win10 x64离线安装包(官方),可避免从官网下载速度慢的问题。 ActivePerl-5.28.1 win10 x64离线安装包(官方...
根据压缩包中提供的文件列表,可以看到还有一个perl-Digest-1.17-245.el7.noarch.rpm依赖包,安装perl-Digest-MD5-2.52-3.el7.x86_64.rpm之前需要确保该依赖包也被安装。 如果在安装过程中遇到问题,可以参考压缩包...
本篇文章将详细介绍一个具体的rpm包文件——perl-libwww-perl-6.05-2.el7.x86-64-86.rpm.tar.gz,及其解压和安装步骤。 首先,从标题“perl-libwww-perl-6.05-2.el7.x86-64-86.rpm.tar.gz”中,我们可以看出这是一...
perl-WWW-Curl4.17版本rpm包
此外,根据给出的信息,该压缩包包含了一系列与perl-Devel-Cover相关的其他rpm包,比如perl-Template-Toolkit、perl-XML-LibXML、perl-Net-SSLeay、perl-IO-Compress、perl-CGI、perl-XML-Parser、perl-libwww-perl...
标题中的"perl-5.16.3-293.el7.x86_64_rpm.zip"指的是Perl编程语言的一个特定版本的RPM(Red Hat Package Manager)包,适用于64位的 CentOS 7 操作系统。RPM是一种在类Unix系统中管理软件包的标准格式,它方便了...
此外,还有 perl-ExtUtils-MakeMaker、perl-ExtUtils-ParseXS、perl-ExtUtils-Install、perl-local-lib等模块,它们对于Perl的安装和管理是必不可少的。 通过上述内容,我们可以总结出,该压缩包是为满足Perl CPAN...
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位系统的,这意味着它设计用于运行在64位版本的Windows上。Perl是一种功能强大的脚本语言,广泛应用于文本处理、网络编程、系统管理任务以及各种Web应用程序。 ...
perl-Config-Tiny-2.12-7.1.el6.noarch.rpm perl-Config-Tiny-2.12-7.1.el6.noarch.rpm
RHEL 7.1安装MySQL 5.6的依赖包:perl-Data-Dumper-2.145-3.el7.x86_64.rpm ------------------------------------------------------------------------------------
`perl-5.26.1`指的是Perl编程语言的5.26.1版本。在这个离线资源包中,我们重点关注的是如何在没有网络的情况下,在Linux系统中安装和使用Perl 5.26.1。 首先,你需要将`perl-5.26.1`的压缩包下载到你的Linux机器上...