beebe_3 发表于 2017-5-17 12:05:58

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(400,400);
glutCreateWindow("myOpenGL program");
glClearColor(0,0,0,255);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(-100,100,-100,100);
glutDisplayFunc(\&mydis);
glutMainLoop();
return 0;
sub mydis()
{
glColor3f(0,255,0);
glBegin(GL_LINES);
glVertex2f(-100,0);
glVertex2f(100,0);
glEnd();
glBegin(GL_LINES);
glVertex2f(0,-100);
glVertex2f(0,100);
glEnd();
glColor3f(255,255,0);
glRecti(-50,-50,50,50);
glFlush();
}


  

 
页: [1]
查看完整版本: perl-opengl画距形