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