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