9a849f265228e075348f6703281379912255b748
[sdlgit/SDL_perl.git] / lib / SDL / OpenGL.pm
1 #!/usr/bin/env perl
2 #
3 # OpenGL.pm
4 #
5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
6 #
7 # ------------------------------------------------------------------------------
8 #
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.
13
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.
18
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
22 #
23 # ------------------------------------------------------------------------------
24 #
25 # Please feel free to send questions, suggestions or improvements to:
26 #
27 #       David J. Goehrig
28 #       dgoehrig@cpan.org
29 #
30
31 package SDL::OpenGL;
32
33 use strict;
34 use warnings;
35 use Carp;
36
37 require Exporter;
38 require DynaLoader;
39 use vars qw(
40         @EXPORT
41         @ISA
42 );
43 @ISA=qw(Exporter DynaLoader);
44
45 use SDL;
46
47
48 bootstrap SDL::OpenGL;
49 for ( keys %SDL::OpenGL:: ) {
50         if (/^gl/) {
51                 push @EXPORT,$_;
52         }
53 }
54
55 use SDL::OpenGL::Constants;
56
57 1;
58
59 __END__;
60
61 =pod
62
63
64
65 =head1 NAME
66
67 SDL::OpenGL - a perl extension
68
69 =head1 DESCRIPTION
70
71 L<SDL::OpenGL> is a perl module which when used by your application
72 exports the gl* and glu* functions into your application's primary namespace.
73 Most of the functions described in the OpenGL 1.3 specification are currently
74 supported in this fashion.  As the implementation of the OpenGL bindings that
75 comes with SDL_perl is largely type agnositic, there is no need to decline
76 the function names in the fashion that is done in the C API. For example,
77 glVertex3d is simply glVertex, and perl just does the right thing with regards
78 to types.
79
80 =head1 CAVEATS
81
82 The following methods work different in Perl than in C:
83
84 =over 2
85
86 =item glCallLists
87
88         glCallLists(@array_of_numbers);
89
90 Unlike the C function, which get's passed a count, a type and a list of
91 numbers, the Perl equivalent only takes a list of numbers.
92
93 Note that this is slow, since it needs to allocate memory and construct a
94 list of numbers from the given scalars. For a faster version see
95 L<glCallListsString>.
96
97 =back
98
99 The following methods exist in addition to the normal OpenGL specification:
100
101 =over 2
102
103 =item glCallListsString
104
105         glCallListsString($string);
106
107 Works like L<glCallLists()>, except that it needs only one parameter, a scalar
108 holding a string. The string is interpreted as a set of bytes, and each of
109 these will be passed to glCallLists as GL_BYTE. This is faster than
110 glCallLists, so you might want to pack your data like this:
111
112         my $lists = pack("C", @array_of_numbers);
113
114 And later use it like this:
115
116         glCallListsString($lists);
117
118 =back
119
120 =head1 AUTHOR
121
122 David J. Goehrig
123
124 =head1 SEE ALSO
125
126 L<perl> L<SDL::App>
127
128 =cut