Fixed the pod path in archive
[sdlgit/SDL_perl.git] / lib / pods / SDL / App.pod
CommitLineData
896b04ee 1=pod
2
3=head1 NAME
4
5SDL::App - a SDL perl extension
6
7=head1 SYNOPSIS
8
9 use SDL;
10 use SDL::Event;
11 use SDL::App;
12
13 my $app = new SDL::App (
14 -title => 'Application Title',
15 -width => 640,
16 -height => 480,
17 -depth => 32 );
18
19This is the manual way of doing things
20
21 my $event = new SDL::Event; # create a new event
22
23 $event->pump();
24 $event->poll();
25
26 while ($event->wait()) {
27 my $type = $event->type(); # get event type
28 print $type;
29 exit if $type == SDL_QUIT;
30 }
31An alternative to the manual Event processing is the L<SDL::App::loop> .
32
33=head1 DESCRIPTION
34
35L<SDL::App> controls the root window of the of your SDL based application.
36It extends the L<SDL::Surface> class, and provides an interface to the window
37manager oriented functions.
38
39=head1 METHODS
40
41=head2 new
42
43C<SDL::App::new> initializes the SDL, creates a new screen,
44and initializes some of the window manager properties.
45C<SDL::App::new> takes a series of named parameters:
46
47=over 4
48
49=item *
50
51-title
52
53=item *
54
55-icon_title
56
57=item *
58
59-icon
60
61=item *
62
63-width
64
65=item *
66
67-height
68
69=item *
70
71-depth
72
73=item *
74
75-flags
76
77=item *
78
79-resizeable
80
81=back
82
83=head2 title
84
85C<SDL::App::title> takes 0, 1, or 2 arguments. It returns the current
86application window title. If one parameter is passed, both the window
87title and icon title will be set to its value. If two parameters are
88passed the window title will be set to the first, and the icon title
89to the second.
90
91=head2 delay
92
93C<SDL::App::delay> takes 1 argument, and will sleep the application for
94that many ms.
95
96=head2 ticks
97
98C<SDL::App::ticks> returns the number of ms since the application began.
99
100=head2 error
101
102C<SDL::App::error> returns the last error message set by the SDL.
103
104=head2 resize
105
106C<SDL::App::resize> takes a new height and width of the application
107if the application was originally created with the -resizable option.
108
109=head2 fullscreen
110
111C<SDL::App::fullscreen> toggles the application in and out of fullscreen mode.
112
113=head2 iconify
114
115C<SDL::App::iconify> iconifies the applicaiton window.
116
117=head2 grab_input
118
119C<SDL::App::grab_input> can be used to change the input focus behavior of
120the application. It takes one argument, which should be one of the following:
121
122=over 4
123
124=item *
125SDL_GRAB_QUERY
126
127=item *
128SDL_GRAB_ON
129
130=item *
131SDL_GRAB_OFF
132
133=back
134
135=head2 loop
136
137C<SDL::App::loop> is a simple event loop method which takes a reference to a hash
138of event handler subroutines. The keys of the hash must be SDL event types such
139as SDL_QUIT(), SDL_KEYDOWN(), and the like. The event method recieves as its parameter
140the event object used in the loop.
141
142 Example:
143
144 my $app = new SDL::App -title => "test.app",
145 -width => 800,
146 -height => 600,
147 -depth => 32;
148
149 my %actions = (
150 SDL_QUIT() => sub { exit(0); },
151 SDL_KEYDOWN() => sub { print "Key Pressed" },
152 );
153
154 $app->loop(\%actions);
155
156=head2 sync
157
158C<SDL::App::sync> encapsulates the various methods of syncronizing the screen with the
159current video buffer. C<SDL::App::sync> will do a fullscreen update, using the double buffer
160or OpenGL buffer if applicable. This is prefered to calling flip on the application window.
161
162=head2 attribute ( attr, [value] )
163
164C<SDL::App::attribute> allows one to set and get GL attributes. By passing a value
165in addition to the attribute selector, the value will be set. C<SDL:::App::attribute>
166always returns the current value of the given attribute, or croaks on failure.
167
168=head1 AUTHOR
169
170David J. Goehrig
171Kartik Thakore
172
173=head1 SEE ALSO
174
175L<perl> L<SDL::Surface> L<SDL::Event> L<SDL::OpenGL>
176
177=cut