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