perl-opengl学习-绘制点
程序员文章站
2022-04-29 13:22:32
...
#!/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立方