fixed url-generator
[sdlgit/SDL-Site.git] / pages / SDL-App.html-inc
CommitLineData
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>
11<li><a href="#title">title</a></li>
12<li><a href="#delay">delay</a></li>
13<li><a href="#ticks">ticks</a></li>
14<li><a href="#error">error</a></li>
15<li><a href="#resize">resize</a></li>
16<li><a href="#fullscreen">fullscreen</a></li>
17<li><a href="#iconify">iconify</a></li>
18<li><a href="#grab_input">grab_input</a></li>
19<li><a href="#loop">loop</a></li>
20<li><a href="#sync">sync</a></li>
21<li><a href="#attribute_attr_value">attribute ( attr, [value] )</a></li>
22</ul>
23</li>
24<li><a href="#AUTHOR">AUTHOR</a></li>
25<li><a href="#SEE_ALSO">SEE ALSO</a>
26</li>
27</ul><hr />
28<!-- INDEX END -->
29
30<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
31<div id="NAME_CONTENT">
32<p>SDL::App - a SDL perl extension</p>
33
34</div>
bfdd9c2e 35<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
36<div id="CATEGORY_CONTENT">
37<p>Extension</p>
38
39</div>
162a0989 40<h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
41<div id="SYNOPSIS_CONTENT">
42<pre> use SDL;
43 use SDL::Event;
44 use SDL::App;
45
46 my $app = new SDL::App (
47 -title =&gt; 'Application Title',
48 -width =&gt; 640,
49 -height =&gt; 480,
50 -depth =&gt; 32 );
51
52</pre>
53<p>This is the manual way of doing things </p>
54<pre> my $event = new SDL::Event; # create a new event
55
56 $event-&gt;pump();
57 $event-&gt;poll();
58
59 while ($event-&gt;wait()) {
60 my $type = $event-&gt;type(); # get event type
61 print $type;
62 exit if $type == SDL_QUIT;
63 }
64An alternative to the manual Event processing is the L&lt;SDL::App::loop&gt; .
65
66</pre>
67
68</div>
69<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
70<div id="DESCRIPTION_CONTENT">
55bbf7a2 71<p><a href="SDL-App.html">SDL::App</a> controls the root window of the of your SDL based application.
72It extends the <a href="SDL-Surface.html">SDL::Surface</a> class, and provides an interface to the window
162a0989 73manager oriented functions.</p>
74
75</div>
76<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
77<div id="METHODS_CONTENT">
78
79</div>
80<h2 id="new">new</h2>
81<div id="new_CONTENT">
82<p><code>SDL::App::new</code> initializes the SDL, creates a new screen,
83and initializes some of the window manager properties.
84<code>SDL::App::new</code> takes a series of named parameters:</p>
85<ul>
86 <li>-title </li>
87 <li>-icon_title </li>
88 <li>-icon </li>
89 <li>-width </li>
90 <li>-height </li>
91 <li>-depth </li>
92 <li>-flags </li>
93 <li>-resizeable</li>
94</ul>
95
96
97</div>
98<h2 id="title">title</h2>
99<div id="title_CONTENT">
100<p><code>SDL::App::title</code> takes 0, 1, or 2 arguments. It returns the current
101application window title. If one parameter is passed, both the window
102title and icon title will be set to its value. If two parameters are
103passed the window title will be set to the first, and the icon title
104to the second.</p>
105
106</div>
107<h2 id="delay">delay</h2>
108<div id="delay_CONTENT">
109<p><code>SDL::App::delay</code> takes 1 argument, and will sleep the application for
110that many ms.</p>
111
112</div>
113<h2 id="ticks">ticks</h2>
114<div id="ticks_CONTENT">
115<p><code>SDL::App::ticks</code> returns the number of ms since the application began.</p>
116
117</div>
118<h2 id="error">error</h2>
119<div id="error_CONTENT">
120<p><code>SDL::App::error</code> returns the last error message set by the SDL.</p>
121
122</div>
123<h2 id="resize">resize</h2>
124<div id="resize_CONTENT">
125<p><code>SDL::App::resize</code> takes a new height and width of the application
126if the application was originally created with the -resizable option.</p>
127
128</div>
129<h2 id="fullscreen">fullscreen</h2>
130<div id="fullscreen_CONTENT">
131<p><code>SDL::App::fullscreen</code> toggles the application in and out of fullscreen mode.</p>
132
133</div>
134<h2 id="iconify">iconify</h2>
135<div id="iconify_CONTENT">
136<p><code>SDL::App::iconify</code> iconifies the applicaiton window.</p>
137
138</div>
139<h2 id="grab_input">grab_input</h2>
140<div id="grab_input_CONTENT">
141<p><code>SDL::App::grab_input</code> can be used to change the input focus behavior of
142the application. It takes one argument, which should be one of the following:</p>
143<dl>
144 <dt>*
145SDL_GRAB_QUERY</dt>
146 <dt>*
147SDL_GRAB_ON</dt>
148 <dt>*
149SDL_GRAB_OFF</dt>
150</dl>
151
152</div>
153<h2 id="loop">loop</h2>
154<div id="loop_CONTENT">
155<p><code>SDL::App::loop</code> is a simple event loop method which takes a reference to a hash
156of event handler subroutines. The keys of the hash must be SDL event types such
157as SDL_QUIT(), SDL_KEYDOWN(), and the like. The event method recieves as its parameter
158the event object used in the loop.</p>
159<pre> Example:
160
161 my $app = new SDL::App -title =&gt; &quot;test.app&quot;,
162 -width =&gt; 800,
163 -height =&gt; 600,
164 -depth =&gt; 32;
165
166 my %actions = (
167 SDL_QUIT() =&gt; sub { exit(0); },
168 SDL_KEYDOWN() =&gt; sub { print &quot;Key Pressed&quot; },
169 );
170
171 $app-&gt;loop(\%actions);
172
173</pre>
174
175</div>
176<h2 id="sync">sync</h2>
177<div id="sync_CONTENT">
178<p><code>SDL::App::sync</code> encapsulates the various methods of syncronizing the screen with the
179current video buffer. <code>SDL::App::sync</code> will do a fullscreen update, using the double buffer
180or OpenGL buffer if applicable. This is prefered to calling flip on the application window.</p>
181
182</div>
183<h2 id="attribute_attr_value">attribute ( attr, [value] )</h2>
184<div id="attribute_attr_value_CONTENT">
185<p><code>SDL::App::attribute</code> allows one to set and get GL attributes. By passing a value
186in addition to the attribute selector, the value will be set. <code>SDL:::App::attribute</code>
187always returns the current value of the given attribute, or croaks on failure.</p>
188
189</div>
190<h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
191<div id="AUTHOR_CONTENT">
192<p>David J. Goehrig
193Kartik Thakore</p>
194
195</div>
196<h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
197<div id="SEE_ALSO_CONTENT">
55bbf7a2 198<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 199
200</div>
201</div>