SDL2::render - SDL 2D Rendering Functions
use SDL2 qw[:render];
Header file for SDL 2D rendering functions.
This API supports the following features:
single pixel points
single pixel lines
filled rectangles
texture images
The primitives may be drawn in opaque, blended, or additive modes.
The texture images may be drawn in opaque, blended, or additive modes. They can have an additional color tint or alpha modulation applied to them, and may also be stretched with linear interpolation.
This API is designed to accelerate simple 2D operations. You may want more functionality such as polygons and particle effects and in that case you should use SDL's OpenGL/Direct3D support or one of the many good 3D engines.
These functions must be called from the main thread. See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995
These functions may be imported by name or with the :render tag.
:render
SDL_GetNumRenderDrivers( )
Get the number of 2D rendering drivers available for the current display.
my $drivers = SDL_GetNumRenderDrivers( );
A render driver is a set of code that handles rendering and texture management on a particular display. Normally there is only one, but some drivers may have several available with different capabilities.
There may be none if SDL was compiled without render support.
Returns a number >= 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetError( )
SDL_GetRenderDriverInfo( ... )
Get info about a specific 2D rendering driver for the current display.
my $info = !SDL_GetRendererDriverInfo( );
Expected parameters include:
index
Returns an SDL2::RendererInfo structure on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_CreateWindowAndRenderer( ... )
Create a window and default renderer.
my ($window, $renderer) = SDL_CreateWindowAndRenderer(640, 480, 0);
width
height
window_flags
SDL_CreateWindow( ... )
Returns a SDL2::Window and SDL2::Renderer objects on success, or -1 on error; call SDL_GetError( ) for more information.
-1
SDL_CreateRenderer( ... )
Create a 2D rendering context for a window.
my $renderer = SDL_CreateRenderer( $window, -1, 0);
window
flags
0
SDL_RendererFlags
Returns a valid rendering context or undefined if there was an error; call SDL_GetError( ) for more information.
SDL_CreateSoftwareRenderer( ... )
Create a 2D software rendering context for a surface.
my $renderer = SDL_CreateSoftwareRenderer( $surface );
Two other API which can be used to create SDL_Renderer:
SDL_CreateRenderer( ... ) and SDL_CreateWindowAndRenderer( ... ). These can also create a software renderer, but they are intended to be used with an SDL2::Window as the final destination and not an SDL2::Surface.
surface
Returns a valid rendering context or undef if there was an error; call SDL_GetError( ) for more information.
SDL_GetRenderer( ... )
Get the renderer associated with a window.
my $renderer = SDL_GetRenderer( $window );
Returns the rendering context on success or undef on failure; call SDL_GetError( ) for more information.
SDL_GetRendererInfo( ... )
Get information about a rendering context.
my $info = !SDL_GetRendererInfo( $renderer );
renderer
SDL_GetRendererOutputSize( ... )
Get the output size in pixels of a rendering context.
my ($w, $h) = SDL_GetRendererOutputSize( $renderer );
Due to high-dpi displays, you might end up with a rendering context that has more pixels than the window that contains it, so use this instead of SDL_GetWindowSize( ... ) to decide how much drawing area you have.
SDL_GetWindowSize( ... )
Returns the width and height on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_CreateTexture( ... )
Create a texture for a rendering context.
my $texture = SDL_CreateTexture( $renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, 1024, 768);
You can set the texture scaling method by setting SDL_HINT_RENDER_SCALE_QUALITY before creating the texture.
SDL_HINT_RENDER_SCALE_QUALITY
format
:pixelFormatEnum
access
:textureAccess
w
h
Returns a pointer to the created texture or undefined if no rendering context was active, the format was unsupported, or the width or height were out of range; call SDL_GetError( ) for more information.
SDL_CreateTextureFromSurface( ... )
Create a texture from an existing surface.
use Config; my ($rmask, $gmask, $bmask, $amask) = $Config{byteorder} == 4321 ? (0xff000000,0x00ff0000,0x0000ff00,0x000000ff) : (0x000000ff,0x0000ff00,0x00ff0000,0xff000000); my $surface = SDL_CreateRGBSurface( 0, 640, 480, 32, $rmask, $gmask, $bmask, $amask ); my $texture = SDL_CreateTextureFromSurface( $renderer, $surface );
The surface is not modified or freed by this function.
The SDL_TextureAccess hint for the created texture is SDL_TEXTUREACCESS_STATIC.
SDL_TEXTUREACCESS_STATIC
The pixel format of the created texture may be different from the pixel format of the surface. Use SDL_QueryTexture( ... ) to query the pixel format of the texture.
SDL_QueryTexture( ... )
Returns the created texture or undef on failure; call SDL_GetError( ) for more information.
Query the attributes of a texture.
my ( $format, $access, $w, $h ) = SDL_QueryTexture( $texture );
texture
Returns the following on success...
SDL_PixelFormatEnum
SDL_TextureAccess
...or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_SetTextureColorMod( ... )
Set an additional color value multiplied into render copy operations.
my $ok = !SDL_SetTextureColorMod( $texture, 64, 64, 64 );
When this texture is rendered, during the copy operation each source color channel is modulated by the appropriate color value according to the following formula:
srcC = srcC * (color / 255)
Color modulation is not always supported by the renderer; it will return -1 if color modulation is not supported.
r
g
b
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_GetTextureColorMod( ... )
Get the additional color value multiplied into render copy operations.
my ( $r, $g, $b ) = SDL_GetTextureColorMod( $texture );
Returns the current red, green, and blue color values on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_SetTextureAlphaMod( ... )
Set an additional alpha value multiplied into render copy operations.
SDL_SetTextureAlphaMod( $texture, 100 );
When this texture is rendered, during the copy operation the source alpha
value is modulated by this alpha value according to the following formula:
srcA = srcA * (alpha / 255)
Alpha modulation is not always supported by the renderer; it will return -1 if alpha modulation is not supported.
alpha
SDL_GetTextureAlphaMod( ... )
Get the additional alpha value multiplied into render copy operations.
my $alpha = SDL_GetTextureAlphaMod( $texture );
Returns the current alpha value on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_SetTextureBlendMode( ... )
Set the blend mode for a texture, used by SDL_RenderCopy( ... ).
SDL_RenderCopy( ... )
If the blend mode is not supported, the closest supported mode is chosen and this function returns -1.
blendMode
SDL_BlendMode
SDL_GetTextureBlendMode( ... )
Get the blend mode used for texture copy operations.
SDL_GetTextureBlendMode( $texture, SDL_BLENDMODE_ADD );
Returns the current :blendMode on success or a negative error code on failure; call SDL_GetError( ) for more information.
:blendMode
SDL_SetTextureScaleMode( ... )
Set the scale mode used for texture scale operations.
SDL_SetTextureScaleMode( $texture, $scaleMode );
If the scale mode is not supported, the closest supported mode is chosen.
scaleMode
Returns 0 on success, or -1 if the texture is not valid.
SDL_GetTextureScaleMode( ... )
Get the scale mode used for texture scale operations.
my $ok = SDL_GetTextureScaleMode( $texture );
Returns the current scale mode on success, or -1 if the texture is not valid.
SDL_UpdateTexture( ... )
Update the given texture rectangle with new pixel data.
my $rect = SDL2::Rect->new( { x => 0, y => ..., w => $surface->w, h => $surface->h } ); SDL_UpdateTexture( $texture, $rect, $surface->pixels, $surface->pitch );
The pixel data must be in the pixel format of the texture. Use SDL_QueryTexture( ... ) to query the pixel format of the texture.
This is a fairly slow function, intended for use with static textures that do not change often.
If the texture is intended to be updated often, it is preferred to create the texture as streaming and use the locking functions referenced below. While this function will work with streaming textures, for optimization reasons you may not get the pixels back if you lock the texture afterward.
rect
pixels
pitch
SDL_UpdateYUVTexture( ... )
Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
SDL_UpdateYUVTexture( $texture, $rect, $yPlane, $yPitch, $uPlane, $uPitch, $vPlane, $vPitch );
You can use SDL_UpdateTexture( ... ) as long as your pixel data is a contiguous block of Y and U/V planes in the proper order, but this function is available if your pixel data is not contiguous.
Yplane
Ypitch
Uplane
Upitch
Vplane
Vpitch
Returns 0 on success or -1 if the texture is not valid; call SDL_GetError( ) for more information.
SDL_UpdateNVTexture( ... )
Update a rectangle within a planar NV12 or NV21 texture with new pixels.
SDL_UpdateNVTexture( $texture, $rect, $yPlane, $yPitch, $uPlane, $uPitch );
You can use SDL_UpdateTexture( ... ) as long as your pixel data is a contiguous block of NV12/21 planes in the proper order, but this function is available if your pixel data is not contiguous.
UVplane
UVpitch
SDL_LockTexture( ... )
Lock a portion of the texture for write-only pixel access.
SDL_LockTexture( $texture, $rect, $pixels, $pitch );
As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.
You must use SDL_UpdateTexture( ... ) to unlock the pixels and apply any changes.
SDL_TEXTUREACCESS_STREAMING
Returns 0 on success or a negative error code if the texture is not valid or was not created with SDL_TEXTUREACCESS_STREAMING; call SDL_GetError( ) for more information.
SDL_LockTextureToSurface( ... )
Lock a portion of the texture for write-only pixel access, and expose it as a SDL surface.
my $surface = SDL_LockTextureSurface( $texture, $rect );
Besides providing an SDL2::Surface instead of raw pixel data, this function operates like SDL2::LockTexture.
You must use SDL_UnlockTexture( ... ) to unlock the pixels and apply any changes.
SDL_UnlockTexture( ... )
The returned surface is freed internally after calling SDL_UnlockTexture( ... ) or SDL_DestroyTexture( ... ). The caller should not free it.
SDL_DestroyTexture( ... )
Returns the SDL2::Surface structure on success, or -1 if the texture is not valid or was not created with SDL_TEXTUREACCESS_STREAMING.
Unlock a texture, uploading the changes to video memory, if needed.
SDL_UnlockTexture( $texture );
Warning: Please note that SDL_LockTexture( ... ) is intended to be write-only; it will not guarantee the previous contents of the texture will be provided. You must fully initialize any area of a texture that you lock before unlocking it, as the pixels might otherwise be uninitialized memory.
Which is to say: locking and immediately unlocking a texture can result in corrupted textures, depending on the renderer in use.
SDL_RenderTargetSupported( ... )
Determine whether a renderer supports the use of render targets.
my $bool = SDL_RenderTargetSupported( $renderer );
Returns true if supported or false if not.
SDL_SetRenderTarget( ... )
Set a texture as the current rendering target.
SDL_SetRenderTarget( $renderer, $texture );
Before using this function, you should check the SDL_RENDERER_TARGETTEXTURE bit in the flags of SDL2::RendererInfo to see if render targets are supported.
SDL_RENDERER_TARGETTEXTURE
The default render target is the window for which the renderer was created. To stop rendering to a texture and render to the window again, call this function with a undefined texture.
SDL_TEXTUREACCESS_TARGET
SDL_GetRenderTarget( ... )
Get the current render target.
my $texture = SDL_GetRenderTarget( $renderer );
The default render target is the window for which the renderer was created, and is reported an undefined value here.
Returns the current render target or undef for the default render target.
SDL_RenderSetLogicalSize( ... )
Set a device independent resolution for rendering.
SDL_RenderSetLogicalSize( $renderer, 100, 100 );
This function uses the viewport and scaling functionality to allow a fixed logical resolution for rendering, regardless of the actual output resolution. If the actual output resolution doesn't have the same aspect ratio the output rendering will be centered within the output display.
If the output display is a window, mouse and touch events in the window will be filtered and scaled so they seem to arrive within the logical resolution.
If this function results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints.
SDL_RenderGetLogicalSize( ... )
Get device independent resolution for rendering.
my ($w, $h) = SDL_RenderGetLogicalSize( $renderer );
This may return 0 for w and h if the SDL2::Renderer has never had its logical size set by SDL_RenderSetLogicalSize( ... ) and never had a render target set.
Returns the width and height.
SDL_RenderSetIntegerScale( ... )
Set whether to force integer scales for resolution-independent rendering.
SDL_RenderSetIntegerScale( $renderer, 1 );
This function restricts the logical viewport to integer values - that is, when a resolution is between two multiples of a logical size, the viewport size is rounded down to the lower multiple.
enable
SDL_RenderGetIntegerScale( ... )
Get whether integer scales are forced for resolution-independent rendering.
SDL_RenderGetIntegerScale( $renderer );
Returns true if integer scales are forced or false if not and on failure; call SDL_GetError( ) for more information.
SDL_RenderSetViewport( ... )
Set the drawing area for rendering on the current target.
SDL_RenderSetViewport( $renderer, $rect );
When the window is resized, the viewport is reset to fill the entire new window size.
SDL_RenderGetViewport( ... )
Get the drawing area for the current target.
my $rect = SDL_RenderGetViewport( $renderer );
Returns an SDL2::Rect structure filled in with the current drawing area.
SDL_RenderSetClipRect( ... )
Set the clip rectangle for rendering on the specified target.
SDL_RenderSetClipRect( $renderer, $rect );
SDL_RenderGetClipRect( ... )
Get the clip rectangle for the current target.
my $rect = SDL_RenderGetClipRect( $renderer );
Returns an SDL2::Rect structure filled in with the current clipping area or an empty rectangle if clipping is disabled.
SDL_RenderIsClipEnabled( ... )
Get whether clipping is enabled on the given renderer.
my $tf = SDL_RenderIsClipEnabled( $renderer );
Returns true if clipping is enabled or false if not; call SDL_GetError( ) for more information.
SDL_RenderSetScale( ... )
Set the drawing scale for rendering on the current target.
SDL_RenderSetScale( $renderer, .5, 1 );
The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer. This allows resolution independent drawing with a single coordinate system.
If this results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints. For best results use integer scaling factors.
scaleX
scaleY
SDL_RenderGetScale( ... )
Get the drawing scale for the current target.
my ($scaleX, $scaleY) = SDL_RenderGetScale( $renderer );
Returns the horizonal and vertical scaling factors.
SDL_SetRenderDrawColor( ... )
Set the color used for drawing operations (Rect, Line and Clear).
SDL_SetRenderDrawColor( $renderer, 0, 0, 128, SDL_ALPHA_OPAQUE );
Set the color for drawing or filling rectangles, lines, and points, and for SDL_RenderClear( ... ).
SDL_RenderClear( ... )
a
SDL_ALPHA_OPAQUE
SDL_SetRenderDrawBlendMode
SDL_GetRenderDrawColor( ... )
Get the color used for drawing operations (Rect, Line and Clear).
my ($r, $g, $b, $a) = SDL_GetRenderDrawColor( $renderer );
Returns red, green, blue, and alpha values on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_SetRenderDrawBlendMode( ... )
Set the blend mode used for drawing operations (Fill and Line).
SDL_SetRenderDrawBlendMode( $renderer, SDL_BLENDMODE_BLEND );
If the blend mode is not supported, the closest supported mode is chosen.
SDL_GetRenderDrawBlendMode( ... )
Get the blend mode used for drawing operations.
my $blendMode = SDL_GetRenderDrawBlendMode( $rendering );
Clear the current rendering target with the drawing color.
SDL_RenderClear( $renderer );
This function clears the entire rendering target, ignoring the viewport and the clip rectangle.
SDL_RenderDrawPoint( ... )
Draw a point on the current rendering target.
SDL_RenderDrawPoint( $renderer, 100, 100 );
SDL_RenderDrawPoint( ... ) draws a single point. If you want to draw multiple, use SDL_RenderDrawPoints( ... ) instead.
SDL_RenderDrawPoints( ... )
x
y
Draw multiple points on the current rendering target.
my @points = map { SDL2::Point->new( {x => int rand, y => int rand } ) } 1..1024; SDL_RenderDrawPoints( $renderer, @points );
points
SDL_RenderDrawLine( ... )
Draw a line on the current rendering target.
SDL_RenderDrawLine( $renderer, 300, 240, 340, 240 );
SDL_RenderDrawLine( ... ) draws the line to include both end points. If you want to draw multiple, connecting lines use SDL_RenderDrawLines( ... ) instead.
SDL_RenderDrawLines( ... )
x1
y1
x2
y2
Draw a series of connected lines on the current rendering target.
SDL_RenderDrawLines( $renderer, @points);
SDL_RenderDrawRect( ... )
Draw a rectangle on the current rendering target.
SDL_RenderDrawRect( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ) );
SDL_RenderDrawRects( ... )
Draw some number of rectangles on the current rendering target.
SDL_RenderDrawRects( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ), SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } ) );
rects
SDL_RenderFillRect( ... )
Fill a rectangle on the current rendering target with the drawing color.
SDL_RenderFillRect( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ) );
The current drawing color is set by SDL_SetRenderDrawColor( ... ), and the color's alpha value is ignored unless blending is enabled with the appropriate call to SDL_SetRenderDrawBlendMode( ... ).
SDL_RenderFillRects( ... )
Fill some number of rectangles on the current rendering target with the drawing color.
SDL_RenderFillRects( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ), SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } ) );
Copy a portion of the texture to the current rendering target.
SDL_RenderCopy( $renderer, $blueShapes, $srcR, $destR );
The texture is blended with the destination based on its blend mode set with SDL_SetTextureBlendMode( ... ).
The texture color is affected based on its color modulation set by SDL_SetTextureColorMod( ... ).
The texture alpha is affected based on its alpha modulation set by SDL_SetTextureAlphaMod( ... ).
srcrect
dstrect
SDL_RenderCopyEx( ... )
Copy a portion of the texture to the current rendering, with optional rotation and flipping.
Copy a portion of the texture to the current rendering target, optionally rotating it by angle around the given center and also flipping it top-bottom and/or left-right.
angle
center
dstrect.w / 2
dstrect.h / 2
flip
SDL_RenderDrawPointF( ... )
Draw a point on the current rendering target at subpixel precision.
SDL_RenderDrawPointF( $renderer, 25.5, 100.25 );
Returns 0 on success, or -1 on error
SDL_RenderDrawPointsF( ... )
Draw multiple points on the current rendering target at subpixel precision.
my @points = map { SDL2::Point->new( {x => int rand, y => int rand } ) } 1..1024; SDL_RenderDrawPointsF( $renderer, @points );
Returns 0 on success, or -1 on error; call SDL_GetError( ) for more information.
SDL_RenderDrawLineF( ... )
Draw a line on the current rendering target at subpixel precision.
SDL_RenderDrawLineF( $renderer, 100, 100, 250, 100);
Returns 0 on success, or -1 on error.
SDL_RenderDrawLinesF( ... )
Draw a series of connected lines on the current rendering target at subpixel precision.
Return 0 on success, or -1 on error.
SDL_RenderDrawRectF( ... )
Draw a rectangle on the current rendering target at subpixel precision.
SDL_RenderDrawRectF( $renderer, $point);
SDL_RenderDrawRectsF( ... )
Draw some number of rectangles on the current rendering target at subpixel precision.
SDL_RenderDrawRectsF( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ), SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } ) );
SDL_RenderFillRectF( ... )
Fill a rectangle on the current rendering target with the drawing color at subpixel precision.
SDL_RenderFillRectF( $renderer, SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } ) );
SDL_RenderFillRectsF( ... )
Fill some number of rectangles on the current rendering target with the drawing color at subpixel precision.
SDL_RenderFillRectsF( $renderer, SDL2::Rect->new( { x => 100, y => 100, w => 100, h => 100 } ), SDL2::Rect->new( { x => 75, y => 75, w => 50, h => 50 } ) );
SDL_RenderCopyF( ... )
Copy a portion of the texture to the current rendering target at subpixel precision.
SDL_RenderCopyExF( ... )
Copy a portion of the source texture to the current rendering target, with rotation and flipping, at subpixel precision.
dstrect.w/2
dstrect.h/2
:rendererFlip
SDL_RenderReadPixels( ... )
Read pixels from the current rendering target to an array of pixels.
SDL_RenderReadPixels( $renderer, SDL2::Rect->new( { x => 0, y => 0, w => 640, h => 480 } ), SDL_PIXELFORMAT_RGB888, $surface->pixels, $surface->pitch );
WARNING: This is a very slow operation, and should not be used frequently.
pitch specifies the number of bytes between rows in the destination pixels data. This allows you to write to a subrectangle or have padded rows in the destination. Generally, pitch should equal the number of pixels per row in the `pixels` data times the number of bytes per pixel, but it might contain additional padding (for example, 24bit RGB Windows Bitmap data pads all rows to multiples of 4 bytes).
SDL_RenderPresent( ... )
Update the screen with any rendering performed since the previous call.
SDL_RenderPresent( $renderer );
SDL's rendering functions operate on a backbuffer; that is, calling a rendering function such as SDL_RenderDrawLine( ... ) does not directly put a line on the screen, but rather updates the backbuffer. As such, you compose your entire scene and *present* the composed backbuffer to the screen as a complete picture.
Therefore, when using SDL's rendering API, one does all drawing intended for the frame, and then calls this function once per frame to present the final drawing to the user.
The backbuffer should be considered invalidated after each present; do not assume that previous contents will exist between frames. You are strongly encouraged to call SDL_RenderClear( ... ) to initialize the backbuffer before starting each new frame's drawing, even if you plan to overwrite every pixel.
Destroy the specified texture.
SDL_DestroyTexture( $texture );
Passing undef or an otherwise invalid texture will set the SDL error message to "Invalid texture".
SDL_DestroyRenderer( ... )
Destroy the rendering context for a window and free associated textures.
SDL_DestroyRenderer( $renderer );
SDL_RenderFlush( ... )
Force the rendering context to flush any pending commands to the underlying rendering API.
SDL_RenderFlush( $renderer );
You do not need to (and in fact, shouldn't) call this function unless you are planning to call into OpenGL/Direct3D/Metal/whatever directly in addition to using an SDL_Renderer.
This is for a very-specific case: if you are using SDL's render API, you asked for a specific renderer backend (OpenGL, Direct3D, etc), you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of this applies, you should call SDL_RenderFlush( ... ) between calls to SDL's render API and the low-level API you're using in cooperation.
SDL_HINT_RENDER_BATCHING
1
In all other cases, you can ignore this function. This is only here to get maximum performance out of a specific situation. In all other cases, SDL will do the right thing, perhaps at a performance loss.
This function is first available in SDL 2.0.10, and is not needed in 2.0.9 and earlier, as earlier versions did not queue rendering commands at all, instead flushing them to the OS immediately.
SDL_GL_BindTexture( ... )
Bind an OpenGL/ES/ES2 texture to the current context.
my ($texw, $texh) = SDL_GL_BindTexture( $texture );
This is for use with OpenGL instructions when rendering OpenGL primitives directly.
If not NULL, the returned width and height values suitable for the provided texture. In most cases, both will be 1.0, however, on systems that support the GL_ARB_texture_rectangle extension, these values will actually be the pixel width and height used to create the texture, so this factor needs to be taken into account when providing texture coordinates to OpenGL.
1.0
You need a renderer to create an SDL2::Texture, therefore you can only use this function with an implicit OpenGL context from SDL_CreateRenderer( ... ), not with your own OpenGL context. If you need control over your OpenGL context, you need to write your own texture-loading methods.
Also note that SDL may upload RGB textures as BGR (or vice-versa), and re-order the color channels in the shaders phase, so the uploaded texture may have swapped color channels.
Returns the texture's with and height on success, or -1 if the operation is not supported; call SDL_GetError( ) for more information.
SDL_GL_UnbindTexture( ... )
Unbind an OpenGL/ES/ES2 texture from the current context.
SDL_GL_UnbindTexture( $texture );
See SDL_GL_BindTexture( ... ) for examples on how to use these functions.
Returns 0 on success, or -1 if the operation is not supported.
SDL_RenderGetMetalLayer( ... )
Get the CAMetalLayer associated with the given Metal renderer.
my $opaque = SDL_RenderGetMetalLayer( $renderer );
This function returns void *, so SDL doesn't have to include Metal's headers, but it can be safely cast to a CAMetalLayer *.
void *
CAMetalLayer *
Returns CAMetalLayer* on success, or undef if the renderer isn't a Metal renderer.
CAMetalLayer*
SDL_RenderGetMetalCommandEncoder( ... )
Get the Metal command encoder for the current frame
$opaque = SDL_RenderGetMetalCommandEncoder( $renderer );
This function returns void *, so SDL doesn't have to include Metal's headers, but it can be safely cast to an id<MTLRenderCommandEncoder>.
id<MTLRenderCommandEncoder>
Returns id<MTLRenderCommandEncoder> on success, or undef if the renderer isn't a Metal renderer.
Variables may be imported by name or with the :render tag. Enumerations may be imported with their given tags.
Flags used when creating a rendering context.
SDL_RENDERER_SOFTWARE
SDL_RENDERER_ACCELERATED
SDL_RENDERER_PRESENTVSYNC
SDL_ScaleMode
The scaling mode for a texture.
SDL_ScaleModeNearest
SDL_ScaleModeLinear
SDL_ScaleModeBest
The access pattern allowed for a texture.
SDL_TextureModulate
The texture channel modulation used in SDL_RenderCopy( ).
SDL_RenderCopy( )
SDL_TEXTUREMODULATE_NONE
SDL_TEXTUREMODULATE_COLOR
srcC = srcC * color
SDL_TEXTUREMODULATE_ALPHA
srcA = srcA * alpha
SDL_RendererFlip
Flip constants for SDL_RenderCopyEx
SDL_FLIP_NONE
SDL_FLIP_HORIZONTAL
SDL_FLIP_VERTICAL
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.
Sanko Robinson <sanko@cpan.org>
To install SDL2::FFI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL2::FFI
CPAN shell
perl -MCPAN -e shell install SDL2::FFI
For more information on module installation, please visit the detailed CPAN module installation guide.