8 use SDL::OpenGL::Constants;
10 #for ( keys %main:: ) {
14 print "Starting $0\n";
16 my $app = new SDL::App -w => 800, -h => 600, -d => 16, -gl => 1;
18 print "Initializing OpenGL settings\n";
19 printf "%-24s%s\n", "GL_RED_SIZE ", $app->attribute( SDL_GL_RED_SIZE() );
20 printf "%-24s%s\n", "GL_GREEN_SIZE ", $app->attribute( SDL_GL_GREEN_SIZE());
21 printf "%-24s%s\n", "GL_BLUE_SIZE ", $app->attribute( SDL_GL_BLUE_SIZE() );
22 printf "%-24s%s\n", "GL_DEPTH_SIZE ", $app->attribute( SDL_GL_DEPTH_SIZE() );
23 printf "%-24s%s\n", "GL_DOUBLEBUFFER ", $app->attribute( SDL_GL_DOUBLEBUFFER() );
27 glClear( GL_DEPTH_BUFFER_BIT()
28 | GL_COLOR_BUFFER_BIT());
32 glTranslate(-1.5,0,-6);
36 glBegin(GL_TRIANGLES());
37 glColor(1,0,0) if (@_);
39 glColor(0,1,0) if (@_);
41 glColor(0,0,1) if (@_);
48 glColor(1,0,0) if (@_);
50 glColor(0,1,0) if (@_);
52 glColor(0,0,1) if (@_);
54 glColor(1,1,0) if (@_);
60 DrawScene 'with color';
64 glViewport(0,0,800,600);
66 glMatrixMode(GL_PROJECTION());
70 gluPerspective(45.0,4/3,0.1,100.0);
72 glFrustum(-0.1,0.1,-0.075,0.075,0.175,100.0);
75 glMatrixMode(GL_MODELVIEW());
88 SDL_QUIT() => sub { exit(0); },
89 SDL_KEYDOWN() => sub { $toggle = ($toggle) ? 0 : 1;
90 ($toggle) ? DrawScene() : DrawColorScene();