3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#CATEGORY">CATEGORY</a></li>
7 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
8 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
9 <li><a href="#METHODS">METHODS</a>
10 <ul><li><a href="#new">new</a></li>
13 <li><a href="#METHODS-2">METHODS</a>
14 <ul><li><a href="#title">title()</a></li>
15 <li><a href="#title_new_title">title( $new_title )</a></li>
16 <li><a href="#title_window_title_icon_title">title( $window_title, $icon_title )</a></li>
17 <li><a href="#delay_ms">delay( $ms )</a></li>
18 <li><a href="#ticks">ticks</a></li>
19 <li><a href="#error">error</a></li>
20 <li><a href="#resize_width_height">resize( $width, $height )</a></li>
21 <li><a href="#fullscreen">fullscreen</a></li>
22 <li><a href="#iconify">iconify</a></li>
23 <li><a href="#grab_input_CONSTANT">grab_input( $CONSTANT )</a></li>
24 <li><a href="#sync">sync</a></li>
25 <li><a href="#attribute_attr">attribute( $attr )</a></li>
26 <li><a href="#attribute_attr_value">attribute( $attr, $value )</a></li>
29 <li><a href="#CALLBACKS">CALLBACKS</a></li>
30 <li><a href="#AUTHORS">AUTHORS</a></li>
31 <li><a href="#SEE_ALSO">SEE ALSO</a>
36 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
37 <div id="NAME_CONTENT">
38 <p>SDLx::App - a SDL perl extension</p>
41 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
42 <div id="CATEGORY_CONTENT">
46 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
47 <div id="SYNOPSIS_CONTENT">
53 my $app = SDLx::App->new(
54 title => 'Application Title',
61 <p>This is the manual way of doing things</p>
62 <pre> my $event = SDL::Event->new; # create a new event
64 SDL::Events::pump_events();
66 while ( SDL::Events::poll_event($event) ) {
67 my $type = $event->type(); # get event type
69 exit if $type == SDL_QUIT;
73 <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.</p>
76 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
77 <div id="DESCRIPTION_CONTENT">
78 <p><a href="http://search.cpan.org/perldoc?SDLx::App">SDLx::App</a> controls the root window of the of your SDL based application.
79 It extends the <a href="SDL-Surface.html">SDL::Surface</a> class, and provides an interface to the window
80 manager oriented functions.</p>
83 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
84 <div id="METHODS_CONTENT">
88 <div id="new_CONTENT">
89 <p><code>SDLx::App::new</code> initializes the SDL, creates a new screen,
90 and initializes some of the window manager properties.
91 <code>SDLx::App::new</code> takes a series of named parameters:</p>
94 the window title. Defaults to the file name. Shorter alias: 't'</dt>
96 the icon title. Defaults to file name. Shortcut: 'it'</dt>
98 the icon itself. Defaults to none. Shortcut: 'i'</dt>
100 Window width, in pixels. Defaults to 800. Shortcut: 'w'</dt>
102 Window height, in pixels. Defaults to 600. Shortcut: 'h'</dt>
104 Screen depth. Defaults to 16. Shortcut: 'd'.</dt>
106 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>
108 Set this to a true value to make the window resizeable by the user. Default is off.</dt>
112 <h1 id="METHODS-2">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
113 <div id="METHODS_CONTENT-2">
116 <h2 id="title">title()</h2>
117 <div id="title_CONTENT">
120 <h2 id="title_new_title">title( $new_title )</h2>
121 <div id="title_new_title_CONTENT">
124 <h2 id="title_window_title_icon_title">title( $window_title, $icon_title )</h2>
125 <div id="title_window_title_icon_title_CONTEN">
126 <p><code>SDLx::App::title</code> takes 0, 1, or 2 arguments. If no parameter is given,
127 it returns the current application window title. If one parameter is
128 passed, both the window title and icon title will be set to its value.
129 If two parameters are passed the window title will be set to the first,
130 and the icon title to the second.</p>
133 <h2 id="delay_ms">delay( $ms )</h2>
134 <div id="delay_ms_CONTENT">
135 <p><code>SDLx::App::delay</code> takes 1 argument, and will sleep the application for
139 <h2 id="ticks">ticks</h2>
140 <div id="ticks_CONTENT">
141 <p><code>SDLx::App::ticks</code> returns the number of ms since the application began.</p>
144 <h2 id="error">error</h2>
145 <div id="error_CONTENT">
146 <p><code>SDLx::App::error</code> returns the last error message set by the SDL.</p>
149 <h2 id="resize_width_height">resize( $width, $height )</h2>
150 <div id="resize_width_height_CONTENT">
151 <p><code>SDLx::App::resize</code> takes a new width and height of the application. Only
152 works if the application was originally created with the resizable option.</p>
155 <h2 id="fullscreen">fullscreen</h2>
156 <div id="fullscreen_CONTENT">
157 <p><code>SDLx::App::fullscreen</code> toggles the application in and out of fullscreen mode.</p>
160 <h2 id="iconify">iconify</h2>
161 <div id="iconify_CONTENT">
162 <p><code>SDLx::App::iconify</code> iconifies the application window.</p>
165 <h2 id="grab_input_CONSTANT">grab_input( $CONSTANT )</h2>
166 <div id="grab_input_CONSTANT_CONTENT">
167 <p><code>SDLx::App::grab_input</code> can be used to change the input focus behavior of
168 the application. It takes one argument, which should be one of the following:</p>
170 <dt>* SDL_GRAB_QUERY</dt>
171 <dt>* SDL_GRAB_ON</dt>
172 <dt>* SDL_GRAB_OFF</dt>
176 <h2 id="sync">sync</h2>
177 <div id="sync_CONTENT">
178 <p><code>SDLx::App::sync</code> encapsulates the various methods of syncronizing the screen with the
179 current video buffer. <code>SDLx::App::sync</code> will do a fullscreen update, using the double buffer
180 or OpenGL buffer if applicable. This is prefered to calling flip on the application window.</p>
183 <h2 id="attribute_attr">attribute( $attr )</h2>
184 <div id="attribute_attr_CONTENT">
187 <h2 id="attribute_attr_value">attribute( $attr, $value )</h2>
188 <div id="attribute_attr_value_CONTENT">
189 <p><code>SDLx::App::attribute</code> allows one to get and set GL attributes. By passing a value
190 in addition to the attribute selector, the value will be set. <code>SDL:::App::attribute</code>
191 always returns the current value of the given attribute, or Carp::confesss on failure.</p>
194 <h1 id="CALLBACKS">CALLBACKS</h1><p><a href="#TOP" class="toplink">Top</a></p>
195 <div id="CALLBACKS_CONTENT">
196 <p><code>SDLx::App</code> is a <code>SDLx::Controller</code>. Use the event, show and handlers to run the app.</p>
200 use SDL::Event; #Where ever the event call back is processed
202 my $app = SDLx::App->new( width => 200, height => 200);
204 $app->add_event_handler( sub{ return 0 if $_[0]->type == SDL_QUIT; return 1});
206 $app->add_show_handler( sub{ $app->update() } );
208 $app->add_move_handler(
210 #calc your physics here
216 <p>see <a href="http://search.cpan.org/perldoc?SDLx::Controller">SDLx::Controller</a> for more details.</p>
219 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
220 <div id="AUTHORS_CONTENT">
221 <p>See <b>AUTHORS</b> in <cite>SDL</cite>.</p>
224 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
225 <div id="SEE_ALSO_CONTENT">
226 <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>