perl-opengl学习-绘制点

阅读更多
#!/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(600,600);
glutCreateWindow("my first OpenGL program");
glutDisplayFunc(\&mydis);
glutMainLoop();
return 0;

sub mydis()
{
  my $x=-1;
  my $y;
  my $z=-1;
  
  glClearColor(0,0,0,255);
  glClear(GL_COLOR_BUFFER_BIT);
  glPointSize(1);
  glBegin(GL_POINTS);
  for (0..10000)
  {
    $x+=0.001;
    $z+=0.001;	
	$y=$x**2;
	glColor3f(255,0,0);
    glVertex2f($x,$y);	
	$y=$z**3;
	glColor3f(0,255,0);
    glVertex2f($x,$y);		
  }
  glEnd();
  glFlush();
}

 绘制x平方和x立方


perl-opengl学习-绘制点_第1张图片
 

  • perl-opengl学习-绘制点_第2张图片
  • 大小: 45.2 KB
  • 查看图片附件

你可能感兴趣的:(perl-opengl学习-绘制点)