#!/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("my OpenGL 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(); }