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