--- /dev/null
+<div class="pod">
+<!-- INDEX START -->
+<h3 id="TOP">Index</h3>
+
+<ul><li><a href="#NAME">NAME</a></li>
+<li><a href="#CATEGORY">CATEGORY</a></li>
+<li><a href="#DESCRIPTION">DESCRIPTION</a>
+<ul><li><a href="#EXAMPLE">EXAMPLE</a></li>
+</ul>
+</li>
+<li><a href="#SEE_ALSO">SEE ALSO</a>
+</li>
+</ul><hr />
+<!-- INDEX END -->
+
+<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="NAME_CONTENT">
+<p>SDL::Cookbook::OpenGL - Using SDL with OpenGL</p>
+
+</div>
+<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="CATEGORY_CONTENT">
+<p>Cookbook</p>
+
+</div>
+<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="DESCRIPTION_CONTENT">
+<p>As of release 2.5 SDL no longer maintains it's own bindings of openGL. Support for openGL has been moved over to a more mature implementation. </p>
+<p>This implementation is the POGL project. <a href="http://search.cpan.org/perldoc?OpenGL">OpenGL</a> is faster and more complete; and works with SDL seemlessly.</p>
+
+</div>
+<h2 id="EXAMPLE">EXAMPLE</h2>
+<div id="EXAMPLE_CONTENT">
+<p>Expanded from Floyd-ATC's OpenGL example.</p>
+<pre>
+
+
+ use strict;
+ use warnings;
+ use SDL;
+ use SDLx::App;
+ use SDL::Mouse;
+ use SDL::Video;
+ use SDL::Events;
+ use SDL::Event;
+ use OpenGL qw(:all);
+
+ my ($SDLAPP, $WIDTH, $HEIGHT, $SDLEVENT);
+
+ $| = 1;
+ $WIDTH = 1024;
+ $HEIGHT = 768;
+ $SDLAPP = SDLx::App->new(-title => "Opengl App", -width => $WIDTH, -height => $HEIGHT, -gl => 1);
+ $SDLEVENT = SDL::Event->new;
+
+
+
+
+ glEnable(GL_DEPTH_TEST);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity;
+ gluPerspective(60, $WIDTH / $HEIGHT, 1, 1000);
+ glTranslatef(0, 0, -20);
+
+
+
+
+ while (1) {
+ &handlepolls;
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glRotatef(.1, 1, 1, 1);
+ &drawscene;
+ $SDLAPP->sync;
+ }
+
+
+
+
+
+
+
+ sub drawscene {
+ my ($color, $x, $y, $z);
+
+ for (-2 .. 2) {
+ glPushMatrix;
+ glTranslatef($_ * 3, 0, 0);
+ glColor3d(1, 0, 0);
+ &draw_cube;
+ glPopMatrix;
+ }
+
+ return "";
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sub draw_cube {
+ my (@indices, @vertices, $face, $vertex, $index, $coords);
+
+ @indices = qw(4 5 6 7 1 2 6 5 0 1 5 4
+ 0 3 2 1 0 4 7 3 2 3 7 6);
+ @vertices = ([-1, -1, -1], [ 1, -1, -1],
+ [ 1, 1, -1], [-1, 1, -1],
+ [-1, -1, 1], [ 1, -1, 1],
+ [ 1, 1, 1], [-1, 1, 1]);
+
+ glBegin(GL_QUADS);
+
+ foreach my $face (0..5) {
+ foreach my $vertex (0..3) {
+ $index = $indices[4 * $face + $vertex];
+ $coords = $vertices[$index];
+
+ glVertex3d(@$coords);
+ }
+ }
+
+ glEnd;
+
+ return "";
+ }
+
+
+
+
+
+
+
+
+
+
+ sub handlepolls {
+ my ($type, $key);
+
+ SDL::Events::pump_events();
+
+ while (SDL::Events::poll_event($SDLEVENT)) {
+ $type = $SDLEVENT->type();
+ $key = ($type == 2 or $type == 3) ? $SDLEVENT->key_sym : "";
+
+ if ($type == 4) { printf("You moved the mouse! x=%s y=%s xrel=%s yrel=%s\n", $SDLEVENT->motion_x, $SDLEVENT->motion_y, $SDLEVENT->motion_xrel, $SDLEVENT->motion_yrel) }
+ elsif ($type == 2) { print "You are pressing $key\n" }
+ elsif ($type == 3) { print "You released $key\n" }
+ elsif ($type == 12) { exit }
+ else { print "TYPE $type UNKNOWN!\n" }
+
+ if ($type == 2) {
+ if ($key eq "q" or $key eq "escape") { exit }
+ }
+ }
+
+ return "";
+ }
+
+</pre>
+
+</div>
+<h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="SEE_ALSO_CONTENT">
+<p><a href="http://search.cpan.org/perldoc?perl">perl</a> <a href="http://search.cpan.org/perldoc?SDLx::App">SDLx::App</a> <a href="http://search.cpan.org/perldoc?OpenGL">OpenGL</a></p>
+
+</div>
+</div>
\ No newline at end of file