Commit | Line | Data |
162a0989 |
1 | <div class="pod"> |
2 | <!-- INDEX START --> |
3 | <h3 id="TOP">Index</h3> |
4 | |
5 | <ul><li><a href="#NAME">NAME</a></li> |
bfdd9c2e |
6 | <li><a href="#CATEGORY">CATEGORY</a></li> |
162a0989 |
7 | <li><a href="#SYNOPSIS">SYNOPSIS</a></li> |
162a0989 |
8 | <li><a href="#METHODS">METHODS</a> |
9 | <ul><li><a href="#new">new</a></li> |
e1ec9f6e |
10 | </ul> |
11 | </li> |
12 | <li><a href="#METHODS-2">METHODS</a> |
13 | <ul><li><a href="#title">title()</a></li> |
285d0cd2 |
14 | <li><a href="#title_new_title">title( $new_title )</a></li> |
15 | <li><a href="#title_window_title_icon_title">title( $window_title, $icon_title )</a></li> |
16 | <li><a href="#delay_ms">delay( $ms )</a></li> |
162a0989 |
17 | <li><a href="#ticks">ticks</a></li> |
18 | <li><a href="#error">error</a></li> |
285d0cd2 |
19 | <li><a href="#resize_width_height">resize( $width, $height )</a></li> |
162a0989 |
20 | <li><a href="#fullscreen">fullscreen</a></li> |
21 | <li><a href="#iconify">iconify</a></li> |
285d0cd2 |
22 | <li><a href="#grab_input_CONSTANT">grab_input( $CONSTANT )</a></li> |
162a0989 |
23 | <li><a href="#sync">sync</a></li> |
285d0cd2 |
24 | <li><a href="#attribute_attr">attribute( $attr )</a></li> |
25 | <li><a href="#attribute_attr_value">attribute( $attr, $value )</a></li> |
162a0989 |
26 | </ul> |
27 | </li> |
e1ec9f6e |
28 | <li><a href="#CALLBACKS">CALLBACKS</a></li> |
c7e8d3c6 |
29 | <li><a href="#AUTHORS">AUTHORS</a></li> |
162a0989 |
30 | <li><a href="#SEE_ALSO">SEE ALSO</a> |
31 | </li> |
32 | </ul><hr /> |
33 | <!-- INDEX END --> |
34 | |
35 | <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p> |
36 | <div id="NAME_CONTENT"> |
ca0a3441 |
37 | <p>SDLx::App - a SDL perl extension</p> |
162a0989 |
38 | |
39 | </div> |
bfdd9c2e |
40 | <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p> |
41 | <div id="CATEGORY_CONTENT"> |
42 | <p>Extension</p> |
43 | |
44 | </div> |
162a0989 |
45 | <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
46 | <div id="SYNOPSIS_CONTENT"> |
f373167e |
47 | <pre> use SDL; |
ca0a3441 |
48 | use SDLx::App; |
f373167e |
49 | use SDL::Event; |
50 | use SDL::Events; |
51 | |
ca0a3441 |
52 | my $app = SDLx::App->new( |
505f308d |
53 | title => 'Application Title', |
54 | width => 640, |
55 | height => 480, |
56 | depth => 32 |
f373167e |
57 | ); |
162a0989 |
58 | |
59 | </pre> |
285d0cd2 |
60 | <p>This is the manual way of doing things</p> |
f373167e |
61 | <pre> my $event = SDL::Event->new; # create a new event |
162a0989 |
62 | |
f373167e |
63 | SDL::Events::pump_events(); |
162a0989 |
64 | |
f373167e |
65 | while ( SDL::Events::poll_event($event) ) { |
66 | my $type = $event->type(); # get event type |
67 | print $type; |
68 | exit if $type == SDL_QUIT; |
69 | } |
162a0989 |
70 | |
71 | </pre> |
3afd3fb0 |
72 | <p>An alternative to the manual Event processing is through the <a href="http://search.cpan.org/perldoc?SDLx::Controller">SDLx::Controller</a> module. <a href="http://search.cpan.org/perldoc?SDLx::App">SDLx::App</a> is a Controller so see the CALLBACKS section below. |
73 | =head1 DESCRIPTION</p> |
ca0a3441 |
74 | <p><a href="http://search.cpan.org/perldoc?SDLx::App">SDLx::App</a> controls the root window of the of your SDL based application. |
55bbf7a2 |
75 | It extends the <a href="SDL-Surface.html">SDL::Surface</a> class, and provides an interface to the window |
162a0989 |
76 | manager oriented functions.</p> |
77 | |
78 | </div> |
79 | <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
80 | <div id="METHODS_CONTENT"> |
81 | |
82 | </div> |
83 | <h2 id="new">new</h2> |
84 | <div id="new_CONTENT"> |
ca0a3441 |
85 | <p><code>SDLx::App::new</code> initializes the SDL, creates a new screen, |
162a0989 |
86 | and initializes some of the window manager properties. |
ca0a3441 |
87 | <code>SDLx::App::new</code> takes a series of named parameters:</p> |
285d0cd2 |
88 | <dl> |
c7e8d3c6 |
89 | <dt>* title |
90 | the window title. Defaults to the file name. Shorter alias: 't'</dt> |
91 | <dt>* icon_title |
92 | the icon title. Defaults to file name. Shortcut: 'it'</dt> |
93 | <dt>* icon |
94 | the icon itself. Defaults to none. Shortcut: 'i'</dt> |
95 | <dt>* width |
96 | Window width, in pixels. Defaults to 800. Shortcut: 'w'</dt> |
97 | <dt>* height |
98 | Window height, in pixels. Defaults to 600. Shortcut: 'h'</dt> |
99 | <dt>* depth |
100 | Screen depth. Defaults to 16. Shortcut: 'd'.</dt> |
101 | <dt>* flags |
102 | Any flags you want to pass to <a href="SDL-Video.html">SDL::Video</a> upon initialization. Defaults to SDL_ANYFORMAT. Flags should be <i>or'ed</i> together if you're passing more than one (flags => FOO|BAR). Shortcut: 'f'.</dt> |
103 | <dt>* resizeable |
104 | Set this to a true value to make the window resizeable by the user. Default is off.</dt> |
285d0cd2 |
105 | </dl> |
106 | |
e1ec9f6e |
107 | </div> |
108 | <h1 id="METHODS-2">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
109 | <div id="METHODS_CONTENT-2"> |
162a0989 |
110 | |
111 | </div> |
285d0cd2 |
112 | <h2 id="title">title()</h2> |
162a0989 |
113 | <div id="title_CONTENT"> |
162a0989 |
114 | |
115 | </div> |
285d0cd2 |
116 | <h2 id="title_new_title">title( $new_title )</h2> |
117 | <div id="title_new_title_CONTENT"> |
118 | |
119 | </div> |
120 | <h2 id="title_window_title_icon_title">title( $window_title, $icon_title )</h2> |
121 | <div id="title_window_title_icon_title_CONTEN"> |
122 | <p><code>SDLx::App::title</code> takes 0, 1, or 2 arguments. If no parameter is given, |
123 | it returns the current application window title. If one parameter is |
124 | passed, both the window title and icon title will be set to its value. |
125 | If two parameters are passed the window title will be set to the first, |
126 | and the icon title to the second.</p> |
127 | |
128 | </div> |
129 | <h2 id="delay_ms">delay( $ms )</h2> |
130 | <div id="delay_ms_CONTENT"> |
ca0a3441 |
131 | <p><code>SDLx::App::delay</code> takes 1 argument, and will sleep the application for |
162a0989 |
132 | that many ms.</p> |
133 | |
134 | </div> |
135 | <h2 id="ticks">ticks</h2> |
136 | <div id="ticks_CONTENT"> |
ca0a3441 |
137 | <p><code>SDLx::App::ticks</code> returns the number of ms since the application began.</p> |
162a0989 |
138 | |
139 | </div> |
140 | <h2 id="error">error</h2> |
141 | <div id="error_CONTENT"> |
ca0a3441 |
142 | <p><code>SDLx::App::error</code> returns the last error message set by the SDL.</p> |
162a0989 |
143 | |
144 | </div> |
285d0cd2 |
145 | <h2 id="resize_width_height">resize( $width, $height )</h2> |
146 | <div id="resize_width_height_CONTENT"> |
147 | <p><code>SDLx::App::resize</code> takes a new width and height of the application. Only |
148 | works if the application was originally created with the resizable option.</p> |
162a0989 |
149 | |
150 | </div> |
151 | <h2 id="fullscreen">fullscreen</h2> |
152 | <div id="fullscreen_CONTENT"> |
ca0a3441 |
153 | <p><code>SDLx::App::fullscreen</code> toggles the application in and out of fullscreen mode.</p> |
162a0989 |
154 | |
155 | </div> |
156 | <h2 id="iconify">iconify</h2> |
157 | <div id="iconify_CONTENT"> |
285d0cd2 |
158 | <p><code>SDLx::App::iconify</code> iconifies the application window.</p> |
162a0989 |
159 | |
160 | </div> |
285d0cd2 |
161 | <h2 id="grab_input_CONSTANT">grab_input( $CONSTANT )</h2> |
162 | <div id="grab_input_CONSTANT_CONTENT"> |
ca0a3441 |
163 | <p><code>SDLx::App::grab_input</code> can be used to change the input focus behavior of |
285d0cd2 |
164 | the application. It takes one argument, which should be one of the following:</p> |
162a0989 |
165 | <dl> |
285d0cd2 |
166 | <dt>* SDL_GRAB_QUERY</dt> |
167 | <dt>* SDL_GRAB_ON</dt> |
168 | <dt>* SDL_GRAB_OFF</dt> |
162a0989 |
169 | </dl> |
170 | |
171 | </div> |
162a0989 |
172 | <h2 id="sync">sync</h2> |
173 | <div id="sync_CONTENT"> |
ca0a3441 |
174 | <p><code>SDLx::App::sync</code> encapsulates the various methods of syncronizing the screen with the |
285d0cd2 |
175 | current video buffer. <code>SDLx::App::sync</code> will do a fullscreen update, using the double buffer |
176 | or OpenGL buffer if applicable. This is prefered to calling flip on the application window.</p> |
177 | |
178 | </div> |
179 | <h2 id="attribute_attr">attribute( $attr )</h2> |
180 | <div id="attribute_attr_CONTENT"> |
162a0989 |
181 | |
182 | </div> |
285d0cd2 |
183 | <h2 id="attribute_attr_value">attribute( $attr, $value )</h2> |
162a0989 |
184 | <div id="attribute_attr_value_CONTENT"> |
285d0cd2 |
185 | <p><code>SDLx::App::attribute</code> allows one to get and set GL attributes. By passing a value |
186 | in addition to the attribute selector, the value will be set. <code>SDL:::App::attribute</code> |
3afd3fb0 |
187 | always returns the current value of the given attribute, or Carp::confesss on failure.</p> |
162a0989 |
188 | |
189 | </div> |
e1ec9f6e |
190 | <h1 id="CALLBACKS">CALLBACKS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
191 | <div id="CALLBACKS_CONTENT"> |
192 | <p><code>SDLx::App</code> is a <code>SDLx::Controller</code>. Use the event, show and handlers to run the app.</p> |
193 | <pre> use SDL; |
194 | use SDLx::App; |
195 | |
196 | use SDL::Event; #Where ever the event call back is processed |
197 | |
198 | my $app = SDLx::App->new( width => 200, height => 200); |
199 | |
200 | $app->add_event_handler( sub{ return 0 if $_[0]->type == SDL_QUIT; return 1}); |
201 | |
202 | $app->add_show_handler( sub{ $app->update() } ); |
203 | |
204 | $app->add_move_handler( |
205 | sub{ |
206 | #calc your physics here |
207 | } ); |
208 | |
209 | $app->run(); |
210 | |
211 | </pre> |
212 | <p>see <a href="http://search.cpan.org/perldoc?SDLx::Controller">SDLx::Controller</a> for more details.</p> |
213 | |
214 | </div> |
c7e8d3c6 |
215 | <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
216 | <div id="AUTHORS_CONTENT"> |
217 | <p>See <b>AUTHORS</b> in <cite>SDL</cite>.</p> |
162a0989 |
218 | |
219 | </div> |
220 | <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p> |
221 | <div id="SEE_ALSO_CONTENT"> |
55bbf7a2 |
222 | <p><a href="http://search.cpan.org/perldoc?perl">perl</a> <a href="SDL-Surface.html">SDL::Surface</a> <a href="SDL-Event.html">SDL::Event</a> <a href="SDL-OpenGL.html">SDL::OpenGL</a></p> |
162a0989 |
223 | |
224 | </div> |
225 | </div> |