5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
7 # ------------------------------------------------------------------------------
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # ------------------------------------------------------------------------------
25 # Please feel free to send questions, suggestions or improvements to:
37 use SDL::OpenGL::Constants;
39 #for ( keys %main:: ) {
43 print "Starting $0\n";
45 my $app = new SDL::App -w => 800, -h => 600, -d => 16, -gl => 1;
47 print "Initializing OpenGL settings\n";
48 printf "%-24s%s\n", "GL_RED_SIZE ", $app->attribute( SDL_GL_RED_SIZE() );
49 printf "%-24s%s\n", "GL_GREEN_SIZE ", $app->attribute( SDL_GL_GREEN_SIZE());
50 printf "%-24s%s\n", "GL_BLUE_SIZE ", $app->attribute( SDL_GL_BLUE_SIZE() );
51 printf "%-24s%s\n", "GL_DEPTH_SIZE ", $app->attribute( SDL_GL_DEPTH_SIZE() );
52 printf "%-24s%s\n", "GL_DOUBLEBUFFER ", $app->attribute( SDL_GL_DOUBLEBUFFER() );
56 glClear( GL_DEPTH_BUFFER_BIT()
57 | GL_COLOR_BUFFER_BIT());
61 glTranslate(-1.5,0,-6);
65 glBegin(GL_TRIANGLES());
66 glColor(1,0,0) if (@_);
68 glColor(0,1,0) if (@_);
70 glColor(0,0,1) if (@_);
77 glColor(1,0,0) if (@_);
79 glColor(0,1,0) if (@_);
81 glColor(0,0,1) if (@_);
83 glColor(1,1,0) if (@_);
89 DrawScene 'with color';
93 glViewport(0,0,800,600);
95 glMatrixMode(GL_PROJECTION());
99 gluPerspective(45.0,4/3,0.1,100.0);
101 glFrustum(-0.1,0.1,-0.075,0.075,0.175,100.0);
104 glMatrixMode(GL_MODELVIEW());
117 SDL_QUIT() => sub { exit(0); },
118 SDL_KEYDOWN() => sub { $toggle = ($toggle) ? 0 : 1;
119 ($toggle) ? DrawScene() : DrawColorScene();