blib/lib/SDL2/render.pm untested

filter: Statementstmt 0.0% 0 / 214 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 240 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package SDL2::render 0.01 {
2 use SDL2::Utils;
3 use experimental 'signatures';
4 #
5 use SDL2::stdinc;
6 use SDL2::rect;
7 use SDL2::video;
8 #
9 enum SDL_RendererFlags => [
10 [ SDL_RENDERER_SOFTWARE => 0x00000001 ],
11 [ SDL_RENDERER_ACCELERATED => 0x00000002 ],
12 [ SDL_RENDERER_PRESENTVSYNC => 0x00000004 ],
13 [ SDL_RENDERER_TARGETTEXTURE => 0x00000008 ]
14 ];
15  
16 package SDL2::RendererInfo {
17 use SDL2::Utils;
18 our $TYPE = has
19 name => 'opaque', # string
20 flags => 'uint32',
21 num_texture_formats => 'uint32',
22 texture_formats => 'uint32[16]',
23 max_texture_width => 'int',
24 max_texture_height => 'int';
25 };
26 enum SDL_ScaleMode => [
27 qw[SDL_ScaleModeNearest
28 SDL_ScaleModeLinear
29 SDL_ScaleModeBest]
30 ],
31 SDL_TextureAccess => [
32 qw[ SDL_TEXTUREACCESS_STATIC
33 SDL_TEXTUREACCESS_STREAMING
34 SDL_TEXTUREACCESS_TARGET
35 ]
36 ],
37 SDL_TextureModulate => [
38 [ SDL_TEXTUREMODULATE_NONE => 0x00000000 ],
39 [ SDL_TEXTUREMODULATE_COLOR => 0x00000001 ],
40 [ SDL_TEXTUREMODULATE_ALPHA => 0x00000002 ]
41 ],
42 SDL_RendererFlip => [
43 [ SDL_FLIP_NONE => 0x00000000 ],
44 [ SDL_FLIP_HORIZONTAL => 0x00000001 ],
45 [ SDL_FLIP_VERTICAL => 0x00000002 ]
46 ];
47  
48 package SDL2::Renderer {
49 use SDL2::Utils;
50 our $TYPE = has();
51 };
52  
53 package SDL2::Texture {
54 use SDL2::Utils;
55 our $TYPE = has();
56 };
57 attach render => {
58 SDL_GetNumRenderDrivers => [ [], 'int' ],
59 SDL_GetRenderDriverInfo => [ [ 'int', 'SDL_RendererInfo' ], 'int' ],
60 SDL_CreateWindowAndRenderer => [
61 [ 'int', 'int', 'uint32', 'opaque*', 'opaque*' ],
62 'int' => sub ( $inner, $width, $height, $window_flags, $window = (), $renderer = () ) {
63  
64 #$window //= SDL2::Window->new;
65 #$renderer //= SDL2::Renderer->new;
66 my $ok = $inner->( $width, $height, $window_flags, \$window, \$renderer );
67 $_[4] = ffi->cast( 'opaque' => 'SDL_Window', $window );
68 $_[5] = ffi->cast( 'opaque' => 'SDL_Renderer', $renderer );
69  
70 #$ok == 0 ? (
71 # ffi->cast( 'opaque' => 'SDL_Window', $window ),
72 # ffi->cast( 'opaque' => 'SDL_Renderer', $renderer ),
73 # ) :
74 $ok;
75 }
76 ],
77 ,
78 SDL_CreateRenderer => [ [ 'SDL_Window', 'int', 'uint32' ], 'SDL_Renderer' ],
79 SDL_CreateSoftwareRenderer => [ ['SDL_Surface'], 'SDL_Renderer' ],
80 SDL_GetRenderer => [ ['SDL_Window'], 'SDL_Renderer' ],
81 SDL_GetRendererInfo => [ [ 'SDL_Renderer', 'SDL_RendererInfo' ], 'int' ],
82 SDL_GetRendererOutputSize => [ [ 'SDL_Renderer', 'int*', 'int*' ], 'int' ],
83 SDL_CreateTexture => [ [ 'SDL_Renderer', 'uint32', 'int', 'int', 'int' ], 'SDL_Texture' ],
84 SDL_CreateTextureFromSurface => [ [ 'SDL_Renderer', 'SDL_Surface' ], 'SDL_Texture' ],
85 SDL_QueryTexture => [ [ 'SDL_Texture', 'uint32*', 'int*', 'int*', 'int*' ], 'int' ],
86 SDL_SetTextureColorMod => [ [ 'SDL_Texture', 'uint8', 'uint8', 'uint8' ], 'int' ],
87 SDL_GetTextureColorMod => [ [ 'SDL_Texture', 'uint8*', 'uint8*', 'uint8*' ], 'int' ],
88 SDL_SetTextureAlphaMod => [ [ 'SDL_Texture', 'uint8' ], 'int' ],
89 SDL_GetTextureAlphaMod => [ [ 'SDL_Texture', 'uint8*' ], 'int' ],
90 SDL_SetTextureBlendMode => [ [ 'SDL_Texture', 'SDL_BlendMode' ], 'int' ],
91 SDL_GetTextureBlendMode => [ [ 'SDL_Texture', 'int*' ], 'int' ],
92 SDL_UpdateTexture => [ [ 'SDL_Texture', 'SDL_Rect', 'opaque*', 'int' ], 'int' ],
93 SDL_UpdateYUVTexture => [
94 [ 'SDL_Texture', 'SDL_Rect', 'uint8*', 'int', 'uint8*', 'int', 'uint8*', 'int' ], 'int'
95 ],
96 SDL_UpdateNVTexture =>
97 [ [ 'SDL_Texture', 'SDL_Rect', 'uint8*', 'int', 'uint8*', 'int' ], 'int' ],
98 SDL_LockTexture => [ [ 'SDL_Texture', 'SDL_Rect', 'opaque*' ], 'int' ],
99 SDL_LockTextureToSurface => [ [ 'SDL_Texture', 'SDL_Rect', 'SDL_Surface' ], 'int' ],
100 SDL_UnlockTexture => [ ['SDL_Texture'] ],
101 SDL_RenderTargetSupported => [ ['SDL_Renderer'], 'bool' ],
102 SDL_SetRenderTarget => [ [ 'SDL_Renderer', 'SDL_Texture' ], 'int' ],
103 SDL_GetRenderTarget => [ ['SDL_Renderer'], 'SDL_Texture' ],
104 SDL_RenderSetLogicalSize => [ [ 'SDL_Renderer', 'int', 'int' ], 'int' ],
105 SDL_RenderGetLogicalSize => [ [ 'SDL_Renderer', 'int*', 'int*' ], 'int' ],
106 SDL_RenderSetIntegerScale => [ [ 'SDL_Renderer', 'bool' ], 'int' ],
107 SDL_RenderGetIntegerScale => [ ['SDL_Renderer'], 'bool' ],
108 SDL_RenderSetViewport => [ [ 'SDL_Renderer', 'SDL_Rect' ], 'int' ],
109 SDL_RenderGetViewport => [ [ 'SDL_Renderer', 'SDL_Rect' ], 'int' ],
110 SDL_RenderSetClipRect => [ [ 'SDL_Renderer', 'SDL_Rect' ], 'int' ],
111 SDL_RenderGetClipRect => [ [ 'SDL_Renderer', 'SDL_Rect' ] ],
112 SDL_RenderIsClipEnabled => [ ['SDL_Renderer'], 'bool' ],
113 SDL_RenderSetScale => [ [ 'SDL_Renderer', 'float', 'float' ], 'int' ],
114 SDL_RenderGetScale => [ [ 'SDL_Renderer', 'float*', 'float*' ], ],
115 SDL_SetRenderDrawColor => [ [ 'SDL_Renderer', 'uint8', 'uint8', 'uint8', 'uint8' ], 'int' ],
116 SDL_GetRenderDrawColor =>
117 [ [ 'SDL_Renderer', 'uint8*', 'uint8*', 'uint8*', 'uint8*' ], 'int' ],
118 SDL_SetRenderDrawBlendMode => [ [ 'SDL_Renderer', 'SDL_BlendMode' ], 'int' ],
119 SDL_GetRenderDrawBlendMode => [ [ 'SDL_Renderer', 'int*' ], 'int' ],
120 SDL_RenderClear => [ ['SDL_Renderer'], 'int' ],
121 SDL_RenderDrawPoint => [ [ 'SDL_Renderer', 'int', 'int' ], 'int' ],
122 SDL_RenderDrawPoints => [
123 [ 'SDL_Renderer', 'PointList_t', 'int' ],
124 'int' => sub ( $inner, $renderer, @points ) {
125  
126 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
127 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
128 $inner->(
129 $renderer,
130 $SDL2::Point::LIST->create(
131 [ map { ref $_ eq 'HASH' ? $_ : { x => $_->x, y => $_->y } } @points ]
132 ),
133 scalar @points
134 );
135 }
136 ],
137 SDL_RenderDrawLine => [ [ 'SDL_Renderer', 'int', 'int', 'int', 'int' ], 'int' ],
138 SDL_RenderDrawLines => [
139 [ 'SDL_Renderer', 'PointList_t', 'int' ],
140 'int' => sub ( $inner, $renderer, @points ) {
141  
142 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
143 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
144 $inner->(
145 $renderer,
146 $SDL2::Point::LIST->create(
147 [ map { ref $_ eq 'HASH' ? $_ : { x => $_->x, y => $_->y } } @points ]
148 ),
149 scalar @points
150 );
151 }
152 ],
153 SDL_RenderDrawRect => [ [ 'SDL_Renderer', 'SDL_Rect' ], 'int' ],
154 SDL_RenderDrawRects => [
155 [ 'SDL_Renderer', 'RectList_t', 'int' ],
156 'int' => sub ( $inner, $renderer, @rects ) {
157  
158 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
159 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
160 $inner->(
161 $renderer,
162 $SDL2::Rect::LIST->create(
163 [ map {
164 ref $_ eq 'HASH' ? $_ :
165 { x => $_->x, y => $_->y, w => $_->w, h => $_->h }
166 } @rects
167 ]
168 ),
169 scalar @rects
170 );
171 }
172 ],
173 SDL_RenderFillRect => [ [ 'SDL_Renderer', 'SDL_Rect' ], 'int' ],
174 SDL_RenderFillRects => [
175 [ 'SDL_Renderer', 'RectList_t', 'int' ],
176 'int' => sub ( $inner, $renderer, @rects ) {
177  
178 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
179 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
180 $inner->(
181 $renderer,
182 $SDL2::Rect::LIST->create(
183 [ map {
184 ref $_ eq 'HASH' ? $_ :
185 { x => $_->x, y => $_->y, w => $_->w, h => $_->h }
186 } @rects
187 ]
188 ),
189 scalar @rects
190 );
191 }
192 ],
193 SDL_RenderCopy => [ [ 'SDL_Renderer', 'SDL_Texture', 'SDL_Rect', 'SDL_Rect' ], 'int' ],
194  
195 # XXX - I do not have an example for this function in docs
196 SDL_RenderCopyEx => [
197 [ 'SDL_Renderer', 'SDL_Texture', 'SDL_Rect', 'SDL_Rect',
198 'double', 'SDL_Point', 'SDL_RendererFlip'
199 ],
200 'int'
201 ],
202 SDL_RenderDrawPointF => [ [ 'SDL_Renderer', 'float', 'float' ], 'int' ],
203 SDL_RenderDrawPointsF => [
204 [ 'SDL_Renderer', 'FPointList_t', 'int' ],
205 'int' => sub ( $inner, $renderer, @points ) {
206  
207 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
208 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
209 $inner->(
210 $renderer,
211 $SDL2::Point::LIST->create(
212 [ map { ref $_ eq 'HASH' ? $_ : { x => $_->x, y => $_->y } } @points ]
213 ),
214 scalar @points
215 );
216 }
217 ],
218 SDL_RenderDrawLineF => [ [ 'SDL_Renderer', 'float', 'float', 'float', 'float' ], 'int' ],
219 SDL_RenderDrawLinesF => [
220 [ 'SDL_Renderer', 'FPointList_t', 'int' ],
221 'int' => sub ( $inner, $renderer, @points ) {
222  
223 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
224 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
225 $inner->(
226 $renderer,
227 $SDL2::FPoint::LIST->create(
228 [ map { ref $_ eq 'HASH' ? $_ : { x => $_->x, y => $_->y } } @points ]
229 ),
230 scalar @points
231 );
232 }
233 ],
234 SDL_RenderDrawRectF => [
235 [ 'SDL_Renderer', 'FRectList_t', 'int' ],
236 'int' => sub ( $inner, $renderer, @rects ) {
237  
238 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
239 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
240 $inner->(
241 $renderer,
242 $SDL2::FRect::LIST->create(
243 [ map {
244 ref $_ eq 'HASH' ? $_ :
245 { x => $_->x, y => $_->y, w => $_->w, h => $_->h }
246 } @rects
247 ]
248 ),
249 scalar @rects
250 );
251 }
252 ],
253 SDL_RenderDrawRectsF => [
254 [ 'SDL_Renderer', 'FRectList_t', 'int' ],
255 'int' => sub ( $inner, $renderer, @rects ) {
256  
257 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
258 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
259 $inner->(
260 $renderer,
261 $SDL2::FRect::LIST->create(
262 [ map {
263 ref $_ eq 'HASH' ? $_ :
264 { x => $_->x, y => $_->y, w => $_->w, h => $_->h }
265 } @rects
266 ]
267 ),
268 scalar @rects
269 );
270 }
271 ],
272 SDL_RenderFillRectsF => [
273 [ 'SDL_Renderer', 'FRectList_t', 'int' ],
274 'int' => sub ( $inner, $renderer, @rects ) {
275  
276 # XXX - This is a workaround for FFI::C::Array not being able to accept a list of objects
277 # XXX - I can rethink this map when https://github.com/PerlFFI/FFI-C/issues/53 is resolved
278 $inner->(
279 $renderer,
280 $SDL2::FRect::LIST->create(
281 [ map {
282 ref $_ eq 'HASH' ? $_ :
283 { x => $_->x, y => $_->y, w => $_->w, h => $_->h }
284 } @rects
285 ]
286 ),
287 scalar @rects
288 );
289 }
290 ],
291  
292 # XXX - I do not have an example for this function in docs
293 SDL_RenderCopyF => [ [ 'SDL_Renderer', 'SDL_Texture', 'SDL_Rect', 'SDL_FRect' ], 'int' ],
294  
295 # XXX - I do not have an example for this function in docs
296 SDL_RenderCopyExF => [
297 [ 'SDL_Renderer', 'SDL_Texture', 'SDL_Rect', 'SDL_FRect',
298 'double', 'SDL_FPoint', 'SDL_RendererFlip'
299 ],
300 'int'
301 ],
302 SDL_RenderReadPixels =>
303 [ [ 'SDL_Renderer', 'SDL_Rect', 'uint32', 'opaque', 'int' ], 'int' ],
304 SDL_RenderPresent => [ ['SDL_Renderer'] ],
305 SDL_DestroyTexture => [ ['SDL_Texture'] ],
306 SDL_DestroyRenderer => [ ['SDL_Renderer'] ],
307 SDL_RenderFlush => [ ['SDL_Renderer'], 'int' ],
308 SDL_GL_BindTexture => [ [ 'SDL_Texture', 'float*', 'float*' ], 'int' ],
309 SDL_GL_UnbindTexture => [ ['SDL_Texture'], 'int' ],
310 SDL_RenderGetMetalLayer => [ ['SDL_Renderer'], 'opaque' ],
311 SDL_RenderGetMetalCommandEncoder => [ ['SDL_Renderer'], 'opaque' ]
312 };
313  
314 =encoding utf-8
315  
316 =head1 NAME
317  
318 SDL2::render - SDL 2D Rendering Functions
319  
320 =head1 SYNOPSIS
321  
322 use SDL2 qw[:render];
323  
324 =head1 DESCRIPTION
325  
326 Header file for SDL 2D rendering functions.
327  
328 This API supports the following features:
329  
330 =over
331  
332 =item * single pixel points
333  
334 =item * single pixel lines
335  
336 =item * filled rectangles
337  
338 =item * texture images
339  
340 =back
341  
342 The primitives may be drawn in opaque, blended, or additive modes.
343  
344 The texture images may be drawn in opaque, blended, or additive modes. They can
345 have an additional color tint or alpha modulation applied to them, and may also
346 be stretched with linear interpolation.
347  
348 This API is designed to accelerate simple 2D operations. You may want more
349 functionality such as polygons and particle effects and in that case you should
350 use SDL's OpenGL/Direct3D support or one of the many good 3D engines.
351  
352 These functions must be called from the main thread. See this bug for details:
353 L<http://bugzilla.libsdl.org/show_bug.cgi?id=1995>
354  
355 =head1 Functions
356  
357 These functions may be imported by name or with the C<:render> tag.
358  
359  
360 =head2 C<SDL_GetNumRenderDrivers( )>
361  
362 Get the number of 2D rendering drivers available for the current display.
363  
364 my $drivers = SDL_GetNumRenderDrivers( );
365  
366 A render driver is a set of code that handles rendering and texture management
367 on a particular display. Normally there is only one, but some drivers may have
368 several available with different capabilities.
369  
370 There may be none if SDL was compiled without render support.
371  
372 Returns a number >= 0 on success or a negative error code on failure; call
373 C<SDL_GetError( )> for more information.
374  
375 =head2 C<SDL_GetRenderDriverInfo( ... )>
376  
377 Get info about a specific 2D rendering driver for the current display.
378  
379 my $info = !SDL_GetRendererDriverInfo( );
380  
381 Expected parameters include:
382  
383 =over
384  
385 =item C<index> - the index of the driver to query information about
386  
387 =back
388  
389 Returns an L<SDL2::RendererInfo> structure on success or a negative error code
390 on failure; call C<SDL_GetError( )> for more information.
391  
392 =head2 C<SDL_CreateWindowAndRenderer( ... )>
393  
394 Create a window and default renderer.
395  
396 my ($window, $renderer) = SDL_CreateWindowAndRenderer(640, 480, 0);
397  
398 Expected parameters include:
399  
400 =over
401  
402 =item C<width> - the width of the window
403  
404 =item C<height> - the height of the window
405  
406 =item C<window_flags> - the flags used to create the window (see C<SDL_CreateWindow( ... )>)
407  
408 =back
409  
410 Returns a L<SDL2::Window> and L<SDL2::Renderer> objects on success, or C<-1> on
411 error; call C<SDL_GetError( )> for more information.
412  
413 =head2 C<SDL_CreateRenderer( ... )>
414  
415 Create a 2D rendering context for a window.
416  
417 my $renderer = SDL_CreateRenderer( $window, -1, 0);
418  
419 Expected parameters include:
420  
421 =over
422  
423 =item C<window> - the window where rendering is displayed
424  
425 =item C<index> - the index of the rendering driver to initialize, or C<-1> to initialize the first one supporting the requested flags
426  
427 =item C<flags> - C<0>, or one or more C<SDL_RendererFlags> OR'd together
428  
429 =back
430  
431 Returns a valid rendering context or undefined if there was an error; call
432 C<SDL_GetError( )> for more information.
433  
434 =head2 C<SDL_CreateSoftwareRenderer( ... )>
435  
436 Create a 2D software rendering context for a surface.
437  
438 my $renderer = SDL_CreateSoftwareRenderer( $surface );
439  
440 Two other API which can be used to create SDL_Renderer:
441  
442 L<< C<SDL_CreateRenderer( ... )>|/C<SDL_CreateRenderer( ... )> >> and L<<
443 C<SDL_CreateWindowAndRenderer( ... )>|/C<SDL_CreateWindowAndRenderer( ... )>
444 >>. These can B<also> create a software renderer, but they are intended to be
445 used with an L<SDL2::Window> as the final destination and not an
446 L<SDL2::Surface>.
447  
448 Expected parameters include:
449  
450 =over
451  
452 =item C<surface> - the L<SDL2::Surface> structure representing the surface where rendering is done
453  
454 =back
455  
456 Returns a valid rendering context or undef if there was an error; call
457 C<SDL_GetError( )> for more information.
458  
459 =head2 C<SDL_GetRenderer( ... )>
460  
461 Get the renderer associated with a window.
462  
463 my $renderer = SDL_GetRenderer( $window );
464  
465 Expected parameters include:
466  
467 =over
468  
469 =item C<window> - the window to query
470  
471 =back
472  
473 Returns the rendering context on success or undef on failure; call
474 C<SDL_GetError( )> for more information.
475  
476 =head2 C<SDL_GetRendererInfo( ... )>
477  
478 Get information about a rendering context.
479  
480 my $info = !SDL_GetRendererInfo( $renderer );
481  
482 Expected parameters include:
483  
484 =over
485  
486 =item C<renderer> - the rendering context
487  
488 =back
489  
490 Returns an L<SDL2::RendererInfo> structure on success or a negative error code
491 on failure; call C<SDL_GetError( )> for more information.
492  
493 =head2 C<SDL_GetRendererOutputSize( ... )>
494  
495 Get the output size in pixels of a rendering context.
496  
497 my ($w, $h) = SDL_GetRendererOutputSize( $renderer );
498  
499 Due to high-dpi displays, you might end up with a rendering context that has
500 more pixels than the window that contains it, so use this instead of
501 C<SDL_GetWindowSize( ... )> to decide how much drawing area you have.
502  
503 Expected parameters include:
504  
505 =over
506  
507 =item C<renderer> - the rendering context
508  
509 =back
510  
511 Returns the width and height on success or a negative error code on failure;
512 call C<SDL_GetError( )> for more information.
513  
514 =head2 C<SDL_CreateTexture( ... )>
515  
516 Create a texture for a rendering context.
517  
518 my $texture = SDL_CreateTexture( $renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, 1024, 768);
519  
520 =for TODO: https://gist.github.com/malja/2193bd656fe50c203f264ce554919976
521  
522 You can set the texture scaling method by setting
523 C<SDL_HINT_RENDER_SCALE_QUALITY> before creating the texture.
524  
525 Expected parameters include:
526  
527 =over
528  
529 =item C<renderer> - the rendering context
530  
531 =item C<format> - one of the enumerated values in C<:pixelFormatEnum>
532  
533 =item C<access> - one of the enumerated values in C<:textureAccess>
534  
535 =item C<w> - the width of the texture in pixels
536  
537 =item C<h> - the height of the texture in pixels
538  
539 =back
540  
541 Returns a pointer to the created texture or undefined if no rendering context
542 was active, the format was unsupported, or the width or height were out of
543 range; call C<SDL_GetError( )> for more information.
544  
545 =head2 C<SDL_CreateTextureFromSurface( ... )>
546  
547 Create a texture from an existing surface.
548  
549 use Config;
550 my ($rmask, $gmask, $bmask, $amask) =
551 $Config{byteorder} == 4321 ? (0xff000000,0x00ff0000,0x0000ff00,0x000000ff) :
552 (0x000000ff,0x0000ff00,0x00ff0000,0xff000000);
553 my $surface = SDL_CreateRGBSurface( 0, 640, 480, 32, $rmask, $gmask, $bmask, $amask );
554 my $texture = SDL_CreateTextureFromSurface( $renderer, $surface );
555  
556 The surface is not modified or freed by this function.
557  
558 The SDL_TextureAccess hint for the created texture is
559 C<SDL_TEXTUREACCESS_STATIC>.
560  
561 The pixel format of the created texture may be different from the pixel format
562 of the surface. Use L<< C<SDL_QueryTexture( ... )>|/C<SDL_QueryTexture( ... )>
563 >> to query the pixel format of the texture.
564  
565 Expected parameters include:
566  
567 =over
568  
569 =item C<renderer> - the rendering context
570  
571 =item C<surface> - the L<SDL2::Surface> structure containing pixel data used to fill the texture
572  
573 =back
574  
575 Returns the created texture or undef on failure; call C<SDL_GetError( )> for
576 more information.
577  
578 =head2 C<SDL_QueryTexture( ... )>
579  
580 Query the attributes of a texture.
581  
582 my ( $format, $access, $w, $h ) = SDL_QueryTexture( $texture );
583  
584 Expected parameters include:
585  
586 =over
587  
588 =item C<texture> - the texture to query
589  
590 =back
591  
592 Returns the following on success...
593  
594 =over
595  
596 =item C<format> - a pointer filled in with the raw format of the texture; the actual format may differ, but pixel transfers will use this format (one of the C<SDL_PixelFormatEnum> values)
597  
598 =item C<access> - a pointer filled in with the actual access to the texture (one of the L<< C<SDL_TextureAccess>|/C<SDL_TextureAccess> >> values)
599  
600 =item C<w> - a pointer filled in with the width of the texture in pixels
601  
602 =item C<h> - a pointer filled in with the height of the texture in pixels
603  
604 =back
605  
606 ...or a negative error code on failure; call C<SDL_GetError( )> for more
607 information.
608  
609 =head2 C<SDL_SetTextureColorMod( ... )>
610  
611 Set an additional color value multiplied into render copy operations.
612  
613 my $ok = !SDL_SetTextureColorMod( $texture, 64, 64, 64 );
614  
615 When this texture is rendered, during the copy operation each source color
616 channel is modulated by the appropriate color value according to the following
617 formula:
618  
619 srcC = srcC * (color / 255)
620  
621 Color modulation is not always supported by the renderer; it will return C<-1>
622 if color modulation is not supported.
623  
624 Expected parameters include:
625  
626 =over
627  
628 =item C<texture> - the texture to update
629  
630 =item C<r> - the red color value multiplied into copy operations
631  
632 =item C<g> - the green color value multiplied into copy operations
633  
634 =item C<b> - the blue color value multiplied into copy operations
635  
636 =back
637  
638 Returns C<0> on success or a negative error code on failure; call
639 C<SDL_GetError( )> for more information.
640  
641 =head2 C<SDL_GetTextureColorMod( ... )>
642  
643 Get the additional color value multiplied into render copy operations.
644  
645 my ( $r, $g, $b ) = SDL_GetTextureColorMod( $texture );
646  
647 Expected parameters include:
648  
649 =over
650  
651 =item C<texture> - the texture to query
652  
653 =back
654  
655 Returns the current red, green, and blue color values on success or a negative
656 error code on failure; call C<SDL_GetError( )> for more information.
657  
658 =head2 C<SDL_SetTextureAlphaMod( ... )>
659  
660 Set an additional alpha value multiplied into render copy operations.
661  
662 SDL_SetTextureAlphaMod( $texture, 100 );
663  
664 When this texture is rendered, during the copy operation the source alpha
665  
666 value is modulated by this alpha value according to the following formula:
667  
668 srcA = srcA * (alpha / 255)
669  
670 Alpha modulation is not always supported by the renderer; it will return C<-1>
671 if alpha modulation is not supported.
672  
673 Expected parameters include:
674  
675 =over
676  
677 =item C<texture> - the texture to update
678  
679 =item C<alpha> - the source alpha value multiplied into copy operations
680  
681 =back
682  
683 Returns C<0> on success or a negative error code on failure; call
684 C<SDL_GetError( )> for more information.
685  
686 =head2 C<SDL_GetTextureAlphaMod( ... )>
687  
688 Get the additional alpha value multiplied into render copy operations.
689  
690 my $alpha = SDL_GetTextureAlphaMod( $texture );
691  
692 Expected parameters include:
693  
694 =over
695  
696 =item C<texture> - the texture to query
697  
698 =back
699  
700 Returns the current alpha value on success or a negative error code on failure;
701 call C<SDL_GetError( )> for more information.
702  
703 =head2 C<SDL_SetTextureBlendMode( ... )>
704  
705 Set the blend mode for a texture, used by L<< C<SDL_RenderCopy( ...
706 )>|/C<SDL_RenderCopy( ... )> >>.
707  
708 If the blend mode is not supported, the closest supported mode is chosen and
709 this function returns C<-1>.
710  
711 Expected parameters include:
712  
713 =over
714  
715 =item C<texture> - the texture to update
716  
717 =item C<blendMode> - the C<SDL_BlendMode> to use for texture blending
718  
719 =back
720  
721 Returns 0 on success or a negative error code on failure; call C<SDL_GetError(
722 )> for more information.
723  
724 =head2 C<SDL_GetTextureBlendMode( ... )>
725  
726 Get the blend mode used for texture copy operations.
727  
728 SDL_GetTextureBlendMode( $texture, SDL_BLENDMODE_ADD );
729  
730 Expected parameters include:
731  
732 =over
733  
734 =item C<texture> - the texture to query
735  
736 =back
737  
738 Returns the current C<:blendMode> on success or a negative error code on
739 failure; call C<SDL_GetError( )> for more information.
740  
741 =head2 C<SDL_SetTextureScaleMode( ... )>
742  
743 Set the scale mode used for texture scale operations.
744  
745 SDL_SetTextureScaleMode( $texture, $scaleMode );
746  
747 If the scale mode is not supported, the closest supported mode is chosen.
748  
749 Expected parameters include:
750  
751 =over
752  
753 =item C<texture> - The texture to update.
754  
755 =item C<scaleMode> - the SDL_ScaleMode to use for texture scaling.
756  
757 =back
758  
759 Returns C<0> on success, or C<-1> if the texture is not valid.
760  
761 =head2 C<SDL_GetTextureScaleMode( ... )>
762  
763 Get the scale mode used for texture scale operations.
764  
765 my $ok = SDL_GetTextureScaleMode( $texture );
766  
767 Expected parameters include:
768  
769 =over
770  
771 =item C<texture> - the texture to query.
772  
773 =back
774  
775 Returns the current scale mode on success, or C<-1> if the texture is not
776 valid.
777  
778 =head2 C<SDL_UpdateTexture( ... )>
779  
780 Update the given texture rectangle with new pixel data.
781  
782 my $rect = SDL2::Rect->new( { x => 0, y => ..., w => $surface->w, h => $surface->h } );
783 SDL_UpdateTexture( $texture, $rect, $surface->pixels, $surface->pitch );
784  
785 The pixel data must be in the pixel format of the texture. Use L<<
786 C<SDL_QueryTexture( ... )>|/C<SDL_QueryTexture( ... )> >> to query the pixel
787 format of the texture.
788  
789 This is a fairly slow function, intended for use with static textures that do
790 not change often.
791  
792 If the texture is intended to be updated often, it is preferred to create the
793 texture as streaming and use the locking functions referenced below. While this
794 function will work with streaming textures, for optimization reasons you may
795 not get the pixels back if you lock the texture afterward.
796  
797 Expected parameters include:
798  
799 =over
800  
801 =item C<texture> - the texture to update
802  
803 =item C<rect> - an L<SDL2::Rect> structure representing the area to update, or undef to update the entire texture
804  
805 =item C<pixels> - the raw pixel data in the format of the texture
806  
807 =item C<pitch> - the number of bytes in a row of pixel data, including padding between lines
808  
809 =back
810  
811 Returns C<0> on success or a negative error code on failure; call
812 C<SDL_GetError( )> for more information.
813  
814 =head2 C<SDL_UpdateYUVTexture( ... )>
815  
816 Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
817  
818 SDL_UpdateYUVTexture( $texture, $rect, $yPlane, $yPitch, $uPlane, $uPitch, $vPlane, $vPitch );
819  
820 You can use L<< C<SDL_UpdateTexture( ... )>|/C<SDL_UpdateTexture( ... )> >> as
821 long as your pixel data is a contiguous block of Y and U/V planes in the proper
822 order, but this function is available if your pixel data is not contiguous.
823  
824 Expected parameters include:
825  
826 =over
827  
828 =item C<texture> - the texture to update
829  
830 =item C<rect> - a pointer to the rectangle of pixels to update, or undef to update the entire texture
831  
832 =item C<Yplane> - the raw pixel data for the Y plane
833  
834 =item C<Ypitch> - the number of bytes between rows of pixel data for the Y plane
835  
836 =item C<Uplane> - the raw pixel data for the U plane
837  
838 =item C<Upitch> - the number of bytes between rows of pixel data for the U plane
839  
840 =item C<Vplane> - the raw pixel data for the V plane
841  
842 =item C<Vpitch> - the number of bytes between rows of pixel data for the V plane
843  
844 =back
845  
846 Returns C<0> on success or -1 if the texture is not valid; call C<SDL_GetError(
847 )> for more information.
848  
849 =head2 C<SDL_UpdateNVTexture( ... )>
850  
851 Update a rectangle within a planar NV12 or NV21 texture with new pixels.
852  
853 SDL_UpdateNVTexture( $texture, $rect, $yPlane, $yPitch, $uPlane, $uPitch );
854  
855 You can use L<< C<SDL_UpdateTexture( ... )>|/C<SDL_UpdateTexture( ... )> >> as
856 long as your pixel data is a contiguous block of NV12/21 planes in the proper
857 order, but this function is available if your pixel data is not contiguous.
858  
859 Expected parameters include:
860  
861 =over
862  
863 =item C<texture> - the texture to update
864  
865 =item C<rect> - a pointer to the rectangle of pixels to update, or undef to update the entire texture.
866  
867 =item C<Yplane> - the raw pixel data for the Y plane.
868  
869 =item C<Ypitch> - the number of bytes between rows of pixel data for the Y plane.
870  
871 =item C<UVplane> - the raw pixel data for the UV plane.
872  
873 =item C<UVpitch> - the number of bytes between rows of pixel data for the UV plane.
874  
875 =back
876  
877 Returns C<0> on success, or C<-1> if the texture is not valid.
878  
879 =head2 C<SDL_LockTexture( ... )>
880  
881 Lock a portion of the texture for B<write-only> pixel access.
882  
883 SDL_LockTexture( $texture, $rect, $pixels, $pitch );
884  
885 As an optimization, the pixels made available for editing don't necessarily
886 contain the old texture data. This is a write-only operation, and if you need
887 to keep a copy of the texture data you should do that at the application level.
888  
889 You must use L<< C<SDL_UpdateTexture( ... )>|/C<SDL_UpdateTexture( ... )> >> to
890 unlock the pixels and apply any changes.
891  
892 Expected parameters include:
893  
894 =over
895  
896 =item C<texture> - the texture to lock for access, which was created with C<SDL_TEXTUREACCESS_STREAMING>
897  
898 =item C<rect> - an L<SDL2::Rect> structure representing the area to lock for access; undef to lock the entire texture
899  
900 =item C<pixels> - this is filled in with a pointer to the locked pixels, appropriately offset by the locked area
901  
902 =item C<pitch> - this is filled in with the pitch of the locked pixels; the pitch is the length of one row in bytes
903  
904 =back
905  
906 Returns 0 on success or a negative error code if the texture is not valid or
907 was not created with C<SDL_TEXTUREACCESS_STREAMING>; call C<SDL_GetError( )>
908 for more information.
909  
910 =head2 C<SDL_LockTextureToSurface( ... )>
911  
912 Lock a portion of the texture for B<write-only> pixel access, and expose it as
913 a SDL surface.
914  
915 my $surface = SDL_LockTextureSurface( $texture, $rect );
916  
917 Besides providing an L<SDL2::Surface> instead of raw pixel data, this function
918 operates like L<SDL2::LockTexture>.
919  
920 As an optimization, the pixels made available for editing don't necessarily
921 contain the old texture data. This is a write-only operation, and if you need
922 to keep a copy of the texture data you should do that at the application level.
923  
924 You must use L<< C<SDL_UnlockTexture( ... )>|/C<SDL_UnlockTexture( ... )> >> to
925 unlock the pixels and apply any changes.
926  
927 The returned surface is freed internally after calling L<< C<SDL_UnlockTexture(
928 ... )>|/C<SDL_UnlockTexture( ... )> >> or L<< C<SDL_DestroyTexture( ...
929 )>|/C<SDL_DestroyTexture( ... )> >>. The caller should not free it.
930  
931 Expected parameters include:
932  
933 =over
934  
935 =item C<texture> - the texture to lock for access, which was created with C<SDL_TEXTUREACCESS_STREAMING>
936  
937 =item C<rect> - a pointer to the rectangle to lock for access. If the rect is undef, the entire texture will be locked
938  
939 =back
940  
941 Returns the L<SDL2::Surface> structure on success, or C<-1> if the texture is
942 not valid or was not created with C<SDL_TEXTUREACCESS_STREAMING>.
943  
944 =head2 C<SDL_UnlockTexture( ... )>
945  
946 Unlock a texture, uploading the changes to video memory, if needed.
947  
948 SDL_UnlockTexture( $texture );
949  
950 B<Warning>: Please note that L<< C<SDL_LockTexture( ... )>|/C<SDL_LockTexture(
951 ... )> >> is intended to be write-only; it will not guarantee the previous
952 contents of the texture will be provided. You must fully initialize any area of
953 a texture that you lock before unlocking it, as the pixels might otherwise be
954 uninitialized memory.
955  
956 Which is to say: locking and immediately unlocking a texture can result in
957 corrupted textures, depending on the renderer in use.
958  
959 Expected parameters include:
960  
961 =over
962  
963 =item C<texture> - a texture locked by L<< C<SDL_LockTexture( ... )>|/C<SDL_LockTexture( ... )> >>
964  
965 =back
966  
967 =head2 C<SDL_RenderTargetSupported( ... )>
968  
969 Determine whether a renderer supports the use of render targets.
970  
971 my $bool = SDL_RenderTargetSupported( $renderer );
972  
973 Expected parameters include:
974  
975 =over
976  
977 =item C<renderer> - the renderer that will be checked
978  
979 =back
980  
981 Returns true if supported or false if not.
982  
983 =head2 C<SDL_SetRenderTarget( ... )>
984  
985 Set a texture as the current rendering target.
986  
987 SDL_SetRenderTarget( $renderer, $texture );
988  
989 Before using this function, you should check the C<SDL_RENDERER_TARGETTEXTURE>
990 bit in the flags of L<SDL2::RendererInfo> to see if render targets are
991 supported.
992  
993 The default render target is the window for which the renderer was created. To
994 stop rendering to a texture and render to the window again, call this function
995 with a undefined C<texture>.
996  
997 Expected parameters include:
998  
999 =over
1000  
1001 =item C<renderer> - the rendering context
1002  
1003 =item C<texture> - the targeted texture, which must be created with the C<SDL_TEXTUREACCESS_TARGET> flag, or undef to render to the window instead of a texture.
1004  
1005 =back
1006  
1007 Returns C<0> on success or a negative error code on failure; call
1008 C<SDL_GetError( )> for more information.
1009  
1010 =head2 C<SDL_GetRenderTarget( ... )>
1011  
1012 Get the current render target.
1013  
1014 my $texture = SDL_GetRenderTarget( $renderer );
1015  
1016 The default render target is the window for which the renderer was created, and
1017 is reported an undefined value here.
1018  
1019 Expected parameters include:
1020  
1021 =over
1022  
1023 =item C<renderer> - the rendering context
1024  
1025 =back
1026  
1027 Returns the current render target or undef for the default render target.
1028  
1029 =head2 C<SDL_RenderSetLogicalSize( ... )>
1030  
1031 Set a device independent resolution for rendering.
1032  
1033 SDL_RenderSetLogicalSize( $renderer, 100, 100 );
1034  
1035 This function uses the viewport and scaling functionality to allow a fixed
1036 logical resolution for rendering, regardless of the actual output resolution.
1037 If the actual output resolution doesn't have the same aspect ratio the output
1038 rendering will be centered within the output display.
1039  
1040 If the output display is a window, mouse and touch events in the window will be
1041 filtered and scaled so they seem to arrive within the logical resolution.
1042  
1043 If this function results in scaling or subpixel drawing by the rendering
1044 backend, it will be handled using the appropriate quality hints.
1045  
1046 Expected parameters include:
1047  
1048 =over
1049  
1050 =item C<renderer> - the renderer for which resolution should be set
1051  
1052 =item C<w> - the width of the logical resolution
1053  
1054 =item C<h> - the height of the logical resolution
1055  
1056 =back
1057  
1058 Returns C<0> on success or a negative error code on failure; call
1059 C<SDL_GetError( )> for more information.
1060  
1061 =head2 C<SDL_RenderGetLogicalSize( ... )>
1062  
1063 Get device independent resolution for rendering.
1064  
1065 my ($w, $h) = SDL_RenderGetLogicalSize( $renderer );
1066  
1067 This may return C<0> for C<w> and C<h> if the L<SDL2::Renderer> has never had
1068 its logical size set by L<< C<SDL_RenderSetLogicalSize( ...
1069 )>|/C<SDL_RenderSetLogicalSize( ... )> >> and never had a render target set.
1070  
1071 Expected parameters include:
1072  
1073 =over
1074  
1075 =item C<renderer> - a rendering context
1076  
1077 =back
1078  
1079 Returns the width and height.
1080  
1081 =head2 C<SDL_RenderSetIntegerScale( ... )>
1082  
1083 Set whether to force integer scales for resolution-independent rendering.
1084  
1085 SDL_RenderSetIntegerScale( $renderer, 1 );
1086  
1087 This function restricts the logical viewport to integer values - that is, when
1088 a resolution is between two multiples of a logical size, the viewport size is
1089 rounded down to the lower multiple.
1090  
1091 Expected parameters include:
1092  
1093 =over
1094  
1095 =item C<renderer> - the renderer for which integer scaling should be set
1096  
1097 =item C<enable> - enable or disable the integer scaling for rendering
1098  
1099 =back
1100  
1101 Returns C<0> on success or a negative error code on failure; call
1102 C<SDL_GetError( )> for more information.
1103  
1104 =head2 C<SDL_RenderGetIntegerScale( ... )>
1105  
1106 Get whether integer scales are forced for resolution-independent rendering.
1107  
1108 SDL_RenderGetIntegerScale( $renderer );
1109  
1110 Expected parameters include:
1111  
1112 =over
1113  
1114 =item C<renderer> - the renderer from which integer scaling should be queried
1115  
1116 =back
1117  
1118 Returns true if integer scales are forced or false if not and on failure; call
1119 C<SDL_GetError( )> for more information.
1120  
1121 =head2 C<SDL_RenderSetViewport( ... )>
1122  
1123 Set the drawing area for rendering on the current target.
1124  
1125 SDL_RenderSetViewport( $renderer, $rect );
1126  
1127 When the window is resized, the viewport is reset to fill the entire new window
1128 size.
1129  
1130 Expected parameters include:
1131  
1132 =over
1133  
1134 =item C<renderer> - the rendering context
1135  
1136 =item C<rect> - the L<SDL2::Rect> structure representing the drawing area, or undef to set the viewport to the entire target
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_RenderGetViewport( ... )>
1144  
1145 Get the drawing area for the current target.
1146  
1147 my $rect = SDL_RenderGetViewport( $renderer );
1148  
1149 Expected parameters include:
1150  
1151 =over
1152  
1153 =item C<renderer> - the rendering context
1154  
1155 =back
1156  
1157 Returns an L<SDL2::Rect> structure filled in with the current drawing area.
1158  
1159 =head2 C<SDL_RenderSetClipRect( ... )>
1160  
1161 Set the clip rectangle for rendering on the specified target.
1162  
1163 SDL_RenderSetClipRect( $renderer, $rect );
1164  
1165 Expected parameters include:
1166  
1167 =over
1168  
1169 =item C<renderer> - the rendering context for which clip rectangle should be set
1170  
1171 =item C<rect> - an L<SDL2::Rect> structure representing the clip area, relative to the viewport, or undef to disable clipping
1172  
1173 =back
1174  
1175 Returns C<0> on success or a negative error code on failure; call
1176 C<SDL_GetError( )> for more information.
1177  
1178 =head2 C<SDL_RenderGetClipRect( ... )>
1179  
1180 Get the clip rectangle for the current target.
1181  
1182 my $rect = SDL_RenderGetClipRect( $renderer );
1183  
1184 Expected parameters include:
1185  
1186 =over
1187  
1188 =item C<renderer> - the rendering context from which clip rectangle should be queried
1189  
1190 =back
1191  
1192 Returns an L<SDL2::Rect> structure filled in with the current clipping area or
1193 an empty rectangle if clipping is disabled.
1194  
1195 =head2 C<SDL_RenderIsClipEnabled( ... )>
1196  
1197 Get whether clipping is enabled on the given renderer.
1198  
1199 my $tf = SDL_RenderIsClipEnabled( $renderer );
1200  
1201 Expected parameters include:
1202  
1203 =over
1204  
1205 =item C<renderer> - the renderer from which clip state should be queried
1206  
1207 =back
1208  
1209 Returns true if clipping is enabled or false if not; call C<SDL_GetError( )>
1210 for more information.
1211  
1212 =head2 C<SDL_RenderSetScale( ... )>
1213  
1214 Set the drawing scale for rendering on the current target.
1215  
1216 SDL_RenderSetScale( $renderer, .5, 1 );
1217  
1218 The drawing coordinates are scaled by the x/y scaling factors before they are
1219 used by the renderer. This allows resolution independent drawing with a single
1220 coordinate system.
1221  
1222 If this results in scaling or subpixel drawing by the rendering backend, it
1223 will be handled using the appropriate quality hints. For best results use
1224 integer scaling factors.
1225  
1226 Expected parameters include:
1227  
1228 =over
1229  
1230 =item C<renderer> - a rendering context
1231  
1232 =item C<scaleX> - the horizontal scaling factor
1233  
1234 =item C<scaleY> - the vertical scaling factor
1235  
1236 =back
1237  
1238 Returns C<0> on success or a negative error code on failure; call
1239 C<SDL_GetError( )> for more information.
1240  
1241 =head2 C<SDL_RenderGetScale( ... )>
1242  
1243 Get the drawing scale for the current target.
1244  
1245 my ($scaleX, $scaleY) = SDL_RenderGetScale( $renderer );
1246  
1247 Expected parameters include:
1248  
1249 =over
1250  
1251 =item C<renderer> - the renderer from which drawing scale should be queried
1252  
1253 =back
1254  
1255 Returns the horizonal and vertical scaling factors.
1256  
1257 =head2 C<SDL_SetRenderDrawColor( ... )>
1258  
1259 Set the color used for drawing operations (Rect, Line and Clear).
1260  
1261 SDL_SetRenderDrawColor( $renderer, 0, 0, 128, SDL_ALPHA_OPAQUE );
1262  
1263 Set the color for drawing or filling rectangles, lines, and points, and for L<<
1264 C<SDL_RenderClear( ... )>|/C<SDL_RenderClear( ... )> >>.
1265  
1266 Expected parameters include:
1267  
1268 =over
1269  
1270 =item C<renderer> - the rendering context
1271  
1272 =item C<r> - the red value used to draw on the rendering target
1273  
1274 =item C<g> - the green value used to draw on the rendering target
1275  
1276 =item C<b> - the blue value used to draw on the rendering target
1277  
1278 =item C<a> - the alpha value used to draw on the rendering target; usually C<SDL_ALPHA_OPAQUE> (255). Use C<SDL_SetRenderDrawBlendMode> to specify how the alpha channel is used
1279  
1280 =back
1281  
1282 Returns C<0> on success or a negative error code on failure; call
1283 C<SDL_GetError( )> for more information.
1284  
1285 =head2 C<SDL_GetRenderDrawColor( ... )>
1286  
1287 Get the color used for drawing operations (Rect, Line and Clear).
1288  
1289 my ($r, $g, $b, $a) = SDL_GetRenderDrawColor( $renderer );
1290  
1291 Expected parameters include:
1292  
1293 =over
1294  
1295 =item C<renderer> - the rendering context
1296  
1297 =back
1298  
1299 Returns red, green, blue, and alpha values on success or a negative error code
1300 on failure; call C<SDL_GetError( )> for more information.
1301  
1302 =head2 C<SDL_SetRenderDrawBlendMode( ... )>
1303  
1304 Set the blend mode used for drawing operations (Fill and Line).
1305  
1306 SDL_SetRenderDrawBlendMode( $renderer, SDL_BLENDMODE_BLEND );
1307  
1308 If the blend mode is not supported, the closest supported mode is chosen.
1309  
1310 Expected parameters include:
1311  
1312 =over
1313  
1314 =item C<renderer> - the rendering context
1315  
1316 =item C<blendMode> - the C<SDL_BlendMode> to use for blending
1317  
1318 =back
1319  
1320 Returns C<0> on success or a negative error code on failure; call
1321 C<SDL_GetError( )> for more information.
1322  
1323 =head2 C<SDL_GetRenderDrawBlendMode( ... )>
1324  
1325 Get the blend mode used for drawing operations.
1326  
1327 my $blendMode = SDL_GetRenderDrawBlendMode( $rendering );
1328  
1329 Expected parameters include:
1330  
1331 =over
1332  
1333 =item C<renderer> - the rendering context
1334  
1335 =back
1336  
1337 Returns the current C<:blendMode> on success or a negative error code on
1338 failure; call C<SDL_GetError( )> for more information.
1339  
1340 =head2 C<SDL_RenderClear( ... )>
1341  
1342 Clear the current rendering target with the drawing color.
1343  
1344 SDL_RenderClear( $renderer );
1345  
1346 This function clears the entire rendering target, ignoring the viewport and the
1347 clip rectangle.
1348  
1349 =over
1350  
1351 =item C<renderer> - the rendering context
1352  
1353 =back
1354  
1355 Returns C<0> on success or a negative error code on failure; call
1356 C<SDL_GetError( )> for more information.
1357  
1358 =head2 C<SDL_RenderDrawPoint( ... )>
1359  
1360 Draw a point on the current rendering target.
1361  
1362 SDL_RenderDrawPoint( $renderer, 100, 100 );
1363  
1364 C<SDL_RenderDrawPoint( ... )> draws a single point. If you want to draw
1365 multiple, use L<< C<SDL_RenderDrawPoints( ... )>|/C<SDL_RenderDrawPoints( ...
1366 )> >> instead.
1367  
1368 Expected parameters include:
1369  
1370 =over
1371  
1372 =item C<renderer> - the rendering context
1373  
1374 =item C<x> - the x coordinate of the point
1375  
1376 =item C<y> - the y coordinate of the point
1377  
1378 =back
1379  
1380 Returns C<0> on success or a negative error code on failure; call
1381 C<SDL_GetError( )> for more information.
1382  
1383 =head2 C<SDL_RenderDrawPoints( ... )>
1384  
1385 Draw multiple points on the current rendering target.
1386  
1387 my @points = map { SDL2::Point->new( {x => int rand, y => int rand } ) } 1..1024;
1388 SDL_RenderDrawPoints( $renderer, @points );
1389  
1390 =over
1391  
1392 =item C<renderer> - the rendering context
1393  
1394 =item C<points> - an array of L<SDL2::Point> structures that represent the points to draw
1395  
1396 =back
1397  
1398 Returns C<0> on success or a negative error code on failure; call
1399 C<SDL_GetError( )> for more information.
1400  
1401 =head2 C<SDL_RenderDrawLine( ... )>
1402  
1403 Draw a line on the current rendering target.
1404  
1405 SDL_RenderDrawLine( $renderer, 300, 240, 340, 240 );
1406  
1407 C<SDL_RenderDrawLine( ... )> draws the line to include both end points. If you
1408 want to draw multiple, connecting lines use L<< C<SDL_RenderDrawLines( ...
1409 )>|/C<SDL_RenderDrawLines( ... )> >> instead.
1410  
1411 Expected parameters include:
1412  
1413 =over
1414  
1415 =item C<renderer> - the rendering context
1416  
1417 =item C<x1> - the x coordinate of the start point
1418  
1419 =item C<y1> - the y coordinate of the start point
1420  
1421 =item C<x2> - the x coordinate of the end point
1422  
1423 =item C<y2> - the y coordinate of the end point
1424  
1425 =back
1426  
1427 Returns C<0> on success or a negative error code on failure; call
1428 C<SDL_GetError( )> for more information.
1429  
1430 =head2 C<SDL_RenderDrawLines( ... )>
1431  
1432 Draw a series of connected lines on the current rendering target.
1433  
1434 SDL_RenderDrawLines( $renderer, @points);
1435  
1436 Expected parameters include:
1437  
1438 =over
1439  
1440 =item C<renderer> - the rendering context
1441  
1442 =item C<points> - an array of L<SDL2::Point> structures representing points along the lines
1443  
1444 =back
1445  
1446 Returns C<0> on success or a negative error code on failure; call
1447 C<SDL_GetError( )> for more information.
1448  
1449 =head2 C<SDL_RenderDrawRect( ... )>
1450  
1451 Draw a rectangle on the current rendering target.
1452  
1453 SDL_RenderDrawRect( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ) );
1454  
1455 Expected parameters include:
1456  
1457 =over
1458  
1459 =item C<renderer> - the rendering context
1460  
1461 =item C<rect> - an L<SDL2::Rect> structure representing the rectangle to draw
1462  
1463 =for TODO - or undef to outline the entire rendering target
1464  
1465 =back
1466  
1467 Returns C<0> on success or a negative error code on failure; call
1468 C<SDL_GetError( )> for more information.
1469  
1470 =head2 C<SDL_RenderDrawRects( ... )>
1471  
1472 Draw some number of rectangles on the current rendering target.
1473  
1474 SDL_RenderDrawRects( $renderer,
1475 SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ),
1476 SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
1477 );
1478  
1479 Expected parameters include:
1480  
1481 =over
1482  
1483 =item C<renderer> - the rendering context
1484  
1485 =item C<rects> - an array of L<SDL2::Rect> structures representing the rectangles to be drawn
1486  
1487 =back
1488  
1489 Returns C<0> on success or a negative error code on failure; call
1490 C<SDL_GetError( )> for more information.
1491  
1492 =head2 C<SDL_RenderFillRect( ... )>
1493  
1494 Fill a rectangle on the current rendering target with the drawing color.
1495  
1496 SDL_RenderFillRect( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ) );
1497  
1498 The current drawing color is set by L<< C<SDL_SetRenderDrawColor( ...
1499 )>|/C<SDL_SetRenderDrawColor( ... )> >>, and the color's alpha value is ignored
1500 unless blending is enabled with the appropriate call to L<<
1501 C<SDL_SetRenderDrawBlendMode( ... )>|/C<SDL_SetRenderDrawBlendMode( ... )> >>.
1502  
1503 Expected parameters include:
1504  
1505 =over
1506  
1507 =item C<renderer> - the rendering context
1508  
1509 =item C<rect> - the L<SDL2::Rect> structure representing the rectangle to fill
1510  
1511 =for TODO - or undef for the entire rendering target
1512  
1513 =back
1514  
1515 Returns C<0> on success or a negative error code on failure; call
1516 C<SDL_GetError( )> for more information.
1517  
1518 =head2 C<SDL_RenderFillRects( ... )>
1519  
1520 Fill some number of rectangles on the current rendering target with the drawing
1521 color.
1522  
1523 SDL_RenderFillRects( $renderer,
1524 SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ),
1525 SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
1526 );
1527  
1528 Expected parameters include:
1529  
1530 =over
1531  
1532 =item C<renderer> - the rendering context
1533  
1534 =item C<rects> - an array of L<SDL2::Rect> structures representing the rectangles to be filled
1535  
1536 =back
1537  
1538 Returns C<0> on success or a negative error code on failure; call
1539 C<SDL_GetError( )> for more information.
1540  
1541 =head2 C<SDL_RenderCopy( ... )>
1542  
1543 Copy a portion of the texture to the current rendering target.
1544  
1545 SDL_RenderCopy( $renderer, $blueShapes, $srcR, $destR );
1546  
1547 The texture is blended with the destination based on its blend mode set with
1548 L<< C<SDL_SetTextureBlendMode( ... )>|/C<SDL_SetTextureBlendMode( ... )> >>.
1549  
1550 The texture color is affected based on its color modulation set by L<<
1551 C<SDL_SetTextureColorMod( ... )>|/C<SDL_SetTextureColorMod( ... )> >>.
1552  
1553 The texture alpha is affected based on its alpha modulation set by L<<
1554 C<SDL_SetTextureAlphaMod( ... )>|/C<SDL_SetTextureAlphaMod( ... )> >>.
1555  
1556 Expected parameters include:
1557  
1558 =over
1559  
1560 =item C<renderer> - the rendering context
1561  
1562 =item C<texture> - the source texture
1563  
1564 =item C<srcrect> - the source L<SDL2::Rect> structure
1565  
1566 =for TODO: or NULL for the entire texture
1567  
1568 =item C<dstrect> - the destination L<SDL2::Rect> structure; the texture will be stretched to fill the given rectangle
1569  
1570 =for TODO or NULL for the entire rendering target;
1571  
1572 =back
1573  
1574 Returns C<0> on success or a negative error code on failure; call
1575 C<SDL_GetError( )> for more information.
1576  
1577 =head2 C<SDL_RenderCopyEx( ... )>
1578  
1579 Copy a portion of the texture to the current rendering, with optional rotation
1580 and flipping.
1581  
1582 =for TODO: I need an example for this... it's complex
1583  
1584 Copy a portion of the texture to the current rendering target, optionally
1585 rotating it by angle around the given center and also flipping it top-bottom
1586 and/or left-right.
1587  
1588 The texture is blended with the destination based on its blend mode set with
1589 L<< C<SDL_SetTextureBlendMode( ... )>|/C<SDL_SetTextureBlendMode( ... )> >>.
1590  
1591 The texture color is affected based on its color modulation set by L<<
1592 C<SDL_SetTextureColorMod( ... )>|/C<SDL_SetTextureColorMod( ... )> >>.
1593  
1594 The texture alpha is affected based on its alpha modulation set by L<<
1595 C<SDL_SetTextureAlphaMod( ... )>|/C<SDL_SetTextureAlphaMod( ... )> >>.
1596  
1597 Expected parameters include:
1598  
1599 =over
1600  
1601 =item C<renderer> - the rendering context
1602  
1603 =item C<texture> - the source texture
1604  
1605 =item C<srcrect> - the source L<SDL2::Rect> structure
1606  
1607 =for TODO: or NULL for the entire texture
1608  
1609 =item C<dstrect> - the destination SDL_Rect structure
1610  
1611 =for TODO: or NULL for the entire rendering target
1612  
1613 =item C<angle> - an angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
1614  
1615 =item C<center> - a pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around C<dstrect.w / 2>, C<dstrect.h / 2>)
1616  
1617 =item C<flip> - a L<:rendererFlip> value stating which flipping actions should be performed on the texture
1618  
1619 =back
1620  
1621 Returns C<0> on success or a negative error code on failure; call
1622 C<SDL_GetError( )> for more information.
1623  
1624 =head2 C<SDL_RenderDrawPointF( ... )>
1625  
1626 Draw a point on the current rendering target at subpixel precision.
1627  
1628 SDL_RenderDrawPointF( $renderer, 25.5, 100.25 );
1629  
1630 Expected parameters include:
1631  
1632 =over
1633  
1634 =item C<renderer> - The renderer which should draw a point.
1635  
1636 =item C<x> - The x coordinate of the point.
1637  
1638 =item C<y> - The y coordinate of the point.
1639  
1640 =back
1641  
1642 Returns C<0> on success, or C<-1> on error
1643  
1644 =head2 C<SDL_RenderDrawPointsF( ... )>
1645  
1646 Draw multiple points on the current rendering target at subpixel precision.
1647  
1648 my @points = map { SDL2::Point->new( {x => int rand, y => int rand } ) } 1..1024;
1649 SDL_RenderDrawPointsF( $renderer, @points );
1650  
1651 Expected parameters include:
1652  
1653 =over
1654  
1655 =item C<renderer> - The renderer which should draw multiple points
1656  
1657 =item C<points> - The points to draw
1658  
1659 =back
1660  
1661 Returns C<0> on success, or C<-1> on error; call C<SDL_GetError( )> for more
1662 information.
1663  
1664 =head2 C<SDL_RenderDrawLineF( ... )>
1665  
1666 Draw a line on the current rendering target at subpixel precision.
1667  
1668 SDL_RenderDrawLineF( $renderer, 100, 100, 250, 100);
1669  
1670 Expected parameters include:
1671  
1672 =over
1673  
1674 =item C<renderer> - The renderer which should draw a line.
1675  
1676 =item C<x1> - The x coordinate of the start point.
1677  
1678 =item C<y1> - The y coordinate of the start point.
1679  
1680 =item C<x2> - The x coordinate of the end point.
1681  
1682 =item C<y2> - The y coordinate of the end point.
1683  
1684 =back
1685  
1686 Returns C<0> on success, or C<-1> on error.
1687  
1688 =head2 C<SDL_RenderDrawLinesF( ... )>
1689  
1690 Draw a series of connected lines on the current rendering target at subpixel
1691 precision.
1692  
1693 SDL_RenderDrawLines( $renderer, @points);
1694  
1695 Expected parameters include:
1696  
1697 =over
1698  
1699 =item C<renderer> - The renderer which should draw multiple lines.
1700  
1701 =item C<points> - The points along the lines
1702  
1703 =back
1704  
1705 Return C<0> on success, or C<-1> on error.
1706  
1707 =head2 C<SDL_RenderDrawRectF( ... )>
1708  
1709 Draw a rectangle on the current rendering target at subpixel precision.
1710  
1711 SDL_RenderDrawRectF( $renderer, $point);
1712  
1713 Expected parameters include:
1714  
1715 =over
1716  
1717 =item C<renderer> - The renderer which should draw a rectangle.
1718  
1719 =item C<rect> - A pointer to the destination rectangle
1720  
1721 =for TODO: or NULL to outline the entire rendering target.
1722  
1723 =back
1724  
1725 Returns C<0> on success, or C<-1> on error
1726  
1727 =head2 C<SDL_RenderDrawRectsF( ... )>
1728  
1729 Draw some number of rectangles on the current rendering target at subpixel
1730 precision.
1731  
1732 SDL_RenderDrawRectsF( $renderer,
1733 SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ),
1734 SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
1735 );
1736  
1737 Expected parameters include:
1738  
1739 =over
1740  
1741 =item C<renderer> - The renderer which should draw multiple rectangles.
1742  
1743 =item C<rects> - A pointer to an array of destination rectangles.
1744  
1745 =back
1746  
1747 Returns C<0> on success, or C<-1> on error.
1748  
1749 =head2 C<SDL_RenderFillRectF( ... )>
1750  
1751 Fill a rectangle on the current rendering target with the drawing color at
1752 subpixel precision.
1753  
1754 SDL_RenderFillRectF( $renderer,
1755 SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
1756 );
1757  
1758 Expected parameters include:
1759  
1760 =over
1761  
1762 =item C<renderer> - The renderer which should fill a rectangle.
1763  
1764 =item C<rect> - A pointer to the destination rectangle
1765  
1766 =for TODO: or NULL for the entire rendering target.
1767  
1768 =back
1769  
1770 Returns C<0> on success, or C<-1> on error.
1771  
1772 =head2 C<SDL_RenderFillRectsF( ... )>
1773  
1774 Fill some number of rectangles on the current rendering target with the drawing
1775 color at subpixel precision.
1776  
1777 SDL_RenderFillRectsF( $renderer,
1778 SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ),
1779 SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } )
1780 );
1781  
1782 Expected parameters include:
1783  
1784 =over
1785  
1786 =item C<renderer> - The renderer which should fill multiple rectangles.
1787  
1788 =item C<rects> - A pointer to an array of destination rectangles.
1789  
1790 =back
1791  
1792 Returns C<0> on success, or C<-1> on error.
1793  
1794 =head2 C<SDL_RenderCopyF( ... )>
1795  
1796 Copy a portion of the texture to the current rendering target at subpixel
1797 precision.
1798  
1799 =for TODO: I need to come up with an example for this as well
1800  
1801 Expected parameters include:
1802  
1803 =over
1804  
1805 =item C<renderer> - The renderer which should copy parts of a texture
1806  
1807 =item C<texture> - The source texture
1808  
1809 =item C<srcrect> - A pointer to the source rectangle
1810  
1811 =for TODO: or NULL for the entiretexture.
1812  
1813 =item C<dstrect> - A pointer to the destination rectangle
1814  
1815 =for TODO: or NULL for the entire rendering target
1816  
1817 =back
1818  
1819 Returns C<0> on success, or C<-1> on error.
1820  
1821 =head2 C<SDL_RenderCopyExF( ... )>
1822  
1823 Copy a portion of the source texture to the current rendering target, with
1824 rotation and flipping, at subpixel precision.
1825  
1826 =for TODO: I need to come up with an example for this as well
1827  
1828 =over
1829  
1830 =item C<renderer> - The renderer which should copy parts of a texture
1831  
1832 =item C<texture> - The source texture
1833  
1834 =item C<srcrect> - A pointer to the source rectangle
1835  
1836 =for TODO: or NULL for the entire texture
1837  
1838 =item C<dstrect> - A pointer to the destination rectangle
1839  
1840 =for TODO: or NULL for the entire rendering target.
1841  
1842 =item C<angle> - An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
1843  
1844 =item C<center> - A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around C<dstrect.w/2>, C<dstrect.h/2>)
1845  
1846 =item C<flip> - A C<:rendererFlip> value stating which flipping actions should be performed on the texture
1847  
1848 =back
1849  
1850 Returns C<0> on success, or C<-1> on error
1851  
1852 =head2 C<SDL_RenderReadPixels( ... )>
1853  
1854 Read pixels from the current rendering target to an array of pixels.
1855  
1856 SDL_RenderReadPixels(
1857 $renderer,
1858 SDL2::Rect->new( { x => 0, y => 0, w => 640, h => 480 } ),
1859 SDL_PIXELFORMAT_RGB888,
1860 $surface->pixels, $surface->pitch
1861 );
1862  
1863 B<WARNING>: This is a very slow operation, and should not be used frequently.
1864  
1865 C<pitch> specifies the number of bytes between rows in the destination
1866 C<pixels> data. This allows you to write to a subrectangle or have padded rows
1867 in the destination. Generally, C<pitch> should equal the number of pixels per
1868 row in the `pixels` data times the number of bytes per pixel, but it might
1869 contain additional padding (for example, 24bit RGB Windows Bitmap data pads all
1870 rows to multiples of 4 bytes).
1871  
1872 Expected parameters include:
1873  
1874 =over
1875  
1876 =item C<renderer> - the rendering context
1877  
1878 =item C<rect> - an L<SDL2::Rect> structure representing the area to read
1879  
1880 =for TODO: or NULL for the entire render target
1881  
1882 =item C<format> - an C<:pixelFormatEnum> value of the desired format of the pixel data, or C<0> to use the format of the rendering target
1883  
1884 =item C<pixels> - pointer to the pixel data to copy into
1885  
1886 =item C<pitch> - the pitch of the C<pixels> parameter
1887  
1888 =back
1889  
1890 Returns C<0> on success or a negative error code on failure; call
1891 C<SDL_GetError( )> for more information.
1892  
1893 =head2 C<SDL_RenderPresent( ... )>
1894  
1895 Update the screen with any rendering performed since the previous call.
1896  
1897 SDL_RenderPresent( $renderer );
1898  
1899 SDL's rendering functions operate on a backbuffer; that is, calling a rendering
1900 function such as L<< C<SDL_RenderDrawLine( ... )>|/C<SDL_RenderDrawLine( ... )>
1901 >> does not directly put a line on the screen, but rather updates the
1902 backbuffer. As such, you compose your entire scene and *present* the composed
1903 backbuffer to the screen as a complete picture.
1904  
1905 Therefore, when using SDL's rendering API, one does all drawing intended for
1906 the frame, and then calls this function once per frame to present the final
1907 drawing to the user.
1908  
1909 The backbuffer should be considered invalidated after each present; do not
1910 assume that previous contents will exist between frames. You are strongly
1911 encouraged to call L<< C<SDL_RenderClear( ... )>|/C<SDL_RenderClear( ... )> >>
1912 to initialize the backbuffer before starting each new frame's drawing, even if
1913 you plan to overwrite every pixel.
1914  
1915 Expected parameters include:
1916  
1917 =over
1918  
1919 =item C<renderer> - the rendering context
1920  
1921 =back
1922  
1923 =head2 C<SDL_DestroyTexture( ... )>
1924  
1925 Destroy the specified texture.
1926  
1927 SDL_DestroyTexture( $texture );
1928  
1929 Passing undef or an otherwise invalid texture will set the SDL error message to
1930 "Invalid texture".
1931  
1932 Expected parameters include:
1933  
1934 =over
1935  
1936 =item C<texture> - the texture to destroy
1937  
1938 =back
1939  
1940  
1941 =head2 C<SDL_DestroyRenderer( ... )>
1942  
1943 Destroy the rendering context for a window and free associated textures.
1944  
1945 SDL_DestroyRenderer( $renderer );
1946  
1947 Expected parameters include:
1948  
1949 =over
1950  
1951 =item C<renderer> - the rendering context
1952  
1953 =back
1954  
1955 =head2 C<SDL_RenderFlush( ... )>
1956  
1957 Force the rendering context to flush any pending commands to the underlying
1958 rendering API.
1959  
1960 SDL_RenderFlush( $renderer );
1961  
1962 You do not need to (and in fact, shouldn't) call this function unless you are
1963 planning to call into OpenGL/Direct3D/Metal/whatever directly in addition to
1964 using an SDL_Renderer.
1965  
1966 This is for a very-specific case: if you are using SDL's render API, you asked
1967 for a specific renderer backend (OpenGL, Direct3D, etc), you set
1968 C<SDL_HINT_RENDER_BATCHING> to "C<1>", and you plan to make OpenGL/D3D/whatever
1969 calls in addition to SDL render API calls. If all of this applies, you should
1970 call L<< C<SDL_RenderFlush( ... )>|/C<SDL_RenderFlush( ... )> >> between calls
1971 to SDL's render API and the low-level API you're using in cooperation.
1972  
1973 In all other cases, you can ignore this function. This is only here to get
1974 maximum performance out of a specific situation. In all other cases, SDL will
1975 do the right thing, perhaps at a performance loss.
1976  
1977 This function is first available in SDL 2.0.10, and is not needed in 2.0.9 and
1978 earlier, as earlier versions did not queue rendering commands at all, instead
1979 flushing them to the OS immediately.
1980  
1981 Expected parameters include:
1982  
1983 =over
1984  
1985 =item C<renderer> - the rendering context
1986  
1987 =back
1988  
1989 Returns C<0> on success or a negative error code on failure; call
1990 C<SDL_GetError( )> for more information.
1991  
1992  
1993 =head2 C<SDL_GL_BindTexture( ... )>
1994  
1995 Bind an OpenGL/ES/ES2 texture to the current context.
1996  
1997 my ($texw, $texh) = SDL_GL_BindTexture( $texture );
1998  
1999 This is for use with OpenGL instructions when rendering OpenGL primitives
2000 directly.
2001  
2002 If not NULL, the returned width and height values suitable for the provided
2003 texture. In most cases, both will be C<1.0>, however, on systems that support
2004 the GL_ARB_texture_rectangle extension, these values will actually be the pixel
2005 width and height used to create the texture, so this factor needs to be taken
2006 into account when providing texture coordinates to OpenGL.
2007  
2008 You need a renderer to create an L<SDL2::Texture>, therefore you can only use
2009 this function with an implicit OpenGL context from L<< C<SDL_CreateRenderer(
2010 ... )>|/C<SDL_CreateRenderer( ... )> >>, not with your own OpenGL context. If
2011 you need control over your OpenGL context, you need to write your own
2012 texture-loading methods.
2013  
2014 Also note that SDL may upload RGB textures as BGR (or vice-versa), and re-order
2015 the color channels in the shaders phase, so the uploaded texture may have
2016 swapped color channels.
2017  
2018 Expected parameters include:
2019  
2020 =over
2021  
2022 =item C<texture> - the texture to bind to the current OpenGL/ES/ES2 context
2023  
2024 =back
2025  
2026 Returns the texture's with and height on success, or -1 if the operation is not
2027 supported; call C<SDL_GetError( )> for more information.
2028  
2029 =head2 C<SDL_GL_UnbindTexture( ... )>
2030  
2031 Unbind an OpenGL/ES/ES2 texture from the current context.
2032  
2033 SDL_GL_UnbindTexture( $texture );
2034  
2035 See L<< C<SDL_GL_BindTexture( ... )>|/C<SDL_GL_BindTexture( ... )> >> for
2036 examples on how to use these functions.
2037  
2038 Expected parameters include:
2039  
2040 =over
2041  
2042 =item C<texture> - the texture to unbind from the current OpenGL/ES/ES2 context
2043  
2044 =back
2045  
2046 Returns C<0> on success, or C<-1> if the operation is not supported.
2047  
2048 =head2 C<SDL_RenderGetMetalLayer( ... )>
2049  
2050 Get the CAMetalLayer associated with the given Metal renderer.
2051  
2052 my $opaque = SDL_RenderGetMetalLayer( $renderer );
2053  
2054 This function returns C<void *>, so SDL doesn't have to include Metal's
2055 headers, but it can be safely cast to a C<CAMetalLayer *>.
2056  
2057 Expected parameters include:
2058  
2059 =over
2060  
2061 =item C<renderer> - the renderer to query
2062  
2063 =back
2064  
2065 Returns C<CAMetalLayer*> on success, or undef if the renderer isn't a Metal
2066 renderer.
2067  
2068 =head2 C<SDL_RenderGetMetalCommandEncoder( ... )>
2069  
2070 Get the Metal command encoder for the current frame
2071  
2072 $opaque = SDL_RenderGetMetalCommandEncoder( $renderer );
2073  
2074 This function returns C<void *>, so SDL doesn't have to include Metal's
2075 headers, but it can be safely cast to an
2076 C<idE<lt>MTLRenderCommandEncoderE<gt>>.
2077  
2078 Expected parameters include:
2079  
2080 =over
2081  
2082 =item C<renderer> - the renderer to query
2083  
2084 =back
2085  
2086 Returns C<idE<lt>MTLRenderCommandEncoderE<gt>> on success, or undef if the
2087 renderer isn't a Metal renderer.
2088  
2089 =head1 Defined Variables and Enumerations
2090  
2091 Variables may be imported by name or with the C<:render> tag. Enumerations may
2092 be imported with their given tags.
2093  
2094 =head2 C<SDL_RendererFlags>
2095  
2096 Flags used when creating a rendering context.
2097  
2098 =over
2099  
2100 =item C<SDL_RENDERER_SOFTWARE> - The renderer is a software fallback
2101  
2102 =item C<SDL_RENDERER_ACCELERATED> - The renderer uses hardware acceleration
2103  
2104 =item C<SDL_RENDERER_PRESENTVSYNC> - Present is synchronized with the refresh rate
2105  
2106 =item C<SDL_RENDERER_TARGETTEXTURE> - The renderer supports rendering to texture
2107  
2108 =back
2109  
2110 =head2 C<SDL_ScaleMode>
2111  
2112 The scaling mode for a texture.
2113  
2114 =over
2115  
2116 =item C<SDL_ScaleModeNearest> - nearest pixel sampling
2117  
2118 =item C<SDL_ScaleModeLinear> - linear filtering
2119  
2120 =item C<SDL_ScaleModeBest> - anisotropic filtering
2121  
2122 =back
2123  
2124 =head2 C<SDL_TextureAccess>
2125  
2126 The access pattern allowed for a texture.
2127  
2128 =over
2129  
2130 =item C<SDL_TEXTUREACCESS_STATIC> - Changes rarely, not lockable
2131  
2132 =item C<SDL_TEXTUREACCESS_STREAMING> - Changes frequently, lockable
2133  
2134 =item C<SDL_TEXTUREACCESS_TARGET> - Texture can be used as a render target
2135  
2136 =back
2137  
2138 =head2 C<SDL_TextureModulate>
2139  
2140 The texture channel modulation used in C<SDL_RenderCopy( )>.
2141  
2142 =over
2143  
2144 =item C<SDL_TEXTUREMODULATE_NONE> - No modulation
2145  
2146 =item C<SDL_TEXTUREMODULATE_COLOR> - C<srcC = srcC * color>
2147  
2148 =item C<SDL_TEXTUREMODULATE_ALPHA> - C<srcA = srcA * alpha>
2149  
2150 =back
2151  
2152 =head2 C<SDL_RendererFlip>
2153  
2154 Flip constants for SDL_RenderCopyEx
2155  
2156 =over
2157  
2158 =item C<SDL_FLIP_NONE> - Do not flip
2159  
2160 =item C<SDL_FLIP_HORIZONTAL> - flip horizontally
2161  
2162 =item C<SDL_FLIP_VERTICAL> - flip vertically
2163  
2164 =back
2165  
2166 =head1 LICENSE
2167  
2168 Copyright (C) Sanko Robinson.
2169  
2170 This library is free software; you can redistribute it and/or modify it under
2171 the terms found in the Artistic License 2. Other copyrights, terms, and
2172 conditions may apply to data transmitted through this module.
2173  
2174 =head1 AUTHOR
2175  
2176 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
2177  
2178 =begin stopwords
2179  
2180 high-dpi rect viewport subpixel dstrect subrectangle backbuffer OpenGL
2181 vice-versa CAMetalLayer
2182  
2183 =end stopwords
2184  
2185 =cut
2186  
2187 };
2188 1;