SDL_render.c File Reference
`#include "../SDL_internal.h"`
`#include "SDL_assert.h"`
`#include "SDL_hints.h"`
`#include "SDL_log.h"`
`#include "SDL_render.h"`
`#include "SDL_sysrender.h"`
`#include "software/SDL_render_sw_c.h"`
Include dependency graph for SDL_render.c:

Go to the source code of this file.

## Macros

#define | SDL_WINDOWRENDERDATA "_SDL_WindowRenderData"
#define | CHECK_RENDERER_MAGIC(renderer, retval)
#define | CHECK_TEXTURE_MAGIC(texture, retval)
#define | SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
#define | SDL_BLENDMODE_NONE_FULL
#define | SDL_BLENDMODE_BLEND_FULL
#define | SDL_BLENDMODE_ADD_FULL
#define | SDL_BLENDMODE_MOD_FULL

## Functions

static int | UpdateLogicalSize (SDL_Renderer *renderer)
int | SDL_GetNumRenderDrivers (void)
| Get the number of 2D rendering drivers available for the current display. More...
int | SDL_GetRenderDriverInfo (int index, SDL_RendererInfo *info)
| Get information about a specific 2D rendering driver for the current display. More...
static int | SDL_RendererEventWatch (void *userdata, SDL_Event *event)
int | SDL_CreateWindowAndRenderer (int width, int height, Uint32 window_flags, SDL_Window **window, SDL_Renderer **renderer)
| Create a window and default renderer. More...
SDL_Renderer * | SDL_CreateRenderer (SDL_Window *window, int index, Uint32 flags)
| Create a 2D rendering context for a window. More...
SDL_Renderer * | SDL_CreateSoftwareRenderer (SDL_Surface *surface)
| Create a 2D software rendering context for a surface. More...
SDL_Renderer * | SDL_GetRenderer (SDL_Window *window)
| Get the renderer associated with a window. More...
int | SDL_GetRendererInfo (SDL_Renderer *renderer, SDL_RendererInfo *info)
| Get information about a rendering context. More...
int | SDL_GetRendererOutputSize (SDL_Renderer *renderer, int *w, int *h)
| Get the output size in pixels of a rendering context. More...
static SDL_bool | IsSupportedBlendMode (SDL_Renderer *renderer, SDL_BlendMode blendMode)
static SDL_bool | IsSupportedFormat (SDL_Renderer *renderer, Uint32 format)
static Uint32 | GetClosestSupportedFormat (SDL_Renderer *renderer, Uint32 format)
SDL_Texture * | SDL_CreateTexture (SDL_Renderer *renderer, Uint32 format, int access, int w, int h)
| Create a texture for a rendering context. More...
SDL_Texture * | SDL_CreateTextureFromSurface (SDL_Renderer *renderer, SDL_Surface *surface)
| Create a texture from an existing surface. More...
int | SDL_QueryTexture (SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h)
| Query the attributes of a texture. More...
int | SDL_SetTextureColorMod (SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b)
| Set an additional color value used in render copy operations. More...
int | SDL_GetTextureColorMod (SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b)
| Get the additional color value used in render copy operations. More...
int | SDL_SetTextureAlphaMod (SDL_Texture *texture, Uint8 alpha)
| Set an additional alpha value used in render copy operations. More...
int | SDL_GetTextureAlphaMod (SDL_Texture *texture, Uint8 *alpha)
| Get the additional alpha value used in render copy operations. More...
int | SDL_SetTextureBlendMode (SDL_Texture *texture, SDL_BlendMode blendMode)
| Set the blend mode used for texture copy operations. More...
int | SDL_GetTextureBlendMode (SDL_Texture *texture, SDL_BlendMode *blendMode)
| Get the blend mode used for texture copy operations. More...
static int | SDL_UpdateTextureYUV (SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
static int | SDL_UpdateTextureNative (SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
int | SDL_UpdateTexture (SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
| Update the given texture rectangle with new pixel data. More...
static int | SDL_UpdateTextureYUVPlanar (SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
int | SDL_UpdateYUVTexture (SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
| Update a rectangle within a planar YV12 or IYUV texture with new pixel data. More...
static int | SDL_LockTextureYUV (SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
static int | SDL_LockTextureNative (SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
int | SDL_LockTexture (SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
| Lock a portion of the texture for write-only pixel access. More...
static void | SDL_UnlockTextureYUV (SDL_Texture *texture)
static void | SDL_UnlockTextureNative (SDL_Texture *texture)
void | SDL_UnlockTexture (SDL_Texture *texture)
| Unlock a texture, uploading the changes to video memory, if needed. More...
SDL_bool | SDL_RenderTargetSupported (SDL_Renderer *renderer)
| Determines whether a window supports the use of render targets. More...
int | SDL_SetRenderTarget (SDL_Renderer *renderer, SDL_Texture *texture)
| Set a texture as the current rendering target. More...
SDL_Texture * | SDL_GetRenderTarget (SDL_Renderer *renderer)
| Get the current render target or NULL for the default render target. More...
int | SDL_RenderSetLogicalSize (SDL_Renderer *renderer, int w, int h)
| Set device independent resolution for rendering. More...
void | SDL_RenderGetLogicalSize (SDL_Renderer *renderer, int *w, int *h)
| Get device independent resolution for rendering. More...
int | SDL_RenderSetIntegerScale (SDL_Renderer *renderer, SDL_bool enable)
| Set whether to force integer scales for resolution-independent rendering. More...
SDL_bool | SDL_RenderGetIntegerScale (SDL_Renderer *renderer)
| Get whether integer scales are forced for resolution-independent rendering. More...
int | SDL_RenderSetViewport (SDL_Renderer *renderer, const SDL_Rect *rect)
| Set the drawing area for rendering on the current target. More...
void | SDL_RenderGetViewport (SDL_Renderer *renderer, SDL_Rect *rect)
| Get the drawing area for the current target. More...
int | SDL_RenderSetClipRect (SDL_Renderer *renderer, const SDL_Rect *rect)
| Set the clip rectangle for the current target. More...
void | SDL_RenderGetClipRect (SDL_Renderer *renderer, SDL_Rect *rect)
| Get the clip rectangle for the current target. More...
SDL_bool | SDL_RenderIsClipEnabled (SDL_Renderer *renderer)
| Get whether clipping is enabled on the given renderer. More...
int | SDL_RenderSetScale (SDL_Renderer *renderer, float scaleX, float scaleY)
| Set the drawing scale for rendering on the current target. More...
void | SDL_RenderGetScale (SDL_Renderer *renderer, float *scaleX, float *scaleY)
| Get the drawing scale for the current target. More...
int | SDL_SetRenderDrawColor (SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
| Set the color used for drawing operations (Rect, Line and Clear). More...
int | SDL_GetRenderDrawColor (SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
| Get the color used for drawing operations (Rect, Line and Clear). More...
int | SDL_SetRenderDrawBlendMode (SDL_Renderer *renderer, SDL_BlendMode blendMode)
| Set the blend mode used for drawing operations (Fill and Line). More...
int | SDL_GetRenderDrawBlendMode (SDL_Renderer *renderer, SDL_BlendMode *blendMode)
| Get the blend mode used for drawing operations. More...
int | SDL_RenderClear (SDL_Renderer *renderer)
| Clear the current rendering target with the drawing color. More...
int | SDL_RenderDrawPoint (SDL_Renderer *renderer, int x, int y)
| Draw a point on the current rendering target. More...
static int | RenderDrawPointsWithRects (SDL_Renderer *renderer, const SDL_Point *points, int count)
int | SDL_RenderDrawPoints (SDL_Renderer *renderer, const SDL_Point *points, int count)
| Draw multiple points on the current rendering target. More...
int | SDL_RenderDrawLine (SDL_Renderer *renderer, int x1, int y1, int x2, int y2)
| Draw a line on the current rendering target. More...
static int | RenderDrawLinesWithRects (SDL_Renderer *renderer, const SDL_Point *points, int count)
int | SDL_RenderDrawLines (SDL_Renderer *renderer, const SDL_Point *points, int count)
| Draw a series of connected lines on the current rendering target. More...
int | SDL_RenderDrawRect (SDL_Renderer *renderer, const SDL_Rect *rect)
| Draw a rectangle on the current rendering target. More...
int | SDL_RenderDrawRects (SDL_Renderer *renderer, const SDL_Rect *rects, int count)
| Draw some number of rectangles on the current rendering target. More...
int | SDL_RenderFillRect (SDL_Renderer *renderer, const SDL_Rect *rect)
| Fill a rectangle on the current rendering target with the drawing color. More...
int | SDL_RenderFillRects (SDL_Renderer *renderer, const SDL_Rect *rects, int count)
| Fill some number of rectangles on the current rendering target with the drawing color. More...
int | SDL_RenderCopy (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect)
| Copy a portion of the texture to the current rendering target. More...
int | SDL_RenderCopyEx (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect, const double angle, const SDL_Point *center, const SDL_RendererFlip flip)
| Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center. More...
int | SDL_RenderReadPixels (SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
| Read pixels from the current rendering target. More...
void | SDL_RenderPresent (SDL_Renderer *renderer)
| Update the screen with rendering performed. More...
void | SDL_DestroyTexture (SDL_Texture *texture)
| Destroy the specified texture. More...
void | SDL_DestroyRenderer (SDL_Renderer *renderer)
| Destroy the rendering context for a window and free associated textures. More...
int | SDL_GL_BindTexture (SDL_Texture *texture, float *texw, float *texh)
| Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions. More...
int | SDL_GL_UnbindTexture (SDL_Texture *texture)
| Unbind a texture from the current OpenGL/ES/ES2 context. More...
void * | SDL_RenderGetMetalLayer (SDL_Renderer *renderer)
| Get the CAMetalLayer associated with the given Metal renderer. More...
void * | SDL_RenderGetMetalCommandEncoder (SDL_Renderer *renderer)
| Get the Metal command encoder for the current frame. More...
static SDL_BlendMode | SDL_GetShortBlendMode (SDL_BlendMode blendMode)
static SDL_BlendMode | SDL_GetLongBlendMode (SDL_BlendMode blendMode)
SDL_BlendMode | SDL_ComposeCustomBlendMode (SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor, SDL_BlendOperation colorOperation, SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor dstAlphaFactor, SDL_BlendOperation alphaOperation)
| Create a custom blend mode, which may or may not be supported by a given renderer. More...
SDL_BlendFactor | SDL_GetBlendModeSrcColorFactor (SDL_BlendMode blendMode)
SDL_BlendFactor | SDL_GetBlendModeDstColorFactor (SDL_BlendMode blendMode)
SDL_BlendOperation | SDL_GetBlendModeColorOperation (SDL_BlendMode blendMode)
SDL_BlendFactor | SDL_GetBlendModeSrcAlphaFactor (SDL_BlendMode blendMode)
SDL_BlendFactor | SDL_GetBlendModeDstAlphaFactor (SDL_BlendMode blendMode)
SDL_BlendOperation | SDL_GetBlendModeAlphaOperation (SDL_BlendMode blendMode)

## Variables

static const SDL_RenderDriver * | render_drivers []
static char | renderer_magic
static char | texture_magic

## Macro Definition Documentation

## CHECK_RENDERER_MAGIC

#define CHECK_RENDERER_MAGIC | ( |  | renderer,
|  |  | retval
| ) |  |

Value:
SDL_assert(renderer && renderer->magic == &renderer_magic); \
if (!renderer || renderer->magic != &renderer_magic) { \
SDL_SetError("Invalid renderer"); \
return retval; \
}
retval
SDL_bool retval
Definition: testgamecontroller.c:65
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:78
renderer_magic
static char renderer_magic
Definition: SDL_render.c:105

Definition at line 35 of file SDL_render.c.

Referenced by SDL_CreateTexture(), SDL_CreateTextureFromSurface(), SDL_DestroyRenderer(), SDL_GetRenderDrawBlendMode(), SDL_GetRenderDrawColor(), SDL_GetRendererInfo(), SDL_GetRendererOutputSize(), SDL_RenderClear(), SDL_RenderCopy(), SDL_RenderCopyEx(), SDL_RenderDrawLines(), SDL_RenderDrawPoints(), SDL_RenderDrawRect(), SDL_RenderDrawRects(), SDL_RenderFillRect(), SDL_RenderFillRects(), SDL_RenderGetClipRect(), SDL_RenderGetIntegerScale(), SDL_RenderGetLogicalSize(), SDL_RenderGetMetalCommandEncoder(), SDL_RenderGetMetalLayer(), SDL_RenderGetScale(), SDL_RenderGetViewport(), SDL_RenderIsClipEnabled(), SDL_RenderPresent(), SDL_RenderReadPixels(), SDL_RenderSetClipRect(), SDL_RenderSetIntegerScale(), SDL_RenderSetLogicalSize(), SDL_RenderSetScale(), SDL_RenderSetViewport(), SDL_SetRenderDrawBlendMode(), and SDL_SetRenderDrawColor().

## CHECK_TEXTURE_MAGIC

#define CHECK_TEXTURE_MAGIC | ( |  | texture,
|  |  | retval
| ) |  |

Value:
SDL_assert(texture && texture->magic == &texture_magic); \
if (!texture || texture->magic != &texture_magic) { \
SDL_SetError("Invalid texture"); \
return retval; \
}
texture_magic
static char texture_magic
Definition: SDL_render.c:106
retval
SDL_bool retval
Definition: testgamecontroller.c:65
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169

Definition at line 42 of file SDL_render.c.

Referenced by SDL_DestroyTexture(), SDL_GetTextureAlphaMod(), SDL_GetTextureBlendMode(), SDL_GetTextureColorMod(), SDL_GL_BindTexture(), SDL_GL_UnbindTexture(), SDL_LockTexture(), SDL_QueryTexture(), SDL_RenderCopy(), SDL_RenderCopyEx(), SDL_SetRenderTarget(), SDL_SetTextureAlphaMod(), SDL_SetTextureBlendMode(), SDL_SetTextureColorMod(), SDL_UnlockTexture(), SDL_UpdateTexture(), and SDL_UpdateYUVTexture().

## SDL_BLENDMODE_ADD_FULL

#define SDL_BLENDMODE_ADD_FULL

Value:
SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, \
SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
SDL_BLENDFACTOR_SRC_ALPHA
Definition: SDL_blendmode.h:81
SDL_BLENDOPERATION_ADD
Definition: SDL_blendmode.h:64
SDL_BLENDFACTOR_ONE
Definition: SDL_blendmode.h:78
SDL_BLENDFACTOR_ZERO
Definition: SDL_blendmode.h:77
SDL_COMPOSE_BLENDMODE
#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
Definition: SDL_render.c:50

Definition at line 67 of file SDL_render.c.

Referenced by SDL_GetLongBlendMode(), and SDL_GetShortBlendMode().

## SDL_BLENDMODE_BLEND_FULL

#define SDL_BLENDMODE_BLEND_FULL

Value:
SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \
SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD)
SDL_BLENDFACTOR_SRC_ALPHA
Definition: SDL_blendmode.h:81
SDL_BLENDOPERATION_ADD
Definition: SDL_blendmode.h:64
SDL_BLENDFACTOR_ONE
Definition: SDL_blendmode.h:78
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA
Definition: SDL_blendmode.h:82
SDL_COMPOSE_BLENDMODE
#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
Definition: SDL_render.c:50

Definition at line 63 of file SDL_render.c.

Referenced by SDL_GetLongBlendMode(), and SDL_GetShortBlendMode().

## SDL_BLENDMODE_MOD_FULL

#define SDL_BLENDMODE_MOD_FULL

Value:
SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_SRC_COLOR, SDL_BLENDOPERATION_ADD, \
SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
SDL_BLENDFACTOR_SRC_COLOR
Definition: SDL_blendmode.h:79
SDL_BLENDOPERATION_ADD
Definition: SDL_blendmode.h:64
SDL_BLENDFACTOR_ONE
Definition: SDL_blendmode.h:78
SDL_BLENDFACTOR_ZERO
Definition: SDL_blendmode.h:77
SDL_COMPOSE_BLENDMODE
#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
Definition: SDL_render.c:50

Definition at line 71 of file SDL_render.c.

Referenced by SDL_GetLongBlendMode(), and SDL_GetShortBlendMode().

## SDL_BLENDMODE_NONE_FULL

#define SDL_BLENDMODE_NONE_FULL

Value:
SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD, \
SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD)
SDL_BLENDOPERATION_ADD
Definition: SDL_blendmode.h:64
SDL_BLENDFACTOR_ONE
Definition: SDL_blendmode.h:78
SDL_BLENDFACTOR_ZERO
Definition: SDL_blendmode.h:77
SDL_COMPOSE_BLENDMODE
#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
Definition: SDL_render.c:50

Definition at line 59 of file SDL_render.c.

Referenced by SDL_GetLongBlendMode(), and SDL_GetShortBlendMode().

## SDL_COMPOSE_BLENDMODE

#define SDL_COMPOSE_BLENDMODE | ( |  | srcColorFactor,
|  |  | dstColorFactor,
|  |  | colorOperation,
|  |  | srcAlphaFactor,
|  |  | dstAlphaFactor,
|  |  | alphaOperation
| ) |  |

Value:
(SDL_BlendMode)(((Uint32)colorOperation << 0) | \
((Uint32)srcColorFactor << 4) | \
((Uint32)dstColorFactor << 8) | \
((Uint32)alphaOperation << 16) | \
((Uint32)srcAlphaFactor << 20) | \
((Uint32)dstAlphaFactor << 24))
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181

Definition at line 50 of file SDL_render.c.

Referenced by SDL_ComposeCustomBlendMode().

## SDL_WINDOWRENDERDATA

#define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData"

Definition at line 33 of file SDL_render.c.

Referenced by SDL_CreateRenderer(), SDL_DestroyRenderer(), and SDL_GetRenderer().

## Function Documentation

## GetClosestSupportedFormat()

static Uint32 GetClosestSupportedFormat | ( | SDL_Renderer * | renderer,
|  | Uint32 | format
| ) |  |

static

Definition at line 471 of file SDL_render.c.

References i, SDL_Renderer::info, SDL_RendererInfo::num_texture_formats, SDL_ISPIXELFORMAT_ALPHA, SDL_ISPIXELFORMAT_FOURCC, and SDL_RendererInfo::texture_formats.

Referenced by SDL_CreateTexture().

{
Uint32 i;
if (SDL_ISPIXELFORMAT_FOURCC(format)) {
/* Look for an exact match */
for (i = 0; i < renderer->info.num_texture_formats; ++i) {
if (renderer->info.texture_formats[i] == format) {
return renderer->info.texture_formats[i];
}
}
} else {
SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format);
/* We just want to match the first format that has the same channels */
for (i = 0; i < renderer->info.num_texture_formats; ++i) {
if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) &&
SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == hasAlpha) {
return renderer->info.texture_formats[i];
}
}
}
return renderer->info.texture_formats[0];
}
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:130
SDL_RendererInfo::texture_formats
Uint32 texture_formats[16]
Definition: SDL_render.h:83
SDL_ISPIXELFORMAT_ALPHA
#define SDL_ISPIXELFORMAT_ALPHA(format)
Definition: SDL_pixels.h:154
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
SDL_RendererInfo::num_texture_formats
Uint32 num_texture_formats
Definition: SDL_render.h:82
SDL_ISPIXELFORMAT_FOURCC
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:167

## IsSupportedBlendMode()

static SDL_bool IsSupportedBlendMode | ( | SDL_Renderer * | renderer,
|  | SDL_BlendMode | blendMode
| ) |  |

static

Definition at line 441 of file SDL_render.c.

References SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, SDL_BLENDMODE_NONE, SDL_TRUE, and SDL_Renderer::SupportsBlendMode.

Referenced by SDL_SetRenderDrawBlendMode(), and SDL_SetTextureBlendMode().

{
switch (blendMode)
{
/* These are required to be supported by all renderers */
case SDL_BLENDMODE_NONE:
case SDL_BLENDMODE_BLEND:
case SDL_BLENDMODE_ADD:
case SDL_BLENDMODE_MOD:
return SDL_TRUE;
default:
return renderer->SupportsBlendMode && renderer->SupportsBlendMode(renderer, blendMode);
}
}
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_BLENDMODE_NONE
Definition: SDL_blendmode.h:42
SDL_Renderer::SupportsBlendMode
SDL_bool(* SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode)
Definition: SDL_sysrender.h:82
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

## IsSupportedFormat()

static SDL_bool IsSupportedFormat | ( | SDL_Renderer * | renderer,
|  | Uint32 | format
| ) |  |

static

Definition at line 458 of file SDL_render.c.

References i, SDL_Renderer::info, SDL_RendererInfo::num_texture_formats, SDL_FALSE, SDL_TRUE, and SDL_RendererInfo::texture_formats.

Referenced by SDL_CreateTexture().

{
Uint32 i;
for (i = 0; i < renderer->info.num_texture_formats; ++i) {
if (renderer->info.texture_formats[i] == format) {
return SDL_TRUE;
}
}
return SDL_FALSE;
}
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:130
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_RendererInfo::texture_formats
Uint32 texture_formats[16]
Definition: SDL_render.h:83
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_RendererInfo::num_texture_formats
Uint32 num_texture_formats
Definition: SDL_render.h:82

## RenderDrawLinesWithRects()

static int RenderDrawLinesWithRects | ( | SDL_Renderer * | renderer,
|  | const SDL_Point * | points,
|  | int | count
| ) |  |

static

Definition at line 1649 of file SDL_render.c.

References SDL_FRect::h, i, SDL_Renderer::RenderDrawLines, SDL_Renderer::RenderFillRects, SDL_Renderer::scale, SDL_max, SDL_min, SDL_OutOfMemory, SDL_stack_alloc, SDL_stack_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_Point::x, SDL_FPoint::y, SDL_FRect::y, and SDL_Point::y.

Referenced by SDL_RenderDrawLines().

{
SDL_FRect *frect;
SDL_FRect *frects;
SDL_FPoint fpoints[2];
int i, nrects;
int status;
frects = SDL_stack_alloc(SDL_FRect, count-1);
if (!frects) {
return SDL_OutOfMemory();
}
status = 0;
nrects = 0;
for (i = 0; i < count-1; ++i) {
if (points[i].x == points[i+1].x) {
int minY = SDL_min(points[i].y, points[i+1].y);
int maxY = SDL_max(points[i].y, points[i+1].y);
frect = &frects[nrects++];
frect->x = points[i].x * renderer->scale.x;
frect->y = minY * renderer->scale.y;
frect->w = renderer->scale.x;
frect->h = (maxY - minY + 1) * renderer->scale.y;
} else if (points[i].y == points[i+1].y) {
int minX = SDL_min(points[i].x, points[i+1].x);
int maxX = SDL_max(points[i].x, points[i+1].x);
frect = &frects[nrects++];
frect->x = minX * renderer->scale.x;
frect->y = points[i].y * renderer->scale.y;
frect->w = (maxX - minX + 1) * renderer->scale.x;
frect->h = renderer->scale.y;
} else {
/* FIXME: We can't use a rect for this line... */
fpoints[0].x = points[i].x * renderer->scale.x;
fpoints[0].y = points[i].y * renderer->scale.y;
fpoints[1].x = points[i+1].x * renderer->scale.x;
fpoints[1].y = points[i+1].y * renderer->scale.y;
status += renderer->RenderDrawLines(renderer, fpoints, 2);
}
}
status += renderer->RenderFillRects(renderer, frects, nrects);
SDL_stack_free(frects);
if (status < 0) {
status = -1;
}
return status;
}
SDL_Renderer::RenderDrawLines
int(* RenderDrawLines)(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Definition: SDL_sysrender.h:107
SDL_FRect::w
float w
Definition: SDL_sysrender.h:44
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_Renderer::RenderFillRects
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Definition: SDL_sysrender.h:109
SDL_FRect::y
float y
Definition: SDL_sysrender.h:43
SDL_max
#define SDL_max(x, y)
Definition: SDL_stdinc.h:407
SDL_Point::x
int x
Definition: SDL_rect.h:50
minY
GLfloat minY
Definition: gl2ext.h:446
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_stack_alloc
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:354
maxX
GLfloat GLfloat GLfloat GLfloat maxX
Definition: gl2ext.h:446
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_FRect::h
float h
Definition: SDL_sysrender.h:45
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
maxY
GLfloat GLfloat GLfloat GLfloat GLfloat maxY
Definition: gl2ext.h:446
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:355
SDL_FRect::x
float x
Definition: SDL_sysrender.h:42
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FRect
Definition: SDL_sysrender.h:40
SDL_FPoint
Definition: SDL_sysrender.h:34
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## RenderDrawPointsWithRects()

static int RenderDrawPointsWithRects | ( | SDL_Renderer * | renderer,
|  | const SDL_Point * | points,
|  | int | count
| ) |  |

static

Definition at line 1569 of file SDL_render.c.

References SDL_FRect::h, i, SDL_Renderer::RenderFillRects, SDL_Renderer::scale, SDL_OutOfMemory, SDL_stack_alloc, SDL_stack_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_Point::x, SDL_FPoint::y, SDL_FRect::y, and SDL_Point::y.

Referenced by SDL_RenderDrawPoints().

{
SDL_FRect *frects;
int i;
int status;
frects = SDL_stack_alloc(SDL_FRect, count);
if (!frects) {
return SDL_OutOfMemory();
}
for (i = 0; i < count; ++i) {
frects[i].x = points[i].x * renderer->scale.x;
frects[i].y = points[i].y * renderer->scale.y;
frects[i].w = renderer->scale.x;
frects[i].h = renderer->scale.y;
}
status = renderer->RenderFillRects(renderer, frects, count);
SDL_stack_free(frects);
return status;
}
SDL_FRect::w
float w
Definition: SDL_sysrender.h:44
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_Renderer::RenderFillRects
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Definition: SDL_sysrender.h:109
SDL_FRect::y
float y
Definition: SDL_sysrender.h:43
SDL_Point::x
int x
Definition: SDL_rect.h:50
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_stack_alloc
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:354
SDL_FRect::h
float h
Definition: SDL_sysrender.h:45
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:355
SDL_FRect::x
float x
Definition: SDL_sysrender.h:42
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FRect
Definition: SDL_sysrender.h:40
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_ComposeCustomBlendMode()

SDL_BlendMode SDL_ComposeCustomBlendMode | ( | SDL_BlendFactor | srcColorFactor,
|  | SDL_BlendFactor | dstColorFactor,
|  | SDL_BlendOperation | colorOperation,
|  | SDL_BlendFactor | srcAlphaFactor,
|  | SDL_BlendFactor | dstAlphaFactor,
|  | SDL_BlendOperation | alphaOperation
| ) |  |

Create a custom blend mode, which may or may not be supported by a given renderer.

Parameters

  srcColorFactor |
  dstColorFactor |
  colorOperation |
  srcAlphaFactor |
  dstAlphaFactor |
  alphaOperation | The result of the blend mode operation will be: dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor and dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor

Definition at line 2182 of file SDL_render.c.

References blendMode, SDL_COMPOSE_BLENDMODE, and SDL_GetShortBlendMode().

{
SDL_BlendMode blendMode = SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation,
srcAlphaFactor, dstAlphaFactor, alphaOperation);
return SDL_GetShortBlendMode(blendMode);
}
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_GetShortBlendMode
static SDL_BlendMode SDL_GetShortBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:2146
SDL_COMPOSE_BLENDMODE
#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
Definition: SDL_render.c:50

## SDL_CreateRenderer()

SDL_Renderer* SDL_CreateRenderer | ( | SDL_Window * | window,
|  | int | index,
|  | Uint32 | flags
| ) |  |

Create a 2D rendering context for a window.

Parameters

  window | The window where rendering is displayed.
  index | The index of the rendering driver to initialize, or -1 to initialize the first one supporting the requested flags.
  flags | SDL_RendererFlags.

Returns
  A valid rendering context or NULL if there was an error.

See also
  SDL_CreateSoftwareRenderer()
  SDL_GetRendererInfo()
  SDL_DestroyRenderer()

Definition at line 278 of file SDL_render.c.

References SDL_RenderDriver::CreateRenderer, SDL_Renderer::dpi_scale, SDL_RendererInfo::flags, SDL_Renderer::GetOutputSize, SDL_Renderer::hidden, SDL_Renderer::info, SDL_RenderDriver::info, SDL_Renderer::magic, SDL_RendererInfo::name, NULL, renderer, renderer_magic, SDL_Renderer::scale, SDL_AddEventWatch, SDL_FALSE, SDL_GetHint, SDL_GetHintBoolean, SDL_GetNumRenderDrivers(), SDL_GetRenderer(), SDL_GetWindowFlags, SDL_GetWindowSize, SDL_HINT_RENDER_DRIVER, SDL_HINT_RENDER_VSYNC, SDL_LOG_CATEGORY_RENDER, SDL_LogInfo, SDL_RENDERER_PRESENTVSYNC, SDL_RendererEventWatch(), SDL_RenderSetViewport(), SDL_SetError, SDL_SetWindowData, SDL_strcasecmp, SDL_TRUE, SDL_WINDOW_HIDDEN, SDL_WINDOW_MINIMIZED, SDL_WINDOWRENDERDATA, SDL_Renderer::window, window_h, window_w, SDL_FPoint::x, and SDL_FPoint::y.

Referenced by SDL_CreateWindowAndRenderer().

{
#if !SDL_RENDER_DISABLED
SDL_Renderer *renderer = NULL;
int n = SDL_GetNumRenderDrivers();
const char *hint;
if (!window) {
SDL_SetError("Invalid window");
return NULL;
}
if (SDL_GetRenderer(window)) {
SDL_SetError("Renderer already associated with window");
return NULL;
}
if (SDL_GetHint(SDL_HINT_RENDER_VSYNC)) {
if (SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)) {
flags |= SDL_RENDERER_PRESENTVSYNC;
} else {
flags &= ~SDL_RENDERER_PRESENTVSYNC;
}
}
if (index < 0) {
hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
if (hint) {
for (index = 0; index < n; ++index) {
const SDL_RenderDriver *driver = render_drivers[index];
if (SDL_strcasecmp(hint, driver->info.name) == 0) {
/* Create a new renderer instance */
renderer = driver->CreateRenderer(window, flags);
break;
}
}
}
if (!renderer) {
for (index = 0; index < n; ++index) {
const SDL_RenderDriver *driver = render_drivers[index];
if ((driver->info.flags & flags) == flags) {
/* Create a new renderer instance */
renderer = driver->CreateRenderer(window, flags);
if (renderer) {
/* Yay, we got one! */
break;
}
}
}
}
if (index == n) {
SDL_SetError("Couldn't find matching render driver");
return NULL;
}
} else {
if (index >= SDL_GetNumRenderDrivers()) {
SDL_SetError("index must be -1 or in the range of 0 - %d",
SDL_GetNumRenderDrivers() - 1);
return NULL;
}
/* Create a new renderer instance */
renderer = render_drivers[index]->CreateRenderer(window, flags);
}
if (renderer) {
renderer->magic = &renderer_magic;
renderer->window = window;
renderer->scale.x = 1.0f;
renderer->scale.y = 1.0f;
renderer->dpi_scale.x = 1.0f;
renderer->dpi_scale.y = 1.0f;
if (window && renderer->GetOutputSize) {
int window_w, window_h;
int output_w, output_h;
if (renderer->GetOutputSize(renderer, &output_w, &output_h) == 0) {
SDL_GetWindowSize(renderer->window, &window_w, &window_h);
renderer->dpi_scale.x = (float)window_w / output_w;
renderer->dpi_scale.y = (float)window_h / output_h;
}
}
if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN|SDL_WINDOW_MINIMIZED)) {
renderer->hidden = SDL_TRUE;
} else {
renderer->hidden = SDL_FALSE;
}
SDL_SetWindowData(window, SDL_WINDOWRENDERDATA, renderer);
SDL_RenderSetViewport(renderer, NULL);
SDL_AddEventWatch(SDL_RendererEventWatch, renderer);
SDL_LogInfo(SDL_LOG_CATEGORY_RENDER,
"Created renderer: %s", renderer->info.name);
}
return renderer;
#else
SDL_SetError("SDL not built with rendering support");
return NULL;
#endif
}
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_HINT_RENDER_VSYNC
#define SDL_HINT_RENDER_VSYNC
A variable controlling whether updates to the SDL screen surface should be synchronized with the vert...
Definition: SDL_hints.h:154
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:130
SDL_RendererInfo::flags
Uint32 flags
Definition: SDL_render.h:81
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_RENDERER_PRESENTVSYNC
Definition: SDL_render.h:69
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
SDL_GetWindowFlags
#define SDL_GetWindowFlags
Definition: SDL_dynapi_overrides.h:518
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_RenderSetViewport
int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the drawing area for rendering on the current target.
Definition: SDL_render.c:1398
SDL_strcasecmp
#define SDL_strcasecmp
Definition: SDL_dynapi_overrides.h:419
SDL_RendererInfo::name
const char * name
Definition: SDL_render.h:80
SDL_WINDOW_HIDDEN
Definition: SDL_video.h:103
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:133
SDL_RenderDriver::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:180
SDL_Renderer::GetOutputSize
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
Definition: SDL_sysrender.h:81
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
SDL_SetWindowData
#define SDL_SetWindowData
Definition: SDL_dynapi_overrides.h:522
SDL_GetWindowSize
#define SDL_GetWindowSize
Definition: SDL_dynapi_overrides.h:527
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_RenderDriver::CreateRenderer
SDL_Renderer *(* CreateRenderer)(SDL_Window *window, Uint32 flags)
Definition: SDL_sysrender.h:177
SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:106
SDL_GetNumRenderDrivers
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
Definition: SDL_render.c:111
index
GLuint index
Definition: SDL_opengl_glext.h:660
NULL
#define NULL
Definition: begin_code.h:164
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
render_drivers
static const SDL_RenderDriver * render_drivers[]
Definition: SDL_render.c:76
SDL_WINDOWRENDERDATA
#define SDL_WINDOWRENDERDATA
Definition: SDL_render.c:33
flags
GLbitfield flags
Definition: SDL_opengl_glext.h:1480
SDL_RenderDriver
Definition: SDL_sysrender.h:175
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_AddEventWatch
#define SDL_AddEventWatch
Definition: SDL_dynapi_overrides.h:128
SDL_LogInfo
#define SDL_LogInfo
Definition: SDL_dynapi_overrides.h:34
SDL_GetRenderer
SDL_Renderer * SDL_GetRenderer(SDL_Window *window)
Get the renderer associated with a window.
Definition: SDL_render.c:408
n
GLdouble n
Definition: SDL_opengl_glext.h:1952
SDL_HINT_RENDER_DRIVER
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
Definition: SDL_hints.h:85
window_h
int window_h
Definition: testoverlay2.c:144
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:78
renderer_magic
static char renderer_magic
Definition: SDL_render.c:105
SDL_LOG_CATEGORY_RENDER
Definition: SDL_log.h:72
window_w
int window_w
Definition: testoverlay2.c:143
SDL_Renderer::dpi_scale
SDL_FPoint dpi_scale
Definition: SDL_sysrender.h:162
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_RendererEventWatch
static int SDL_RendererEventWatch(void *userdata, SDL_Event *event)
Definition: SDL_render.c:136
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_CreateSoftwareRenderer()

SDL_Renderer* SDL_CreateSoftwareRenderer | ( | SDL_Surface * | surface | ) |

Create a 2D software rendering context for a surface.

Parameters

  surface | The surface where rendering is done.

Returns
  A valid rendering context or NULL if there was an error.

See also
  SDL_CreateRenderer()
  SDL_DestroyRenderer()

Definition at line 386 of file SDL_render.c.

References SDL_Renderer::magic, NULL, renderer, renderer_magic, SDL_Renderer::scale, SDL_RenderSetViewport(), SDL_SetError, SW_CreateRendererForSurface(), SDL_FPoint::x, and SDL_FPoint::y.

{
#if !SDL_RENDER_DISABLED
SDL_Renderer *renderer;
renderer = SW_CreateRendererForSurface(surface);
if (renderer) {
renderer->magic = &renderer_magic;
renderer->scale.x = 1.0f;
renderer->scale.y = 1.0f;
SDL_RenderSetViewport(renderer, NULL);
}
return renderer;
#else
SDL_SetError("SDL not built with rendering support");
return NULL;
#endif /* !SDL_RENDER_DISABLED */
}
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_RenderSetViewport
int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the drawing area for rendering on the current target.
Definition: SDL_render.c:1398
SW_CreateRendererForSurface
SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface *surface)
Definition: SDL_render_sw.c:126
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
NULL
#define NULL
Definition: begin_code.h:164
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:78
renderer_magic
static char renderer_magic
Definition: SDL_render.c:105
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_CreateTexture()

SDL_Texture* SDL_CreateTexture | ( | SDL_Renderer * | renderer,
|  | Uint32 | format,
|  | int | access,
|  | int | w,
|  | int | h
| ) |  |

Create a texture for a rendering context.

Parameters

  renderer | The renderer.
  format | The format of the texture.
  access | One of the enumerated values in SDL_TextureAccess.
  w | The width of the texture in pixels.
  h | The height of the texture in pixels.

Returns
  The created texture is returned, or NULL if no rendering context was active, the format was unsupported, or the width or height were out of range.

Note
  The contents of the texture are not defined at creation.

See also
  SDL_QueryTexture()
  SDL_UpdateTexture()
  SDL_DestroyTexture()

Definition at line 497 of file SDL_render.c.

References SDL_Texture::a, SDL_Texture::access, SDL_Texture::b, CHECK_RENDERER_MAGIC, SDL_Renderer::CreateTexture, SDL_Texture::format, SDL_Texture::g, GetClosestSupportedFormat(), SDL_Texture::h, SDL_Renderer::info, IsSupportedFormat(), SDL_Texture::magic, SDL_RendererInfo::max_texture_height, SDL_RendererInfo::max_texture_width, SDL_Texture::native, SDL_Texture::next, NULL, SDL_Texture::pitch, SDL_Texture::pixels, SDL_Texture::prev, SDL_Texture::r, renderer, SDL_Texture::renderer, SDL_BYTESPERPIXEL, SDL_calloc, SDL_DestroyTexture(), SDL_ISPIXELFORMAT_FOURCC, SDL_ISPIXELFORMAT_INDEXED, SDL_OutOfMemory, SDL_SetError, SDL_SW_CreateYUVTexture(), SDL_TEXTUREACCESS_STREAMING, SDL_RendererInfo::texture_formats, texture_magic, SDL_Renderer::textures, SDL_Texture::w, and SDL_Texture::yuv.

Referenced by SDL_CreateTextureFromSurface().

{
SDL_Texture *texture;
CHECK_RENDERER_MAGIC(renderer, NULL);
if (!format) {
format = renderer->info.texture_formats[0];
}
if (SDL_BYTESPERPIXEL(format) == 0) {
SDL_SetError("Invalid texture format");
return NULL;
}
if (SDL_ISPIXELFORMAT_INDEXED(format)) {
SDL_SetError("Palettized textures are not supported");
return NULL;
}
if (w <= 0 || h <= 0) {
SDL_SetError("Texture dimensions can't be 0");
return NULL;
}
if ((renderer->info.max_texture_width && w > renderer->info.max_texture_width) ||
(renderer->info.max_texture_height && h > renderer->info.max_texture_height)) {
SDL_SetError("Texture dimensions are limited to %dx%d", renderer->info.max_texture_width, renderer->info.max_texture_height);
return NULL;
}
texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
if (!texture) {
SDL_OutOfMemory();
return NULL;
}
texture->magic = &texture_magic;
texture->format = format;
texture->access = access;
texture->w = w;
texture->h = h;
texture->r = 255;
texture->g = 255;
texture->b = 255;
texture->a = 255;
texture->renderer = renderer;
texture->next = renderer->textures;
if (renderer->textures) {
renderer->textures->prev = texture;
}
renderer->textures = texture;
if (IsSupportedFormat(renderer, format)) {
if (renderer->CreateTexture(renderer, texture) < 0) {
SDL_DestroyTexture(texture);
return NULL;
}
} else {
texture->native = SDL_CreateTexture(renderer,
GetClosestSupportedFormat(renderer, format),
access, w, h);
if (!texture->native) {
SDL_DestroyTexture(texture);
return NULL;
}
/* Swap textures to have texture before texture->native in the list */
texture->native->next = texture->next;
if (texture->native->next) {
texture->native->next->prev = texture->native;
}
texture->prev = texture->native->prev;
if (texture->prev) {
texture->prev->next = texture;
}
texture->native->prev = texture;
texture->next = texture->native;
renderer->textures = texture;
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
texture->yuv = SDL_SW_CreateYUVTexture(format, w, h);
if (!texture->yuv) {
SDL_DestroyTexture(texture);
return NULL;
}
} else if (access == SDL_TEXTUREACCESS_STREAMING) {
/* The pitch is 4 byte aligned */
texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3);
texture->pixels = SDL_calloc(1, texture->pitch * h);
if (!texture->pixels) {
SDL_DestroyTexture(texture);
return NULL;
}
}
}
return texture;
}
SDL_Texture::pixels
void * pixels
Definition: SDL_sysrender.h:65
SDL_Texture::pitch
int pitch
Definition: SDL_sysrender.h:66
SDL_SW_CreateYUVTexture
SDL_SW_YUVTexture * SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
Definition: SDL_yuv_sw.c:31
SDL_RendererInfo::max_texture_width
int max_texture_width
Definition: SDL_render.h:84
GetClosestSupportedFormat
static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, Uint32 format)
Definition: SDL_render.c:471
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:130
SDL_ISPIXELFORMAT_INDEXED
#define SDL_ISPIXELFORMAT_INDEXED(format)
Definition: SDL_pixels.h:134
SDL_Texture::g
Uint8 g
Definition: SDL_sysrender.h:58
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_RendererInfo::texture_formats
Uint32 texture_formats[16]
Definition: SDL_render.h:83
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
SDL_Renderer::textures
SDL_Texture * textures
Definition: SDL_sysrender.h:165
SDL_RendererInfo::max_texture_height
int max_texture_height
Definition: SDL_render.h:85
texture_magic
static char texture_magic
Definition: SDL_render.c:106
SDL_Texture::a
Uint8 a
Definition: SDL_sysrender.h:58
access
GLuint GLint GLboolean GLint GLenum access
Definition: SDL_opengl_glext.h:2162
SDL_Texture
Definition: SDL_sysrender.h:49
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
SDL_Texture::next
SDL_Texture * next
Definition: SDL_sysrender.h:72
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_DestroyTexture
void SDL_DestroyTexture(SDL_Texture *texture)
Destroy the specified texture.
Definition: SDL_render.c:2034
SDL_Texture::prev
SDL_Texture * prev
Definition: SDL_sysrender.h:71
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:94
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
NULL
#define NULL
Definition: begin_code.h:164
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_Texture::b
Uint8 b
Definition: SDL_sysrender.h:58
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
IsSupportedFormat
static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, Uint32 format)
Definition: SDL_render.c:458
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_Renderer::CreateTexture
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:83
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_ISPIXELFORMAT_FOURCC
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:167
SDL_Texture::magic
const void * magic
Definition: SDL_sysrender.h:51
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53
SDL_CreateTexture
SDL_Texture * SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int h)
Create a texture for a rendering context.
Definition: SDL_render.c:497
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55
SDL_Texture::r
Uint8 r
Definition: SDL_sysrender.h:58

## SDL_CreateTextureFromSurface()

SDL_Texture* SDL_CreateTextureFromSurface | ( | SDL_Renderer * | renderer,
|  | SDL_Surface * | surface
| ) |  |

Create a texture from an existing surface.

Parameters

  renderer | The renderer.
  surface | The surface containing pixel data used to fill the texture.

Returns
  The created texture is returned, or NULL on error.

Note
  The surface is not modified or freed by this function.

See also
  SDL_QueryTexture()
  SDL_DestroyTexture()

Definition at line 591 of file SDL_render.c.

References SDL_PixelFormat::Amask, blendMode, CHECK_RENDERER_MAGIC, SDL_Surface::format, SDL_PixelFormat::format, SDL_Surface::h, i, SDL_Renderer::info, NULL, SDL_RendererInfo::num_texture_formats, SDL_Surface::pitch, SDL_Surface::pixels, SDL_AllocFormat, SDL_BLENDMODE_BLEND, SDL_ConvertSurface, SDL_CreateTexture(), SDL_DestroyTexture(), SDL_FALSE, SDL_FreeFormat, SDL_FreeSurface, SDL_GetColorKey, SDL_GetSurfaceAlphaMod, SDL_GetSurfaceBlendMode, SDL_GetSurfaceColorMod, SDL_ISPIXELFORMAT_ALPHA, SDL_ISPIXELFORMAT_FOURCC, SDL_LockSurface, SDL_MUSTLOCK, SDL_SetError, SDL_SetTextureAlphaMod(), SDL_SetTextureBlendMode(), SDL_SetTextureColorMod(), SDL_TEXTUREACCESS_STATIC, SDL_TRUE, SDL_UnlockSurface, SDL_UpdateTexture(), SDL_RendererInfo::texture_formats, and SDL_Surface::w.

{
const SDL_PixelFormat *fmt;
SDL_bool needAlpha;
Uint32 i;
Uint32 format;
SDL_Texture *texture;
CHECK_RENDERER_MAGIC(renderer, NULL);
if (!surface) {
SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
return NULL;
}
/* See what the best texture format is */
fmt = surface->format;
if (fmt->Amask || SDL_GetColorKey(surface, NULL) == 0) {
needAlpha = SDL_TRUE;
} else {
needAlpha = SDL_FALSE;
}
format = renderer->info.texture_formats[0];
for (i = 0; i < renderer->info.num_texture_formats; ++i) {
if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) &&
SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) {
format = renderer->info.texture_formats[i];
break;
}
}
texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC,
surface->w, surface->h);
if (!texture) {
return NULL;
}
if (format == surface->format->format) {
if (SDL_MUSTLOCK(surface)) {
SDL_LockSurface(surface);
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
SDL_UnlockSurface(surface);
} else {
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
}
} else {
SDL_PixelFormat *dst_fmt;
SDL_Surface *temp = NULL;
/* Set up a destination surface for the texture update */
dst_fmt = SDL_AllocFormat(format);
if (!dst_fmt) {
SDL_DestroyTexture(texture);
return NULL;
}
temp = SDL_ConvertSurface(surface, dst_fmt, 0);
SDL_FreeFormat(dst_fmt);
if (temp) {
SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
SDL_FreeSurface(temp);
} else {
SDL_DestroyTexture(texture);
return NULL;
}
}
{
Uint8 r, g, b, a;
SDL_BlendMode blendMode;
SDL_GetSurfaceColorMod(surface, &r, &g, &b);
SDL_SetTextureColorMod(texture, r, g, b);
SDL_GetSurfaceAlphaMod(surface, &a);
SDL_SetTextureAlphaMod(texture, a);
if (SDL_GetColorKey(surface, NULL) == 0) {
/* We converted to a texture with alpha format */
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
} else {
SDL_GetSurfaceBlendMode(surface, &blendMode);
SDL_SetTextureBlendMode(texture, blendMode);
}
}
return texture;
}
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_UnlockSurface
#define SDL_UnlockSurface
Definition: SDL_dynapi_overrides.h:449
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:130
SDL_Surface::h
int h
Definition: SDL_surface.h:73
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
SDL_ConvertSurface
#define SDL_ConvertSurface
Definition: SDL_dynapi_overrides.h:463
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
SDL_RendererInfo::texture_formats
Uint32 texture_formats[16]
Definition: SDL_render.h:83
SDL_AllocFormat
#define SDL_AllocFormat
Definition: SDL_dynapi_overrides.h:280
SDL_ISPIXELFORMAT_ALPHA
#define SDL_ISPIXELFORMAT_ALPHA(format)
Definition: SDL_pixels.h:154
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
SDL_Surface::w
int w
Definition: SDL_surface.h:73
SDL_Texture
Definition: SDL_sysrender.h:49
SDL_GetSurfaceBlendMode
#define SDL_GetSurfaceBlendMode
Definition: SDL_dynapi_overrides.h:460
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
SDL_SetTextureBlendMode
int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode)
Set the blend mode used for texture copy operations.
Definition: SDL_render.c:777
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_DestroyTexture
void SDL_DestroyTexture(SDL_Texture *texture)
Destroy the specified texture.
Definition: SDL_render.c:2034
SDL_Surface::pixels
void * pixels
Definition: SDL_surface.h:75
SDL_GetColorKey
#define SDL_GetColorKey
Definition: SDL_dynapi_overrides.h:454
SDL_FreeSurface
#define SDL_FreeSurface
Definition: SDL_dynapi_overrides.h:446
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:157
SDL_TEXTUREACCESS_STATIC
Definition: SDL_render.h:93
SDL_FreeFormat
#define SDL_FreeFormat
Definition: SDL_dynapi_overrides.h:281
SDL_GetSurfaceAlphaMod
#define SDL_GetSurfaceAlphaMod
Definition: SDL_dynapi_overrides.h:458
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_SetTextureAlphaMod
int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha)
Set an additional alpha value used in render copy operations.
Definition: SDL_render.c:743
SDL_UpdateTexture
int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL_render.c:896
NULL
#define NULL
Definition: begin_code.h:164
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_LockSurface
#define SDL_LockSurface
Definition: SDL_dynapi_overrides.h:448
SDL_GetSurfaceColorMod
#define SDL_GetSurfaceColorMod
Definition: SDL_dynapi_overrides.h:456
SDL_MUSTLOCK
#define SDL_MUSTLOCK(S)
Definition: SDL_surface.h:61
SDL_PixelFormat
Definition: SDL_pixels.h:315
SDL_Surface::pitch
int pitch
Definition: SDL_surface.h:74
SDL_SetTextureColorMod
int SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in render copy operations.
Definition: SDL_render.c:700
SDL_RendererInfo::num_texture_formats
Uint32 num_texture_formats
Definition: SDL_render.h:82
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:325
SDL_ISPIXELFORMAT_FOURCC
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:167
SDL_PixelFormat::format
Uint32 format
Definition: SDL_pixels.h:317
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
SDL_CreateTexture
SDL_Texture * SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int h)
Create a texture for a rendering context.
Definition: SDL_render.c:497
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

## SDL_CreateWindowAndRenderer()

int SDL_CreateWindowAndRenderer | ( | int | width,
|  | int | height,
|  | Uint32 | window_flags,
|  | SDL_Window ** | window,
|  | SDL_Renderer ** | renderer
| ) |  |

Create a window and default renderer.

Parameters

  width | The width of the window
  height | The height of the window
  window_flags | The flags used to create the window
  window | A pointer filled with the window, or NULL on error
  renderer | A pointer filled with the renderer, or NULL on error

Returns
  0 on success, or -1 on error

Definition at line 258 of file SDL_render.c.

References NULL, SDL_CreateRenderer(), SDL_CreateWindow, and SDL_WINDOWPOS_UNDEFINED.

{
*window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
width, height, window_flags);
if (!*window) {
*renderer = NULL;
return -1;
}
*renderer = SDL_CreateRenderer(*window, -1, 0);
if (!*renderer) {
return -1;
}
return 0;
}
SDL_CreateWindow
#define SDL_CreateWindow
Definition: SDL_dynapi_overrides.h:514
SDL_WINDOWPOS_UNDEFINED
#define SDL_WINDOWPOS_UNDEFINED
Definition: SDL_video.h:130
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
NULL
#define NULL
Definition: begin_code.h:164
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
SDL_CreateRenderer
SDL_Renderer * SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags)
Create a 2D rendering context for a window.
Definition: SDL_render.c:278

## SDL_DestroyRenderer()

void SDL_DestroyRenderer | ( | SDL_Renderer * | renderer | ) |

Destroy the rendering context for a window and free associated textures.

See also
  SDL_CreateRenderer()

Definition at line 2069 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::DestroyRenderer, SDL_Renderer::magic, NULL, SDL_assert, SDL_DelEventWatch, SDL_DestroyTexture(), SDL_RendererEventWatch(), SDL_SetWindowData, SDL_WINDOWRENDERDATA, SDL_Renderer::textures, void, and SDL_Renderer::window.

{
CHECK_RENDERER_MAGIC(renderer, );
SDL_DelEventWatch(SDL_RendererEventWatch, renderer);
/* Free existing textures for this renderer */
while (renderer->textures) {
SDL_Texture *tex = renderer->textures; (void) tex;
SDL_DestroyTexture(renderer->textures);
SDL_assert(tex != renderer->textures); /* satisfy static analysis. */
}
if (renderer->window) {
SDL_SetWindowData(renderer->window, SDL_WINDOWRENDERDATA, NULL);
}
/* It's no longer magical... */
renderer->magic = NULL;
/* Free the renderer instance */
renderer->DestroyRenderer(renderer);
}
SDL_DelEventWatch
#define SDL_DelEventWatch
Definition: SDL_dynapi_overrides.h:129
SDL_Renderer::textures
SDL_Texture * textures
Definition: SDL_sysrender.h:165
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:133
SDL_Renderer::DestroyRenderer
void(* DestroyRenderer)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:121
SDL_Texture
Definition: SDL_sysrender.h:49
SDL_SetWindowData
#define SDL_SetWindowData
Definition: SDL_dynapi_overrides.h:522
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_DestroyTexture
void SDL_DestroyTexture(SDL_Texture *texture)
Destroy the specified texture.
Definition: SDL_render.c:2034
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
NULL
#define NULL
Definition: begin_code.h:164
SDL_WINDOWRENDERDATA
#define SDL_WINDOWRENDERDATA
Definition: SDL_render.c:33
void
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
Definition: SDL_dynapi_procs.h:89
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:78
SDL_RendererEventWatch
static int SDL_RendererEventWatch(void *userdata, SDL_Event *event)
Definition: SDL_render.c:136

## SDL_DestroyTexture()

void SDL_DestroyTexture | ( | SDL_Texture * | texture | ) |

Destroy the specified texture.

See also
  SDL_CreateTexture()
  SDL_CreateTextureFromSurface()

Definition at line 2034 of file SDL_render.c.

References CHECK_TEXTURE_MAGIC, SDL_Renderer::DestroyTexture, SDL_Texture::magic, SDL_Texture::native, SDL_Texture::next, NULL, SDL_Texture::pixels, SDL_Texture::prev, renderer, SDL_Texture::renderer, SDL_free, SDL_SetRenderTarget(), SDL_SW_DestroyYUVTexture(), SDL_Renderer::target, SDL_Renderer::textures, and SDL_Texture::yuv.

Referenced by SDL_CreateTexture(), SDL_CreateTextureFromSurface(), and SDL_DestroyRenderer().

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, );
renderer = texture->renderer;
if (texture == renderer->target) {
SDL_SetRenderTarget(renderer, NULL);
}
texture->magic = NULL;
if (texture->next) {
texture->next->prev = texture->prev;
}
if (texture->prev) {
texture->prev->next = texture->next;
} else {
renderer->textures = texture->next;
}
if (texture->native) {
SDL_DestroyTexture(texture->native);
}
if (texture->yuv) {
SDL_SW_DestroyYUVTexture(texture->yuv);
}
SDL_free(texture->pixels);
renderer->DestroyTexture(renderer, texture);
SDL_free(texture);
}
SDL_Texture::pixels
void * pixels
Definition: SDL_sysrender.h:65
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_Renderer::textures
SDL_Texture * textures
Definition: SDL_sysrender.h:165
SDL_Texture::next
SDL_Texture * next
Definition: SDL_sysrender.h:72
SDL_DestroyTexture
void SDL_DestroyTexture(SDL_Texture *texture)
Destroy the specified texture.
Definition: SDL_render.c:2034
SDL_Texture::prev
SDL_Texture * prev
Definition: SDL_sysrender.h:71
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:166
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_SW_DestroyYUVTexture
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
Definition: SDL_yuv_sw.c:404
NULL
#define NULL
Definition: begin_code.h:164
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Renderer::DestroyTexture
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:119
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_SetRenderTarget
int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
Set a texture as the current rendering target.
Definition: SDL_render.c:1165
SDL_Texture::magic
const void * magic
Definition: SDL_sysrender.h:51

## SDL_GetBlendModeAlphaOperation()

SDL_BlendOperation SDL_GetBlendModeAlphaOperation | ( | SDL_BlendMode | blendMode | ) |

Definition at line 2228 of file SDL_render.c.

References SDL_GetLongBlendMode().

{
blendMode = SDL_GetLongBlendMode(blendMode);
return (SDL_BlendOperation)(((Uint32)blendMode >> 16) & 0xF);
}
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
SDL_BlendOperation
SDL_BlendOperation
The blend operation used when combining source and destination pixel components.
Definition: SDL_blendmode.h:62
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_GetLongBlendMode
static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:2164

## SDL_GetBlendModeColorOperation()

SDL_BlendOperation SDL_GetBlendModeColorOperation | ( | SDL_BlendMode | blendMode | ) |

Definition at line 2207 of file SDL_render.c.

References SDL_GetLongBlendMode().

{
blendMode = SDL_GetLongBlendMode(blendMode);
return (SDL_BlendOperation)(((Uint32)blendMode >> 0) & 0xF);
}
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
SDL_BlendOperation
SDL_BlendOperation
The blend operation used when combining source and destination pixel components.
Definition: SDL_blendmode.h:62
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_GetLongBlendMode
static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:2164

## SDL_GetBlendModeDstAlphaFactor()

SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor | ( | SDL_BlendMode | blendMode | ) |

Definition at line 2221 of file SDL_render.c.

References SDL_GetLongBlendMode().

{
blendMode = SDL_GetLongBlendMode(blendMode);
return (SDL_BlendFactor)(((Uint32)blendMode >> 24) & 0xF);
}
SDL_BlendFactor
SDL_BlendFactor
The normalized factor used to multiply pixel components.
Definition: SDL_blendmode.h:75
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_GetLongBlendMode
static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:2164

## SDL_GetBlendModeDstColorFactor()

SDL_BlendFactor SDL_GetBlendModeDstColorFactor | ( | SDL_BlendMode | blendMode | ) |

Definition at line 2200 of file SDL_render.c.

References SDL_GetLongBlendMode().

{
blendMode = SDL_GetLongBlendMode(blendMode);
return (SDL_BlendFactor)(((Uint32)blendMode >> 8) & 0xF);
}
SDL_BlendFactor
SDL_BlendFactor
The normalized factor used to multiply pixel components.
Definition: SDL_blendmode.h:75
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_GetLongBlendMode
static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:2164

## SDL_GetBlendModeSrcAlphaFactor()

SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor | ( | SDL_BlendMode | blendMode | ) |

Definition at line 2214 of file SDL_render.c.

References SDL_GetLongBlendMode().

{
blendMode = SDL_GetLongBlendMode(blendMode);
return (SDL_BlendFactor)(((Uint32)blendMode >> 20) & 0xF);
}
SDL_BlendFactor
SDL_BlendFactor
The normalized factor used to multiply pixel components.
Definition: SDL_blendmode.h:75
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_GetLongBlendMode
static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:2164

## SDL_GetBlendModeSrcColorFactor()

SDL_BlendFactor SDL_GetBlendModeSrcColorFactor | ( | SDL_BlendMode | blendMode | ) |

Definition at line 2193 of file SDL_render.c.

References SDL_GetLongBlendMode().

{
blendMode = SDL_GetLongBlendMode(blendMode);
return (SDL_BlendFactor)(((Uint32)blendMode >> 4) & 0xF);
}
SDL_BlendFactor
SDL_BlendFactor
The normalized factor used to multiply pixel components.
Definition: SDL_blendmode.h:75
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:181
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_GetLongBlendMode
static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:2164

## SDL_GetLongBlendMode()

static SDL_BlendMode SDL_GetLongBlendMode | ( | SDL_BlendMode | blendMode | ) |

static

Definition at line 2164 of file SDL_render.c.

References blendMode, SDL_BLENDMODE_ADD, SDL_BLENDMODE_ADD_FULL, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_BLEND_FULL, SDL_BLENDMODE_MOD, SDL_BLENDMODE_MOD_FULL, SDL_BLENDMODE_NONE, and SDL_BLENDMODE_NONE_FULL.

Referenced by SDL_GetBlendModeAlphaOperation(), SDL_GetBlendModeColorOperation(), SDL_GetBlendModeDstAlphaFactor(), SDL_GetBlendModeDstColorFactor(), SDL_GetBlendModeSrcAlphaFactor(), and SDL_GetBlendModeSrcColorFactor().

{
if (blendMode == SDL_BLENDMODE_NONE) {
return SDL_BLENDMODE_NONE_FULL;
}
if (blendMode == SDL_BLENDMODE_BLEND) {
return SDL_BLENDMODE_BLEND_FULL;
}
if (blendMode == SDL_BLENDMODE_ADD) {
return SDL_BLENDMODE_ADD_FULL;
}
if (blendMode == SDL_BLENDMODE_MOD) {
return SDL_BLENDMODE_MOD_FULL;
}
return blendMode;
}
SDL_BLENDMODE_NONE
Definition: SDL_blendmode.h:42
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_BLENDMODE_BLEND_FULL
#define SDL_BLENDMODE_BLEND_FULL
Definition: SDL_render.c:63
SDL_BLENDMODE_MOD_FULL
#define SDL_BLENDMODE_MOD_FULL
Definition: SDL_render.c:71
SDL_BLENDMODE_NONE_FULL
#define SDL_BLENDMODE_NONE_FULL
Definition: SDL_render.c:59
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_BLENDMODE_ADD_FULL
#define SDL_BLENDMODE_ADD_FULL
Definition: SDL_render.c:67
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

## SDL_GetNumRenderDrivers()

int SDL_GetNumRenderDrivers | ( | void |  | ) |

Get the number of 2D rendering drivers available for the current display.

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.

See also
  SDL_GetRenderDriverInfo()
  SDL_CreateRenderer()

Definition at line 111 of file SDL_render.c.

References SDL_arraysize.

Referenced by SDL_CreateRenderer(), and SDL_GetRenderDriverInfo().

{
#if !SDL_RENDER_DISABLED
return SDL_arraysize(render_drivers);
#else
return 0;
#endif
}
render_drivers
static const SDL_RenderDriver * render_drivers[]
Definition: SDL_render.c:76
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93

## SDL_GetRenderDrawBlendMode()

int SDL_GetRenderDrawBlendMode | ( | SDL_Renderer * | renderer,
|  | SDL_BlendMode * | blendMode
| ) |  |

Get the blend mode used for drawing operations.

Parameters

  renderer | The renderer from which blend mode should be queried.
  blendMode | A pointer filled in with the current blend mode.

Returns
  0 on success, or -1 on error

See also
  SDL_SetRenderDrawBlendMode()

Definition at line 1538 of file SDL_render.c.

References SDL_Renderer::blendMode, and CHECK_RENDERER_MAGIC.

{
CHECK_RENDERER_MAGIC(renderer, -1);
*blendMode = renderer->blendMode;
return 0;
}
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::blendMode
SDL_BlendMode blendMode
Definition: SDL_sysrender.h:169

## SDL_GetRenderDrawColor()

int SDL_GetRenderDrawColor | ( | SDL_Renderer * | renderer,
|  | Uint8 * | r,
|  | Uint8 * | g,
|  | Uint8 * | b,
|  | Uint8 * | a
| ) |  |

Get the color used for drawing operations (Rect, Line and Clear).

Parameters

  renderer | The renderer from which drawing color should be queried.
  r | A pointer to the red value used to draw on the rendering target.
  g | A pointer to the green value used to draw on the rendering target.
  b | A pointer to the blue value used to draw on the rendering target.
  a | A pointer to the alpha value used to draw on the rendering target, usually SDL_ALPHA_OPAQUE (255).

Returns
  0 on success, or -1 on error

Definition at line 1505 of file SDL_render.c.

References SDL_Renderer::a, SDL_Renderer::b, CHECK_RENDERER_MAGIC, SDL_Renderer::g, and SDL_Renderer::r.

{
CHECK_RENDERER_MAGIC(renderer, -1);
if (r) {
*r = renderer->r;
}
if (g) {
*g = renderer->g;
}
if (b) {
*b = renderer->b;
}
if (a) {
*a = renderer->a;
}
return 0;
}
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::g
Uint8 g
Definition: SDL_sysrender.h:168
SDL_Renderer::b
Uint8 b
Definition: SDL_sysrender.h:168
SDL_Renderer::r
Uint8 r
Definition: SDL_sysrender.h:168
SDL_Renderer::a
Uint8 a
Definition: SDL_sysrender.h:168
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

## SDL_GetRenderDriverInfo()

int SDL_GetRenderDriverInfo | ( | int | index,
|  | SDL_RendererInfo * | info
| ) |  |

Get information about a specific 2D rendering driver for the current display.

Parameters

  index | The index of the driver to query information about.
  info | A pointer to an SDL_RendererInfo struct to be filled with information on the rendering driver.

Returns
  0 on success, -1 if the index was out of range.

See also
  SDL_CreateRenderer()

Definition at line 121 of file SDL_render.c.

References SDL_RenderDriver::info, SDL_GetNumRenderDrivers(), SDL_SetError, and SDLCALL.

{
#if !SDL_RENDER_DISABLED
if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
return SDL_SetError("index must be in the range of 0 - %d",
SDL_GetNumRenderDrivers() - 1);
}
*info = render_drivers[index]->info;
return 0;
#else
return SDL_SetError("SDL not built with rendering support");
#endif
}
SDL_RenderDriver::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:180
SDL_GetNumRenderDrivers
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
Definition: SDL_render.c:111
index
GLuint index
Definition: SDL_opengl_glext.h:660
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
render_drivers
static const SDL_RenderDriver * render_drivers[]
Definition: SDL_render.c:76

## SDL_GetRenderer()

SDL_Renderer* SDL_GetRenderer | ( | SDL_Window * | window | ) |

Get the renderer associated with a window.

Definition at line 408 of file SDL_render.c.

References SDL_GetWindowData, and SDL_WINDOWRENDERDATA.

Referenced by SDL_CreateRenderer().

{
return (SDL_Renderer *)SDL_GetWindowData(window, SDL_WINDOWRENDERDATA);
}
SDL_GetWindowData
#define SDL_GetWindowData
Definition: SDL_dynapi_overrides.h:523
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_WINDOWRENDERDATA
#define SDL_WINDOWRENDERDATA
Definition: SDL_render.c:33

## SDL_GetRendererInfo()

int SDL_GetRendererInfo | ( | SDL_Renderer * | renderer,
|  | SDL_RendererInfo * | info
| ) |  |

Get information about a rendering context.

Definition at line 414 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, and SDL_Renderer::info.

{
CHECK_RENDERER_MAGIC(renderer, -1);
*info = renderer->info;
return 0;
}
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:130
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35

## SDL_GetRendererOutputSize()

int SDL_GetRendererOutputSize | ( | SDL_Renderer * | renderer,
|  | int * | w,
|  | int * | h
| ) |  |

Get the output size in pixels of a rendering context.

Definition at line 423 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::GetOutputSize, NULL, SDL_assert, SDL_GetWindowSize, SDL_QueryTexture(), SDL_SetError, SDL_Renderer::target, and SDL_Renderer::window.

Referenced by SDL_RendererEventWatch(), SDL_RenderSetViewport(), and UpdateLogicalSize().

{
CHECK_RENDERER_MAGIC(renderer, -1);
if (renderer->target) {
return SDL_QueryTexture(renderer->target, NULL, NULL, w, h);
} else if (renderer->GetOutputSize) {
return renderer->GetOutputSize(renderer, w, h);
} else if (renderer->window) {
SDL_GetWindowSize(renderer->window, w, h);
return 0;
} else {
SDL_assert(0 && "This should never happen");
return SDL_SetError("Renderer doesn't support querying output size");
}
}
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:133
SDL_Renderer::GetOutputSize
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
Definition: SDL_sysrender.h:81
SDL_QueryTexture
int SDL_QueryTexture(SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h)
Query the attributes of a texture.
Definition: SDL_render.c:679
SDL_GetWindowSize
#define SDL_GetWindowSize
Definition: SDL_dynapi_overrides.h:527
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:166
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
NULL
#define NULL
Definition: begin_code.h:164
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30

## SDL_GetRenderTarget()

SDL_Texture* SDL_GetRenderTarget | ( | SDL_Renderer * | renderer | ) |

Get the current render target or NULL for the default render target.

Returns
  The current render target

See also
  SDL_SetRenderTarget()

Definition at line 1236 of file SDL_render.c.

References SDL_Renderer::target.

Referenced by SDL_RendererEventWatch().

{
return renderer->target;
}
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:166

## SDL_GetShortBlendMode()

static SDL_BlendMode SDL_GetShortBlendMode | ( | SDL_BlendMode | blendMode | ) |

static

Definition at line 2146 of file SDL_render.c.

References blendMode, SDL_BLENDMODE_ADD, SDL_BLENDMODE_ADD_FULL, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_BLEND_FULL, SDL_BLENDMODE_MOD, SDL_BLENDMODE_MOD_FULL, SDL_BLENDMODE_NONE, and SDL_BLENDMODE_NONE_FULL.

Referenced by SDL_ComposeCustomBlendMode().

{
if (blendMode == SDL_BLENDMODE_NONE_FULL) {
return SDL_BLENDMODE_NONE;
}
if (blendMode == SDL_BLENDMODE_BLEND_FULL) {
return SDL_BLENDMODE_BLEND;
}
if (blendMode == SDL_BLENDMODE_ADD_FULL) {
return SDL_BLENDMODE_ADD;
}
if (blendMode == SDL_BLENDMODE_MOD_FULL) {
return SDL_BLENDMODE_MOD;
}
return blendMode;
}
SDL_BLENDMODE_NONE
Definition: SDL_blendmode.h:42
SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_BLENDMODE_BLEND_FULL
#define SDL_BLENDMODE_BLEND_FULL
Definition: SDL_render.c:63
SDL_BLENDMODE_MOD_FULL
#define SDL_BLENDMODE_MOD_FULL
Definition: SDL_render.c:71
SDL_BLENDMODE_NONE_FULL
#define SDL_BLENDMODE_NONE_FULL
Definition: SDL_render.c:59
SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_BLENDMODE_ADD_FULL
#define SDL_BLENDMODE_ADD_FULL
Definition: SDL_render.c:67
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

## SDL_GetTextureAlphaMod()

int SDL_GetTextureAlphaMod | ( | SDL_Texture * | texture,
|  | Uint8 * | alpha
| ) |  |

Get the additional alpha value used in render copy operations.

Parameters

  texture | The texture to query.
  alpha | A pointer filled in with the current alpha value.

Returns
  0 on success, or -1 if the texture is not valid.

See also
  SDL_SetTextureAlphaMod()

Definition at line 766 of file SDL_render.c.

References SDL_Texture::a, and CHECK_TEXTURE_MAGIC.

{
CHECK_TEXTURE_MAGIC(texture, -1);
if (alpha) {
*alpha = texture->a;
}
return 0;
}
SDL_Texture::a
Uint8 a
Definition: SDL_sysrender.h:58
alpha
GLfloat GLfloat GLfloat alpha
Definition: SDL_opengl_glext.h:412
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42

## SDL_GetTextureBlendMode()

int SDL_GetTextureBlendMode | ( | SDL_Texture * | texture,
|  | SDL_BlendMode * | blendMode
| ) |  |

Get the blend mode used for texture copy operations.

Parameters

  texture | The texture to query.
  blendMode | A pointer filled in with the current blend mode.

Returns
  0 on success, or -1 if the texture is not valid.

See also
  SDL_SetTextureBlendMode()

Definition at line 798 of file SDL_render.c.

References SDL_Texture::blendMode, and CHECK_TEXTURE_MAGIC.

{
CHECK_TEXTURE_MAGIC(texture, -1);
if (blendMode) {
*blendMode = texture->blendMode;
}
return 0;
}
SDL_Texture::blendMode
SDL_BlendMode blendMode
Definition: SDL_sysrender.h:57
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42

## SDL_GetTextureColorMod()

int SDL_GetTextureColorMod | ( | SDL_Texture * | texture,
|  | Uint8 * | r,
|  | Uint8 * | g,
|  | Uint8 * | b
| ) |  |

Get the additional color value used in render copy operations.

Parameters

  texture | The texture to query.
  r | A pointer filled in with the current red color value.
  g | A pointer filled in with the current green color value.
  b | A pointer filled in with the current blue color value.

Returns
  0 on success, or -1 if the texture is not valid.

See also
  SDL_SetTextureColorMod()

Definition at line 725 of file SDL_render.c.

References SDL_Texture::b, CHECK_TEXTURE_MAGIC, SDL_Texture::g, and SDL_Texture::r.

{
CHECK_TEXTURE_MAGIC(texture, -1);
if (r) {
*r = texture->r;
}
if (g) {
*g = texture->g;
}
if (b) {
*b = texture->b;
}
return 0;
}
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_Texture::g
Uint8 g
Definition: SDL_sysrender.h:58
SDL_Texture::b
Uint8 b
Definition: SDL_sysrender.h:58
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
SDL_Texture::r
Uint8 r
Definition: SDL_sysrender.h:58

## SDL_GL_BindTexture()

int SDL_GL_BindTexture | ( | SDL_Texture * | texture,
|  | float * | texw,
|  | float * | texh
| ) |  |

Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions.

Parameters

  texture | The SDL texture to bind
  texw | A pointer to a float that will be filled with the texture width
  texh | A pointer to a float that will be filled with the texture height

Returns
  0 on success, or -1 if the operation is not supported

Definition at line 2093 of file SDL_render.c.

References CHECK_TEXTURE_MAGIC, SDL_Renderer::GL_BindTexture, SDL_Texture::native, renderer, SDL_Texture::renderer, and SDL_Unsupported.

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, -1);
renderer = texture->renderer;
if (texture->native) {
return SDL_GL_BindTexture(texture->native, texw, texh);
} else if (renderer && renderer->GL_BindTexture) {
return renderer->GL_BindTexture(renderer, texture, texw, texh);
} else {
return SDL_Unsupported();
}
}
SDL_Renderer
Definition: SDL_sysrender.h:76
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Renderer::GL_BindTexture
int(* GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
Definition: SDL_sysrender.h:123
SDL_GL_BindTexture
int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh)
Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions.
Definition: SDL_render.c:2093
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53

## SDL_GL_UnbindTexture()

int SDL_GL_UnbindTexture | ( | SDL_Texture * | texture | ) |

Unbind a texture from the current OpenGL/ES/ES2 context.

Parameters

  texture | The SDL texture to unbind

Returns
  0 on success, or -1 if the operation is not supported

Definition at line 2108 of file SDL_render.c.

References CHECK_TEXTURE_MAGIC, SDL_Renderer::GL_UnbindTexture, SDL_Texture::native, renderer, SDL_Texture::renderer, and SDL_Unsupported.

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, -1);
renderer = texture->renderer;
if (texture->native) {
return SDL_GL_UnbindTexture(texture->native);
} else if (renderer && renderer->GL_UnbindTexture) {
return renderer->GL_UnbindTexture(renderer, texture);
}
return SDL_Unsupported();
}
SDL_Renderer
Definition: SDL_sysrender.h:76
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Renderer::GL_UnbindTexture
int(* GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:124
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_GL_UnbindTexture
int SDL_GL_UnbindTexture(SDL_Texture *texture)
Unbind a texture from the current OpenGL/ES/ES2 context.
Definition: SDL_render.c:2108

## SDL_LockTexture()

int SDL_LockTexture | ( | SDL_Texture * | texture,
|  | const SDL_Rect * | rect,
|  | void ** | pixels,
|  | int * | pitch
| ) |  |

Lock a portion of the texture for write-only pixel access.

Parameters

  texture | The texture to lock for access, which was created with SDL_TEXTUREACCESS_STREAMING.
  rect | A pointer to the rectangle to lock for access. If the rect is NULL, the entire texture will be locked.
  pixels | This is filled in with a pointer to the locked pixels, appropriately offset by the locked area.
  pitch | This is filled in with the pitch of the locked pixels.

Returns
  0 on success, or -1 if the texture is not valid or was not created with SDL_TEXTUREACCESS_STREAMING.

See also
  SDL_UnlockTexture()

Definition at line 1063 of file SDL_render.c.

References SDL_Texture::access, CHECK_TEXTURE_MAGIC, SDL_Texture::h, SDL_Rect::h, SDL_Renderer::LockTexture, SDL_Texture::native, renderer, SDL_Texture::renderer, SDL_LockTextureNative(), SDL_LockTextureYUV(), SDL_SetError, SDL_TEXTUREACCESS_STREAMING, SDL_Texture::w, SDL_Rect::w, SDL_Rect::x, SDL_Rect::y, and SDL_Texture::yuv.

Referenced by SDL_UnlockTextureNative(), SDL_UnlockTextureYUV(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), and SDL_UpdateTextureYUVPlanar().

{
SDL_Renderer *renderer;
SDL_Rect full_rect;
CHECK_TEXTURE_MAGIC(texture, -1);
if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
return SDL_SetError("SDL_LockTexture(): texture must be streaming");
}
if (!rect) {
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = texture->w;
full_rect.h = texture->h;
rect = &full_rect;
}
if (texture->yuv) {
return SDL_LockTextureYUV(texture, rect, pixels, pitch);
} else if (texture->native) {
return SDL_LockTextureNative(texture, rect, pixels, pitch);
} else {
renderer = texture->renderer;
return renderer->LockTexture(renderer, texture, rect, pixels, pitch);
}
}
SDL_Renderer::LockTexture
int(* LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_sysrender.h:98
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_LockTextureYUV
static int SDL_LockTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_render.c:1044
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:94
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_Rect::x
int x
Definition: SDL_rect.h:66
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_LockTextureNative
static int SDL_LockTextureNative(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_render.c:1051
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

## SDL_LockTextureNative()

static int SDL_LockTextureNative | ( | SDL_Texture * | texture,
|  | const SDL_Rect * | rect,
|  | void ** | pixels,
|  | int * | pitch
| ) |  |

static

Definition at line 1051 of file SDL_render.c.

References SDL_Texture::format, SDL_Texture::locked_rect, SDL_Texture::pitch, SDL_Texture::pixels, rect, SDL_BYTESPERPIXEL, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_LockTexture().

{
texture->locked_rect = *rect;
*pixels = (void *) ((Uint8 *) texture->pixels +
rect->y * texture->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
*pitch = texture->pitch;
return 0;
}
SDL_Texture::pixels
void * pixels
Definition: SDL_sysrender.h:65
SDL_Texture::pitch
int pitch
Definition: SDL_sysrender.h:66
rect
SDL_Rect rect
Definition: testrelative.c:27
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
SDL_Texture::locked_rect
SDL_Rect locked_rect
Definition: SDL_sysrender.h:67
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:157
SDL_Rect::x
int x
Definition: SDL_rect.h:66
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_Rect::y
int y
Definition: SDL_rect.h:66

## SDL_LockTextureYUV()

static int SDL_LockTextureYUV | ( | SDL_Texture * | texture,
|  | const SDL_Rect * | rect,
|  | void ** | pixels,
|  | int * | pitch
| ) |  |

static

Definition at line 1044 of file SDL_render.c.

References SDL_SW_LockYUVTexture(), and SDL_Texture::yuv.

Referenced by SDL_LockTexture().

{
return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch);
}
SDL_SW_LockYUVTexture
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_yuv_sw.c:302
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572

## SDL_QueryTexture()

int SDL_QueryTexture | ( | SDL_Texture * | texture,
|  | Uint32 * | format,
|  | int * | access,
|  | int * | w,
|  | int * | h
| ) |  |

Query the attributes of a texture.

Parameters

  texture | A texture to be queried.
  format | A pointer filled in with the raw format of the texture. The actual format may differ, but pixel transfers will use this format.
  access | A pointer filled in with the actual access to the texture.
  w | A pointer filled in with the width of the texture in pixels.
  h | A pointer filled in with the height of the texture in pixels.

Returns
  0 on success, or -1 if the texture is not valid.

Definition at line 679 of file SDL_render.c.

References SDL_Texture::access, CHECK_TEXTURE_MAGIC, SDL_Texture::format, SDL_Texture::h, and SDL_Texture::w.

Referenced by SDL_GetRendererOutputSize().

{
CHECK_TEXTURE_MAGIC(texture, -1);
if (format) {
*format = texture->format;
}
if (access) {
*access = texture->access;
}
if (w) {
*w = texture->w;
}
if (h) {
*h = texture->h;
}
return 0;
}
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
access
GLuint GLint GLboolean GLint GLenum access
Definition: SDL_opengl_glext.h:2162
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

## SDL_RenderClear()

int SDL_RenderClear | ( | SDL_Renderer * | renderer | ) |

Clear the current rendering target with the drawing color.

This function clears the entire rendering target, ignoring the viewport and the clip rectangle.

Returns
  0 on success, or -1 on error

Definition at line 1547 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::hidden, and SDL_Renderer::RenderClear.

{
CHECK_RENDERER_MAGIC(renderer, -1);
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
return renderer->RenderClear(renderer);
}
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
SDL_Renderer::RenderClear
int(* RenderClear)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:104
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35

## SDL_RenderCopy()

int SDL_RenderCopy | ( | SDL_Renderer * | renderer,
|  | SDL_Texture * | texture,
|  | const SDL_Rect * | srcrect,
|  | const SDL_Rect * | dstrect
| ) |  |

Copy a portion of the texture to the current rendering target.

Parameters

  renderer | The renderer which should copy parts of a texture.
  texture | The source texture.
  srcrect | A pointer to the source rectangle, or NULL for the entire texture.
  dstrect | A pointer to the destination rectangle, or NULL for the entire rendering target.

Returns
  0 on success, or -1 on error

Definition at line 1861 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, CHECK_TEXTURE_MAGIC, SDL_FRect::h, SDL_Texture::h, SDL_Rect::h, SDL_Renderer::hidden, SDL_Texture::native, SDL_Renderer::RenderCopy, SDL_Texture::renderer, SDL_Renderer::scale, SDL_HasIntersection, SDL_IntersectRect, SDL_RenderGetViewport(), SDL_SetError, SDL_FRect::w, SDL_Texture::w, SDL_Rect::w, SDL_FPoint::x, SDL_FRect::x, SDL_Rect::x, SDL_FPoint::y, SDL_FRect::y, and SDL_Rect::y.

Referenced by SDL_RenderCopyEx().

{
SDL_Rect real_srcrect = { 0, 0, 0, 0 };
SDL_Rect real_dstrect = { 0, 0, 0, 0 };
SDL_FRect frect;
CHECK_RENDERER_MAGIC(renderer, -1);
CHECK_TEXTURE_MAGIC(texture, -1);
if (renderer != texture->renderer) {
return SDL_SetError("Texture was not created with this renderer");
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
real_srcrect.x = 0;
real_srcrect.y = 0;
real_srcrect.w = texture->w;
real_srcrect.h = texture->h;
if (srcrect) {
if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
return 0;
}
}
SDL_RenderGetViewport(renderer, &real_dstrect);
real_dstrect.x = 0;
real_dstrect.y = 0;
if (dstrect) {
if (!SDL_HasIntersection(dstrect, &real_dstrect)) {
return 0;
}
real_dstrect = *dstrect;
}
if (texture->native) {
texture = texture->native;
}
frect.x = real_dstrect.x * renderer->scale.x;
frect.y = real_dstrect.y * renderer->scale.y;
frect.w = real_dstrect.w * renderer->scale.x;
frect.h = real_dstrect.h * renderer->scale.y;
return renderer->RenderCopy(renderer, texture, &real_srcrect, &frect);
}
SDL_FRect::w
float w
Definition: SDL_sysrender.h:44
SDL_HasIntersection
#define SDL_HasIntersection
Definition: SDL_dynapi_overrides.h:293
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:294
SDL_FRect::y
float y
Definition: SDL_sysrender.h:43
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_FRect::h
float h
Definition: SDL_sysrender.h:45
SDL_Renderer::RenderCopy
int(* RenderCopy)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
Definition: SDL_sysrender.h:111
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_RenderGetViewport
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
Definition: SDL_render.c:1418
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_FRect::x
float x
Definition: SDL_sysrender.h:42
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FRect
Definition: SDL_sysrender.h:40
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderCopyEx()

int SDL_RenderCopyEx | ( | SDL_Renderer * | renderer,
|  | SDL_Texture * | texture,
|  | const SDL_Rect * | srcrect,
|  | const SDL_Rect * | dstrect,
|  | const double | angle,
|  | const SDL_Point * | center,
|  | const SDL_RendererFlip | flip
| ) |  |

Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center.

Parameters

  renderer | The renderer which should copy parts of a texture.
  texture | The source texture.
  srcrect | A pointer to the source rectangle, or NULL for the entire texture.
  dstrect | A pointer to the destination rectangle, or NULL for the entire rendering target.
  angle | An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
  center | A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
  flip | An SDL_RendererFlip value stating which flipping actions should be performed on the texture

Returns
  0 on success, or -1 on error

Definition at line 1914 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, CHECK_TEXTURE_MAGIC, SDL_FRect::h, SDL_Texture::h, SDL_Rect::h, SDL_Renderer::hidden, SDL_Texture::native, SDL_Renderer::RenderCopyEx, SDL_Texture::renderer, SDL_Renderer::scale, SDL_FLIP_NONE, SDL_IntersectRect, SDL_RenderCopy(), SDL_RenderGetViewport(), SDL_SetError, SDL_FRect::w, SDL_Texture::w, SDL_Rect::w, SDL_FPoint::x, SDL_FRect::x, SDL_Point::x, SDL_Rect::x, SDL_FPoint::y, SDL_FRect::y, SDL_Point::y, and SDL_Rect::y.

{
SDL_Rect real_srcrect = { 0, 0, 0, 0 };
SDL_Rect real_dstrect = { 0, 0, 0, 0 };
SDL_Point real_center;
SDL_FRect frect;
SDL_FPoint fcenter;
if (flip == SDL_FLIP_NONE && (int)(angle/360) == angle/360) { /* fast path when we don't need rotation or flipping */
return SDL_RenderCopy(renderer, texture, srcrect, dstrect);
}
CHECK_RENDERER_MAGIC(renderer, -1);
CHECK_TEXTURE_MAGIC(texture, -1);
if (renderer != texture->renderer) {
return SDL_SetError("Texture was not created with this renderer");
}
if (!renderer->RenderCopyEx) {
return SDL_SetError("Renderer does not support RenderCopyEx");
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
real_srcrect.x = 0;
real_srcrect.y = 0;
real_srcrect.w = texture->w;
real_srcrect.h = texture->h;
if (srcrect) {
if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
return 0;
}
}
/* We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we? */
if (dstrect) {
real_dstrect = *dstrect;
} else {
SDL_RenderGetViewport(renderer, &real_dstrect);
real_dstrect.x = 0;
real_dstrect.y = 0;
}
if (texture->native) {
texture = texture->native;
}
if (center) {
real_center = *center;
} else {
real_center.x = real_dstrect.w/2;
real_center.y = real_dstrect.h/2;
}
frect.x = real_dstrect.x * renderer->scale.x;
frect.y = real_dstrect.y * renderer->scale.y;
frect.w = real_dstrect.w * renderer->scale.x;
frect.h = real_dstrect.h * renderer->scale.y;
fcenter.x = real_center.x * renderer->scale.x;
fcenter.y = real_center.y * renderer->scale.y;
return renderer->RenderCopyEx(renderer, texture, &real_srcrect, &frect, angle, &fcenter, flip);
}
SDL_FRect::w
float w
Definition: SDL_sysrender.h:44
SDL_RenderCopy
int SDL_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect)
Copy a portion of the texture to the current rendering target.
Definition: SDL_render.c:1861
SDL_FLIP_NONE
Definition: SDL_render.h:113
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
SDL_Point
The structure that defines a point.
Definition: SDL_rect.h:48
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:294
SDL_FRect::y
float y
Definition: SDL_sysrender.h:43
SDL_Point::x
int x
Definition: SDL_rect.h:50
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_FRect::h
float h
Definition: SDL_sysrender.h:45
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
SDL_Renderer::RenderCopyEx
int(* RenderCopyEx)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcquad, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
Definition: SDL_sysrender.h:113
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_RenderGetViewport
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
Definition: SDL_render.c:1418
angle
GLfloat angle
Definition: SDL_opengl_glext.h:6097
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_FRect::x
float x
Definition: SDL_sysrender.h:42
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FRect
Definition: SDL_sysrender.h:40
SDL_FPoint
Definition: SDL_sysrender.h:34
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderDrawLine()

int SDL_RenderDrawLine | ( | SDL_Renderer * | renderer,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2
| ) |  |

Draw a line on the current rendering target.

Parameters

  renderer | The renderer which should draw a line.
  x1 | The x coordinate of the start point.
  y1 | The y coordinate of the start point.
  x2 | The x coordinate of the end point.
  y2 | The y coordinate of the end point.

Returns
  0 on success, or -1 on error

Definition at line 1637 of file SDL_render.c.

References SDL_RenderDrawLines(), SDL_Point::x, and SDL_Point::y.

{
SDL_Point points[2];
points[0].x = x1;
points[0].y = y1;
points[1].x = x2;
points[1].y = y2;
return SDL_RenderDrawLines(renderer, points, 2);
}
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
SDL_Point
The structure that defines a point.
Definition: SDL_rect.h:48
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
points
GLfixed GLfixed GLint GLint GLfixed points
Definition: SDL_opengl_glext.h:4558
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
SDL_Point::x
int x
Definition: SDL_rect.h:50
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_RenderDrawLines
int SDL_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count)
Draw a series of connected lines on the current rendering target.
Definition: SDL_render.c:1705

## SDL_RenderDrawLines()

int SDL_RenderDrawLines | ( | SDL_Renderer * | renderer,
|  | const SDL_Point * | points,
|  | int | count
| ) |  |

Draw a series of connected lines on the current rendering target.

Parameters

  renderer | The renderer which should draw multiple lines.
  points | The points along the lines
  count | The number of points, drawing count-1 lines

Returns
  0 on success, or -1 on error

Definition at line 1705 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::hidden, i, SDL_Renderer::RenderDrawLines, RenderDrawLinesWithRects(), SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_stack_alloc, SDL_stack_free, SDL_FPoint::x, SDL_Point::x, SDL_FPoint::y, and SDL_Point::y.

Referenced by SDL_RenderDrawLine(), and SDL_RenderDrawRect().

{
SDL_FPoint *fpoints;
int i;
int status;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!points) {
return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
}
if (count < 2) {
return 0;
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
return RenderDrawLinesWithRects(renderer, points, count);
}
fpoints = SDL_stack_alloc(SDL_FPoint, count);
if (!fpoints) {
return SDL_OutOfMemory();
}
for (i = 0; i < count; ++i) {
fpoints[i].x = points[i].x * renderer->scale.x;
fpoints[i].y = points[i].y * renderer->scale.y;
}
status = renderer->RenderDrawLines(renderer, fpoints, count);
SDL_stack_free(fpoints);
return status;
}
SDL_Renderer::RenderDrawLines
int(* RenderDrawLines)(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Definition: SDL_sysrender.h:107
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
RenderDrawLinesWithRects
static int RenderDrawLinesWithRects(SDL_Renderer *renderer, const SDL_Point *points, int count)
Definition: SDL_render.c:1649
SDL_Point::x
int x
Definition: SDL_rect.h:50
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_stack_alloc
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:354
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:355
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint
Definition: SDL_sysrender.h:34
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderDrawPoint()

int SDL_RenderDrawPoint | ( | SDL_Renderer * | renderer,
|  | int | x,
|  | int | y
| ) |  |

Draw a point on the current rendering target.

Parameters

  renderer | The renderer which should draw a point.
  x | The x coordinate of the point.
  y | The y coordinate of the point.

Returns
  0 on success, or -1 on error

Definition at line 1559 of file SDL_render.c.

References SDL_RenderDrawPoints(), SDL_Point::x, and SDL_Point::y.

{
SDL_Point point;
point.x = x;
point.y = y;
return SDL_RenderDrawPoints(renderer, &point, 1);
}
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
SDL_Point
The structure that defines a point.
Definition: SDL_rect.h:48
SDL_Point::x
int x
Definition: SDL_rect.h:50
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_RenderDrawPoints
int SDL_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count)
Draw multiple points on the current rendering target.
Definition: SDL_render.c:1595
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

## SDL_RenderDrawPoints()

int SDL_RenderDrawPoints | ( | SDL_Renderer * | renderer,
|  | const SDL_Point * | points,
|  | int | count
| ) |  |

Draw multiple points on the current rendering target.

Parameters

  renderer | The renderer which should draw multiple points.
  points | The points to draw
  count | The number of points to draw

Returns
  0 on success, or -1 on error

Definition at line 1595 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::hidden, i, SDL_Renderer::RenderDrawPoints, RenderDrawPointsWithRects(), SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_stack_alloc, SDL_stack_free, SDL_FPoint::x, SDL_Point::x, SDL_FPoint::y, and SDL_Point::y.

Referenced by SDL_RenderDrawPoint().

{
SDL_FPoint *fpoints;
int i;
int status;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!points) {
return SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
}
if (count < 1) {
return 0;
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
return RenderDrawPointsWithRects(renderer, points, count);
}
fpoints = SDL_stack_alloc(SDL_FPoint, count);
if (!fpoints) {
return SDL_OutOfMemory();
}
for (i = 0; i < count; ++i) {
fpoints[i].x = points[i].x * renderer->scale.x;
fpoints[i].y = points[i].y * renderer->scale.y;
}
status = renderer->RenderDrawPoints(renderer, fpoints, count);
SDL_stack_free(fpoints);
return status;
}
SDL_Renderer::RenderDrawPoints
int(* RenderDrawPoints)(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Definition: SDL_sysrender.h:105
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
RenderDrawPointsWithRects
static int RenderDrawPointsWithRects(SDL_Renderer *renderer, const SDL_Point *points, int count)
Definition: SDL_render.c:1569
SDL_Point::x
int x
Definition: SDL_rect.h:50
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_stack_alloc
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:354
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:355
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint
Definition: SDL_sysrender.h:34
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderDrawRect()

int SDL_RenderDrawRect | ( | SDL_Renderer * | renderer,
|  | const SDL_Rect * | rect
| ) |  |

Draw a rectangle on the current rendering target.

Parameters

  renderer | The renderer which should draw a rectangle.
  rect | A pointer to the destination rectangle, or NULL to outline the entire rendering target.

Returns
  0 on success, or -1 on error

Definition at line 1747 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Rect::h, SDL_RenderDrawLines(), SDL_RenderGetViewport(), SDL_Rect::w, SDL_Point::x, SDL_Rect::x, SDL_Point::y, and SDL_Rect::y.

Referenced by SDL_RenderDrawRects().

{
SDL_Rect full_rect;
SDL_Point points[5];
CHECK_RENDERER_MAGIC(renderer, -1);
/* If 'rect' == NULL, then outline the whole surface */
if (!rect) {
SDL_RenderGetViewport(renderer, &full_rect);
full_rect.x = 0;
full_rect.y = 0;
rect = &full_rect;
}
points[0].x = rect->x;
points[0].y = rect->y;
points[1].x = rect->x+rect->w-1;
points[1].y = rect->y;
points[2].x = rect->x+rect->w-1;
points[2].y = rect->y+rect->h-1;
points[3].x = rect->x;
points[3].y = rect->y+rect->h-1;
points[4].x = rect->x;
points[4].y = rect->y;
return SDL_RenderDrawLines(renderer, points, 5);
}
SDL_Point
The structure that defines a point.
Definition: SDL_rect.h:48
points
GLfixed GLfixed GLint GLint GLfixed points
Definition: SDL_opengl_glext.h:4558
SDL_Point::x
int x
Definition: SDL_rect.h:50
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_RenderDrawLines
int SDL_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count)
Draw a series of connected lines on the current rendering target.
Definition: SDL_render.c:1705
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_RenderGetViewport
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
Definition: SDL_render.c:1418
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

## SDL_RenderDrawRects()

int SDL_RenderDrawRects | ( | SDL_Renderer * | renderer,
|  | const SDL_Rect * | rects,
|  | int | count
| ) |  |

Draw some number of rectangles on the current rendering target.

Parameters

  renderer | The renderer which should draw multiple rectangles.
  rects | A pointer to an array of destination rectangles.
  count | The number of rectangles.

Returns
  0 on success, or -1 on error

Definition at line 1776 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::hidden, i, SDL_RenderDrawRect(), and SDL_SetError.

{
int i;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!rects) {
return SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
}
if (count < 1) {
return 0;
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
for (i = 0; i < count; ++i) {
if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) {
return -1;
}
}
return 0;
}
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_RenderDrawRect
int SDL_RenderDrawRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Draw a rectangle on the current rendering target.
Definition: SDL_render.c:1747
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30

## SDL_RendererEventWatch()

static int SDL_RendererEventWatch | ( | void * | userdata,
|  | SDL_Event * | event
| ) |  |

static

Definition at line 136 of file SDL_render.c.

References SDL_Event::button, SDL_Renderer::dpi_scale, SDL_WindowEvent::event, SDL_Renderer::GetOutputSize, SDL_Rect::h, SDL_Renderer::hidden, SDL_Renderer::logical_h, SDL_Renderer::logical_w, SDL_Event::motion, NULL, renderer, SDL_Renderer::scale, SDL_FALSE, SDL_FINGERDOWN, SDL_FINGERMOTION, SDL_FINGERUP, SDL_GetRendererOutputSize(), SDL_GetRenderTarget(), SDL_GetWindowFlags, SDL_GetWindowFromID, SDL_GetWindowSize, SDL_max, SDL_min, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEMOTION, SDL_SetRenderTarget(), SDL_TRUE, SDL_WINDOW_HIDDEN, SDL_WINDOW_MINIMIZED, SDL_WINDOWEVENT, SDL_WINDOWEVENT_HIDDEN, SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_MINIMIZED, SDL_WINDOWEVENT_RESTORED, SDL_WINDOWEVENT_SHOWN, SDL_WINDOWEVENT_SIZE_CHANGED, SDL_Renderer::target, SDL_Event::type, UpdateLogicalSize(), SDL_Renderer::UpdateViewport, SDL_Renderer::viewport, SDL_Renderer::viewport_backup, SDL_Rect::w, SDL_Renderer::window, SDL_Event::window, SDL_Renderer::WindowEvent, SDL_WindowEvent::windowID, SDL_MouseMotionEvent::windowID, SDL_MouseButtonEvent::windowID, SDL_FPoint::x, SDL_Rect::x, SDL_MouseMotionEvent::x, SDL_MouseButtonEvent::x, SDL_MouseMotionEvent::xrel, SDL_FPoint::y, SDL_Rect::y, SDL_MouseMotionEvent::y, SDL_MouseButtonEvent::y, and SDL_MouseMotionEvent::yrel.

Referenced by SDL_CreateRenderer(), and SDL_DestroyRenderer().

{
SDL_Renderer *renderer = (SDL_Renderer *)userdata;
if (event->type == SDL_WINDOWEVENT) {
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
if (window == renderer->window) {
if (renderer->WindowEvent) {
renderer->WindowEvent(renderer, &event->window);
}
if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
/* Make sure we're operating on the default render target */
SDL_Texture *saved_target = SDL_GetRenderTarget(renderer);
if (saved_target) {
SDL_SetRenderTarget(renderer, NULL);
}
if (renderer->logical_w) {
UpdateLogicalSize(renderer);
} else {
/* Window was resized, reset viewport */
int w, h;
if (renderer->GetOutputSize) {
renderer->GetOutputSize(renderer, &w, &h);
} else {
SDL_GetWindowSize(renderer->window, &w, &h);
}
if (renderer->target) {
renderer->viewport_backup.x = 0;
renderer->viewport_backup.y = 0;
renderer->viewport_backup.w = w;
renderer->viewport_backup.h = h;
} else {
renderer->viewport.x = 0;
renderer->viewport.y = 0;
renderer->viewport.w = w;
renderer->viewport.h = h;
renderer->UpdateViewport(renderer);
}
}
if (saved_target) {
SDL_SetRenderTarget(renderer, saved_target);
}
} else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
renderer->hidden = SDL_TRUE;
} else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)) {
renderer->hidden = SDL_FALSE;
}
} else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
renderer->hidden = SDL_TRUE;
} else if (event->window.event == SDL_WINDOWEVENT_RESTORED ||
event->window.event == SDL_WINDOWEVENT_MAXIMIZED) {
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) {
renderer->hidden = SDL_FALSE;
}
}
}
} else if (event->type == SDL_MOUSEMOTION) {
SDL_Window *window = SDL_GetWindowFromID(event->motion.windowID);
if (renderer->logical_w && window == renderer->window) {
event->motion.x -= (int)(renderer->viewport.x * renderer->dpi_scale.x);
event->motion.y -= (int)(renderer->viewport.y * renderer->dpi_scale.y);
event->motion.x = (int)(event->motion.x / (renderer->scale.x * renderer->dpi_scale.x));
event->motion.y = (int)(event->motion.y / (renderer->scale.y * renderer->dpi_scale.y));
if (event->motion.xrel > 0) {
event->motion.xrel = SDL_max(1, (int)(event->motion.xrel / (renderer->scale.x * renderer->dpi_scale.x)));
} else if (event->motion.xrel < 0) {
event->motion.xrel = SDL_min(-1, (int)(event->motion.xrel / (renderer->scale.x * renderer->dpi_scale.x)));
}
if (event->motion.yrel > 0) {
event->motion.yrel = SDL_max(1, (int)(event->motion.yrel / (renderer->scale.y * renderer->dpi_scale.y)));
} else if (event->motion.yrel < 0) {
event->motion.yrel = SDL_min(-1, (int)(event->motion.yrel / (renderer->scale.y * renderer->dpi_scale.y)));
}
}
} else if (event->type == SDL_MOUSEBUTTONDOWN ||
event->type == SDL_MOUSEBUTTONUP) {
SDL_Window *window = SDL_GetWindowFromID(event->button.windowID);
if (renderer->logical_w && window == renderer->window) {
event->button.x -= (int)(renderer->viewport.x * renderer->dpi_scale.x);
event->button.y -= (int)(renderer->viewport.y * renderer->dpi_scale.y);
event->button.x = (int)(event->button.x / (renderer->scale.x * renderer->dpi_scale.x));
event->button.y = (int)(event->button.y / (renderer->scale.y * renderer->dpi_scale.y));
}
} else if (event->type == SDL_FINGERDOWN ||
event->type == SDL_FINGERUP ||
event->type == SDL_FINGERMOTION) {
if (renderer->logical_w) {
int w = 1;
int h = 1;
SDL_GetRendererOutputSize(renderer, &w, &h);
event->tfinger.x *= (w - 1);
event->tfinger.y *= (h - 1);
event->tfinger.x -= (renderer->viewport.x * renderer->dpi_scale.x);
event->tfinger.y -= (renderer->viewport.y * renderer->dpi_scale.y);
event->tfinger.x = (event->tfinger.x / (renderer->scale.x * renderer->dpi_scale.x));
event->tfinger.y = (event->tfinger.y / (renderer->scale.y * renderer->dpi_scale.y));
if (renderer->logical_w > 1) {
event->tfinger.x = event->tfinger.x / (renderer->logical_w - 1);
} else {
event->tfinger.x = 0.5f;
}
if (renderer->logical_h > 1) {
event->tfinger.y = event->tfinger.y / (renderer->logical_h - 1);
} else {
event->tfinger.y = 0.5f;
}
}
}
return 0;
}
SDL_Event::motion
SDL_MouseMotionEvent motion
Definition: SDL_events.h:533
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_MouseMotionEvent::y
Sint32 y
Definition: SDL_events.h:240
SDL_MOUSEBUTTONUP
Definition: SDL_events.h:104
SDL_WINDOWEVENT_MINIMIZED
Definition: SDL_video.h:159
SDL_MouseButtonEvent::y
Sint32 y
Definition: SDL_events.h:259
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
SDL_FALSE
Definition: SDL_stdinc.h:141
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_GetRenderTarget
SDL_Texture * SDL_GetRenderTarget(SDL_Renderer *renderer)
Get the current render target or NULL for the default render target.
Definition: SDL_render.c:1236
SDL_MOUSEBUTTONDOWN
Definition: SDL_events.h:103
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:138
SDL_GetWindowFlags
#define SDL_GetWindowFlags
Definition: SDL_dynapi_overrides.h:518
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_MouseMotionEvent::x
Sint32 x
Definition: SDL_events.h:239
SDL_WINDOWEVENT_MAXIMIZED
Definition: SDL_video.h:160
SDL_WINDOWEVENT_SIZE_CHANGED
Definition: SDL_video.h:156
SDL_WINDOW_HIDDEN
Definition: SDL_video.h:103
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:133
SDL_GetRendererOutputSize
int SDL_GetRendererOutputSize(SDL_Renderer *renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
Definition: SDL_render.c:423
SDL_max
#define SDL_max(x, y)
Definition: SDL_stdinc.h:407
SDL_WINDOWEVENT_HIDDEN
Definition: SDL_video.h:150
SDL_Texture
Definition: SDL_sysrender.h:49
SDL_Renderer::GetOutputSize
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
Definition: SDL_sysrender.h:81
SDL_Event::window
SDL_WindowEvent window
Definition: SDL_events.h:529
SDL_GetWindowSize
#define SDL_GetWindowSize
Definition: SDL_dynapi_overrides.h:527
SDL_MouseMotionEvent::yrel
Sint32 yrel
Definition: SDL_events.h:242
SDL_FINGERDOWN
Definition: SDL_events.h:125
SDL_MouseMotionEvent::xrel
Sint32 xrel
Definition: SDL_events.h:241
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:166
SDL_WINDOWEVENT_RESTORED
Definition: SDL_video.h:161
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_WINDOWEVENT
Definition: SDL_events.h:89
SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:106
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_WindowEvent::event
Uint8 event
Definition: SDL_events.h:179
SDL_Renderer::UpdateViewport
int(* UpdateViewport)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:102
SDL_GetWindowFromID
#define SDL_GetWindowFromID
Definition: SDL_dynapi_overrides.h:517
SDL_FINGERMOTION
Definition: SDL_events.h:127
SDL_Rect::w
int w
Definition: SDL_rect.h:67
UpdateLogicalSize
static int UpdateLogicalSize(SDL_Renderer *renderer)
Definition: SDL_render.c:1242
NULL
#define NULL
Definition: begin_code.h:164
SDL_FINGERUP
Definition: SDL_events.h:126
SDL_MOUSEMOTION
Definition: SDL_events.h:102
SDL_WINDOWEVENT_SHOWN
Definition: SDL_video.h:149
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:146
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_MouseMotionEvent::windowID
Uint32 windowID
Definition: SDL_events.h:236
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:73
SDL_Renderer::WindowEvent
void(* WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event)
Definition: SDL_sysrender.h:80
SDL_Event::button
SDL_MouseButtonEvent button
Definition: SDL_events.h:534
SDL_MouseButtonEvent::x
Sint32 x
Definition: SDL_events.h:258
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:137
SDL_Renderer::viewport_backup
SDL_Rect viewport_backup
Definition: SDL_sysrender.h:147
SDL_MouseButtonEvent::windowID
Uint32 windowID
Definition: SDL_events.h:252
SDL_SetRenderTarget
int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
Set a texture as the current rendering target.
Definition: SDL_render.c:1165
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_WindowEvent::windowID
Uint32 windowID
Definition: SDL_events.h:178
SDL_Renderer::dpi_scale
SDL_FPoint dpi_scale
Definition: SDL_sysrender.h:162
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_Event::type
Uint32 type
Definition: SDL_events.h:527
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderFillRect()

int SDL_RenderFillRect | ( | SDL_Renderer * | renderer,
|  | const SDL_Rect * | rect
| ) |  |

Fill a rectangle on the current rendering target with the drawing color.

Parameters

  renderer | The renderer which should fill a rectangle.
  rect | A pointer to the destination rectangle, or NULL for the entire rendering target.

Returns
  0 on success, or -1 on error

Definition at line 1804 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_RenderFillRects(), SDL_RenderGetViewport(), SDL_Rect::x, and SDL_Rect::y.

{
SDL_Rect full_rect = { 0, 0, 0, 0 };
CHECK_RENDERER_MAGIC(renderer, -1);
/* If 'rect' == NULL, then outline the whole surface */
if (!rect) {
SDL_RenderGetViewport(renderer, &full_rect);
full_rect.x = 0;
full_rect.y = 0;
rect = &full_rect;
}
return SDL_RenderFillRects(renderer, rect, 1);
}
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_RenderFillRects
int SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count)
Fill some number of rectangles on the current rendering target with the drawing color.
Definition: SDL_render.c:1821
SDL_RenderGetViewport
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
Definition: SDL_render.c:1418
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

## SDL_RenderFillRects()

int SDL_RenderFillRects | ( | SDL_Renderer * | renderer,
|  | const SDL_Rect * | rects,
|  | int | count
| ) |  |

Fill some number of rectangles on the current rendering target with the drawing color.

Parameters

  renderer | The renderer which should fill multiple rectangles.
  rects | A pointer to an array of destination rectangles.
  count | The number of rectangles.

Returns
  0 on success, or -1 on error

Definition at line 1821 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_FRect::h, SDL_Rect::h, SDL_Renderer::hidden, i, SDL_Renderer::RenderFillRects, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_stack_alloc, SDL_stack_free, SDL_FRect::w, SDL_Rect::w, SDL_FPoint::x, SDL_FRect::x, SDL_Rect::x, SDL_FPoint::y, SDL_FRect::y, and SDL_Rect::y.

Referenced by SDL_RenderFillRect().

{
SDL_FRect *frects;
int i;
int status;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!rects) {
return SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
}
if (count < 1) {
return 0;
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
frects = SDL_stack_alloc(SDL_FRect, count);
if (!frects) {
return SDL_OutOfMemory();
}
for (i = 0; i < count; ++i) {
frects[i].x = rects[i].x * renderer->scale.x;
frects[i].y = rects[i].y * renderer->scale.y;
frects[i].w = rects[i].w * renderer->scale.x;
frects[i].h = rects[i].h * renderer->scale.y;
}
status = renderer->RenderFillRects(renderer, frects, count);
SDL_stack_free(frects);
return status;
}
SDL_FRect::w
float w
Definition: SDL_sysrender.h:44
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_Renderer::RenderFillRects
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Definition: SDL_sysrender.h:109
SDL_FRect::y
float y
Definition: SDL_sysrender.h:43
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_stack_alloc
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:354
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_FRect::h
float h
Definition: SDL_sysrender.h:45
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:355
SDL_FRect::x
float x
Definition: SDL_sysrender.h:42
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FRect
Definition: SDL_sysrender.h:40
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderGetClipRect()

void SDL_RenderGetClipRect | ( | SDL_Renderer * | renderer,
|  | SDL_Rect * | rect
| ) |  |

Get the clip rectangle for the current target.

Parameters

  renderer | The renderer from which clip rectangle should be queried.
  rect | A pointer filled in with the current clip rectangle, or an empty rectangle if clipping is disabled.

See also
  SDL_RenderSetClipRect()

Definition at line 1449 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::clip_rect, SDL_Rect::h, SDL_Renderer::scale, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

{
CHECK_RENDERER_MAGIC(renderer, )
if (rect) {
rect->x = (int)(renderer->clip_rect.x / renderer->scale.x);
rect->y = (int)(renderer->clip_rect.y / renderer->scale.y);
rect->w = (int)(renderer->clip_rect.w / renderer->scale.x);
rect->h = (int)(renderer->clip_rect.h / renderer->scale.y);
}
}
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_Renderer::clip_rect
SDL_Rect clip_rect
Definition: SDL_sysrender.h:150
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderGetIntegerScale()

SDL_bool SDL_RenderGetIntegerScale | ( | SDL_Renderer * | renderer | ) |

Get whether integer scales are forced for resolution-independent rendering.

Parameters

  renderer | The renderer from which integer scaling should be queried.

See also
  SDL_RenderSetIntegerScale()

Definition at line 1390 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::integer_scale, and SDL_FALSE.

{
CHECK_RENDERER_MAGIC(renderer, SDL_FALSE);
return renderer->integer_scale;
}
SDL_FALSE
Definition: SDL_stdinc.h:141
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::integer_scale
SDL_bool integer_scale
Definition: SDL_sysrender.h:143

## SDL_RenderGetLogicalSize()

void SDL_RenderGetLogicalSize | ( | SDL_Renderer * | renderer,
|  | int * | w,
|  | int * | h
| ) |  |

Get device independent resolution for rendering.

Parameters

  renderer | The renderer from which resolution should be queried.
  w | A pointer filled with the width of the logical resolution
  h | A pointer filled with the height of the logical resolution

See also
  SDL_RenderSetLogicalSize()

Definition at line 1367 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::logical_h, and SDL_Renderer::logical_w.

{
CHECK_RENDERER_MAGIC(renderer, );
if (w) {
*w = renderer->logical_w;
}
if (h) {
*h = renderer->logical_h;
}
}
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:138
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:137

## SDL_RenderGetMetalCommandEncoder()

void* SDL_RenderGetMetalCommandEncoder | ( | SDL_Renderer * | renderer | ) |

Get the Metal command encoder for the current frame.

Parameters

  renderer | The renderer to query

Returns
  id<MTLRenderCommandEncoder> on success, or NULL if the renderer isn't a Metal renderer

See also
  SDL_RenderGetMetalLayer()

Definition at line 2135 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::GetMetalCommandEncoder, and NULL.

{
CHECK_RENDERER_MAGIC(renderer, NULL);
if (renderer->GetMetalCommandEncoder) {
return renderer->GetMetalCommandEncoder(renderer);
}
return NULL;
}
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
NULL
#define NULL
Definition: begin_code.h:164
SDL_Renderer::GetMetalCommandEncoder
void *(* GetMetalCommandEncoder)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:127

## SDL_RenderGetMetalLayer()

void* SDL_RenderGetMetalLayer | ( | SDL_Renderer * | renderer | ) |

Get the CAMetalLayer associated with the given Metal renderer.

Parameters

  renderer | The renderer to query

Returns
  CAMetalLayer* on success, or NULL if the renderer isn't a Metal renderer

See also
  SDL_RenderGetMetalCommandEncoder()

Definition at line 2124 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::GetMetalLayer, and NULL.

{
CHECK_RENDERER_MAGIC(renderer, NULL);
if (renderer->GetMetalLayer) {
return renderer->GetMetalLayer(renderer);
}
return NULL;
}
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::GetMetalLayer
void *(* GetMetalLayer)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:126
NULL
#define NULL
Definition: begin_code.h:164

## SDL_RenderGetScale()

void SDL_RenderGetScale | ( | SDL_Renderer * | renderer,
|  | float * | scaleX,
|  | float * | scaleY
| ) |  |

Get the drawing scale for the current target.

Parameters

  renderer | The renderer from which drawing scale should be queried.
  scaleX | A pointer filled in with the horizontal scaling factor
  scaleY | A pointer filled in with the vertical scaling factor

See also
  SDL_RenderSetScale()

Definition at line 1479 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::scale, SDL_FPoint::x, and SDL_FPoint::y.

{
CHECK_RENDERER_MAGIC(renderer, );
if (scaleX) {
*scaleX = renderer->scale.x;
}
if (scaleY) {
*scaleY = renderer->scale.y;
}
}
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderGetViewport()

void SDL_RenderGetViewport | ( | SDL_Renderer * | renderer,
|  | SDL_Rect * | rect
| ) |  |

Get the drawing area for the current target.

See also
  SDL_RenderSetViewport()

Definition at line 1418 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Rect::h, SDL_Renderer::scale, SDL_Renderer::viewport, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

Referenced by SDL_RenderCopy(), SDL_RenderCopyEx(), SDL_RenderDrawRect(), and SDL_RenderFillRect().

{
CHECK_RENDERER_MAGIC(renderer, );
if (rect) {
rect->x = (int)(renderer->viewport.x / renderer->scale.x);
rect->y = (int)(renderer->viewport.y / renderer->scale.y);
rect->w = (int)(renderer->viewport.w / renderer->scale.x);
rect->h = (int)(renderer->viewport.h / renderer->scale.y);
}
}
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:146
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderIsClipEnabled()

SDL_bool SDL_RenderIsClipEnabled | ( | SDL_Renderer * | renderer | ) |

Get whether clipping is enabled on the given renderer.

Parameters

  renderer | The renderer from which clip state should be queried.

See also
  SDL_RenderGetClipRect()

Definition at line 1462 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::clipping_enabled, and SDL_FALSE.

{
CHECK_RENDERER_MAGIC(renderer, SDL_FALSE)
return renderer->clipping_enabled;
}
SDL_FALSE
Definition: SDL_stdinc.h:141
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::clipping_enabled
SDL_bool clipping_enabled
Definition: SDL_sysrender.h:154

## SDL_RenderPresent()

void SDL_RenderPresent | ( | SDL_Renderer * | renderer | ) |

Update the screen with rendering performed.

Definition at line 2022 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::hidden, and SDL_Renderer::RenderPresent.

{
CHECK_RENDERER_MAGIC(renderer, );
/* Don't draw while we're hidden */
if (renderer->hidden) {
return;
}
renderer->RenderPresent(renderer);
}
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:134
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::RenderPresent
void(* RenderPresent)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:118

## SDL_RenderReadPixels()

int SDL_RenderReadPixels | ( | SDL_Renderer * | renderer,
|  | const SDL_Rect * | rect,
|  | Uint32 | format,
|  | void * | pixels,
|  | int | pitch
| ) |  |

Read pixels from the current rendering target.

Parameters

  renderer | The renderer from which pixels should be read.
  rect | A pointer to the rectangle to read, or NULL for the entire render target.
  format | The desired format of the pixel data, or 0 to use the format of the rendering target
  pixels | A pointer to be filled in with the pixel data
  pitch | The pitch of the pixels parameter.

Returns
  0 on success, or -1 if pixel reading is not supported.

Warning
  This is a very slow operation, and should not be used frequently.

Definition at line 1985 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Rect::h, SDL_Renderer::RenderReadPixels, SDL_BYTESPERPIXEL, SDL_GetWindowPixelFormat, SDL_IntersectRect, SDL_Unsupported, SDL_Renderer::viewport, SDL_Rect::w, SDL_Renderer::window, SDL_Rect::x, and SDL_Rect::y.

{
SDL_Rect real_rect;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!renderer->RenderReadPixels) {
return SDL_Unsupported();
}
if (!format) {
format = SDL_GetWindowPixelFormat(renderer->window);
}
real_rect.x = renderer->viewport.x;
real_rect.y = renderer->viewport.y;
real_rect.w = renderer->viewport.w;
real_rect.h = renderer->viewport.h;
if (rect) {
if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
return 0;
}
if (real_rect.y > rect->y) {
pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
}
if (real_rect.x > rect->x) {
int bpp = SDL_BYTESPERPIXEL(format);
pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
}
}
return renderer->RenderReadPixels(renderer, &real_rect,
format, pixels, pitch);
}
SDL_Renderer::RenderReadPixels
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
Definition: SDL_sysrender.h:116
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:294
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:133
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:157
SDL_Rect::x
int x
Definition: SDL_rect.h:66
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:146
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_GetWindowPixelFormat
#define SDL_GetWindowPixelFormat
Definition: SDL_dynapi_overrides.h:513
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

## SDL_RenderSetClipRect()

int SDL_RenderSetClipRect | ( | SDL_Renderer * | renderer,
|  | const SDL_Rect * | rect
| ) |  |

Set the clip rectangle for the current target.

Parameters

  renderer | The renderer for which clip rectangle should be set.
  rect | A pointer to the rectangle to set as the clip rectangle, or NULL to disable clipping.

Returns
  0 on success, or -1 on error

See also
  SDL_RenderGetClipRect()

Definition at line 1431 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::clip_rect, SDL_Renderer::clipping_enabled, SDL_Rect::h, SDL_Renderer::scale, SDL_ceil, SDL_FALSE, SDL_floor, SDL_TRUE, SDL_zero, SDL_Renderer::UpdateClipRect, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

{
CHECK_RENDERER_MAGIC(renderer, -1)
if (rect) {
renderer->clipping_enabled = SDL_TRUE;
renderer->clip_rect.x = (int)SDL_floor(rect->x * renderer->scale.x);
renderer->clip_rect.y = (int)SDL_floor(rect->y * renderer->scale.y);
renderer->clip_rect.w = (int)SDL_ceil(rect->w * renderer->scale.x);
renderer->clip_rect.h = (int)SDL_ceil(rect->h * renderer->scale.y);
} else {
renderer->clipping_enabled = SDL_FALSE;
SDL_zero(renderer->clip_rect);
}
return renderer->UpdateClipRect(renderer);
}
SDL_ceil
#define SDL_ceil
Definition: SDL_dynapi_overrides.h:426
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_Renderer::clip_rect
SDL_Rect clip_rect
Definition: SDL_sysrender.h:150
SDL_floor
#define SDL_floor
Definition: SDL_dynapi_overrides.h:431
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Renderer::UpdateClipRect
int(* UpdateClipRect)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:103
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_Renderer::clipping_enabled
SDL_bool clipping_enabled
Definition: SDL_sysrender.h:154
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderSetIntegerScale()

int SDL_RenderSetIntegerScale | ( | SDL_Renderer * | renderer,
|  | SDL_bool | enable
| ) |  |

Set whether to force integer scales for resolution-independent rendering.

Parameters

  renderer | The renderer for which integer scaling should be set.
  enable | Enable or disable integer scaling

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.

See also
  SDL_RenderSetLogicalSize()

Definition at line 1380 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::integer_scale, and UpdateLogicalSize().

{
CHECK_RENDERER_MAGIC(renderer, -1);
renderer->integer_scale = enable;
return UpdateLogicalSize(renderer);
}
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
UpdateLogicalSize
static int UpdateLogicalSize(SDL_Renderer *renderer)
Definition: SDL_render.c:1242
enable
GLboolean enable
Definition: SDL_opengl_glext.h:4996
SDL_Renderer::integer_scale
SDL_bool integer_scale
Definition: SDL_sysrender.h:143

## SDL_RenderSetLogicalSize()

int SDL_RenderSetLogicalSize | ( | SDL_Renderer * | renderer,
|  | int | w,
|  | int | h
| ) |  |

Set device independent resolution for rendering.

Parameters

  renderer | The renderer for which resolution should be set.
  w | The width of the logical resolution
  h | The height of the logical resolution

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 events in the window will be filtered and scaled so they seem to arrive within the logical resolution.

Note
  If this function results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints.

See also
  SDL_RenderGetLogicalSize()
  SDL_RenderSetScale()
  SDL_RenderSetViewport()

Definition at line 1347 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::logical_h, SDL_Renderer::logical_w, NULL, SDL_RenderSetScale(), SDL_RenderSetViewport(), and UpdateLogicalSize().

{
CHECK_RENDERER_MAGIC(renderer, -1);
if (!w || !h) {
/* Clear any previous logical resolution */
renderer->logical_w = 0;
renderer->logical_h = 0;
SDL_RenderSetViewport(renderer, NULL);
SDL_RenderSetScale(renderer, 1.0f, 1.0f);
return 0;
}
renderer->logical_w = w;
renderer->logical_h = h;
return UpdateLogicalSize(renderer);
}
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:138
f
GLfloat f
Definition: SDL_opengl_glext.h:1870
SDL_RenderSetViewport
int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the drawing area for rendering on the current target.
Definition: SDL_render.c:1398
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
UpdateLogicalSize
static int UpdateLogicalSize(SDL_Renderer *renderer)
Definition: SDL_render.c:1242
SDL_RenderSetScale
int SDL_RenderSetScale(SDL_Renderer *renderer, float scaleX, float scaleY)
Set the drawing scale for rendering on the current target.
Definition: SDL_render.c:1469
NULL
#define NULL
Definition: begin_code.h:164
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:137

## SDL_RenderSetScale()

int SDL_RenderSetScale | ( | SDL_Renderer * | renderer,
|  | float | scaleX,
|  | float | scaleY
| ) |  |

Set the drawing scale for rendering on the current target.

Parameters

  renderer | The renderer for which the drawing scale should be set.
  scaleX | The horizontal scaling factor
  scaleY | The vertical scaling factor

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.

Note
  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.

See also
  SDL_RenderGetScale()
  SDL_RenderSetLogicalSize()

Definition at line 1469 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Renderer::scale, SDL_FPoint::x, and SDL_FPoint::y.

Referenced by SDL_RenderSetLogicalSize(), and UpdateLogicalSize().

{
CHECK_RENDERER_MAGIC(renderer, -1);
renderer->scale.x = scaleX;
renderer->scale.y = scaleY;
return 0;
}
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderSetViewport()

int SDL_RenderSetViewport | ( | SDL_Renderer * | renderer,
|  | const SDL_Rect * | rect
| ) |  |

Set the drawing area for rendering on the current target.

Parameters

  renderer | The renderer for which the drawing area should be set.
  rect | The rectangle representing the drawing area, or NULL to set the viewport to the entire target.

The x,y of the viewport rect represents the origin for rendering.

Returns
  0 on success, or -1 on error

Note
  If the window associated with the renderer is resized, the viewport is automatically reset.

See also
  SDL_RenderGetViewport()
  SDL_RenderSetLogicalSize()

Definition at line 1398 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, SDL_Rect::h, SDL_Renderer::scale, SDL_ceil, SDL_floor, SDL_GetRendererOutputSize(), SDL_Renderer::UpdateViewport, SDL_Renderer::viewport, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

Referenced by SDL_CreateRenderer(), SDL_CreateSoftwareRenderer(), SDL_RenderSetLogicalSize(), and UpdateLogicalSize().

{
CHECK_RENDERER_MAGIC(renderer, -1);
if (rect) {
renderer->viewport.x = (int)SDL_floor(rect->x * renderer->scale.x);
renderer->viewport.y = (int)SDL_floor(rect->y * renderer->scale.y);
renderer->viewport.w = (int)SDL_ceil(rect->w * renderer->scale.x);
renderer->viewport.h = (int)SDL_ceil(rect->h * renderer->scale.y);
} else {
renderer->viewport.x = 0;
renderer->viewport.y = 0;
if (SDL_GetRendererOutputSize(renderer, &renderer->viewport.w, &renderer->viewport.h) < 0) {
return -1;
}
}
return renderer->UpdateViewport(renderer);
}
SDL_ceil
#define SDL_ceil
Definition: SDL_dynapi_overrides.h:426
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_floor
#define SDL_floor
Definition: SDL_dynapi_overrides.h:431
SDL_GetRendererOutputSize
int SDL_GetRendererOutputSize(SDL_Renderer *renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
Definition: SDL_render.c:423
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Renderer::UpdateViewport
int(* UpdateViewport)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:102
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:146
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_RenderTargetSupported()

SDL_bool SDL_RenderTargetSupported | ( | SDL_Renderer * | renderer | ) |

Determines whether a window supports the use of render targets.

Parameters

  renderer | The renderer that will be checked

Returns
  SDL_TRUE if supported, SDL_FALSE if not.

Definition at line 1156 of file SDL_render.c.

References SDL_RendererInfo::flags, SDL_Renderer::info, SDL_FALSE, SDL_RENDERER_TARGETTEXTURE, and SDL_Renderer::SetRenderTarget.

Referenced by SDL_SetRenderTarget().

{
if (!renderer || !renderer->SetRenderTarget) {
return SDL_FALSE;
}
return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0;
}
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:130
SDL_RENDERER_TARGETTEXTURE
Definition: SDL_render.h:71
SDL_RendererInfo::flags
Uint32 flags
Definition: SDL_render.h:81
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_Renderer::SetRenderTarget
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:101

## SDL_SetRenderDrawBlendMode()

int SDL_SetRenderDrawBlendMode | ( | SDL_Renderer * | renderer,
|  | SDL_BlendMode | blendMode
| ) |  |

Set the blend mode used for drawing operations (Fill and Line).

Parameters

  renderer | The renderer for which blend mode should be set.
  blendMode | SDL_BlendMode to use for blending.

Returns
  0 on success, or -1 on error

Note
  If the blend mode is not supported, the closest supported mode is chosen.

See also
  SDL_GetRenderDrawBlendMode()

Definition at line 1526 of file SDL_render.c.

References blendMode, SDL_Renderer::blendMode, CHECK_RENDERER_MAGIC, IsSupportedBlendMode(), and SDL_Unsupported.

{
CHECK_RENDERER_MAGIC(renderer, -1);
if (!IsSupportedBlendMode(renderer, blendMode)) {
return SDL_Unsupported();
}
renderer->blendMode = blendMode;
return 0;
}
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::blendMode
SDL_BlendMode blendMode
Definition: SDL_sysrender.h:169
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
IsSupportedBlendMode
static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
Definition: SDL_render.c:441

## SDL_SetRenderDrawColor()

int SDL_SetRenderDrawColor | ( | SDL_Renderer * | renderer,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b,
|  | Uint8 | a
| ) |  |

Set the color used for drawing operations (Rect, Line and Clear).

Parameters

  renderer | The renderer for which drawing color should be set.
  r | The red value used to draw on the rendering target.
  g | The green value used to draw on the rendering target.
  b | The blue value used to draw on the rendering target.
  a | The alpha value used to draw on the rendering target, usually SDL_ALPHA_OPAQUE (255).

Returns
  0 on success, or -1 on error

Definition at line 1492 of file SDL_render.c.

References SDL_Renderer::a, SDL_Renderer::b, CHECK_RENDERER_MAGIC, SDL_Renderer::g, and SDL_Renderer::r.

{
CHECK_RENDERER_MAGIC(renderer, -1);
renderer->r = r;
renderer->g = g;
renderer->b = b;
renderer->a = a;
return 0;
}
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::g
Uint8 g
Definition: SDL_sysrender.h:168
SDL_Renderer::b
Uint8 b
Definition: SDL_sysrender.h:168
SDL_Renderer::r
Uint8 r
Definition: SDL_sysrender.h:168
SDL_Renderer::a
Uint8 a
Definition: SDL_sysrender.h:168
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

## SDL_SetRenderTarget()

int SDL_SetRenderTarget | ( | SDL_Renderer * | renderer,
|  | SDL_Texture * | texture
| ) |  |

Set a texture as the current rendering target.

Parameters

  renderer | The renderer.
  texture | The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target

Returns
  0 on success, or -1 on error

See also
  SDL_GetRenderTarget()

Definition at line 1165 of file SDL_render.c.

References SDL_Texture::access, CHECK_TEXTURE_MAGIC, SDL_Renderer::clip_rect, SDL_Renderer::clip_rect_backup, SDL_Renderer::clipping_enabled, SDL_Renderer::clipping_enabled_backup, SDL_Texture::h, SDL_Rect::h, SDL_Renderer::logical_h, SDL_Renderer::logical_h_backup, SDL_Renderer::logical_w, SDL_Renderer::logical_w_backup, SDL_Texture::native, SDL_Texture::renderer, SDL_Renderer::scale, SDL_Renderer::scale_backup, SDL_FALSE, SDL_RenderTargetSupported(), SDL_SetError, SDL_TEXTUREACCESS_TARGET, SDL_Unsupported, SDL_zero, SDL_Renderer::SetRenderTarget, SDL_Renderer::target, SDL_Renderer::UpdateClipRect, SDL_Renderer::UpdateViewport, SDL_Renderer::viewport, SDL_Renderer::viewport_backup, SDL_Texture::w, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

Referenced by SDL_DestroyTexture(), and SDL_RendererEventWatch().

{
if (!SDL_RenderTargetSupported(renderer)) {
return SDL_Unsupported();
}
if (texture == renderer->target) {
/* Nothing to do! */
return 0;
}
/* texture == NULL is valid and means reset the target to the window */
if (texture) {
CHECK_TEXTURE_MAGIC(texture, -1);
if (renderer != texture->renderer) {
return SDL_SetError("Texture was not created with this renderer");
}
if (texture->access != SDL_TEXTUREACCESS_TARGET) {
return SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET");
}
if (texture->native) {
/* Always render to the native texture */
texture = texture->native;
}
}
if (texture && !renderer->target) {
/* Make a backup of the viewport */
renderer->viewport_backup = renderer->viewport;
renderer->clip_rect_backup = renderer->clip_rect;
renderer->clipping_enabled_backup = renderer->clipping_enabled;
renderer->scale_backup = renderer->scale;
renderer->logical_w_backup = renderer->logical_w;
renderer->logical_h_backup = renderer->logical_h;
}
renderer->target = texture;
if (renderer->SetRenderTarget(renderer, texture) < 0) {
return -1;
}
if (texture) {
renderer->viewport.x = 0;
renderer->viewport.y = 0;
renderer->viewport.w = texture->w;
renderer->viewport.h = texture->h;
SDL_zero(renderer->clip_rect);
renderer->clipping_enabled = SDL_FALSE;
renderer->scale.x = 1.0f;
renderer->scale.y = 1.0f;
renderer->logical_w = texture->w;
renderer->logical_h = texture->h;
} else {
renderer->viewport = renderer->viewport_backup;
renderer->clip_rect = renderer->clip_rect_backup;
renderer->clipping_enabled = renderer->clipping_enabled_backup;
renderer->scale = renderer->scale_backup;
renderer->logical_w = renderer->logical_w_backup;
renderer->logical_h = renderer->logical_h_backup;
}
if (renderer->UpdateViewport(renderer) < 0) {
return -1;
}
if (renderer->UpdateClipRect(renderer) < 0) {
return -1;
}
/* All set! */
return 0;
}
SDL_Renderer::clip_rect_backup
SDL_Rect clip_rect_backup
Definition: SDL_sysrender.h:151
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:158
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:138
SDL_Renderer::clip_rect
SDL_Rect clip_rect
Definition: SDL_sysrender.h:150
SDL_Renderer::scale_backup
SDL_FPoint scale_backup
Definition: SDL_sysrender.h:159
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:166
SDL_Renderer::logical_w_backup
int logical_w_backup
Definition: SDL_sysrender.h:139
SDL_Renderer::logical_h_backup
int logical_h_backup
Definition: SDL_sysrender.h:140
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Renderer::SetRenderTarget
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:101
SDL_Renderer::UpdateViewport
int(* UpdateViewport)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:102
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_RenderTargetSupported
SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer)
Determines whether a window supports the use of render targets.
Definition: SDL_render.c:1156
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:146
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_TEXTUREACCESS_TARGET
Definition: SDL_render.h:95
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:137
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Renderer::viewport_backup
SDL_Rect viewport_backup
Definition: SDL_sysrender.h:147
SDL_Renderer::UpdateClipRect
int(* UpdateClipRect)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:103
SDL_Renderer::clipping_enabled_backup
SDL_bool clipping_enabled_backup
Definition: SDL_sysrender.h:155
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_Renderer::clipping_enabled
SDL_bool clipping_enabled
Definition: SDL_sysrender.h:154
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

## SDL_SetTextureAlphaMod()

int SDL_SetTextureAlphaMod | ( | SDL_Texture * | texture,
|  | Uint8 | alpha
| ) |  |

Set an additional alpha value used in render copy operations.

Parameters

  texture | The texture to update.
  alpha | The alpha value multiplied into copy operations.

Returns
  0 on success, or -1 if the texture is not valid or alpha modulation is not supported.

See also
  SDL_GetTextureAlphaMod()

Definition at line 743 of file SDL_render.c.

References SDL_Texture::a, CHECK_TEXTURE_MAGIC, SDL_Texture::modMode, SDL_Texture::native, renderer, SDL_Texture::renderer, SDL_TEXTUREMODULATE_ALPHA, and SDL_Renderer::SetTextureAlphaMod.

Referenced by SDL_CreateTextureFromSurface().

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, -1);
renderer = texture->renderer;
if (alpha < 255) {
texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
} else {
texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
}
texture->a = alpha;
if (texture->native) {
return SDL_SetTextureAlphaMod(texture->native, alpha);
} else if (renderer->SetTextureAlphaMod) {
return renderer->SetTextureAlphaMod(renderer, texture);
} else {
return 0;
}
}
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_Texture::a
Uint8 a
Definition: SDL_sysrender.h:58
alpha
GLfloat GLfloat GLfloat alpha
Definition: SDL_opengl_glext.h:412
SDL_TEXTUREMODULATE_ALPHA
Definition: SDL_render.h:105
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_SetTextureAlphaMod
int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha)
Set an additional alpha value used in render copy operations.
Definition: SDL_render.c:743
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Renderer::SetTextureAlphaMod
int(* SetTextureAlphaMod)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:86
SDL_Texture::modMode
int modMode
Definition: SDL_sysrender.h:56
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63

## SDL_SetTextureBlendMode()

int SDL_SetTextureBlendMode | ( | SDL_Texture * | texture,
|  | SDL_BlendMode | blendMode
| ) |  |

Set the blend mode used for texture copy operations.

Parameters

  texture | The texture to update.
  blendMode | SDL_BlendMode to use for texture blending.

Returns
  0 on success, or -1 if the texture is not valid or the blend mode is not supported.

Note
  If the blend mode is not supported, the closest supported mode is chosen.

See also
  SDL_GetTextureBlendMode()

Definition at line 777 of file SDL_render.c.

References blendMode, SDL_Texture::blendMode, CHECK_TEXTURE_MAGIC, IsSupportedBlendMode(), SDL_Texture::native, renderer, SDL_Texture::renderer, SDL_Unsupported, and SDL_Renderer::SetTextureBlendMode.

Referenced by SDL_CreateTextureFromSurface().

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, -1);
renderer = texture->renderer;
if (!IsSupportedBlendMode(renderer, blendMode)) {
return SDL_Unsupported();
}
texture->blendMode = blendMode;
if (texture->native) {
return SDL_SetTextureBlendMode(texture->native, blendMode);
} else if (renderer->SetTextureBlendMode) {
return renderer->SetTextureBlendMode(renderer, texture);
} else {
return 0;
}
}
SDL_Texture::blendMode
SDL_BlendMode blendMode
Definition: SDL_sysrender.h:57
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_Renderer::SetTextureBlendMode
int(* SetTextureBlendMode)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:88
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_SetTextureBlendMode
int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode)
Set the blend mode used for texture copy operations.
Definition: SDL_render.c:777
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
IsSupportedBlendMode
static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
Definition: SDL_render.c:441

## SDL_SetTextureColorMod()

int SDL_SetTextureColorMod | ( | SDL_Texture * | texture,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b
| ) |  |

Set an additional color value used in render copy operations.

Parameters

  texture | The texture to update.
  r | The red color value multiplied into copy operations.
  g | The green color value multiplied into copy operations.
  b | The blue color value multiplied into copy operations.

Returns
  0 on success, or -1 if the texture is not valid or color modulation is not supported.

See also
  SDL_GetTextureColorMod()

Definition at line 700 of file SDL_render.c.

References SDL_Texture::b, CHECK_TEXTURE_MAGIC, SDL_Texture::g, SDL_Texture::modMode, SDL_Texture::native, SDL_Texture::r, renderer, SDL_Texture::renderer, SDL_TEXTUREMODULATE_COLOR, and SDL_Renderer::SetTextureColorMod.

Referenced by SDL_CreateTextureFromSurface().

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, -1);
renderer = texture->renderer;
if (r < 255 || g < 255 || b < 255) {
texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
} else {
texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
}
texture->r = r;
texture->g = g;
texture->b = b;
if (texture->native) {
return SDL_SetTextureColorMod(texture->native, r, g, b);
} else if (renderer->SetTextureColorMod) {
return renderer->SetTextureColorMod(renderer, texture);
} else {
return 0;
}
}
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_Texture::g
Uint8 g
Definition: SDL_sysrender.h:58
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_TEXTUREMODULATE_COLOR
Definition: SDL_render.h:104
SDL_Renderer::SetTextureColorMod
int(* SetTextureColorMod)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:84
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Texture::b
Uint8 b
Definition: SDL_sysrender.h:58
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_SetTextureColorMod
int SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in render copy operations.
Definition: SDL_render.c:700
SDL_Texture::modMode
int modMode
Definition: SDL_sysrender.h:56
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
SDL_Texture::r
Uint8 r
Definition: SDL_sysrender.h:58

## SDL_UnlockTexture()

void SDL_UnlockTexture | ( | SDL_Texture * | texture | ) |

Unlock a texture, uploading the changes to video memory, if needed.

See also
  SDL_LockTexture()

Definition at line 1136 of file SDL_render.c.

References SDL_Texture::access, CHECK_TEXTURE_MAGIC, SDL_Texture::native, renderer, SDL_Texture::renderer, SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTextureNative(), SDL_UnlockTextureYUV(), SDL_Renderer::UnlockTexture, and SDL_Texture::yuv.

Referenced by SDL_UnlockTextureNative(), SDL_UnlockTextureYUV(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), and SDL_UpdateTextureYUVPlanar().

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, );
if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
return;
}
if (texture->yuv) {
SDL_UnlockTextureYUV(texture);
} else if (texture->native) {
SDL_UnlockTextureNative(texture);
} else {
renderer = texture->renderer;
renderer->UnlockTexture(renderer, texture);
}
}
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_UnlockTextureNative
static void SDL_UnlockTextureNative(SDL_Texture *texture)
Definition: SDL_render.c:1115
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:94
SDL_Renderer::UnlockTexture
void(* UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:100
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_UnlockTextureYUV
static void SDL_UnlockTextureYUV(SDL_Texture *texture)
Definition: SDL_render.c:1094
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53

## SDL_UnlockTextureNative()

static void SDL_UnlockTextureNative | ( | SDL_Texture * | texture | ) |

static

Definition at line 1115 of file SDL_render.c.

References SDL_Texture::format, SDL_Rect::h, SDL_Texture::locked_rect, SDL_Texture::native, NULL, SDL_Texture::pitch, SDL_Texture::pixels, rect, SDL_BYTESPERPIXEL, SDL_ConvertPixels, SDL_LockTexture(), SDL_UnlockTexture(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_UnlockTexture().

{
SDL_Texture *native = texture->native;
void *native_pixels = NULL;
int native_pitch = 0;
const SDL_Rect *rect = &texture->locked_rect;
const void* pixels = (void *) ((Uint8 *) texture->pixels +
rect->y * texture->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
int pitch = texture->pitch;
if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
return;
}
SDL_ConvertPixels(rect->w, rect->h,
texture->format, pixels, pitch,
native->format, native_pixels, native_pitch);
SDL_UnlockTexture(native);
}
SDL_Texture::pixels
void * pixels
Definition: SDL_sysrender.h:65
SDL_Texture::pitch
int pitch
Definition: SDL_sysrender.h:66
rect
SDL_Rect rect
Definition: testrelative.c:27
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
SDL_Texture::locked_rect
SDL_Rect locked_rect
Definition: SDL_sysrender.h:67
SDL_Texture
Definition: SDL_sysrender.h:49
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:157
SDL_UnlockTexture
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL_render.c:1136
SDL_LockTexture
int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL_render.c:1063
SDL_Rect::x
int x
Definition: SDL_rect.h:66
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_Rect::w
int w
Definition: SDL_rect.h:67
NULL
#define NULL
Definition: begin_code.h:164
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_ConvertPixels
#define SDL_ConvertPixels
Definition: SDL_dynapi_overrides.h:465
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

## SDL_UnlockTextureYUV()

static void SDL_UnlockTextureYUV | ( | SDL_Texture * | texture | ) |

static

Definition at line 1094 of file SDL_render.c.

References SDL_Texture::format, SDL_Texture::h, SDL_Rect::h, SDL_Texture::native, NULL, rect, SDL_LockTexture(), SDL_SW_CopyYUVToRGB(), SDL_UnlockTexture(), SDL_Texture::w, SDL_Rect::w, SDL_Rect::x, SDL_Rect::y, and SDL_Texture::yuv.

Referenced by SDL_UnlockTexture().

{
SDL_Texture *native = texture->native;
void *native_pixels = NULL;
int native_pitch = 0;
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = texture->w;
rect.h = texture->h;
if (SDL_LockTexture(native, &rect, &native_pixels, &native_pitch) < 0) {
return;
}
SDL_SW_CopyYUVToRGB(texture->yuv, &rect, native->format,
rect.w, rect.h, native_pixels, native_pitch);
SDL_UnlockTexture(native);
}
rect
SDL_Rect rect
Definition: testrelative.c:27
SDL_Texture
Definition: SDL_sysrender.h:49
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_UnlockTexture
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL_render.c:1136
SDL_LockTexture
int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL_render.c:1063
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
NULL
#define NULL
Definition: begin_code.h:164
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_SW_CopyYUVToRGB
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, Uint32 target_format, int w, int h, void *pixels, int pitch)
Definition: SDL_yuv_sw.c:334
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

## SDL_UpdateTexture()

int SDL_UpdateTexture | ( | SDL_Texture * | texture,
|  | const SDL_Rect * | rect,
|  | const void * | pixels,
|  | int | pitch
| ) |  |

Update the given texture rectangle with new pixel data.

Parameters

  texture | The texture to update
  rect | A pointer to the rectangle of pixels to update, or NULL to update the entire texture.
  pixels | The raw pixel data in the format of the texture.
  pitch | The number of bytes in a row of pixel data, including padding between lines.

The pixel data must be in the format of the texture. The pixel format can be queried with SDL_QueryTexture.

Returns
  0 on success, or -1 if the texture is not valid.

Note
  This is a fairly slow function.

Definition at line 896 of file SDL_render.c.

References CHECK_TEXTURE_MAGIC, SDL_Texture::h, SDL_Rect::h, SDL_Texture::native, renderer, SDL_Texture::renderer, SDL_InvalidParamError, SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), SDL_Renderer::UpdateTexture, SDL_Texture::w, SDL_Rect::w, SDL_Rect::x, SDL_Rect::y, and SDL_Texture::yuv.

Referenced by SDL_CreateTextureFromSurface(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), and SDL_UpdateTextureYUVPlanar().

{
SDL_Renderer *renderer;
SDL_Rect full_rect;
CHECK_TEXTURE_MAGIC(texture, -1);
if (!pixels) {
return SDL_InvalidParamError("pixels");
}
if (!pitch) {
return SDL_InvalidParamError("pitch");
}
if (!rect) {
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = texture->w;
full_rect.h = texture->h;
rect = &full_rect;
}
if ((rect->w == 0) || (rect->h == 0)) {
return 0; /* nothing to do. */
} else if (texture->yuv) {
return SDL_UpdateTextureYUV(texture, rect, pixels, pitch);
} else if (texture->native) {
return SDL_UpdateTextureNative(texture, rect, pixels, pitch);
} else {
renderer = texture->renderer;
return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
}
}
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_UpdateTextureNative
static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_render.c:855
SDL_InvalidParamError
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_Renderer::UpdateTexture
int(* UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_sysrender.h:90
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_Rect::x
int x
Definition: SDL_rect.h:66
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_UpdateTextureYUV
static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_render.c:809
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

## SDL_UpdateTextureNative()

static int SDL_UpdateTextureNative | ( | SDL_Texture * | texture,
|  | const SDL_Rect * | rect,
|  | const void * | pixels,
|  | int | pitch
| ) |  |

static

Definition at line 855 of file SDL_render.c.

References SDL_Texture::access, SDL_Texture::format, SDL_Rect::h, SDL_Texture::native, NULL, SDL_BYTESPERPIXEL, SDL_ConvertPixels, SDL_free, SDL_LockTexture(), SDL_malloc, SDL_OutOfMemory, SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTexture(), SDL_UpdateTexture(), and SDL_Rect::w.

Referenced by SDL_UpdateTexture().

{
SDL_Texture *native = texture->native;
if (!rect->w || !rect->h) {
return 0; /* nothing to do. */
}
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
/* We can lock the texture and copy to it */
void *native_pixels = NULL;
int native_pitch = 0;
if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
return -1;
}
SDL_ConvertPixels(rect->w, rect->h,
texture->format, pixels, pitch,
native->format, native_pixels, native_pitch);
SDL_UnlockTexture(native);
} else {
/* Use a temporary buffer for updating */
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
const size_t alloclen = rect->h * temp_pitch;
if (alloclen > 0) {
void *temp_pixels = SDL_malloc(alloclen);
if (!temp_pixels) {
return SDL_OutOfMemory();
}
SDL_ConvertPixels(rect->w, rect->h,
texture->format, pixels, pitch,
native->format, temp_pixels, temp_pitch);
SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
SDL_free(temp_pixels);
}
}
return 0;
}
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
SDL_Texture
Definition: SDL_sysrender.h:49
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_UnlockTexture
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL_render.c:1136
SDL_LockTexture
int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL_render.c:1063
SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:94
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_UpdateTexture
int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL_render.c:896
NULL
#define NULL
Definition: begin_code.h:164
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
SDL_ConvertPixels
#define SDL_ConvertPixels
Definition: SDL_dynapi_overrides.h:465
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53

## SDL_UpdateTextureYUV()

static int SDL_UpdateTextureYUV | ( | SDL_Texture * | texture,
|  | const SDL_Rect * | rect,
|  | const void * | pixels,
|  | int | pitch
| ) |  |

static

Definition at line 809 of file SDL_render.c.

References SDL_Texture::access, SDL_Texture::format, SDL_Texture::h, SDL_Rect::h, SDL_Texture::native, NULL, SDL_BYTESPERPIXEL, SDL_free, SDL_LockTexture(), SDL_malloc, SDL_OutOfMemory, SDL_SW_CopyYUVToRGB(), SDL_SW_UpdateYUVTexture(), SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTexture(), SDL_UpdateTexture(), SDL_Texture::w, SDL_Rect::w, SDL_Rect::x, SDL_Rect::y, and SDL_Texture::yuv.

Referenced by SDL_UpdateTexture().

{
SDL_Texture *native = texture->native;
SDL_Rect full_rect;
if (SDL_SW_UpdateYUVTexture(texture->yuv, rect, pixels, pitch) < 0) {
return -1;
}
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = texture->w;
full_rect.h = texture->h;
rect = &full_rect;
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
/* We can lock the texture and copy to it */
void *native_pixels = NULL;
int native_pitch = 0;
if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
return -1;
}
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
rect->w, rect->h, native_pixels, native_pitch);
SDL_UnlockTexture(native);
} else {
/* Use a temporary buffer for updating */
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
const size_t alloclen = rect->h * temp_pitch;
if (alloclen > 0) {
void *temp_pixels = SDL_malloc(alloclen);
if (!temp_pixels) {
return SDL_OutOfMemory();
}
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
rect->w, rect->h, temp_pixels, temp_pitch);
SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
SDL_free(temp_pixels);
}
}
return 0;
}
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
SDL_Texture
Definition: SDL_sysrender.h:49
SDL_SW_UpdateYUVTexture
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_yuv_sw.c:139
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_UnlockTexture
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL_render.c:1136
SDL_LockTexture
int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL_render.c:1063
SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:94
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_Rect::x
int x
Definition: SDL_rect.h:66
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_UpdateTexture
int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL_render.c:896
NULL
#define NULL
Definition: begin_code.h:164
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_SW_CopyYUVToRGB
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, Uint32 target_format, int w, int h, void *pixels, int pitch)
Definition: SDL_yuv_sw.c:334
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

## SDL_UpdateTextureYUVPlanar()

static int SDL_UpdateTextureYUVPlanar | ( | SDL_Texture * | texture,
|  | const SDL_Rect * | rect,
|  | const Uint8 * | Yplane,
|  | int | Ypitch,
|  | const Uint8 * | Uplane,
|  | int | Upitch,
|  | const Uint8 * | Vplane,
|  | int | Vpitch
| ) |  |

static

Definition at line 932 of file SDL_render.c.

References SDL_Texture::access, SDL_Texture::format, SDL_Texture::h, SDL_Rect::h, SDL_Texture::native, NULL, SDL_BYTESPERPIXEL, SDL_free, SDL_LockTexture(), SDL_malloc, SDL_OutOfMemory, SDL_SW_CopyYUVToRGB(), SDL_SW_UpdateYUVTexturePlanar(), SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTexture(), SDL_UpdateTexture(), SDL_Texture::w, SDL_Rect::w, SDL_Rect::x, SDL_Rect::y, and SDL_Texture::yuv.

Referenced by SDL_UpdateYUVTexture().

{
SDL_Texture *native = texture->native;
SDL_Rect full_rect;
if (SDL_SW_UpdateYUVTexturePlanar(texture->yuv, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch) < 0) {
return -1;
}
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = texture->w;
full_rect.h = texture->h;
rect = &full_rect;
if (!rect->w || !rect->h) {
return 0; /* nothing to do. */
}
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
/* We can lock the texture and copy to it */
void *native_pixels = NULL;
int native_pitch = 0;
if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
return -1;
}
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
rect->w, rect->h, native_pixels, native_pitch);
SDL_UnlockTexture(native);
} else {
/* Use a temporary buffer for updating */
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
const size_t alloclen = rect->h * temp_pitch;
if (alloclen > 0) {
void *temp_pixels = SDL_malloc(alloclen);
if (!temp_pixels) {
return SDL_OutOfMemory();
}
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
rect->w, rect->h, temp_pixels, temp_pitch);
SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
SDL_free(temp_pixels);
}
}
return 0;
}
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
SDL_Texture
Definition: SDL_sysrender.h:49
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_UnlockTexture
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL_render.c:1136
SDL_LockTexture
int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL_render.c:1063
SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:94
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_UpdateTexture
int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL_render.c:896
NULL
#define NULL
Definition: begin_code.h:164
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_SW_UpdateYUVTexturePlanar
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
Definition: SDL_yuv_sw.c:247
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_SW_CopyYUVToRGB
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, Uint32 target_format, int w, int h, void *pixels, int pitch)
Definition: SDL_yuv_sw.c:334
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

## SDL_UpdateYUVTexture()

int SDL_UpdateYUVTexture | ( | SDL_Texture * | texture,
|  | const SDL_Rect * | rect,
|  | const Uint8 * | Yplane,
|  | int | Ypitch,
|  | const Uint8 * | Uplane,
|  | int | Upitch,
|  | const Uint8 * | Vplane,
|  | int | Vpitch
| ) |  |

Update a rectangle within a planar YV12 or IYUV texture with new pixel data.

Parameters

  texture | The texture to update
  rect | A pointer to the rectangle of pixels to update, or NULL to update the entire texture.
  Yplane | The raw pixel data for the Y plane.
  Ypitch | The number of bytes between rows of pixel data for the Y plane.
  Uplane | The raw pixel data for the U plane.
  Upitch | The number of bytes between rows of pixel data for the U plane.
  Vplane | The raw pixel data for the V plane.
  Vpitch | The number of bytes between rows of pixel data for the V plane.

Returns
  0 on success, or -1 if the texture is not valid.

Note
  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.

Definition at line 983 of file SDL_render.c.

References CHECK_TEXTURE_MAGIC, SDL_Texture::format, SDL_Texture::h, SDL_Rect::h, SDL_Texture::native, renderer, SDL_Texture::renderer, SDL_assert, SDL_InvalidParamError, SDL_PIXELFORMAT_IYUV, SDL_PIXELFORMAT_YV12, SDL_SetError, SDL_Unsupported, SDL_UpdateTextureYUVPlanar(), SDL_Renderer::UpdateTextureYUV, SDL_Texture::w, SDL_Rect::w, SDL_Rect::x, SDL_Rect::y, and SDL_Texture::yuv.

{
SDL_Renderer *renderer;
SDL_Rect full_rect;
CHECK_TEXTURE_MAGIC(texture, -1);
if (!Yplane) {
return SDL_InvalidParamError("Yplane");
}
if (!Ypitch) {
return SDL_InvalidParamError("Ypitch");
}
if (!Uplane) {
return SDL_InvalidParamError("Uplane");
}
if (!Upitch) {
return SDL_InvalidParamError("Upitch");
}
if (!Vplane) {
return SDL_InvalidParamError("Vplane");
}
if (!Vpitch) {
return SDL_InvalidParamError("Vpitch");
}
if (texture->format != SDL_PIXELFORMAT_YV12 &&
texture->format != SDL_PIXELFORMAT_IYUV) {
return SDL_SetError("Texture format must by YV12 or IYUV");
}
if (!rect) {
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = texture->w;
full_rect.h = texture->h;
rect = &full_rect;
}
if (!rect->w || !rect->h) {
return 0; /* nothing to do. */
}
if (texture->yuv) {
return SDL_UpdateTextureYUVPlanar(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
} else {
SDL_assert(!texture->native);
renderer = texture->renderer;
SDL_assert(renderer->UpdateTextureYUV);
if (renderer->UpdateTextureYUV) {
return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
} else {
return SDL_Unsupported();
}
}
}
SDL_UpdateTextureYUVPlanar
static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
Definition: SDL_render.c:932
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_InvalidParamError
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_Renderer::UpdateTextureYUV
int(* UpdateTextureYUV)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
Definition: SDL_sysrender.h:93
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
SDL_PIXELFORMAT_YV12
Definition: SDL_pixels.h:277
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:42
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_PIXELFORMAT_IYUV
Definition: SDL_pixels.h:279
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

## UpdateLogicalSize()

static int UpdateLogicalSize | ( | SDL_Renderer * | renderer | ) |

static

Definition at line 1242 of file SDL_render.c.

References SDL_Rect::h, SDL_Renderer::integer_scale, SDL_Renderer::logical_h, SDL_Renderer::logical_w, NULL, SDL_ceil, SDL_fabs, SDL_FALSE, SDL_GetCurrentVideoDriver, SDL_GetHint, SDL_GetRendererOutputSize(), SDL_HINT_RENDER_LOGICAL_SIZE_MODE, SDL_RenderSetScale(), SDL_RenderSetViewport(), SDL_strcasecmp, SDL_TRUE, viewport, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_RendererEventWatch(), SDL_RenderSetIntegerScale(), and SDL_RenderSetLogicalSize().

{
int w = 1, h = 1;
float want_aspect;
float real_aspect;
float scale;
SDL_Rect viewport;
/* 0 is for letterbox, 1 is for overscan */
int scale_policy = 0;
const char *hint;
if (!renderer->logical_w || !renderer->logical_h) {
return 0;
}
if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) {
return -1;
}
hint = SDL_GetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE);
if (hint && (*hint == '1' || SDL_strcasecmp(hint, "overscan") == 0)) {
SDL_bool overscan_supported = SDL_TRUE;
/* Unfortunately, Direct3D 9 doesn't support negative viewport numbers
which the overscan implementation relies on.
*/
if (SDL_strcasecmp(SDL_GetCurrentVideoDriver(), "direct3d") == 0) {
overscan_supported = SDL_FALSE;
}
if (overscan_supported) {
scale_policy = 1;
}
}
want_aspect = (float)renderer->logical_w / renderer->logical_h;
real_aspect = (float)w / h;
/* Clear the scale because we're setting viewport in output coordinates */
SDL_RenderSetScale(renderer, 1.0f, 1.0f);
if (renderer->integer_scale) {
if (want_aspect > real_aspect) {
scale = (float)(w / renderer->logical_w);
} else {
scale = (float)(h / renderer->logical_h);
}
viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
viewport.x = (w - viewport.w) / 2;
viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
viewport.y = (h - viewport.h) / 2;
SDL_RenderSetViewport(renderer, &viewport);
} else if (SDL_fabs(want_aspect-real_aspect) < 0.0001) {
/* The aspect ratios are the same, just scale appropriately */
scale = (float)w / renderer->logical_w;
SDL_RenderSetViewport(renderer, NULL);
} else if (want_aspect > real_aspect) {
if (scale_policy == 1) {
/* We want a wider aspect ratio than is available -
zoom so logical height matches the real height
and the width will grow off the screen
*/
scale = (float)h / renderer->logical_h;
viewport.y = 0;
viewport.h = h;
viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
viewport.x = (w - viewport.w) / 2;
SDL_RenderSetViewport(renderer, &viewport);
} else {
/* We want a wider aspect ratio than is available - letterbox it */
scale = (float)w / renderer->logical_w;
viewport.x = 0;
viewport.w = w;
viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
viewport.y = (h - viewport.h) / 2;
SDL_RenderSetViewport(renderer, &viewport);
}
} else {
if (scale_policy == 1) {
/* We want a narrower aspect ratio than is available -
zoom so logical width matches the real width
and the height will grow off the screen
*/
scale = (float)w / renderer->logical_w;
viewport.x = 0;
viewport.w = w;
viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
viewport.y = (h - viewport.h) / 2;
SDL_RenderSetViewport(renderer, &viewport);
} else {
/* We want a narrower aspect ratio than is available - use side-bars */
scale = (float)h / renderer->logical_h;
viewport.y = 0;
viewport.h = h;
viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
viewport.x = (w - viewport.w) / 2;
SDL_RenderSetViewport(renderer, &viewport);
}
}
/* Set the new scale */
SDL_RenderSetScale(renderer, scale, scale);
return 0;
}
scale
GLenum GLenum GLenum GLenum GLenum scale
Definition: SDL_opengl_glext.h:9375
SDL_ceil
#define SDL_ceil
Definition: SDL_dynapi_overrides.h:426
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_fabs
#define SDL_fabs
Definition: SDL_dynapi_overrides.h:430
SDL_FALSE
Definition: SDL_stdinc.h:141
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:138
f
GLfloat f
Definition: SDL_opengl_glext.h:1870
SDL_RenderSetViewport
int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the drawing area for rendering on the current target.
Definition: SDL_render.c:1398
SDL_strcasecmp
#define SDL_strcasecmp
Definition: SDL_dynapi_overrides.h:419
SDL_GetRendererOutputSize
int SDL_GetRendererOutputSize(SDL_Renderer *renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
Definition: SDL_render.c:423
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_RenderSetScale
int SDL_RenderSetScale(SDL_Renderer *renderer, float scaleX, float scaleY)
Set the drawing scale for rendering on the current target.
Definition: SDL_render.c:1469
SDL_HINT_RENDER_LOGICAL_SIZE_MODE
#define SDL_HINT_RENDER_LOGICAL_SIZE_MODE
A variable controlling the scaling policy for SDL_RenderSetLogicalSize.
Definition: SDL_hints.h:131
NULL
#define NULL
Definition: begin_code.h:164
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
SDL_GetCurrentVideoDriver
#define SDL_GetCurrentVideoDriver
Definition: SDL_dynapi_overrides.h:500
SDL_Rect::h
int h
Definition: SDL_rect.h:67
viewport
SDL_Rect viewport
Definition: testviewport.c:28
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:137
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_Renderer::integer_scale
SDL_bool integer_scale
Definition: SDL_sysrender.h:143
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

## Variable Documentation

## render_drivers

const SDL_RenderDriver* render_drivers[]

static

Initial value:
= {
&SW_RenderDriver
}
SW_RenderDriver
SDL_RenderDriver SW_RenderDriver
Definition: SDL_render_sw.c:78

Definition at line 76 of file SDL_render.c.

## renderer_magic

char renderer_magic

static

Definition at line 105 of file SDL_render.c.

Referenced by SDL_CreateRenderer(), and SDL_CreateSoftwareRenderer().

## texture_magic

char texture_magic

static

Definition at line 106 of file SDL_render.c.

Referenced by SDL_CreateTexture().