Rechercher une page de manuel
SDL::OpenGL.3pm
Langue: en
Version: 2003-03-27 (debian - 07/07/09)
Section: 3 (Bibliothèques de fonctions)
Sommaire
NAME
SDL::OpenGL - a perl extensionDESCRIPTION
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.
- glReadPixels
-
$scalar = glReadPixels($x,$y,$width,$height,$format,$type);
Reads the pixels at $x,$y and returnes them packed into the scalar.
Here is a short example on how to make a screenshot of an OpenGL app and save it to a BMP file:
# get the data from the screen $data = glReadPixels(0,0,$width,$height,GL_GBR,GL_UNSIGNED_BYTE); SaveBMP ($filename, $width, $height, 24, $data);
See also glSaveBMP(), which implements this.
The following methods exist in Perl in addition to the normal OpenGL specification:
- glCallListsScalar
-
glCallListsScalar($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:
glCallListsScalar($lists);
- glReadPixel
-
($r,$g,$b,$a) = glReadPixel($x,$y);
Reads one pixel and unpacks the returned data into RGBA. If you specified a pixel type different than GL_BGRA or GL_RGBA, only partial information is returned, e.g. GL_BLUE sets $b, and leaves $r,$g and $a as 0.
- SDL::OpenGL::SaveBMP
-
SDL::OpenGL::SaveBMP ($file, $width, $height, $bits_per_pixel, $data);
Save the data in $data to a BMP file. $data must contain 3-byte per pixel, BGR packed data and $bits_per_pixel must (currently) be 24.
See glReadPixels() for an example how to get the data.
AUTHOR
David J. Goehrig, additional doc plus SaveBMP by TelsSEE ALSO
perl, SDL::App and SDL::OpenGL::Constants.Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre