72ae752fba01a4edf48a22c36061b6a175bb50e6
[sdlgit/SDL-Site.git] / pages / SDLx-App.html-inc
1 <div class="pod">
2 <!-- INDEX START -->
3 <h3 id="TOP">Index</h3>
4
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>
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>
15 <li><a href="#ticks">ticks</a></li>
16 <li><a href="#error">error</a></li>
17 <li><a href="#resize_width_height">resize( $width, $height )</a></li>
18 <li><a href="#fullscreen">fullscreen</a></li>
19 <li><a href="#iconify">iconify</a></li>
20 <li><a href="#grab_input_CONSTANT">grab_input( $CONSTANT )</a></li>
21 <li><a href="#loop_actions">loop( \%actions )</a></li>
22 <li><a href="#sync">sync</a></li>
23 <li><a href="#attribute_attr">attribute( $attr )</a></li>
24 <li><a href="#attribute_attr_value">attribute( $attr, $value )</a></li>
25 </ul>
26 </li>
27 <li><a href="#AUTHOR">AUTHOR</a></li>
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">
35 <p>SDLx::App - a SDL perl extension</p>
36
37 </div>
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>
43 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
44 <div id="SYNOPSIS_CONTENT">
45 <pre>    use SDL;
46     use SDLx::App; 
47     use SDL::Event;
48     use SDL::Events; 
49
50     my $app = SDLx::App-&gt;new( 
51         title  =&gt; 'Application Title',
52         width  =&gt; 640,
53         height =&gt; 480,
54         depth  =&gt; 32
55     ); 
56
57 </pre>
58 <p>This is the manual way of doing things</p>
59 <pre>    my $event = SDL::Event-&gt;new; # create a new event 
60
61     SDL::Events::pump_events();
62
63     while ( SDL::Events::poll_event($event) ) { 
64         my $type = $event-&gt;type(); # get event type 
65         print $type; 
66         exit if $type == SDL_QUIT; 
67     }
68
69 </pre>
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>
71
72 </div>
73 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
74 <div id="DESCRIPTION_CONTENT">
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.
76 It extends the <a href="SDL-Surface.html">SDL::Surface</a> class, and provides an interface to the window
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">
86 <p><code>SDLx::App::new</code> initializes the SDL, creates a new screen,
87 and initializes some of the window manager properties.
88 <code>SDLx::App::new</code> takes a series of named parameters:</p>
89 <dl>
90         <dt>* title</dt>
91         <dt>* icon_title</dt>
92         <dt>* icon</dt>
93         <dt>* width</dt>
94         <dt>* height</dt>
95         <dt>* depth</dt>
96         <dt>* flags</dt>
97         <dt>* resizeable</dt>
98 </dl>
99
100
101
102
103
104 </div>
105 <h2 id="title">title()</h2>
106 <div id="title_CONTENT">
107
108 </div>
109 <h2 id="title_new_title">title( $new_title )</h2>
110 <div id="title_new_title_CONTENT">
111
112 </div>
113 <h2 id="title_window_title_icon_title">title( $window_title, $icon_title )</h2>
114 <div id="title_window_title_icon_title_CONTEN">
115 <p><code>SDLx::App::title</code> takes 0, 1, or 2 arguments. If no parameter is given,
116 it returns the current application window title. If one parameter is
117 passed, both the window title and icon title will be set to its value.
118 If two parameters are passed the window title will be set to the first,
119 and the icon title to the second.</p>
120
121 </div>
122 <h2 id="delay_ms">delay( $ms )</h2>
123 <div id="delay_ms_CONTENT">
124 <p><code>SDLx::App::delay</code> takes 1 argument, and will sleep the application for
125 that many ms.</p>
126
127 </div>
128 <h2 id="ticks">ticks</h2>
129 <div id="ticks_CONTENT">
130 <p><code>SDLx::App::ticks</code> returns the number of ms since the application began.</p>
131
132 </div>
133 <h2 id="error">error</h2>
134 <div id="error_CONTENT">
135 <p><code>SDLx::App::error</code> returns the last error message set by the SDL.</p>
136
137 </div>
138 <h2 id="resize_width_height">resize( $width, $height )</h2>
139 <div id="resize_width_height_CONTENT">
140 <p><code>SDLx::App::resize</code> takes a new width and height of the application. Only
141 works if the application was originally created with the resizable option.</p>
142
143 </div>
144 <h2 id="fullscreen">fullscreen</h2>
145 <div id="fullscreen_CONTENT">
146 <p><code>SDLx::App::fullscreen</code> toggles the application in and out of fullscreen mode.</p>
147
148 </div>
149 <h2 id="iconify">iconify</h2>
150 <div id="iconify_CONTENT">
151 <p><code>SDLx::App::iconify</code> iconifies the application window.</p>
152
153 </div>
154 <h2 id="grab_input_CONSTANT">grab_input( $CONSTANT )</h2>
155 <div id="grab_input_CONSTANT_CONTENT">
156 <p><code>SDLx::App::grab_input</code> can be used to change the input focus behavior of
157 the application. It takes one argument, which should be one of the following:</p>
158 <dl>
159         <dt>* SDL_GRAB_QUERY</dt>
160         <dt>* SDL_GRAB_ON</dt>
161         <dt>* SDL_GRAB_OFF</dt>
162 </dl>
163
164 </div>
165 <h2 id="loop_actions">loop( \%actions )</h2>
166 <div id="loop_actions_CONTENT">
167 <p><code>SDLx::App::loop</code> is a simple event loop method which takes a reference to a hash
168 of event handler subroutines. The keys of the hash must be SDL event types such
169 as SDL_QUIT(), SDL_KEYDOWN(), and the like. When called, the event method recieves
170 as its parameter the event object used in the loop.</p>
171 <p>Example:</p>
172 <pre>    my $app = SDLx::App-&gt;new(
173         title  =&gt; &quot;test.app&quot;, 
174         width  =&gt; 800, 
175         height =&gt; 600, 
176         depth  =&gt; 32
177     );
178
179     my %actions = (
180         SDL_QUIT()    =&gt; sub { exit(0); },
181         SDL_KEYDOWN() =&gt; sub { print &quot;Key Pressed&quot; },
182     );
183
184     $app-&gt;loop( \%actions );
185
186 </pre>
187
188 </div>
189 <h2 id="sync">sync</h2>
190 <div id="sync_CONTENT">
191 <p><code>SDLx::App::sync</code> encapsulates the various methods of syncronizing the screen with the
192 current video buffer. <code>SDLx::App::sync</code> will do a fullscreen update, using the double buffer
193 or OpenGL buffer if applicable. This is prefered to calling flip on the application window.</p>
194
195 </div>
196 <h2 id="attribute_attr">attribute( $attr )</h2>
197 <div id="attribute_attr_CONTENT">
198
199 </div>
200 <h2 id="attribute_attr_value">attribute( $attr, $value )</h2>
201 <div id="attribute_attr_value_CONTENT">
202 <p><code>SDLx::App::attribute</code> allows one to get and set GL attributes. By passing a value
203 in addition to the attribute selector, the value will be set. <code>SDL:::App::attribute</code>
204 always returns the current value of the given attribute, or croaks on failure.</p>
205
206 </div>
207 <h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
208 <div id="AUTHOR_CONTENT">
209 <p>David J. Goehrig
210 Kartik Thakore</p>
211
212 </div>
213 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
214 <div id="SEE_ALSO_CONTENT">
215 <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>
216
217 </div>
218 </div>