cf8ef334f414196a9e8d521e0e782561a7d7aa4b
[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 bootstrap SDL::OpenGL;
48 for ( keys %SDL::OpenGL:: ) {
49         if (/^gl/) {
50                 push @EXPORT,$_;
51         }
52 }
53
54 use SDL::OpenGL::Constants;
55
56 sub import {
57           my $self = shift;
58            
59             $self->export_to_level(1, @_);
60       SDL::OpenGL::Constants->export_to_level(1);
61       }
62
63
64
65 1;
66
67 __END__;
68
69 =pod
70
71
72
73 =head1 NAME
74
75 SDL::OpenGL - a perl extension
76
77 =head1 DESCRIPTION
78
79 L<SDL::OpenGL> is a perl module which when used by your application
80 exports the gl* and glu* functions into your application's primary namespace.
81 Most of the functions described in the OpenGL 1.3 specification are currently
82 supported in this fashion.  As the implementation of the OpenGL bindings that
83 comes with SDL_perl is largely type agnositic, there is no need to decline
84 the function names in the fashion that is done in the C API. For example,
85 glVertex3d is simply glVertex, and perl just does the right thing with regards
86 to types.
87
88 =head1 CAVEATS
89
90 The following methods work different in Perl than in C:
91
92 =over 2
93
94 =item glCallLists
95
96         glCallLists(@array_of_numbers);
97
98 Unlike the C function, which get's passed a count, a type and a list of
99 numbers, the Perl equivalent only takes a list of numbers.
100
101 Note that this is slow, since it needs to allocate memory and construct a
102 list of numbers from the given scalars. For a faster version see
103 L<glCallListsString>.
104
105 =back
106
107 The following methods exist in addition to the normal OpenGL specification:
108
109 =over 2
110
111 =item glCallListsString
112
113         glCallListsString($string);
114
115 Works like L<glCallLists()>, except that it needs only one parameter, a scalar
116 holding a string. The string is interpreted as a set of bytes, and each of
117 these will be passed to glCallLists as GL_BYTE. This is faster than
118 glCallLists, so you might want to pack your data like this:
119
120         my $lists = pack("C", @array_of_numbers);
121
122 And later use it like this:
123
124         glCallListsString($lists);
125
126 =back
127
128 =head1 AUTHOR
129
130 David J. Goehrig
131
132 =head1 SEE ALSO
133
134 L<perl> L<SDL::App>
135
136 =cut