blib/lib/SDL2/video.pm untested

filter: Statementstmt 0.0% 0 / 251 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 270 CC 1 SCAR 6.9
CC
1
Cov
0%
data
2.0
prev
2.0
next
2.0
CRAP 2.0
1 package SDL2::video {
2 use lib '../../lib';
3 use strictures 2;
4 use experimental 'signatures';
5 use SDL2::Utils;
6 #
7 use SDL2::stdinc;
8 use SDL2::pixels;
9 use SDL2::rect;
10 use SDL2::surface;
11 #
12 package SDL2::DisplayMode {
13 use SDL2::Utils;
14 our $TYPE = has
15 'format' => 'uint32',
16 w => 'int',
17 h => 'int',
18 refresh_rate => 'int',
19 driverdata => 'opaque';
20 };
21  
22 package SDL2::Window {
23 use SDL2::Utils;
24 has
25 magic => 'uint8',
26 id => 'uint32',
27 title => 'opaque', # char *
28 icon => 'SDL_Surface',
29 x => 'int',
30 y => 'int',
31 w => 'int',
32 h => 'int',
33 min_w => 'int',
34 min_h => 'int',
35 max_w => 'int',
36 max_h => 'int',
37 flags => 'uint32',
38 last_fullscreen_flags => 'uint32',
39 windowed => 'SDL_Rect',
40 fullscreen_mode => 'SDL_DisplayMode',
41 opacity => 'float',
42 brightness => 'float',
43 gamma => 'opaque', # uint16*
44 saved_gamma => 'opaque', # uint16*
45 surface => 'SDL_Surface',
46 surface_valid => 'SDL_bool',
47 is_hiding => 'SDL_bool',
48 is_destroying => 'SDL_bool',
49 is_dropping => 'SDL_bool',
50 shaper => 'opaque', # SDL_WindowShaper
51 hit_test => 'opaque', # SDL_HitTest
52 hit_test_data => 'opaque', # void*
53 _data => 'opaque', # SDL_WindowUserData*
54 driverdata => 'opaque', # void*
55 _prev => 'opaque', # SDL_Window*
56 _next => 'opaque' # SDL_Window*
57 ;
58  
59 sub data {
60 ffi->cast( 'opaque', 'SDL_WindowUserData', $_[0]->_data );
61 }
62  
63 sub prev {
64 ffi->cast( 'opaque', 'SDL_Window', $_[0]->_prev );
65 }
66  
67 sub next {
68 ffi->cast( 'opaque', 'SDL_Window', $_[0]->_next );
69 }
70 };
71 #
72 enum SDL_WindowFlags => [
73 [ SDL_WINDOW_FULLSCREEN => 0x00000001 ],
74 [ SDL_WINDOW_OPENGL => 0x00000002 ],
75 [ SDL_WINDOW_SHOWN => 0x00000004 ],
76 [ SDL_WINDOW_HIDDEN => 0x00000008 ],
77 [ SDL_WINDOW_BORDERLESS => 0x00000010 ],
78 [ SDL_WINDOW_RESIZABLE => 0x00000020 ],
79 [ SDL_WINDOW_MINIMIZED => 0x00000040 ],
80 [ SDL_WINDOW_MAXIMIZED => 0x00000080 ],
81 [ SDL_WINDOW_MOUSE_GRABBED => 0x00000100 ],
82 [ SDL_WINDOW_INPUT_FOCUS => 0x00000200 ],
83 [ SDL_WINDOW_MOUSE_FOCUS => 0x00000400 ],
84 [ SDL_WINDOW_FULLSCREEN_DESKTOP =>
85 sub { ( SDL2::FFI::SDL_WINDOW_FULLSCREEN() | 0x00001000 ) }
86 ],
87 [ SDL_WINDOW_FOREIGN => 0x00000800 ],
88 [ SDL_WINDOW_ALLOW_HIGHDPI => 0x00002000 ],
89 [ SDL_WINDOW_MOUSE_CAPTURE => 0x00004000 ],
90 [ SDL_WINDOW_ALWAYS_ON_TOP => 0x00008000 ],
91 [ SDL_WINDOW_SKIP_TASKBAR => 0x00010000 ],
92 [ SDL_WINDOW_UTILITY => 0x00020000 ],
93 [ SDL_WINDOW_TOOLTIP => 0x00040000 ],
94 [ SDL_WINDOW_POPUP_MENU => 0x00080000 ],
95 [ SDL_WINDOW_KEYBOARD_GRABBED => 0x00100000 ],
96 [ SDL_WINDOW_VULKAN => 0x10000000 ],
97 [ SDL_WINDOW_METAL => 0x20000000 ],
98 [ SDL_WINDOW_INPUT_GRABBED => sub { SDL2::FFI::SDL_WINDOW_MOUSE_GRABBED() } ]
99 ];
100 define video => [
101 [ SDL_WINDOWPOS_UNDEFINED_MASK => 0x1FFF0000 ],
102 [ SDL_WINDOWPOS_UNDEFINED_DISPLAY =>
103 sub ($X) { ( SDL2::FFI::SDL_WINDOWPOS_UNDEFINED_MASK() | ($X) ) }
104 ],
105 [ SDL_WINDOWPOS_UNDEFINED => sub () { SDL2::FFI::SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) } ],
106 [ SDL_WINDOWPOS_ISUNDEFINED => sub ($X) {
107 ( ( ($X) & 0xFFFF0000 ) == SDL2::FFI::SDL_WINDOWPOS_UNDEFINED_MASK() )
108 }
109 ],
110 [ SDL_WINDOWPOS_CENTERED_MASK => sub () {0x2FFF0000} ],
111 [ SDL_WINDOWPOS_CENTERED_DISPLAY =>
112 sub ($X) { ( SDL2::FFI::SDL_WINDOWPOS_CENTERED_MASK() | ($X) ) }
113 ],
114 [ SDL_WINDOWPOS_CENTERED => sub() { SDL2::FFI::SDL_WINDOWPOS_CENTERED_DISPLAY(0) } ],
115 [ SDL_WINDOWPOS_ISCENTERED => sub ($X) {
116 ( ( ($X) & 0xFFFF0000 ) == SDL2::FFI::SDL_WINDOWPOS_CENTERED_MASK() )
117 }
118 ],
119 ];
120 enum SDL_WindowEventID => [
121 qw[
122 SDL_WINDOWEVENT_NONE
123 SDL_WINDOWEVENT_SHOWN
124 SDL_WINDOWEVENT_HIDDEN
125 SDL_WINDOWEVENT_EXPOSED
126 SDL_WINDOWEVENT_MOVED
127 SDL_WINDOWEVENT_RESIZED
128 SDL_WINDOWEVENT_SIZE_CHANGED
129 SDL_WINDOWEVENT_MINIMIZED
130 SDL_WINDOWEVENT_MAXIMIZED
131 SDL_WINDOWEVENT_RESTORED
132 SDL_WINDOWEVENT_ENTER
133 SDL_WINDOWEVENT_LEAVE
134 SDL_WINDOWEVENT_FOCUS_GAINED
135 SDL_WINDOWEVENT_FOCUS_LOST
136 SDL_WINDOWEVENT_CLOSE
137 SDL_WINDOWEVENT_TAKE_FOCUS
138 SDL_WINDOWEVENT_HIT_TEST]
139 ],
140 SDL_DisplayEventID => [
141 qw[SDL_DISPLAYEVENT_NONE SDL_DISPLAYEVENT_ORIENTATION
142 SDL_DISPLAYEVENT_CONNECTED SDL_DISPLAYEVENT_DISCONNECTED
143 ]
144 ],
145 SDL_DisplayOrientation => [
146 qw[SDL_ORIENTATION_UNKNOWN
147 SDL_ORIENTATION_LANDSCAPE SDL_ORIENTATION_LANDSCAPE_FLIPPED
148 SDL_ORIENTATION_PORTRAIT SDL_ORIENTATION_PORTRAIT_FLIPPED
149 ]
150 ],
151 SDL_FlashOperation => [qw[SDL_FLASH_CANCEL SDL_FLASH_BRIEFLY SDL_FLASH_UNTIL_FOCUSED]],
152 ;
153  
154 package SDL2::GLContext 0.01 {
155 use SDL2::Utils qw[has];
156 our $TYPE = has(); # opaque
157 };
158 enum SDL_GLattr => [
159 qw[
160 SDL_GL_RED_SIZE
161 SDL_GL_GREEN_SIZE
162 SDL_GL_BLUE_SIZE
163 SDL_GL_ALPHA_SIZE
164 SDL_GL_BUFFER_SIZE
165 SDL_GL_DOUBLEBUFFER
166 SDL_GL_DEPTH_SIZE
167 SDL_GL_STENCIL_SIZE
168 SDL_GL_ACCUM_RED_SIZE
169 SDL_GL_ACCUM_GREEN_SIZE
170 SDL_GL_ACCUM_BLUE_SIZE
171 SDL_GL_ACCUM_ALPHA_SIZE
172 SDL_GL_STEREO
173 SDL_GL_MULTISAMPLEBUFFERS
174 SDL_GL_MULTISAMPLESAMPLES
175 SDL_GL_ACCELERATED_VISUAL
176 SDL_GL_RETAINED_BACKING
177 SDL_GL_CONTEXT_MAJOR_VERSION
178 SDL_GL_CONTEXT_MINOR_VERSION
179 SDL_GL_CONTEXT_EGL
180 SDL_GL_CONTEXT_FLAGS
181 SDL_GL_CONTEXT_PROFILE_MASK
182 SDL_GL_SHARE_WITH_CURRENT_CONTEXT
183 SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
184 SDL_GL_CONTEXT_RELEASE_BEHAVIOR
185 SDL_GL_CONTEXT_RESET_NOTIFICATION
186 SDL_GL_CONTEXT_NO_ERROR
187 ]
188 ],
189 SDL_GLprofile => [
190 [ SDL_GL_CONTEXT_PROFILE_CORE => 0x0001 ],
191 [ SDL_GL_CONTEXT_PROFILE_COMPATIBILITY => 0x0002 ],
192 [ SDL_GL_CONTEXT_PROFILE_ES => 0x0004 ]
193 ],
194 SDL_GLcontextFlag => [
195 [ SDL_GL_CONTEXT_DEBUG_FLAG => 0x0001 ],
196 [ SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG => 0x0002 ],
197 [ SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG => 0x0004 ],
198 [ SDL_GL_CONTEXT_RESET_ISOLATION_FLAG => 0x0008 ]
199 ],
200 SDL_GLcontextReleaseFlag => [
201 [ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE => 0x0000 ],
202 [ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH => 0x0001 ]
203 ],
204 SDL_GLContextResetNotification => [
205 [ SDL_GL_CONTEXT_RESET_NO_NOTIFICATION => 0x0000 ],
206 [ SDL_GL_CONTEXT_RESET_LOSE_CONTEXT => 0x0001 ]
207 ];
208 attach video => {
209 SDL_GetNumVideoDrivers => [ [], 'int' ],
210 SDL_GetVideoDriver => [ ['int'], 'string' ],
211 SDL_VideoInit => [ ['string'], 'int' ],
212 SDL_VideoQuit => [ [] ],
213 SDL_GetCurrentVideoDriver => [ [], 'string' ],
214 SDL_GetNumVideoDisplays => [ [], 'int' ],
215 SDL_GetDisplayName => [ ['int'], 'string' ],
216 SDL_GetDisplayBounds => [ [ 'int', 'SDL_Rect' ], 'int' ],
217 SDL_GetDisplayUsableBounds => [ [ 'int', 'SDL_Rect' ], 'int' ],
218 SDL_GetDisplayDPI => [ [ 'int', 'float*', 'float*', 'float*' ], 'int' ],
219 SDL_GetDisplayOrientation => [ ['int'], 'SDL_DisplayOrientation' ],
220 SDL_GetNumDisplayModes => [ ['int'], 'int' ],
221 SDL_GetDisplayMode => [ [ 'int', 'int', 'SDL_DisplayMode' ], 'int' ],
222 SDL_GetDesktopDisplayMode => [ [ 'int', 'SDL_DisplayMode' ], 'int' ],
223 SDL_GetCurrentDisplayMode => [ [ 'int', 'SDL_DisplayMode' ], 'int' ],
224 SDL_GetClosestDisplayMode =>
225 [ [ 'int', 'SDL_DisplayMode', 'SDL_DisplayMode' ], 'SDL_DisplayMode' ],
226 SDL_GetWindowDisplayIndex => [ ['SDL_Window'], 'int' ],
227 SDL_SetWindowDisplayMode => [ [ 'SDL_Window', 'SDL_DisplayMode' ], 'int' ],
228 SDL_GetWindowDisplayMode => [ [ 'SDL_Window', 'SDL_DisplayMode' ], 'int' ],
229 SDL_GetWindowPixelFormat => [ ['SDL_Window'], 'uint32' ],
230 SDL_CreateWindow => [ [ 'string', 'int', 'int', 'int', 'int', 'uint32' ] => 'SDL_Window' ],
231 SDL_CreateWindowFrom => [ ['opaque'] => 'SDL_Window' ],
232 SDL_GetWindowID => [ ['SDL_Window'] => 'uint32' ],
233 SDL_GetWindowFromID => [ ['uint32'] => 'SDL_Window' ],
234 SDL_GetWindowFlags => [ ['SDL_Window'] => 'uint32' ],
235 SDL_SetWindowTitle => [ [ 'SDL_Window', 'string' ] ],
236 SDL_GetWindowTitle => [ ['SDL_Window'], 'string' ],
237 SDL_SetWindowIcon => [ [ 'SDL_Window', 'SDL_Surface' ] ],
238  
239 # These don't work correctly yet. (cast issues)
240 SDL_SetWindowData => [ [ 'SDL_Window', 'string', 'opaque' ], 'opaque' ],
241 SDL_GetWindowData => [ [ 'SDL_Window', 'string' ], 'opaque' ],
242 SDL_SetWindowPosition => [ [ 'SDL_Window', 'int', 'int' ] ],
243 SDL_GetWindowPosition => [ [ 'SDL_Window', 'int*', 'int*' ] ],
244 SDL_SetWindowSize => [ [ 'SDL_Window', 'int', 'int' ] ],
245 SDL_GetWindowSize => [ [ 'SDL_Window', 'int*', 'int*' ] ],
246 SDL_GetWindowBordersSize => [ [ 'SDL_Window', 'int*', 'int*', 'int*', 'int*' ], 'int' ],
247 SDL_SetWindowMinimumSize => [ [ 'SDL_Window', 'int', 'int' ] ],
248 SDL_GetWindowMinimumSize => [ [ 'SDL_Window', 'int*', 'int*' ] ],
249 SDL_SetWindowMaximumSize => [ [ 'SDL_Window', 'int', 'int' ] ],
250 SDL_GetWindowMaximumSize => [ [ 'SDL_Window', 'int*', 'int*' ] ],
251 SDL_SetWindowBordered => [ [ 'SDL_Window', 'SDL_bool' ] ],
252 SDL_SetWindowResizable => [ [ 'SDL_Window', 'SDL_bool' ] ],
253 SDL_SetWindowAlwaysOnTop => [ [ 'SDL_Window', 'SDL_bool' ] ],
254 SDL_ShowWindow => [ ['SDL_Window'] ],
255 SDL_HideWindow => [ ['SDL_Window'] ],
256 SDL_RaiseWindow => [ ['SDL_Window'] ],
257 SDL_MaximizeWindow => [ ['SDL_Window'] ],
258 SDL_MinimizeWindow => [ ['SDL_Window'] ],
259 SDL_RestoreWindow => [ ['SDL_Window'] ],
260 SDL_SetWindowFullscreen => [ [ 'SDL_Window', 'uint32' ], 'int' ],
261 SDL_GetWindowSurface => [ ['SDL_Window'], 'SDL_Surface' ],
262 SDL_UpdateWindowSurface => [ ['SDL_Window'], 'int' ],
263 SDL_UpdateWindowSurfaceRects => [ [ 'SDL_Window', 'Rects', 'int' ], 'int' ],
264 SDL_UpdateWindowSurfaceRects => [
265 [ 'SDL_Window', 'RectList_t', 'int' ],
266 'int' => sub ( $inner, $window, $_rects, $numrects ) {
267 my $rects = $SDL2::rect::List->create(
268 [ map { { x => $_->x, y => $_->y, w => $_->w, h => $_->h } } @$_rects ] );
269 $inner->( $window, $rects, $numrects );
270 }
271 ],
272 SDL_SetWindowGrab => [ [ 'SDL_Window', 'SDL_bool' ] ],
273 SDL_SetWindowKeyboardGrab => [ [ 'SDL_Window', 'SDL_bool' ] ],
274 SDL_SetWindowMouseGrab => [ [ 'SDL_Window', 'SDL_bool' ] ],
275 SDL_GetWindowGrab => [ ['SDL_Window'], 'SDL_bool' ],
276 SDL_GetWindowKeyboardGrab => [ ['SDL_Window'], 'SDL_bool' ],
277 SDL_GetWindowMouseGrab => [ ['SDL_Window'], 'SDL_bool' ],
278 SDL_GetGrabbedWindow => [ [], 'SDL_Window' ],
279 SDL_SetWindowBrightness => [ [ 'SDL_Window', 'float' ], 'int' ],
280 SDL_GetWindowBrightness => [ ['SDL_Window'], 'float' ],
281 SDL_SetWindowOpacity => [ [ 'SDL_Window', 'float' ], 'int' ],
282 SDL_GetWindowOpacity => [ [ 'SDL_Window', 'float*' ], 'int' ],
283 SDL_SetWindowModalFor => [ [ 'SDL_Window', 'SDL_Window' ], 'int' ],
284 SDL_SetWindowInputFocus => [ ['SDL_Window'], 'int' ],
285 SDL_SetWindowGammaRamp =>
286 [ [ 'SDL_Window', 'uint16[256]', 'uint16[256]', 'uint16[256]' ], 'int' ],
287 SDL_GetWindowGammaRamp => [
288 [ 'SDL_Window', 'uint16[256]', 'uint16[256]', 'uint16[256]' ], 'int'
289  
290 #=> sub ( $inner, $window ) {
291 # my @red = my @blue = my @green = map { \0 } 1 .. 256;
292 # my $ok = $inner->( $window, \@red, \@green, \@blue );
293 # $ok == 0 ? ( \@red, \@green, \@blue ) : $ok;
294 #}
295 ]
296 };
297 enum SDL_HitTestResult => [
298 qw[SDL_HITTEST_NORMAL
299 SDL_HITTEST_DRAGGABLE
300 SDL_HITTEST_RESIZE_TOPLEFT
301 SDL_HITTEST_RESIZE_TOP
302 SDL_HITTEST_RESIZE_TOPRIGHT
303 SDL_HITTEST_RESIZE_RIGHT
304 SDL_HITTEST_RESIZE_BOTTOMRIGHT
305 SDL_HITTEST_RESIZE_BOTTOM
306 SDL_HITTEST_RESIZE_BOTTOMLEFT
307 SDL_HITTEST_RESIZE_LEFT]
308 ];
309 #
310 ffi->type( '(opaque,opaque,opaque)->opaque' => 'SDL_HitTest' );
311 attach video => {
312 SDL_SetWindowHitTest => [
313 [ 'SDL_Window', 'SDL_HitTest', 'opaque' ],
314 'int' => sub ( $xsub, $window, $callback, $callback_data = () ) { # Fake void pointer
315 my $cb = $callback;
316 if ( defined $callback ) {
317 $cb = FFI::Platypus::Closure->new(
318 sub ( $win, $area, $data ) {
319 $callback->(
320 ffi->cast( 'opaque' => 'SDL_Window', $win ),
321 ffi->cast( 'opaque' => 'SDL_Point', $area ),
322 $callback_data
323 );
324 }
325 );
326 $cb->sticky;
327 }
328 $xsub->( $window, $cb, $callback_data );
329 return $cb;
330 }
331 ],
332 SDL_FlashWindow => [ [ 'SDL_Window', 'SDL_FlashOperation' ], 'int' ],
333 SDL_DestroyWindow => [ ['SDL_Window'] ],
334 SDL_IsScreenSaverEnabled => [ [], 'SDL_bool' ],
335 SDL_EnableScreenSaver => [ [] ],
336 SDL_DisableScreenSaver => [ [] ],
337 #
338 SDL_GL_LoadLibrary => [ ['string'], 'int' ],
339 SDL_GL_GetProcAddress => [ ['string'], 'opaque' ],
340 SDL_GL_UnloadLibrary => [ [] ],
341 SDL_GL_ExtensionSupported => [ ['string'], 'SDL_bool' ],
342 SDL_GL_ResetAttributes => [ [] ],
343 SDL_GL_SetAttribute => [ [ 'SDL_GLattr', 'int' ], 'int' ],
344 SDL_GL_GetAttribute => [ [ 'SDL_GLattr', 'int*' ], 'int' ],
345 SDL_GL_CreateContext => [ ['SDL_Window'], 'SDL_GLContext' ],
346 SDL_GL_MakeCurrent => [ [ 'SDL_Window', 'SDL_GLContext' ], 'int' ],
347 SDL_GL_GetCurrentWindow => [ [], 'SDL_Window' ],
348 SDL_GL_GetCurrentContext => [ [], 'SDL_GLContext' ],
349 SDL_GL_GetDrawableSize => [ [ 'SDL_Window', 'int*', 'int*' ] ],
350 SDL_GL_SetSwapInterval => [ ['int'], 'int' ],
351 SDL_GL_GetSwapInterval => [ [], 'int' ],
352 SDL_GL_SwapWindow => [ ['SDL_Window'] ],
353 SDL_GL_DeleteContext => [ ['SDL_GLContext'] ]
354 };
355  
356 =encoding utf-8
357  
358 =head1 NAME
359  
360 SDL2::video - SDL Video Functions
361  
362 =head1 SYNOPSIS
363  
364 use SDL2 qw[:version];
365 SDL_GetVersion( my $ver = SDL2::version->new );
366 CORE::say sprintf 'SDL version %d.%d.%d', $ver->major, $ver->minor, $ver->patch;
367  
368 =head1 DESCRIPTION
369  
370 SDL2::version represents the library's version as three levels: major, minor,
371 and patch level.
372  
373 =head1 Functions
374  
375 These may be imported by name or with the C<:video> tag.
376  
377 =head2 C<SDL_GetNumVideoDrivers( )>
378  
379 Get the number of video drivers compiled into SDL.
380  
381 my $num = SDL_GetNumVideoDrivers( );
382  
383 Returns a number >= 1 on success or a negative error code on failure; call
384 C<SDL_GetError( )> for more information.
385  
386 =head2 C<SDL_GetVideoDriver( ... )>
387  
388 Get the name of a built in video driver.
389  
390 CORE::say SDL_GetVideoDriver($_) for 0 .. SDL_GetNumVideoDrivers( ) - 1;
391  
392 The video drivers are presented in the order in which they are normally checked
393 during initialization.
394  
395 Expected parameters include:
396  
397 =over
398  
399 =item C<index> - the index of a video driver
400  
401 =back
402  
403 Returns the name of the video driver with the given C<index>.
404  
405 =head2 C<SDL_VideoInit( ... )>
406  
407 Initialize the video subsystem, optionally specifying a video driver.
408  
409 SDL_VideoInit( 'x11' );
410  
411 This function initializes the video subsystem, setting up a connection to the
412 window manager, etc, and determines the available display modes and pixel
413 formats, but does not initialize a window or graphics mode.
414  
415 If you use this function and you haven't used the C<SDL_INIT_VIDEO> flag with
416 either C<SDL_Init( ... )> or C<SDL_InitSubSystem( ... )>, you should call
417 C<SDL_VideoQuit( )> before calling C<SDL_Quit( )>.
418  
419 It is safe to call this function multiple times. C<SDL_VideoInit( )> will call
420 C<SDL_VideoQuit( )> itself if the video subsystem has already been initialized.
421  
422 You can use C<SDL_GetNumVideoDrivers( )> and C<SDL_GetVideoDriver( )> to find a
423 specific C<driver_name>.
424  
425 Expected parameters include:
426  
427 =over
428  
429 =item C<driver_name> - the name of a video driver to initialize, or C<undef> for the default driver
430  
431 =back
432  
433 Returns C<0> on success or a negative error code on failure; call
434 C<SDL_GetError( )> for more information.
435  
436 =head2 C<SDL_VideoQuit( )>
437  
438 Shut down the video subsystem, if initialized with SDL_VideoInit().
439  
440 SDL_VideoQuit( );
441  
442 This function closes all windows, and restores the original video mode.
443  
444 =head2 C<SDL_GetCurrentVideoDriver( ... )>
445  
446 Get the name of the currently initialized video driver.
447  
448 my $driver = SDL_GetCurrentVideoDriver( );
449  
450 Returns the name of the current video driver or C<undef> if no driver has been
451 initialized.
452  
453 =head2 C<SDL_GetNumVideoDisplays( ... )>
454  
455 Get the number of available video displays.
456  
457 my $screens = SDL_GetNumVideoDisplays( );
458  
459 Returns a number >= 1 or a negative error code on failure; call C<SDL_GetError(
460 )> for more information.
461  
462 =head2 C<SDL_GetDisplayName( ... )>
463  
464 Get the name of a display in UTF-8 encoding.
465  
466 my $screen = SDL_GetDisplayName( 0 );
467  
468 Expected parameters include:
469  
470 =over
471  
472 =item C<displayIndex> the index of display from which the name should be queried
473  
474 =back
475  
476 Returns the name of a display or C<undef> for an invalid display index or
477 failure; call C<SDL_GetError( )> for more information.
478  
479 =head2 C<SDL_GetDisplayBounds( ... )>
480  
481 Get the desktop area represented by a display.
482  
483 SDL_GetDisplayBounds( 0, my $rect );
484  
485 The primary display (C<displayIndex> zero) is always located at C<0,0>.
486  
487 Expected parameters include:
488  
489 =over
490  
491 =item C<displayIndex> - the index of the display to query
492  
493 =item C<rect> - the L<SDL2::Rect> structure filled in with the display bounds
494  
495 =back
496  
497 Returns C<0> on success or a negative error code on failure; call
498 C<SDL_GetError( )> for more information.
499  
500 =head2 C<SDL_GetDisplayUsableBounds( ... )>
501  
502 Get the usable desktop area represented by a display.
503  
504 SDL_GetDisplayUsableBounds( 0, my $rect );
505  
506 The primary display (C<displayIndex> zero) is always located at C<0,0>.
507  
508 This is the same area as C<SDL_GetDisplayBounds( ... )> reports, but with
509 portions reserved by the system removed. For example, on Apple's macOS, this
510 subtracts the area occupied by the menu bar and dock.
511  
512 Setting a window to be fullscreen generally bypasses these unusable areas, so
513 these are good guidelines for the maximum space available to a non-fullscreen
514 window.
515  
516 The parameter C<rect> is ignored if it is C<undef>.
517  
518 This function also returns C<-1> if the parameter C<displayIndex> is out of
519 range.
520  
521 Expected parameters include:
522  
523 =over
524  
525 =item C<displayIndex> - the index of the display to query the usable bounds from
526  
527 =item C<rect> - the L<SDL2::Rect> structure filled in with the display bounds
528  
529 =back
530  
531 Returns C<0> on success or a negative error code on failure; call
532 C<SDL_GetError( )> for more information.
533  
534 =head2 C<SDL_GetDisplayDPI( ... )>
535  
536 Get the dots/pixels-per-inch for a display.
537  
538 SDL_GetDisplayDPI( 0, \my $ddpi, \my $hdpi, \my $vdpi );
539  
540 Diagonal, horizontal and vertical DPI can all be optionally returned if the
541 appropriate parameter is non-NULL.
542  
543 A failure of this function usually means that either no DPI information is
544 available or the C<displayIndex> is out of range.
545  
546 Expected parameters include:
547  
548 =over
549  
550 =item C<displayIndex> - the index of the display from which DPI information should be queried
551  
552 =item C<ddpi> - a pointer filled in with the diagonal DPI of the display; may be C<undef>
553  
554 =item C<hdpi> - a pointer filled in with the horizontal DPI of the display; may be C<undef>
555  
556 =item C<vdpi> - a pointer filled in with the vertical DPI of the display; may be C<undef>
557  
558 =back
559  
560 Returns C<0> on success or a negative error code on failure; call
561 C<SDL_GetError( )> for more information.
562  
563 =head2 C<SDL_GetDisplayOrientation( ... )>
564  
565 Get the orientation of a display.
566  
567 Expected parameters include:
568  
569 =over
570  
571 =item C<displayIndex> - the index of the display to query
572  
573 =back
574  
575 Returns The SDL_DisplayOrientation enum value of the display, or
576 C<SDL_ORIENTATION_UNKNOWN> if it isn't available.
577  
578 =head2 C<SDL_GetNumDisplayModes( ... )>
579  
580 Get the number of available display modes.
581  
582 The C<displayIndex> needs to be in the range from 0 to
583 C<SDL_GetNumVideoDisplays( ) - 1>.
584  
585 Expected parameters include:
586  
587 =over
588  
589 =item C<displayIndex> - the index of the display to query
590  
591 =back
592  
593 Returns a number >= 1 on success or a negative error code on failure; call
594 C<SDL_GetError( )> for more information.
595  
596 =head2 C<SDL_GetDisplayMode( ... )>
597  
598 Get information about a specific display mode.
599  
600 The display modes are sorted in this priority:
601  
602 =over
603  
604 =item - width -> largest to smallest
605  
606 =item - height -> largest to smallest
607  
608 =item - bits per pixel -> more colors to fewer colors
609  
610 =item - packed pixel layout -> largest to smallest
611  
612 =item - refresh rate -> highest to lowest
613  
614 =back
615  
616 Expected parameters include:
617  
618 =over
619  
620 =item C<displayIndex> - the index of the display to query
621  
622 =item C<modeIndex> - the index of the display mode to query
623  
624 =item C<mode> - an L<SDL2::DisplayMode> structure filled in with the mode at C<modeIndex>
625  
626 =back
627  
628 Returns C<0> on success or a negative error code on failure; call
629 C<SDL_GetError( )> for more information.
630  
631 =head2 C<SDL_GetDesktopDisplayMode( ... )>
632  
633 Get information about the desktop's display mode.
634  
635 There's a difference between this function and L<< C<SDL_GetCurrentDisplayMode(
636 ... )>|/C<SDL_GetCurrentDisplayMode( ... )> >> when SDL runs fullscreen and has
637 changed the resolution. In that case this function will return the previous
638 native display mode, and not the current display mode.
639  
640 Expected parameters include:
641  
642 =over
643  
644 =item C<displayIndex> - the index of the display to query
645  
646 =item C<mode> - an L<SDL2::DisplayMode> structure filled in with the current display mode
647  
648 =back
649  
650 Returns C<0> on success or a negative error code on failure; call
651 C<SDL_GetError( )> for more information.
652  
653 =head2 C<SDL_GetCurrentDisplayMode( ... )>
654  
655 Get information about the current display mode.
656  
657 There's a difference between this function and L<< C<SDL_GetDesktopDisplayMode(
658 ... )>|/C<SDL_GetDesktopDisplayMode( ... )> >> when SDL runs fullscreen and has
659 changed the resolution. In that case this function will return the current
660 display mode, and not the previous native display mode.
661  
662 Expected parameters include:
663  
664 =over
665  
666 =item C<displayIndex> - the index of the display to query
667  
668 =item C<mode> - an L<SDL2::DisplayMode> structure filled in with the current display mode
669  
670 =back
671  
672 Returns C<0> on success or a negative error code on failure; call
673 C<SDL_GetError( )> for more information.
674  
675 =head2 C<SDL_GetClosestDisplayMode( ... )>
676  
677 Get the closest match to the requested display mode.
678  
679 The available display modes are scanned and C<closest> is filled in with the
680 closest mode matching the requested mode and returned. The mode format and
681 refresh rate default to the desktop mode if they are set to C<0>. The modes are
682 scanned with size being first priority, format being second priority, and
683 finally checking the refresh rate. If all the available modes are too small,
684 then C<undef> is returned.
685  
686 Expected parameters include:
687  
688 =over
689  
690 =item C<displayIndex> - the index of the display to query
691  
692 =item C<mode> - an L<SDL2::DisplayMode> structure containing the desired display mode
693  
694 =item C<closest> - an L<SDL2::DisplayMode> structure filled in with the closest match of the available display modes
695  
696 =back
697  
698 Returns the passed in value C<closest> or C<undef> if no matching video mode
699 was available; call C<SDL_GetError( )> for more information.
700  
701 =head2 C<SDL_GetWindowDisplayIndex( ... )>
702  
703 Get the index of the display associated with a window.
704  
705 Expected parameters include:
706  
707 =over
708  
709 =item C<window> - the window to query
710  
711 =back
712  
713 Returns the index of the display containing the center of the window on success
714 or a negative error code on failure; call C<SDL_GetError( )> for more
715 information.
716  
717 =head2 C<SDL_SetWindowDisplayMode( ... )>
718  
719 Set the display mode to use when a window is visible at fullscreen.
720  
721 This only affects the display mode used when the window is fullscreen. To
722 change the window size when the window is not fullscreen, use
723 SDL_SetWindowSize().
724  
725 Expected parameters include:
726  
727 =over
728  
729 =item C<window> - the window to affect
730  
731 =item C<mode> - the L<SDL2::DisplayMode> structure representing the mode to use, or C<undef> to use the window's dimensions and the desktop's format and refresh rate
732  
733 =back
734  
735 Returns C<0> on success or a negative error code on failure; call
736 C<SDL_GetError( )> for more information.
737  
738 =head2 C<SDL_GetWindowDisplayMode( ... )>
739  
740 Query the display mode to use when a window is visible at fullscreen.
741  
742 Expected parameters include:
743  
744 =over
745  
746 =item C<window> - the window to query
747  
748 =item C<mode> - an L<SDL2::DisplayMode> structure filled in with the fullscreen display mode
749  
750 =back
751  
752 Returns C<0> on success or a negative error code on failure; call
753 C<SDL_GetError( )> for more information.
754  
755 =head2 C<SDL_GetWindowPixelFormat( ... )>
756  
757 Get the pixel format associated with the window.
758  
759 Expected parameters include:
760  
761 =over
762  
763 =item C<window> - the window to query
764  
765 =back
766  
767 Returns the pixel format of the window on success or C<SDL_PIXELFORMAT_UNKNOWN>
768 on failure; call C<SDL_GetError( )> for more information.
769  
770 =head2 C<SDL_CreateWindow( ... )>
771  
772 Create a window with the specified position, dimensions, and flags.
773  
774 my $window = SDL_CreateWindow( 'Example',
775 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
776 1280, 720,
777 SDL_WINDOW_SHOWN
778 );
779  
780 C<flags> may be any of the following OR'd together:
781  
782 =over
783  
784 =item C<SDL_WINDOW_FULLSCREEN> - fullscreen window
785  
786 =item C<SDL_WINDOW_FULLSCREEN_DESKTOP> - fullscreen window at desktop resolution
787  
788 =item C<SDL_WINDOW_OPENGL> - window usable with an OpenGL context
789  
790 =item C<SDL_WINDOW_VULKAN> - window usable with a Vulkan instance
791  
792 =item C<SDL_WINDOW_METAL> - window usable with a Metal instance
793  
794 =item C<SDL_WINDOW_HIDDEN> - window is not visible
795  
796 =item C<SDL_WINDOW_BORDERLESS> - no window decoration
797  
798 =item C<SDL_WINDOW_RESIZABLE> - window can be resized
799  
800 =item C<SDL_WINDOW_MINIMIZED> - window is minimized
801  
802 =item C<SDL_WINDOW_MAXIMIZED> - window is maximized
803  
804 =item C<SDL_WINDOW_INPUT_GRABBED> - window has grabbed input focus
805  
806 =item C<SDL_WINDOW_ALLOW_HIGHDPI> - window should be created in high-DPI mode if supported (>= SDL 2.0.1)
807  
808 =back
809  
810 C<SDL_WINDOW_SHOWN> is ignored by C<SDL_CreateWindow( )>. The SDL_Window is
811 implicitly shown if C<SDL_WINDOW_HIDDEN> is not set. C<SDL_WINDOW_SHOWN> may be
812 queried later using L<< C<SDL_GetWindowFlags( ... )>|/C<SDL_GetWindowFlags( ...
813 )> >>.
814  
815 On Apple's macOS, you B<must> set the NSHighResolutionCapable Info.plist
816 property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
817  
818 If the window is created with the C<SDL_WINDOW_ALLOW_HIGHDPI> flag, its size in
819 pixels may differ from its size in screen coordinates on platforms with
820 high-DPI support (e.g. iOS and macOS). Use L<< C<SDL_GetWindowSize( ...
821 )>|/C<SDL_GetWindowSize( ... )> >> to query the client area's size in screen
822 coordinates, and L<< C<SDL_GL_GetDrawableSize( ...
823 )>|/C<SDL_GL_GetDrawableSize( ... )> >> or C<SDL_GetRendererOutputSize( ... )>
824 to query the drawable size in pixels.
825  
826 If the window is set fullscreen, the width and height parameters C<w> and C<h>
827 will not be used. However, invalid size parameters (e.g. too large) may still
828 fail. Window size is actually limited to 16384 x 16384 for all platforms at
829 window creation.
830  
831 If the window is created with any of the SDL_WINDOW_OPENGL or
832 C<SDL_WINDOW_VULKAN> flags, then the corresponding LoadLibrary function (L<<
833 C<SDL_GL_LoadLibrary( ... )>|/C<SDL_GL_LoadLibrary( ... )> >> or
834 C<SDL_Vulkan_LoadLibrary( ... )>) is called and the corresponding
835 C<UnloadLibrary> function is called by L<< C<SDL_DestroyWindow( ...
836 )>|/C<SDL_DestroyWindow( ... )> >>.
837  
838 If C<SDL_WINDOW_VULKAN> is specified and there isn't a working Vulkan driver,
839 C<SDL_CreateWindow( ... )> will fail because C<SDL_Vulkan_LoadLibrary( ... )>
840 will fail.
841  
842 If C<SDL_WINDOW_METAL> is specified on an OS that does not support Metal,
843 C<SDL_CreateWindow( ... )> will fail.
844  
845 On non-Apple devices, SDL requires you to either not link to the Vulkan loader
846 or link to a dynamic library version. This limitation may be removed in a
847 future version of SDL.
848  
849 Expected parameters include:
850  
851 =over
852  
853 =item C<title> - the title of the window, in UTF-8 encoding
854  
855 =item C<x> - the x position of the window, C<SDL_WINDOWPOS_CENTERED>, or C<SDL_WINDOWPOS_UNDEFINED>
856  
857 =item C<y> - the y position of the window, C<SDL_WINDOWPOS_CENTERED>, or C<SDL_WINDOWPOS_UNDEFINED>
858  
859 =item C<w> - the width of the window, in screen coordinates
860  
861 =item C<h> - the height of the window, in screen coordinates
862  
863 =item C<flags> - C<0>, or one or more C<SDL_WindowFlags> OR'd together
864  
865 =back
866  
867 Returns the window that was created or NULL on failure; call C<SDL_GetError( )>
868 for more information.
869  
870 =head2 C<SDL_CreateWindowFrom( ... )>
871  
872 Create an SDL window from an existing native window.
873  
874 In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows) the
875 hint C<SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT> needs to be configured before
876 using L<< C<SDL_CreateWindowFrom( ... )>|/C<SDL_CreateWindowFrom( ... )> >>.
877  
878 Expected parameters include:
879  
880 =over
881  
882 =item C<data> - a pointer to driver-dependent window creation data, typically your native window cast to a void*
883  
884 =back
885  
886 Returns the window that was created or NULL on failure; call C<SDL_GetError( )>
887 for more information.
888  
889 =head2 C<SDL_GetWindowID( ... )>
890  
891 Get the numeric ID of a window.
892  
893 The numeric ID is what L<SDL2::WindowEvent> references, and is necessary to map
894 these events to specific L<SDL2::Window> objects.
895  
896 Expected parameters include:
897  
898 =over
899  
900 =item C<window> - the window to query
901  
902 =back
903  
904 Returns the ID of the window on success or C<0> on failure; call
905 C<SDL_GetError( )> for more information.
906  
907 =head2 C<SDL_GetWindowFromID( ... )>
908  
909 Get a window from a stored ID.
910  
911 The numeric ID is what L<SDL2::WindowEvent> references, and is necessary to map
912 these events to specific L<SDL2::Window> objects.
913  
914 Expected parameters include:
915  
916 =over
917  
918 =item C<id> - the ID of the window
919  
920 =back
921  
922 Returns the window associated with C<id> or C<undef> if it doesn't exist; call
923 C<SDL_GetError( )> for more information.
924  
925 =head2 C<SDL_GetWindowFlags( ... )>
926  
927 Get the window flags.
928  
929 Expected parameters include:
930  
931 =over
932  
933 =item C<window> - the window to query
934  
935 =back
936  
937 Returns a mask of the C<SDL_WindowFlags> associated with C<window>.
938  
939 =head2 C<SDL_SetWindowTitle( ... )>
940  
941 Set the title of a window.
942  
943 This string is expected to be in UTF-8 encoding.
944  
945 Expected parameters include:
946  
947 =over
948  
949 =item C<window> - the window to change
950  
951 =item C<title> - the desired window title in UTF-8 format
952  
953 =back
954  
955 =head2 C<SDL_GetWindowTitle( ... )>
956  
957 Get the title of a window.
958  
959 Expected parameters include:
960  
961 =over
962  
963 =item C<window> - the window to query
964  
965 =back
966  
967 Returns the title of the window in UTF-8 format or C<""> if there is no title.
968  
969 =head2 C<SDL_SetWindowIcon( ... )>
970  
971 Set the icon for a window.
972  
973 Expected parameters include:
974  
975 =over
976  
977 =item C<window> - the window to change
978  
979 =item C<icon> - an L<SDL2::Surface> structure containing the icon for the window
980  
981 =back
982  
983 =head2 C<SDL_SetWindowData( ... )>
984  
985 Associate an arbitrary named pointer with a window.
986  
987 C<name> is case-sensitive.
988  
989 Expected parameters include:
990  
991 =over
992  
993 =item C<window> - the window to associate with the pointer
994  
995 =item C<name> - the name of the pointer
996  
997 =item C<userdata> - the associated pointer
998  
999 =back
1000  
1001 Returns the previous value associated with C<name>.
1002  
1003 =head2 C<SDL_GetWindowData( ... )>
1004  
1005 Retrieve the data pointer associated with a window.
1006  
1007 Expected parameters include:
1008  
1009 =over
1010  
1011 =item C<window> - the window to query
1012  
1013 =item C<name> - the name of the pointer
1014  
1015 =back
1016  
1017 Returns the value associated with C<name>.
1018  
1019 =head2 C<SDL_SetWindowPosition( ... )>
1020  
1021 Set the position of a window.
1022  
1023 The window coordinate origin is the upper left of the display.
1024  
1025 Expected parameters include:
1026  
1027 =over
1028  
1029 =item C<window> - the window to reposition
1030  
1031 =item C<x> - the x coordinate of the window in screen coordinates, or C<SDL_WINDOWPOS_CENTERED> or C<SDL_WINDOWPOS_UNDEFINED>
1032  
1033 =item C<y> - the y coordinate of the window in screen coordinates, or C<SDL_WINDOWPOS_CENTERED> or C<SDL_WINDOWPOS_UNDEFINED>
1034  
1035 =back
1036  
1037 =head2 C<SDL_GetWindowPosition( ... )>
1038  
1039 Get the position of a window.
1040  
1041 If you do not need the value for one of the positions a C<undef> may be passed
1042 in the C<x> or C<y> parameter.
1043  
1044 Expected parameters include:
1045  
1046 =over
1047  
1048 =item C<window> - the window to query
1049  
1050 =item C<x> - a pointer filled in with the x position of the window, in screen coordinates, may be C<undef>
1051  
1052 =item C<y> - a pointer filled in with the y position of the window, in screen coordinates, may be C<undef>
1053  
1054 =back
1055  
1056 =head2 C<SDL_SetWindowSize( ... )>
1057  
1058 Set the size of a window's client area.
1059  
1060 The window size in screen coordinates may differ from the size in pixels, if
1061 the window was created with C<SDL_WINDOW_ALLOW_HIGHDPI> on a platform with
1062 high-dpi support (e.g. iOS or macOS). Use L<< C<SDL_GL_GetDrawableSize( ...
1063 )>|/C<SDL_GL_GetDrawableSize( ... )> >> or C<SDL_GetRendererOutputSize( ... )>
1064 to get the real client area size in pixels.
1065  
1066 Fullscreen windows automatically match the size of the display mode, and you
1067 should use L<< C<SDL_SetWindowDisplayMode( ... )>|/C<SDL_SetWindowDisplayMode(
1068 ... )> >> to change their size.
1069  
1070 Expected parameters include:
1071  
1072 =over
1073  
1074 =item C<window> - the window to change
1075  
1076 =item C<w> - the width of the window in pixels, in screen coordinates, must be > 0
1077  
1078 =item C<h> - the height of the window in pixels, in screen coordinates, must be > 0
1079  
1080 =back
1081  
1082 =head2 C<SDL_GetWindowSize( ... )>
1083  
1084 Get the size of a window's client area.
1085  
1086 C<undef> can safely be passed as the C<w> or C<h> parameter if the width or
1087 height value is not desired.
1088  
1089 The window size in screen coordinates may differ from the size in pixels, if
1090 the window was created with C<SDL_WINDOW_ALLOW_HIGHDPI> on a platform with
1091 high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize(),
1092 C<SDL_Vulkan_GetDrawableSize( ... )>, or C<SDL_GetRendererOutputSize( ... )> to
1093 get the real client area size in pixels.
1094  
1095 Expected parameters include:
1096  
1097 =over
1098  
1099 =item C<window> - the window to query the width and height from
1100  
1101 =item C<w> - a pointer filled in with the width of the window, in screen coordinates, may be C<undef>
1102  
1103 =item C<h> - a pointer filled in with the height of the window, in screen coordinates, may be C<undef>
1104  
1105 =back
1106  
1107 =head2 C<SDL_GetWindowBordersSize( ... )>
1108  
1109 Get the size of a window's borders (decorations) around the client area.
1110  
1111 Note: If this function fails (returns C<-1>), the size values will be
1112 initialized to C<0, 0, 0, 0> (if a non-NULL pointer is provided), as if the
1113 window in question was borderless.
1114  
1115 Note: This function may fail on systems where the window has not yet been
1116 decorated by the display server (for example, immediately after calling L<<
1117 C<SDL_CreateWindow( ... )>|/C<SDL_CreateWindow( ... )> >>). It is recommended
1118 that you wait at least until the window has been presented and composited, so
1119 that the window system has a chance to decorate the window and provide the
1120 border dimensions to SDL.
1121  
1122 This function also returns C<-1> if getting the information is not supported.
1123  
1124 Expected parameters include:
1125  
1126 =over
1127  
1128 =item C<window> - the window to query the size values of the border (decorations) from
1129  
1130 =item C<top> - pointer to variable for storing the size of the top border; C<undef> is permitted
1131  
1132 =item C<left> - pointer to variable for storing the size of the left border; C<undef> is permitted
1133  
1134 =item C<bottom> - pointer to variable for storing the size of the bottom border; C<undef> is permitted
1135  
1136 =item C<right> - pointer to variable for storing the size of the right border; C<undef> is permitted
1137  
1138 =back
1139  
1140 Returns C<0> on success or a negative error code on failure; call
1141 C<SDL_GetError( )> for more information.
1142  
1143 =head2 C<SDL_SetWindowMinimumSize( ... )>
1144  
1145 Set the minimum size of a window's client area.
1146  
1147 Expected parameters include:
1148  
1149 =over
1150  
1151 =item C<window> - the window to change
1152  
1153 =item C<min_w> - the minimum width of the window in pixels
1154  
1155 =item C<min_h> - the minimum height of the window in pixels
1156  
1157 =back
1158  
1159 =head2 C<SDL_GetWindowMinimumSize( ... )>
1160  
1161 Get the minimum size of a window's client area.
1162  
1163 Expected parameters include:
1164  
1165 =over
1166  
1167 =item C<window> - the window to query
1168  
1169 =item C<w> - a pointer filled in with the minimum width of the window, may be C<undef>
1170  
1171 =item C<h> - a pointer filled in with the minimum height of the window, may be C<undef>
1172  
1173 =back
1174  
1175 =head2 C<SDL_SetWindowMaximumSize( ... )>
1176  
1177 Set the maximum size of a window's client area.
1178  
1179 Expected parameters include:
1180  
1181 =over
1182  
1183 =item C<window> - the window to change
1184  
1185 =item C<max_w> - the maximum width of the window in pixels
1186  
1187 =item C<max_h> - the maximum height of the window in pixels
1188  
1189 =back
1190  
1191 =head2 C<SDL_GetWindowMaximumSize( ... )>
1192  
1193 Get the maximum size of a window's client area.
1194  
1195 Expected parameters include:
1196  
1197 =over
1198  
1199 =item C<window> - the window to query
1200  
1201 =item C<w> - a pointer filled in with the maximum width of the window, may be C<undef>
1202  
1203 =item C<h> - a pointer filled in with the maximum height of the window, may be C<undef>
1204  
1205 =back
1206  
1207 =head2 C<SDL_SetWindowBordered( ... )>
1208  
1209 Set the border state of a window.
1210  
1211 This will add or remove the window's C<SDL_WINDOW_BORDERLESS> flag and add or
1212 remove the border from the actual window. This is a no-op if the window's
1213 border already matches the requested state.
1214  
1215 You can't change the border state of a fullscreen window.
1216  
1217 Expected parameters include:
1218  
1219 =over
1220  
1221 =item C<window> - the window of which to change the border state
1222  
1223 =item C<bordered> - C<SDL_FALSE> to remove border, C<SDL_TRUE> to add border
1224  
1225 =back
1226  
1227 =head2 C<SDL_SetWindowResizable( ... )>
1228  
1229 Set the user-resizable state of a window.
1230  
1231 This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and
1232 allow/disallow user resizing of the window. This is a no-op if the window's
1233 resizable state already matches the requested state.
1234  
1235 You can't change the resizable state of a fullscreen window.
1236  
1237 Expected parameters include:
1238  
1239 =over
1240  
1241 =item C<window> - the window of which to change the resizable state
1242  
1243 =item C<resizable> - C<SDL_TRUE> to allow resizing, C<SDL_FALSE> to disallow
1244  
1245 =back
1246  
1247 =head2 C<SDL_SetWindowAlwaysOnTop( ... )>
1248  
1249 Set the window to always be above the others.
1250  
1251 This will add or remove the window's C<SDL_WINDOW_ALWAYS_ON_TOP> flag. This
1252 will bring the window to the front and keep the window above the rest.
1253  
1254 Expected parameters include:
1255  
1256 =over
1257  
1258 =item C<window> - window of which to change the always on top state
1259  
1260 =item C<on_top> - C<SDL_TRUE> to set the window always on top, C<SDL_FALSE> to disable
1261  
1262 =back
1263  
1264 =head2 C<SDL_ShowWindow( ... )>
1265  
1266 Show a window.
1267  
1268 Expected parameters include:
1269  
1270 =over
1271  
1272 =item C<window> - the window to show
1273  
1274 =back
1275  
1276 =head2 C<SDL_HideWindow( ... )>
1277  
1278 Hide a window.
1279  
1280 Expected parameters include:
1281  
1282 =over
1283  
1284 =item C<window> - the window to hide
1285  
1286 =back
1287  
1288 =head2 C<SDL_RaiseWindow( ... )>
1289  
1290 Raise a window above other windows and set the input focus.
1291  
1292 Expected parameters include:
1293  
1294 =over
1295  
1296 =item C<window> - the window to raise
1297  
1298 =back
1299  
1300 =head2 C<SDL_MaximizeWindow( ... )>
1301  
1302 Make a window as large as possible.
1303  
1304 Expected parameters include:
1305  
1306 =over
1307  
1308 =item C<window> - the window to maximize
1309  
1310 =back
1311  
1312 =head2 C<SDL_MinimizeWindow( ... )>
1313  
1314 Minimize a window to an iconic representation.
1315  
1316 Expected parameters include:
1317  
1318 =over
1319  
1320 =item C<window> - the window to minimize
1321  
1322 =back
1323  
1324 =head2 C<SDL_RestoreWindow( ... )>
1325  
1326 Restore the size and position of a minimized or maximized window.
1327  
1328 Expected parameters include:
1329  
1330 =over
1331  
1332 =item C<window> - the window to restore
1333  
1334 =back
1335  
1336 =head2 C<SDL_SetWindowFullscreen( ... )>
1337  
1338 Set a window's fullscreen state.
1339  
1340 C<flags> may be C<SDL_WINDOW_FULLSCREEN>, for "real" fullscreen with a
1341 videomode change; C<SDL_WINDOW_FULLSCREEN_DESKTOP> for "fake" fullscreen that
1342 takes the size of the desktop; and 0 for windowed mode.
1343  
1344 Expected parameters include:
1345  
1346 =over
1347  
1348 =item C<window> - the window to change
1349  
1350 =item C<flags> - C<SDL_WINDOW_FULLSCREEN>, C<SDL_WINDOW_FULLSCREEN_DESKTOP> or C<0>
1351  
1352 =back
1353  
1354 Returns C<0> on success or a negative error code on failure; call
1355 C<SDL_GetError( )> for more information.
1356  
1357 =head2 C<SDL_GetWindowSurface( ... )>
1358  
1359 Get the SDL surface associated with the window.
1360  
1361 A new surface will be created with the optimal format for the window, if
1362 necessary. This surface will be freed when the window is destroyed. Do not free
1363 this surface.
1364  
1365 This surface will be invalidated if the window is resized. After resizing a
1366 window this function must be called again to return a valid surface.
1367  
1368 You may not combine this with 3D or the rendering API on this window.
1369  
1370 This function is affected by C<SDL_HINT_FRAMEBUFFER_ACCELERATION>.
1371  
1372  
1373 Expected parameters include:
1374  
1375 =over
1376  
1377 =item C<window> - the window to query
1378  
1379 =back
1380  
1381 Returns the surface associated with the window, or NULL on failure; call
1382 C<SDL_GetError( )> for more information.
1383  
1384 =head2 C<SDL_UpdateWindowSurface( ... )>
1385  
1386 Copy the window surface to the screen.
1387  
1388 This is the function you use to reflect any changes to the surface on the
1389 screen.
1390  
1391 Expected parameters include:
1392  
1393 =over
1394  
1395 =item C<window> - the window to update
1396  
1397 =back
1398  
1399 Returns C<0> on success or a negative error code on failure; call
1400 C<SDL_GetError( )> for more information.
1401  
1402 =head2 C<SDL_UpdateWindowSurfaceRects( ... )>
1403  
1404 Copy areas of the window surface to the screen.
1405  
1406 This is the function you use to reflect changes to portions of the surface on
1407 the screen.
1408  
1409 Expected parameters include:
1410  
1411 =over
1412  
1413 =item C<window> - the window to update
1414  
1415 =item C<rects> - an array of L<SDL2::Rect> structures representing areas of the surface to copy
1416  
1417 =item C<numrects> - the number of rectangles
1418  
1419 =back
1420  
1421 Returns C<0> on success or a negative error code on failure; call
1422 C<SDL_GetError( )> for more information.
1423  
1424 =head2 C<SDL_SetWindowGrab( ... )>
1425  
1426 Set a window's input grab mode.
1427  
1428 When input is grabbed the mouse is confined to the window.
1429  
1430 If the caller enables a grab while another window is currently grabbed, the
1431 other window loses its grab in favor of the caller's window.
1432  
1433 Expected parameters include:
1434  
1435 =over
1436  
1437 =item C<window> - the window for which the input grab mode should be set
1438  
1439 =item C<grabbed> - C<SDL_TRUE> to grab input or C<SDL_FALSE> to release input
1440  
1441 =back
1442  
1443 =head2 C<SDL_SetWindowKeyboardGrab( ... )>
1444  
1445 Set a window's keyboard grab mode.
1446  
1447 If the caller enables a grab while another window is currently grabbed, the
1448 other window loses its grab in favor of the caller's window.
1449  
1450 Expected parameters include:
1451  
1452 =over
1453  
1454 =item C<window> - window for which the keyboard grab mode should be set
1455  
1456 =item C<grabbed> - C<SDL_TRUE> to grab keyboard, C<SDL_FALSE> to release
1457  
1458 =back
1459  
1460 =head2 C<SDL_SetWindowMouseGrab( ... )>
1461  
1462 Set a window's mouse grab mode.
1463  
1464 Expected parameters include:
1465  
1466 =over
1467  
1468 =item C<window> - the window for which the mouse grab mode should be set.
1469  
1470 =back
1471  
1472 =head2 C<SDL_GetWindowGrab( ... )>
1473  
1474 Get a window's input grab mode.
1475  
1476 Expected parameters include:
1477  
1478 =over
1479  
1480 =item C<window> - the window to query
1481  
1482 =back
1483  
1484 Returns C<SDL_TRUE> if input is grabbed, C<SDL_FALSE> otherwise.
1485  
1486 =head2 C<SDL_GetWindowKeyboardGrab( ... )>
1487  
1488 Get a window's keyboard grab mode.
1489  
1490 Expected parameters include:
1491  
1492 =over
1493  
1494 =item C<param> - window the window to query
1495  
1496 =back
1497  
1498 Returns C<SDL_TRUE> if keyboard is grabbed, and C<SDL_FALSE> otherwise.
1499  
1500 =head2 C<SDL_GetWindowMouseGrab( ... )>
1501  
1502 Get a window's mouse grab mode.
1503  
1504 Expected parameters include:
1505  
1506 =over
1507  
1508 =item C<window> - the window to query
1509  
1510 =back
1511  
1512 Returns C<SDL_TRUE> if mouse is grabbed, and C<SDL_FALSE> otherwise.
1513  
1514 =head2 C<SDL_GetGrabbedWindow( )>
1515  
1516 Get the window that currently has an input grab enabled.
1517  
1518 Returns the window if input is grabbed or C<undef> otherwise.
1519  
1520 =head2 C<SDL_SetWindowBrightness( ... )>
1521  
1522 Set the brightness (gamma multiplier) for a given window's display.
1523  
1524 Despite the name and signature, this method sets the brightness of the entire
1525 display, not an individual window. A window is considered to be owned by the
1526 display that contains the window's center pixel. (The index of this display can
1527 be retrieved using SDL_GetWindowDisplayIndex().) The brightness set will not
1528 follow the window if it is moved to another display.
1529  
1530 Many platforms will refuse to set the display brightness in modern times. You
1531 are better off using a shader to adjust gamma during rendering, or something
1532 similar.
1533  
1534 Expected parameters include:
1535  
1536 =over
1537  
1538 =item C<window> - the window used to select the display whose brightness will be changed
1539  
1540 =item C<brightness> - the brightness (gamma multiplier) value to set where C<0.0> is completely dark and C<1.0> is normal brightness
1541  
1542 =back
1543  
1544 Returns C<0> on success or a negative error code on failure; call
1545 C<SDL_GetError( )> for more information.
1546  
1547 =head2 C<SDL_GetWindowBrightness( ... )>
1548  
1549 Get the brightness (gamma multiplier) for a given window's display.
1550  
1551 Despite the name and signature, this method retrieves the brightness of the
1552 entire display, not an individual window. A window is considered to be owned by
1553 the display that contains the window's center pixel. (The index of this display
1554 can be retrieved using L<< C<SDL_GetWindowDisplayIndex( ...
1555 )>|/C<SDL_GetWindowDisplayIndex( ... )> >>.)
1556  
1557 Expected parameters include:
1558  
1559 =over
1560  
1561 =item C<window> - the window used to select the display whose brightness will be queried
1562  
1563 =back
1564  
1565 Returns the brightness for the display where C<0.0> is completely dark and
1566 C<1.0> is normal brightness.
1567  
1568 =head2 C<SDL_SetWindowOpacity( ... )>
1569  
1570 Set the opacity for a window.
1571  
1572 The parameter C<opacity> will be clamped internally between C<0.0>
1573 (transparent) and C<1.0> (opaque).
1574  
1575 This function also returns C<-1> if setting the opacity isn't supported.
1576  
1577 Expected parameters include:
1578  
1579 =over
1580  
1581 =item C<window> - the window which will be made transparent or opaque
1582  
1583 =item C<opacity> - the opacity value (C<0.0> - transparent, C<1.0> - opaque)
1584  
1585 =back
1586  
1587 Returns C<0> on success or a negative error code on failure; call
1588 C<SDL_GetError( )> for more information.
1589  
1590 =head2 C<SDL_GetWindowOpacity( ... )>
1591  
1592 Get the opacity of a window.
1593  
1594 If transparency isn't supported on this platform, opacity will be reported as
1595 C<1.0> without error.
1596  
1597 The parameter C<opacity> is ignored if it is C<undef>.
1598  
1599 This function also returns -1 if an invalid window was provided.
1600  
1601 Expected parameters include:
1602  
1603 =over
1604  
1605 =item C<window> - the window to get the current opacity value from
1606  
1607 =item C<out_opacity> - the float filled in (0.0f - transparent, 1.0f - opaque)
1608  
1609 =back
1610  
1611 Returns C<0> on success or a negative error code on failure; call
1612 C<SDL_GetError( )> for more information.
1613  
1614 =head2 C<SDL_SetWindowModalFor( ... )>
1615  
1616 Set the window as a modal for another window.
1617  
1618 Expected parameters include:
1619  
1620 =over
1621  
1622 =item C<modal_window> - the window that should be set modal
1623  
1624 =item C<parent_window> - the parent window for the modal window
1625  
1626 =back
1627  
1628 Returns C<0> on success or a negative error code on failure; call
1629 C<SDL_GetError( )> for more information.
1630  
1631 =head2 C<SDL_SetWindowInputFocus( ... )>
1632  
1633 Explicitly set input focus to the window.
1634  
1635 You almost certainly want L<< C<SDL_RaiseWindow( ... )>|/C<SDL_RaiseWindow( ...
1636 )> >> instead of this function. Use this with caution, as you might give focus
1637 to a window that is completely obscured by other windows.
1638  
1639 Expected parameters include:
1640  
1641 =over
1642  
1643 =item C<window> - the window that should get the input focus
1644  
1645 =back
1646  
1647 Returns C<0> on success or a negative error code on failure; call
1648 C<SDL_GetError( )> for more information.
1649  
1650 =head2 C<SDL_SetWindowGammaRamp( ... )>
1651  
1652 Set the gamma ramp for the display that owns a given window.
1653  
1654 Set the gamma translation table for the red, green, and blue channels of the
1655 video hardware. Each table is an array of 256 16-bit quantities, representing a
1656 mapping between the input and output for that channel. The input is the index
1657 into the array, and the output is the 16-bit gamma value at that index, scaled
1658 to the output color precision.
1659  
1660 Despite the name and signature, this method sets the gamma ramp of the entire
1661 display, not an individual window. A window is considered to be owned by the
1662 display that contains the window's center pixel. (The index of this display can
1663 be retrieved using L<< C<SDL_GetWindowDisplayIndex( ...
1664 )>|/C<SDL_GetWindowDisplayIndex( ... )> >>.) The gamma ramp set will not follow
1665 the window if it is moved to another display.
1666  
1667 Expected parameters include:
1668  
1669 =over
1670  
1671 =item C<window> - the window used to select the display whose gamma ramp will be changed
1672  
1673 =item C<red> - a 256 element array of 16-bit quantities representing the translation table for the red channel, or C<undef>
1674  
1675 =item C<green> - a 256 element array of 16-bit quantities representing the translation table for the green channel, or C<undef>
1676  
1677 =item C<blue> - a 256 element array of 16-bit quantities representing the translation table for the blue channel, or C<undef>
1678  
1679 =back
1680  
1681 Returns C<0> on success or a negative error code on failure; call
1682 C<SDL_GetError( )> for more information.
1683  
1684 =head2 C<SDL_GetWindowGammaRamp( ... )>
1685  
1686 Get the gamma ramp for a given window's display.
1687  
1688 Despite the name and signature, this method retrieves the gamma ramp of the
1689 entire display, not an individual window. A window is considered to be owned by
1690 the display that contains the window's center pixel. (The index of this display
1691 can be retrieved using L<< C<SDL_GetWindowDisplayIndex( ...
1692 )>|/C<SDL_GetWindowDisplayIndex( ... )> >>.)
1693  
1694  
1695 Expected parameters include:
1696  
1697 =over
1698  
1699 =item C<window> - the window used to select the display whose gamma ramp will be queried
1700  
1701 =item C<red> - a 256 element array of 16-bit quantities filled in with the translation table for the red channel, or C<undef>
1702  
1703 =item C<green> - a 256 element array of 16-bit quantities filled in with the translation table for the green channel, or C<undef>
1704  
1705 =item C<blue> - a 256 element array of 16-bit quantities filled in with the translation table for the blue channel, or C<undef>
1706  
1707 =back
1708  
1709 Returns C<0> on success or a negative error code on failure; call
1710 C<SDL_GetError( )> for more information.
1711  
1712 =head2 C<SDL_SetWindowHitTest( ... )>
1713  
1714 Provide a callback that decides if a window region has special properties.
1715  
1716 Normally windows are dragged and resized by decorations provided by the system
1717 window manager (a title bar, borders, etc), but for some apps, it makes sense
1718 to drag them from somewhere else inside the window itself; for example, one
1719 might have a borderless window that wants to be draggable from any part, or
1720 simulate its own title bar, etc.
1721  
1722 This function lets the app provide a callback that designates pieces of a given
1723 window as special. This callback is run during event processing if we need to
1724 tell the OS to treat a region of the window specially; the use of this callback
1725 is known as "hit testing."
1726  
1727 Mouse input may not be delivered to your application if it is within a special
1728 area; the OS will often apply that input to moving the window or resizing the
1729 window and not deliver it to the application.
1730  
1731 Specifying C<undef> for a callback disables hit-testing. Hit-testing is
1732 disabled by default.
1733  
1734 Platforms that don't support this functionality will return C<-1>
1735 unconditionally, even if you're attempting to disable hit-testing.
1736  
1737 Your callback may fire at any time, and its firing does not indicate any
1738 specific behavior (for example, on Windows, this certainly might fire when the
1739 OS is deciding whether to drag your window, but it fires for lots of other
1740 reasons, too, some unrelated to anything you probably care about _and when the
1741 mouse isn't actually at the location it is testing_). Since this can fire at
1742 any time, you should try to keep your callback efficient, devoid of
1743 allocations, etc.
1744  
1745 Expected parameters include:
1746  
1747 =over
1748  
1749 =item C<window> - the window to set hit-testing on
1750  
1751 =item C<callback> - the function to call when doing a hit-test
1752  
1753 =item C<callback_data> - an app-defined void pointer passed to C<callback>
1754  
1755 =back
1756  
1757 Returns C<0> on success or C<-1> on error (including unsupported); call
1758 C<SDL_GetError( )> for more information.
1759  
1760 =head2 C<SDL_FlashWindow( ... )>
1761  
1762 Request a window to demand attention from the user.
1763  
1764 Expected parameters include:
1765  
1766 =over
1767  
1768 =item C<window> - the window to be flashed
1769  
1770 =item C<operation> - the flash operation
1771  
1772 =back
1773  
1774 Returns C<0> on success or a negative error code on failure; call
1775 C<SDL_GetError( )> for more information.
1776  
1777 =head2 C<SDL_DestroyWindow( ... )>
1778  
1779 Destroy a window.
1780  
1781 If C<window> is C<undef>, this function will return immediately after setting
1782 the SDL error message to "Invalid window". See C<SDL_GetError( )>.
1783  
1784 Expected parameters include:
1785  
1786 =over
1787  
1788 =item C<window> - the window to destroy
1789  
1790 =back
1791  
1792 =head2 C<SDL_IsScreenSaverEnabled( )>
1793  
1794 Check whether the screensaver is currently enabled.
1795  
1796 The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2 the
1797 screensaver was enabled by default.
1798  
1799 The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`.
1800  
1801 Returns C<SDL_TRUE> if the screensaver is enabled, C<SDL_FALSE> if it is
1802 disabled.
1803  
1804 =head2 C<SDL_EnableScreenSaver( )>
1805  
1806 Allow the screen to be blanked by a screen saver.
1807  
1808 SDL_EnableScreenSaver( );
1809  
1810 =head2 C<SDL_DisableScreenSaver( )>
1811  
1812 Prevent the screen from being blanked by a screen saver.
1813  
1814 SDL_DisableScreenSaver( );
1815  
1816 If you disable the screensaver, it is automatically re-enabled when SDL quits.
1817  
1818 =head2 C<SDL_GL_LoadLibrary( ... )>
1819  
1820 Dynamically load an OpenGL library.
1821  
1822 This should be done after initializing the video driver, but before creating
1823 any OpenGL windows. If no OpenGL library is loaded, the default library will be
1824 loaded upon creation of the first OpenGL window.
1825  
1826 If you do this, you need to retrieve all of the GL functions used in your
1827 program from the dynamic library using C<SDL_GL_GetProcAddress( ... )>.
1828  
1829 Expected parameters include:
1830  
1831 =over
1832  
1833 =item C<path> - the platform dependent OpenGL library name, or C<undef> to open the default OpenGL library
1834  
1835 =back
1836  
1837 Returns C<0> on success or a negative error code on failure; call
1838 C<SDL_GetError( )> for more information.
1839  
1840 =head2 C<SDL_GL_GetProcAddress( ... )>
1841  
1842 Get an OpenGL function by name.
1843  
1844 If the GL library is loaded at runtime with L<< C<SDL_GL_LoadLibrary( ...
1845 )>|/C<SDL_GL_LoadLibrary( ... )> >>, then all GL functions must be retrieved
1846 this way. Usually this is used to retrieve function pointers to OpenGL
1847 extensions.
1848  
1849 There are some quirks to looking up OpenGL functions that require some extra
1850 care from the application. If you code carefully, you can handle these quirks
1851 without any platform-specific code, though:
1852  
1853 =over
1854  
1855 =item
1856  
1857 On Windows, function pointers are specific to the current GL context; this
1858 means you need to have created a GL context and made it current before calling
1859 SDL_GL_GetProcAddress(). If you recreate your context or create a second
1860 context, you should assume that any existing function pointers aren't valid to
1861 use with it. This is (currently) a Windows-specific limitation, and in practice
1862 lots of drivers don't suffer this limitation, but it is still the way the wgl
1863 API is documented to work and you should expect crashes if you don't respect
1864 it. Store a copy of the function pointers that comes and goes with context
1865 lifespan.
1866  
1867 =item
1868  
1869 On X11, function pointers returned by this function are valid for any context,
1870 and can even be looked up before a context is created at all. This means that,
1871 for at least some common OpenGL implementations, if you look up a function that
1872 doesn't exist, you'll get a non-NULL result that is _NOT_ safe to call. You
1873 must always make sure the function is actually available for a given GL context
1874 before calling it, by checking for the existence of the appropriate extension
1875 with SDL_GL_ExtensionSupported(), or verifying that the version of OpenGL
1876 you're using offers the function as core functionality.
1877  
1878 =item
1879  
1880 Some OpenGL drivers, on all platforms, *will* return NULL if a function isn't
1881 supported, but you can't count on this behavior. Check for extensions you use,
1882 and if you get a NULL anyway, act as if that extension wasn't available. This
1883 is probably a bug in the driver, but you can code defensively for this scenario
1884 anyhow.
1885  
1886 =item
1887  
1888 Just because you're on Linux/Unix, don't assume you'll be using X11. Next-gen
1889 display servers are waiting to replace it, and may or may not make the same
1890 promises about function pointers.
1891  
1892 =item
1893  
1894 OpenGL function pointers must be declared `APIENTRY` as in the example code.
1895 This will ensure the proper calling convention is followed on platforms where
1896 this matters (Win32) thereby avoiding stack corruption.
1897  
1898 =back
1899  
1900 Expected parameters include:
1901  
1902 =over
1903  
1904 =item C<proc> - the name of an OpenGL function
1905  
1906 =back
1907  
1908 Returns a pointer to the named OpenGL function. The returned pointer should be
1909 cast to the appropriate function signature.
1910  
1911 =head2 C<SDL_GL_UnloadLibrary( )>
1912  
1913 Unload the OpenGL library previously loaded by L<< C<SDL_GL_LoadLibrary( ...
1914 )>|/C<SDL_GL_LoadLibrary( ... )> >>.
1915  
1916 =head2 C<SDL_GL_ExtensionSupported( ... )>
1917  
1918 Check if an OpenGL extension is supported for the current context.
1919  
1920 This function operates on the current GL context; you must have created a
1921 context and it must be current before calling this function. Do not assume that
1922 all contexts you create will have the same set of extensions available, or that
1923 recreating an existing context will offer the same extensions again.
1924  
1925 While it's probably not a massive overhead, this function is not an O(1)
1926 operation. Check the extensions you care about after creating the GL context
1927 and save that information somewhere instead of calling the function every time
1928 you need to know.
1929  
1930 Expected parameters include:
1931  
1932 =over
1933  
1934 =item C<extension> - the name of the extension to check
1935  
1936 =back
1937  
1938 Returns C<SDL_TRUE> if the extension is supported, C<SDL_FALSE> otherwise.
1939  
1940 =head2 C<SDL_GL_ResetAttributes( )>
1941  
1942 Reset all previously set OpenGL context attributes to their default values.
1943  
1944 =head2 <SDL_GL_SetAttribute( ... )>
1945  
1946 Set an OpenGL window attribute before window creation.
1947  
1948 This function sets the OpenGL attribute C<attr> to C<value>. The requested
1949 attributes should be set before creating an OpenGL window. You should use L<<
1950 C<SDL_GL_GetAttribute( ... )>| C<SDL_GL_GetAttribute( ... )> >> to check the
1951 values after creating the OpenGL context, since the values obtained can differ
1952 from the requested ones.
1953  
1954 Expected parameters include;
1955  
1956 =over
1957  
1958 =item C<attr> - an C<SDL_GLattr> enum value specifying the OpenGL attribute to set
1959  
1960 =item C<value> - the desired value for the attribute
1961  
1962 =back
1963  
1964 Returns C<0> on success or a negative error code on failure; call
1965 C<SDL_GetError( )> for more information.
1966  
1967 =head2 C<SDL_GL_GetAttribute( ... )>
1968  
1969 Get the actual value for an attribute from the current context.
1970  
1971 Expected parameters include:
1972  
1973 =over
1974  
1975 =item C<attr> - an SDL_GLattr enum value specifying the OpenGL attribute to get
1976  
1977 =item C<value> - a pointer filled in with the current value of C<attr>
1978  
1979 =back
1980  
1981 Returns C<0> on success or a negative error code on failure; call
1982 C<SDL_GetError( )> for more information.
1983  
1984 =head2 C<SDL_GL_CreateContext( ... )>
1985  
1986 Create an OpenGL context for an OpenGL window, and make it current.
1987  
1988 Windows users new to OpenGL should note that, for historical reasons, GL
1989 functions added after OpenGL version 1.1 are not available by default. Those
1990 functions must be loaded at run-time, either with an OpenGL extension-handling
1991 library or with L<< C<SDL_GL_GetProcAddress( ... )>|/C<SDL_GL_GetProcAddress(
1992 ... )> >> and its related functions.
1993  
1994 C<SDL_GLContext> is an alias for C<void *>. It's opaque to the application.
1995  
1996 Expected parameters include:
1997  
1998 =over
1999  
2000 =item C<window> - the window to associate with the context
2001  
2002 =back
2003  
2004 Returns the OpenGL context associated with C<window> or NULL on error; call
2005 C<SDL_GetError( )> for more details.
2006  
2007 =head2 C<SDL_GL_MakeCurrent( ... )>
2008  
2009 Set up an OpenGL context for rendering into an OpenGL window.
2010  
2011 The context must have been created with a compatible window.
2012  
2013 Expected parameters include:
2014  
2015 =over
2016  
2017 =item C<window> - the window to associate with the context
2018  
2019 =item C<context> - the OpenGL context to associate with the window
2020  
2021 =back
2022  
2023 Returns C<0> on success or a negative error code on failure; call
2024 C<SDL_GetError( )> for more information.
2025  
2026 =head2 C<SDL_GL_GetCurrentWindow( )>
2027  
2028 Get the currently active OpenGL window.
2029  
2030 Returns the currently active OpenGL window on success or C<undef> on failure;
2031 call C<SDL_GetError( )> for more information.
2032  
2033 =head2 C<SDL_GL_GetCurrentContext( )>
2034  
2035 Get the currently active OpenGL context.
2036  
2037 Returns the currently active OpenGL context or C<undef> on failure; call
2038 C<SDL_GetError( )> for more information.
2039  
2040 =head2 C<SDL_GL_GetDrawableSize( ... )>
2041  
2042 Get the size of a window's underlying drawable in pixels.
2043  
2044 This returns info useful for calling C<glViewport( )>.
2045  
2046 This may differ from L<< C<SDL_GetWindowSize( ... )>|/C<SDL_GetWindowSize( ...
2047 )> >> if we're rendering to a high-DPI drawable, i.e. the window was created
2048 with C<SDL_WINDOW_ALLOW_HIGHDPI> on a platform with high-DPI support (Apple
2049 calls this "Retina"), and not disabled by the
2050 C<SDL_HINT_VIDEO_HIGHDPI_DISABLED> hint.
2051  
2052 Expected parameters include:
2053  
2054 =over
2055  
2056 =item C<window> - the window from which the drawable size should be queried
2057  
2058 =item C<w> - a pointer to variable for storing the width in pixels, may be C<undef>
2059  
2060 =item C<h> - a pointer to variable for storing the height in pixels, may be C<undef>
2061  
2062 =back
2063  
2064 =head2 C<SDL_GL_SetSwapInterval( ... )>
2065  
2066 Set the swap interval for the current OpenGL context.
2067  
2068 Some systems allow specifying C<-1> for the interval, to enable adaptive vsync.
2069 Adaptive vsync works the same as vsync, but if you've already missed the
2070 vertical retrace for a given frame, it swaps buffers immediately, which might
2071 be less jarring for the user during occasional framerate drops. If an
2072 application requests adaptive vsync and the system does not support it, this
2073 function will fail and return C<-1>. In such a case, you should probably retry
2074 the call with 1 for the interval.
2075  
2076 Adaptive vsync is implemented for some glX drivers with
2077 GLX_EXT_swap_control_tear:
2078 L<https://www.opengl.org/registry/specs/EXT/glx_swap_control_tear.txt> and for
2079 some Windows drivers with WGL_EXT_swap_control_tear:
2080 L<https://www.opengl.org/registry/specs/EXT/wgl_swap_control_tear.txt>
2081  
2082 Read more on the Khronos wiki:
2083 L<https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync>
2084  
2085 Expected parameters include:
2086  
2087 =over
2088  
2089 =item C<interval> - C<0> for immediate updates, C<1> for updates synchronized with the vertical retrace, C<-1> for adaptive vsync
2090  
2091 =back
2092  
2093 Returns C<0> on success or C<-1> if setting the swap interval is not supported;
2094 call C<SDL_GetError( )> for more information.
2095  
2096 =head2 C<SDL_GL_GetSwapInterval( )>
2097  
2098 Get the swap interval for the current OpenGL context.
2099  
2100 If the system can't determine the swap interval, or there isn't a valid current
2101 context, this function will return 0 as a safe default.
2102  
2103 Returns C<0> if there is no vertical retrace synchronization, C<1> if the
2104 buffer swap is synchronized with the vertical retrace, and C<-1> if late swaps
2105 happen immediately instead of waiting for the next retrace; call
2106 C<SDL_GetError( )> for more information.
2107  
2108 =head2 C<SDL_GL_SwapWindow( ... )>
2109  
2110 Update a window with OpenGL rendering.
2111  
2112 This is used with double-buffered OpenGL contexts, which are the default.
2113  
2114 On macOS, make sure you bind 0 to the draw framebuffer before swapping the
2115 window, otherwise nothing will happen. If you aren't using C<glBindFramebuffer(
2116 )>, this is the default and you won't have to do anything extra.
2117  
2118 Expected parameters include:
2119  
2120 =over
2121  
2122 =item C<window> - the window to change
2123  
2124 =back
2125  
2126 =head2 C<SDL_GL_DeleteContext( ... )>
2127  
2128 Delete an OpenGL context.
2129  
2130 Expected parameters include:
2131  
2132 =over
2133  
2134 =item C<context> - the OpenGL context to be deleted
2135  
2136 =back
2137  
2138 =head1 Defined values and enumerations
2139  
2140 These may be imported with their given tags.
2141  
2142 =head2 Window position flags
2143  
2144 =over
2145  
2146 =item C<SDL_WINDOWPOS_UNDEFINED>
2147  
2148 Used to indicate that you don't care what the window position is.
2149  
2150 =item C<SDL_WINDOWPOS_CENTERED>
2151  
2152 Used to indicate that the window position should be centered.
2153  
2154 =back
2155  
2156 =head2 C<SDL_WindowFlags>
2157  
2158 The flags on a window. These may be imported with the C<:windowflags> tag.
2159  
2160 =over
2161  
2162 =item C<SDL_WINDOW_FULLSCREEN> - Fullscreen window
2163  
2164 =item C<SDL_WINDOW_OPENGL> - Window usable with OpenGL context
2165  
2166 =item C<SDL_WINDOW_SHOWN> - Window is visible
2167  
2168 =item C<SDL_WINDOW_HIDDEN> - Window is not visible
2169  
2170 =item C<SDL_WINDOW_BORDERLESS> - No window decoration
2171  
2172 =item C<SDL_WINDOW_RESIZABLE> - Window can be resized
2173  
2174 =item C<SDL_WINDOW_MINIMIZED> - Window is minimized
2175  
2176 =item C<SDL_WINDOW_MAXIMIZED> - Window is maximized
2177  
2178 =item C<SDL_WINDOW_MOUSE_GRABBED> - Window has grabbed mouse input
2179  
2180 =item C<SDL_WINDOW_INPUT_FOCUS> - Window has input focus
2181  
2182 =item C<SDL_WINDOW_MOUSE_FOCUS> - Window has mouse focus
2183  
2184 =item C<SDL_WINDOW_FULLSCREEN_DESKTOP> - Fullscreen window without frame
2185  
2186 =item C<SDL_WINDOW_FOREIGN> - Window not created by SDL
2187  
2188 =item C<SDL_WINDOW_ALLOW_HIGHDPI> - Window should be created in high-DPI mode if supported.
2189  
2190 On macOS NSHighResolutionCapable must be set true in the application's
2191 Info.plist for this to have any effect.
2192  
2193 =item C<SDL_WINDOW_MOUSE_CAPTURE> - Window has mouse captured (unrelated to C<MOUSE_GRABBED>)
2194  
2195 =item C<SDL_WINDOW_ALWAYS_ON_TOP> - Window should always be above others
2196  
2197 =item C<SDL_WINDOW_SKIP_TASKBAR> - Window should not be added to the taskbar
2198  
2199 =item C<SDL_WINDOW_UTILITY> - Window should be treated as a utility window
2200  
2201 =item C<SDL_WINDOW_TOOLTIP> - Window should be treated as a tooltip
2202  
2203 =item C<SDL_WINDOW_POPUP_MENU> - Window should be treated as a popup menu
2204  
2205 =item C<SDL_WINDOW_KEYBOARD_GRABBED> - Window has grabbed keyboard input
2206  
2207 =item C<SDL_WINDOW_VULKAN> - Window usable for Vulkan surface
2208  
2209 =item C<SDL_WINDOW_METAL> - Window usable for Metal view
2210  
2211 =item C<SDL_WINDOW_INPUT_GRABBED> - Equivalent to C<SDL_WINDOW_MOUSE_GRABBED> for compatibility
2212  
2213 =back
2214  
2215 =head2 C<SDL_WindowEventID>
2216  
2217 Event subtype for window events. These may be imported with the
2218 C<:windowEventID> tag.
2219  
2220 =over
2221  
2222 =item C<SDL_WINDOWEVENT_NONE> - Never used
2223  
2224 =item C<SDL_WINDOWEVENT_SHOWN> - Window has been shown
2225  
2226 =item C<SDL_WINDOWEVENT_HIDDEN> - Window has been hidden
2227  
2228 =item C<SDL_WINDOWEVENT_EXPOSED> - Window has been exposed and should be redrawn
2229  
2230 =item C<SDL_WINDOWEVENT_MOVED> - Window has been moved to C<data1, data2>
2231  
2232 =item C<SDL_WINDOWEVENT_RESIZED> - Window has been resized to C<data1 x data2>
2233  
2234 =item C<SDL_WINDOWEVENT_SIZE_CHANGED> - The window size has changed, either as a result of an API call or through the system or user changing the window size.
2235  
2236 =item C<SDL_WINDOWEVENT_MINIMIZED> - Window has been minimized
2237  
2238 =item C<SDL_WINDOWEVENT_MAXIMIZED> - Window has been maximized
2239  
2240 =item C<SDL_WINDOWEVENT_RESTORED> - Window has been restored to normal size and position
2241  
2242 =item C<SDL_WINDOWEVENT_ENTER> - Window has gained mouse focus
2243  
2244 =item C<SDL_WINDOWEVENT_LEAVE> - Window has lost mouse focus
2245  
2246 =item C<SDL_WINDOWEVENT_FOCUS_GAINED> - Window has gained keyboard focus
2247  
2248 =item C<SDL_WINDOWEVENT_FOCUS_LOST> - Window has lost keyboard focus
2249  
2250 =item C<SDL_WINDOWEVENT_CLOSE> - The window manager requests that the window be closed
2251  
2252 =item C<SDL_WINDOWEVENT_TAKE_FOCUS> - Window is being offered a focus (should C<SetWindowInputFocus( )> on itself or a subwindow, or ignore)
2253  
2254 =item C<SDL_WINDOWEVENT_HIT_TEST> - Window had a hit test that wasn't C<SDL_HITTEST_NORMAL>.
2255  
2256 =back
2257  
2258 =head2 C<SDL_DisplayEventID>
2259  
2260 Event subtype for display events. These may be imported with the
2261 C<:displayEventID> tag.
2262  
2263 =over
2264  
2265 =item C<SDL_DISPLAYEVENT_NONE> - Never used
2266  
2267 =item C<SDL_DISPLAYEVENT_ORIENTATION> - Display orientation has changed to data1
2268  
2269 =item C<SDL_DISPLAYEVENT_CONNECTED> - Display has been added to the system
2270  
2271 =item C<SDL_DISPLAYEVENT_DISCONNECTED> - Display has been removed from the system
2272  
2273 =back
2274  
2275 =head2 C<SDL_DisplayOrientation>
2276  
2277 These may be imported with the C<:displayOrientation> tag.
2278  
2279 =over
2280  
2281 =item C<SDL_ORIENTATION_UNKNOWN> - The display orientation can't be determined
2282  
2283 =item C<SDL_ORIENTATION_LANDSCAPE> - The display is in landscape mode, with the right side up, relative to portrait mode
2284  
2285 =item C<SDL_ORIENTATION_LANDSCAPE_FLIPPED> - The display is in landscape mode, with the left side up, relative to portrait mode
2286  
2287 =item C<SDL_ORIENTATION_PORTRAIT> - The display is in portrait mode
2288  
2289 =item C<SDL_ORIENTATION_PORTRAIT_FLIPPED> - The display is in portrait mode, upside down
2290  
2291 =back
2292  
2293 =head2 C<SDL_FlashOperation>
2294  
2295 Window flash operation. These may be imported with the C<:flashOperation> tag.
2296  
2297 =over
2298  
2299 =item C<SDL_FLASH_CANCEL> - Cancel any window flash state
2300  
2301 =item C<SDL_FLASH_BRIEFLY> - Flash the window briefly to get attention
2302  
2303 =item C<SDL_FLASH_UNTIL_FOCUSED> - Flash the window until it gets focus
2304  
2305 =back
2306  
2307 =head2 C<SDL_GLattr>
2308  
2309 OpenGL configuration attributes. These may be imported with the C<:glAttr> tag.
2310  
2311 =over
2312  
2313 =item C<SDL_GL_RED_SIZE>
2314  
2315 =item C<SDL_GL_GREEN_SIZE>
2316  
2317 =item C<SDL_GL_BLUE_SIZE>
2318  
2319 =item C<SDL_GL_ALPHA_SIZE>
2320  
2321 =item C<SDL_GL_BUFFER_SIZE>
2322  
2323 =item C<SDL_GL_DOUBLEBUFFER>
2324  
2325 =item C<SDL_GL_DEPTH_SIZE>
2326  
2327 =item C<SDL_GL_STENCIL_SIZE>
2328  
2329 =item C<SDL_GL_ACCUM_RED_SIZE>
2330  
2331 =item C<SDL_GL_ACCUM_GREEN_SIZE>
2332  
2333 =item C<SDL_GL_ACCUM_BLUE_SIZE>
2334  
2335 =item C<SDL_GL_ACCUM_ALPHA_SIZE>
2336  
2337 =item C<SDL_GL_STEREO>
2338  
2339 =item C<SDL_GL_MULTISAMPLEBUFFERS>
2340  
2341 =item C<SDL_GL_MULTISAMPLESAMPLES>
2342  
2343 =item C<SDL_GL_ACCELERATED_VISUAL>
2344  
2345 =item C<SDL_GL_RETAINED_BACKING>
2346  
2347 =item C<SDL_GL_CONTEXT_MAJOR_VERSION>
2348  
2349 =item C<SDL_GL_CONTEXT_MINOR_VERSION>
2350  
2351 =item C<SDL_GL_CONTEXT_EGL>
2352  
2353 =item C<SDL_GL_CONTEXT_FLAGS>
2354  
2355 =item C<SDL_GL_CONTEXT_PROFILE_MASK>
2356  
2357 =item C<SDL_GL_SHARE_WITH_CURRENT_CONTEXT>
2358  
2359 =item C<SDL_GL_FRAMEBUFFER_SRGB_CAPABLE>
2360  
2361 =item C<SDL_GL_CONTEXT_RELEASE_BEHAVIOR>
2362  
2363 =item C<SDL_GL_CONTEXT_RESET_NOTIFICATION>
2364  
2365 =item C<SDL_GL_CONTEXT_NO_ERROR>
2366  
2367 =back
2368  
2369 =head2 C<SDL_GLprofile>
2370  
2371 These may be imported with the C<:glProfile> tag.
2372  
2373 =over
2374  
2375 =item C<SDL_GL_CONTEXT_PROFILE_CORE>
2376  
2377 =item C<SDL_GL_CONTEXT_PROFILE_COMPATIBILITY>
2378  
2379 =item C<SDL_GL_CONTEXT_PROFILE_ES>
2380  
2381 =back
2382  
2383 =head2 C<SDL_GLcontextFlag>
2384  
2385 These may be imported with the C<:glContextFlag> tag.
2386  
2387 =over
2388  
2389 =item C<SDL_GL_CONTEXT_DEBUG_FLAG>
2390  
2391 =item C<SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG>
2392  
2393 =item C<SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG>
2394  
2395 =item C<SDL_GL_CONTEXT_RESET_ISOLATION_FLAG>
2396  
2397 =back
2398  
2399 =head2 C<SDL_GLcontextReleaseFlag>
2400  
2401 These may be imported with the C<:glContextReleaseFlag> tag.
2402  
2403 =over
2404  
2405 =item C<SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE>
2406  
2407 =item C<SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH>
2408  
2409 =back
2410  
2411 =head2 C<SDL_GLContextResetNotification>
2412  
2413 These may be imported with the C<:glContextResetNotification> tag.
2414  
2415 =over
2416  
2417 =item C<SDL_GL_CONTEXT_RESET_NO_NOTIFICATION>
2418  
2419 =item C<SDL_GL_CONTEXT_RESET_LOSE_CONTEXT>
2420  
2421 =back
2422  
2423 =head2 C<SDL_HitTest>
2424  
2425 Callback used for hit-testing.
2426  
2427 Parameters to expect include:
2428  
2429 =over
2430  
2431 =item C<win> - the L<SDL2::Window> where hit-testing was set on
2432  
2433 =item C<area> - an L<SDL2::Point> which should be hit-tested
2434  
2435 =item C<data> - what was passed as C<callback_data> to L<< C<SDL_SetWindowHitTest( ... )>|/C<SDL_SetWindowHitTest( ... )> >>
2436  
2437 =back
2438  
2439 Your callback should return an C<SDL_HitTestResult> value.
2440  
2441 =head2 C<SDL_HitTestResult>
2442  
2443 Possible return values from the L<SDL_HitTest> callback.
2444  
2445 =over
2446  
2447 =item C<SDL_HITTEST_NORMAL> - Region is normal. No special properties
2448  
2449 =item C<SDL_HITTEST_DRAGGABLE> - Region can drag entire window
2450  
2451 =item C<SDL_HITTEST_RESIZE_TOPLEFT>
2452  
2453 =item C<SDL_HITTEST_RESIZE_TOP>
2454  
2455 =item C<SDL_HITTEST_RESIZE_TOPRIGHT>
2456  
2457 =item C<SDL_HITTEST_RESIZE_RIGHT>
2458  
2459 =item C<SDL_HITTEST_RESIZE_BOTTOMRIGHT>
2460  
2461 =item C<SDL_HITTEST_RESIZE_BOTTOM>
2462  
2463 =item C<SDL_HITTEST_RESIZE_BOTTOMLEFT>
2464  
2465 =item C<SDL_HITTEST_RESIZE_LEFT>
2466  
2467 =back
2468  
2469 =head1 LICENSE
2470  
2471 Copyright (C) Sanko Robinson.
2472  
2473 This library is free software; you can redistribute it and/or modify it under
2474 the terms found in the Artistic License 2. Other copyrights, terms, and
2475 conditions may apply to data transmitted through this module.
2476  
2477 =head1 AUTHOR
2478  
2479 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
2480  
2481 =begin stopwords
2482  
2483 fullscreen non-fullscreen high-dpi borderless resizable draggable taskbar
2484 tooltip popup subwindow macOS iOS NSHighResolutionCapable videomode screensaver
2485 wgl lifespan vsync glX framebuffer framerate
2486  
2487 =end stopwords
2488  
2489 =cut
2490  
2491 };
2492 1;