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