Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sdl::opengl(3) [suse man page]

SDL::OpenGL(3)						User Contributed Perl Documentation					    SDL::OpenGL(3)

NAME
SDL::OpenGL - a perl extension DESCRIPTION
SDL::OpenGL is a perl module which when used by your application exports the gl* and glu* functions into your application's primary namespace. Most of the functions described in the OpenGL 1.3 specification are currently supported in this fashion. As the implementation of the OpenGL bindings that comes with SDL_perl is largely type agnositic, there is no need to decline the function names in the fashion that is done in the C API. For example, glVertex3d is simply glVertex, and perl just does the right thing with regards to types. CAVEATS
The following methods work different in Perl than in C: glCallLists glCallLists(@array_of_numbers); Unlike the C function, which get's passed a count, a type and a list of numbers, the Perl equivalent only takes a list of numbers. Note that this is slow, since it needs to allocate memory and construct a list of numbers from the given scalars. For a faster version see glCallListsString. The following methods exist in addition to the normal OpenGL specification: glCallListsString glCallListsString($string); Works like glCallLists(), except that it needs only one parameter, a scalar holding a string. The string is interpreted as a set of bytes, and each of these will be passed to glCallLists as GL_BYTE. This is faster than glCallLists, so you might want to pack your data like this: my $lists = pack("C", @array_of_numbers); And later use it like this: glCallListsString($lists); AUTHOR
David J. Goehrig SEE ALSO
perl SDL::App perl v5.12.1 2010-07-05 SDL::OpenGL(3)

Check Out this Related Man Page

pods::SDL::Cookbook::OpenGL(3pm)			User Contributed Perl Documentation			  pods::SDL::Cookbook::OpenGL(3pm)

NAME
SDL::Cookbook::OpenGL - Using SDL with OpenGL CATEGORY
Cookbook DESCRIPTION
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. This implementation is the POGL project. OpenGL is faster and more complete; and works with SDL seamlessly. EXAMPLE Expanded from Floyd-ATC's OpenGL example. 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); You can use OpenGL as needed here. 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; SDLx::App can start an OpenGL application with the parameter gl => 1. glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity; gluPerspective(60, $WIDTH / $HEIGHT, 1, 1000); glTranslatef(0, 0, -20); Above we enable GL and set the correct perspective while(1) { &handlepolls; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glRotatef(.1, 1, 1, 1); &drawscene; $SDLAPP->sync; } For SDLx::App sync handles the GL buffer clean. 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 ""; } Below we can use SDL::Events as normal: 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 ", $SDLEVENT->motion_x, $SDLEVENT->motion_y, $SDLEVENT->motion_xrel, $SDLEVENT->motion_yrel) } elsif ($type == 2) { print "You are pressing $key " } elsif ($type == 3) { print "You released $key " } elsif ($type == 12) { exit } else { print "TYPE $type UNKNOWN! " } if ($type == 2) { if ($key eq "q" or $key eq "escape") { exit } } } return ""; } SEE ALSO
perl SDLx::App OpenGL AUTHORS
See "AUTHORS" in SDL. perl v5.14.2 2012-05-28 pods::SDL::Cookbook::OpenGL(3pm)
Man Page