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)

## 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 | 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_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...

## Variables

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

## Macro Definition Documentation

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

Value:
if (!renderer || renderer->magic != &renderer_magic) { \
SDL_SetError("Invalid renderer"); \
return retval; \
}
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
retval
SDL_bool retval
Definition: testgamecontroller.c:65
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:78
renderer_magic
static char renderer_magic
Definition: SDL_render.c:75

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_RenderGetLogicalSize(), SDL_RenderGetScale(), SDL_RenderGetViewport(), SDL_RenderIsClipEnabled(), SDL_RenderPresent(), SDL_RenderReadPixels(), SDL_RenderSetClipRect(), SDL_RenderSetLogicalSize(), SDL_RenderSetScale(), SDL_RenderSetViewport(), SDL_SetRenderDrawBlendMode(), and SDL_SetRenderDrawColor().

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

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

Definition at line 41 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().

#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

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

static

Definition at line 385 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];
}
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:157
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:126
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:153
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
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:42
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:166

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

static

Definition at line 372 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;
}
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:157
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:126
SDL_RendererInfo::texture_formats
Uint32 texture_formats[16]
Definition: SDL_render.h:83
SDL_TRUE
Definition: SDL_stdinc.h:129
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:42
SDL_FALSE
Definition: SDL_stdinc.h:128
SDL_RendererInfo::num_texture_formats
Uint32 num_texture_formats
Definition: SDL_render.h:82

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

static

Definition at line 1466 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:106
SDL_FRect::w
float w
Definition: SDL_sysrender.h:44
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:347
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_Renderer::RenderFillRects
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Definition: SDL_sysrender.h:108
SDL_FRect::y
float y
Definition: SDL_sysrender.h:43
SDL_max
#define SDL_max(x, y)
Definition: SDL_stdinc.h:348
SDL_Point::x
int x
Definition: SDL_rect.h:50
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_stack_alloc
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:326
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:42
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:327
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

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

static

Definition at line 1387 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:1564
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_Renderer::RenderFillRects
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Definition: SDL_sysrender.h:108
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:326
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:42
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:327
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_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 220 of file SDL_render.c.

References SDL_RenderDriver::CreateRenderer, SDL_RendererInfo::flags, 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_GetNumRenderDrivers(), SDL_GetRenderer(), SDL_GetWindowFlags, 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, window, SDL_Renderer::window, 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;
}
hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
if (hint) {
if (*hint == '0') {
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;
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
}
n
GLdouble n
Definition: SDL_opengl_glext.h:1952
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:142
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:126
SDL_RendererInfo::flags
Uint32 flags
Definition: SDL_render.h:81
window
SDL_Window * window
Definition: testautomation_render.c:26
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:130
SDL_RENDERER_PRESENTVSYNC
Definition: SDL_render.h:69
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:197
SDL_GetWindowFlags
#define SDL_GetWindowFlags
Definition: SDL_dynapi_overrides.h:522
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:1219
SDL_strcasecmp
#define SDL_strcasecmp
Definition: SDL_dynapi_overrides.h:425
SDL_RendererInfo::name
const char * name
Definition: SDL_render.h:80
SDL_WINDOW_HIDDEN
Definition: SDL_video.h:101
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:129
SDL_RenderDriver::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:170
SDL_SetWindowData
#define SDL_SetWindowData
Definition: SDL_dynapi_overrides.h:526
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
SDL_RenderDriver::CreateRenderer
SDL_Renderer *(* CreateRenderer)(SDL_Window *window, Uint32 flags)
Definition: SDL_sysrender.h:167
SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:104
SDL_GetNumRenderDrivers
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
Definition: SDL_render.c:81
SDL_TRUE
Definition: SDL_stdinc.h:129
index
GLuint index
Definition: SDL_opengl_glext.h:660
NULL
#define NULL
Definition: begin_code.h:143
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
render_drivers
static const SDL_RenderDriver * render_drivers[]
Definition: SDL_render.c:49
SDL_WINDOWRENDERDATA
#define SDL_WINDOWRENDERDATA
Definition: SDL_render.c:33
SDL_RenderDriver
Definition: SDL_sysrender.h:165
SDL_AddEventWatch
#define SDL_AddEventWatch
Definition: SDL_dynapi_overrides.h:134
SDL_LogInfo
#define SDL_LogInfo
Definition: SDL_dynapi_overrides.h:40
SDL_GetRenderer
SDL_Renderer * SDL_GetRenderer(SDL_Window *window)
Get the renderer associated with a window.
Definition: SDL_render.c:339
SDL_FALSE
Definition: SDL_stdinc.h:128
SDL_HINT_RENDER_DRIVER
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
Definition: SDL_hints.h:84
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:78
flags
GLbitfield flags
Definition: SDL_opengl_glext.h:1480
renderer_magic
static char renderer_magic
Definition: SDL_render.c:75
SDL_LOG_CATEGORY_RENDER
Definition: SDL_log.h:72
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:106
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

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 317 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:151
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:1219
SW_CreateRendererForSurface
SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface *surface)
Definition: SDL_render_sw.c:126
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
NULL
#define NULL
Definition: begin_code.h:143
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:78
renderer_magic
static char renderer_magic
Definition: SDL_render.c:75
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

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.

See also
  SDL_QueryTexture()
  SDL_UpdateTexture()
  SDL_DestroyTexture()

Definition at line 411 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
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
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:1021
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:385
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:126
SDL_ISPIXELFORMAT_INDEXED
#define SDL_ISPIXELFORMAT_INDEXED(format)
Definition: SDL_pixels.h:133
SDL_Texture::g
Uint8 g
Definition: SDL_sysrender.h:58
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
SDL_RendererInfo::texture_formats
Uint32 texture_formats[16]
Definition: SDL_render.h:83
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:127
SDL_Renderer::textures
SDL_Texture * textures
Definition: SDL_sysrender.h:155
SDL_RendererInfo::max_texture_height
int max_texture_height
Definition: SDL_render.h:85
texture_magic
static char texture_magic
Definition: SDL_render.c:76
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
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
SDL_Texture::next
SDL_Texture * next
Definition: SDL_sysrender.h:72
SDL_calloc
void * SDL_calloc(size_t nmemb, size_t size)
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:1842
SDL_Texture::prev
SDL_Texture * prev
Definition: SDL_sysrender.h:71
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
NULL
#define NULL
Definition: begin_code.h:143
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:36
IsSupportedFormat
static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, Uint32 format)
Definition: SDL_render.c:372
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Renderer::CreateTexture
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:82
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_ISPIXELFORMAT_FOURCC
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:166
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:411
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55
SDL_Texture::r
Uint8 r
Definition: SDL_sysrender.h:58

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 505 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;
}
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
SDL_UnlockSurface
#define SDL_UnlockSurface
Definition: SDL_dynapi_overrides.h:453
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:157
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:126
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:467
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
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:286
SDL_ISPIXELFORMAT_ALPHA
#define SDL_ISPIXELFORMAT_ALPHA(format)
Definition: SDL_pixels.h:153
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:464
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
SDL_SetTextureBlendMode
int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode)
Set the blend mode used for texture copy operations.
Definition: SDL_render.c:691
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:1842
SDL_Surface::pixels
void * pixels
Definition: SDL_surface.h:75
SDL_GetColorKey
#define SDL_GetColorKey
Definition: SDL_dynapi_overrides.h:458
SDL_FreeSurface
#define SDL_FreeSurface
Definition: SDL_dynapi_overrides.h:450
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
SDL_TEXTUREACCESS_STATIC
Definition: SDL_render.h:93
SDL_FreeFormat
#define SDL_FreeFormat
Definition: SDL_dynapi_overrides.h:287
SDL_TRUE
Definition: SDL_stdinc.h:129
SDL_GetSurfaceAlphaMod
#define SDL_GetSurfaceAlphaMod
Definition: SDL_dynapi_overrides.h:462
SDL_SetTextureAlphaMod
int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha)
Set an additional alpha value used in render copy operations.
Definition: SDL_render.c:657
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:42
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:803
NULL
#define NULL
Definition: begin_code.h:143
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_LockSurface
#define SDL_LockSurface
Definition: SDL_dynapi_overrides.h:452
SDL_GetSurfaceColorMod
#define SDL_GetSurfaceColorMod
Definition: SDL_dynapi_overrides.h:460
SDL_MUSTLOCK
#define SDL_MUSTLOCK(S)
Definition: SDL_surface.h:61
SDL_PixelFormat
Definition: SDL_pixels.h:299
SDL_FALSE
Definition: SDL_stdinc.h:128
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:614
SDL_RendererInfo::num_texture_formats
Uint32 num_texture_formats
Definition: SDL_render.h:82
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:309
SDL_ISPIXELFORMAT_FOURCC
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:166
SDL_PixelFormat::format
Uint32 format
Definition: SDL_pixels.h:301
a
GLboolean GLboolean GLboolean GLboolean a
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:411
SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44

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 200 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;
}
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
SDL_CreateWindow
#define SDL_CreateWindow
Definition: SDL_dynapi_overrides.h:518
SDL_WINDOWPOS_UNDEFINED
#define SDL_WINDOWPOS_UNDEFINED
Definition: SDL_video.h:120
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
NULL
#define NULL
Definition: begin_code.h:143
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:220

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

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

See also
  SDL_CreateRenderer()

Definition at line 1877 of file SDL_render.c.

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

{
CHECK_RENDERER_MAGIC(renderer, );
SDL_DelEventWatch(SDL_RendererEventWatch, renderer);
/* Free existing textures for this renderer */
while (renderer->textures) {
SDL_DestroyTexture(renderer->textures);
}
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:135
SDL_Renderer::textures
SDL_Texture * textures
Definition: SDL_sysrender.h:155
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:129
SDL_Renderer::DestroyRenderer
void(* DestroyRenderer)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:120
SDL_SetWindowData
#define SDL_SetWindowData
Definition: SDL_dynapi_overrides.h:526
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:1842
NULL
#define NULL
Definition: begin_code.h:143
SDL_WINDOWRENDERDATA
#define SDL_WINDOWRENDERDATA
Definition: SDL_render.c:33
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:106

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

Destroy the specified texture.

See also
  SDL_CreateTexture()
  SDL_CreateTextureFromSurface()

Definition at line 1842 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:155
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
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:1842
SDL_Texture::prev
SDL_Texture * prev
Definition: SDL_sysrender.h:71
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:156
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64
SDL_free
void SDL_free(void *mem)
SDL_SW_DestroyYUVTexture
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
Definition: SDL_yuv_sw.c:1393
NULL
#define NULL
Definition: begin_code.h:143
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
SDL_Renderer::DestroyTexture
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:118
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:1064
SDL_Texture::magic
const void * magic
Definition: SDL_sysrender.h:51

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 81 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:49
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93

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 1356 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:159

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 1326 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:2072
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::g
Uint8 g
Definition: SDL_sysrender.h:158
SDL_Renderer::b
Uint8 b
Definition: SDL_sysrender.h:158
SDL_Renderer::r
Uint8 r
Definition: SDL_sysrender.h:158
SDL_Renderer::a
Uint8 a
Definition: SDL_sysrender.h:158
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

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 91 of file SDL_render.c.

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

{
#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:170
SDL_GetNumRenderDrivers
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
Definition: SDL_render.c:81
index
GLuint index
Definition: SDL_opengl_glext.h:660
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
render_drivers
static const SDL_RenderDriver * render_drivers[]
Definition: SDL_render.c:49

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

Get the renderer associated with a window.

Definition at line 339 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:527
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_WINDOWRENDERDATA
#define SDL_WINDOWRENDERDATA
Definition: SDL_render.c:33

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

Get information about a rendering context.

Definition at line 345 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:126
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35

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

Get the output size in pixels of a rendering context.

Definition at line 354 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_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");
}
}
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:129
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:593
SDL_GetWindowSize
#define SDL_GetWindowSize
Definition: SDL_dynapi_overrides.h:531
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:156
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:167
NULL
#define NULL
Definition: begin_code.h:143
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946

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 1133 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:156

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 680 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:41

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 709 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:41

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 639 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:2072
SDL_Texture::g
Uint8 g
Definition: SDL_sysrender.h:58
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
SDL_Texture::b
Uint8 b
Definition: SDL_sysrender.h:58
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
SDL_Texture::r
Uint8 r
Definition: SDL_sysrender.h:58

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 1899 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
SDL_Renderer * renderer
Definition: testautomation_render.c:27
SDL_Renderer::GL_BindTexture
int(* GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
Definition: SDL_sysrender.h:122
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:1899
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53

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 1914 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
SDL_Renderer * renderer
Definition: testautomation_render.c:27
SDL_Renderer::GL_UnbindTexture
int(* GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:123
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
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:1914

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 962 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:97
SDL_Renderer
Definition: SDL_sysrender.h:76
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
SDL_LockTextureYUV
static int SDL_LockTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_render.c:943
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
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
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
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:950
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

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

static

Definition at line 950 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:127
SDL_Texture::locked_rect
SDL_Rect locked_rect
Definition: SDL_sysrender.h:67
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_Rect::y
int y
Definition: SDL_rect.h:66

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

static

Definition at line 943 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:1243
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
SDL_Texture::yuv
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:64

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 593 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;
}
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
access
GLuint GLint GLboolean GLint GLenum access
Definition: SDL_opengl_glext.h:2162
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55

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.

Returns
  0 on success, or -1 on error

Definition at line 1365 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:130
SDL_Renderer::RenderClear
int(* RenderClear)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:103
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35

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 1675 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");
}
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;
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
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:299
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:130
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:300
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:110
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
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:1239
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

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
  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 1728 of file SDL_render.c.

References CHECK_RENDERER_MAGIC, CHECK_TEXTURE_MAGIC, SDL_FRect::h, SDL_Texture::h, SDL_Rect::h, 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 && angle == 0) { /* 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");
}
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:1675
SDL_FLIP_NONE
Definition: SDL_render.h:113
SDL_Point
The structure that defines a point.
Definition: SDL_rect.h:48
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:300
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:36
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:112
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
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:1239
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

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 1454 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:1522

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 1522 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:106
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:130
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
RenderDrawLinesWithRects
static int RenderDrawLinesWithRects(SDL_Renderer *renderer, const SDL_Point *points, int count)
Definition: SDL_render.c:1466
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:326
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:42
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:327
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

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 1377 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:1567
SDL_Point
The structure that defines a point.
Definition: SDL_rect.h:48
SDL_Point::x
int x
Definition: SDL_rect.h:50
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
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:1413

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 1413 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:104
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:130
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
RenderDrawPointsWithRects
static int RenderDrawPointsWithRects(SDL_Renderer *renderer, const SDL_Point *points, int count)
Definition: SDL_render.c:1387
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:326
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:42
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:327
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

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 1563 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:1522
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:1239
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

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 1592 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:1564
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:130
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:1563
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:42
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36

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

static

Definition at line 106 of file SDL_render.c.

References SDL_Event::button, SDL_WindowEvent::event, SDL_Renderer::GetOutputSize, SDL_Rect::h, SDL_Renderer::hidden, SDL_Renderer::logical_w, SDL_Event::motion, NULL, renderer, SDL_Renderer::scale, SDL_FALSE, 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, window, 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 -= renderer->viewport.x;
event->motion.y -= renderer->viewport.y;
event->motion.x = (int)(event->motion.x / renderer->scale.x);
event->motion.y = (int)(event->motion.y / renderer->scale.y);
if (event->motion.xrel > 0) {
event->motion.xrel = SDL_max(1, (int)(event->motion.xrel / renderer->scale.x));
} else if (event->motion.xrel < 0) {
event->motion.xrel = SDL_min(-1, (int)(event->motion.xrel / renderer->scale.x));
}
if (event->motion.yrel > 0) {
event->motion.yrel = SDL_max(1, (int)(event->motion.yrel / renderer->scale.y));
} else if (event->motion.yrel < 0) {
event->motion.yrel = SDL_min(-1, (int)(event->motion.yrel / renderer->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 -= renderer->viewport.x;
event->button.y -= renderer->viewport.y;
event->button.x = (int)(event->button.x / renderer->scale.x);
event->button.y = (int)(event->button.y / renderer->scale.y);
}
}
return 0;
}
SDL_Event::motion
SDL_MouseMotionEvent motion
Definition: SDL_events.h:529
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:347
SDL_MouseMotionEvent::y
Sint32 y
Definition: SDL_events.h:237
SDL_MOUSEBUTTONUP
Definition: SDL_events.h:104
SDL_WINDOWEVENT_MINIMIZED
Definition: SDL_video.h:149
SDL_MouseButtonEvent::y
Sint32 y
Definition: SDL_events.h:256
window
SDL_Window * window
Definition: testautomation_render.c:26
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:130
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:1133
SDL_MOUSEBUTTONDOWN
Definition: SDL_events.h:103
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_GetWindowFlags
#define SDL_GetWindowFlags
Definition: SDL_dynapi_overrides.h:522
SDL_Renderer
Definition: SDL_sysrender.h:76
SDL_MouseMotionEvent::x
Sint32 x
Definition: SDL_events.h:236
SDL_WINDOWEVENT_MAXIMIZED
Definition: SDL_video.h:150
SDL_WINDOWEVENT_SIZE_CHANGED
Definition: SDL_video.h:146
SDL_WINDOW_HIDDEN
Definition: SDL_video.h:101
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:129
SDL_max
#define SDL_max(x, y)
Definition: SDL_stdinc.h:348
SDL_WINDOWEVENT_HIDDEN
Definition: SDL_video.h:140
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:525
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
SDL_GetWindowSize
#define SDL_GetWindowSize
Definition: SDL_dynapi_overrides.h:531
SDL_MouseMotionEvent::yrel
Sint32 yrel
Definition: SDL_events.h:239
SDL_MouseMotionEvent::xrel
Sint32 xrel
Definition: SDL_events.h:238
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:156
SDL_WINDOWEVENT_RESTORED
Definition: SDL_video.h:151
SDL_WINDOWEVENT
Definition: SDL_events.h:89
SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:104
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_WindowEvent::event
Uint8 event
Definition: SDL_events.h:176
SDL_Renderer::UpdateViewport
int(* UpdateViewport)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:101
SDL_GetWindowFromID
#define SDL_GetWindowFromID
Definition: SDL_dynapi_overrides.h:521
SDL_TRUE
Definition: SDL_stdinc.h:129
SDL_Rect::w
int w
Definition: SDL_rect.h:67
UpdateLogicalSize
static int UpdateLogicalSize(SDL_Renderer *renderer)
Definition: SDL_render.c:1139
NULL
#define NULL
Definition: begin_code.h:143
SDL_MOUSEMOTION
Definition: SDL_events.h:102
SDL_WINDOWEVENT_SHOWN
Definition: SDL_video.h:139
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:139
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_MouseMotionEvent::windowID
Uint32 windowID
Definition: SDL_events.h:233
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:71
SDL_FALSE
Definition: SDL_stdinc.h:128
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:530
SDL_MouseButtonEvent::x
Sint32 x
Definition: SDL_events.h:255
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:133
SDL_Renderer::viewport_backup
SDL_Rect viewport_backup
Definition: SDL_sysrender.h:140
SDL_MouseButtonEvent::windowID
Uint32 windowID
Definition: SDL_events.h:249
SDL_SetRenderTarget
int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
Set a texture as the current rendering target.
Definition: SDL_render.c:1064
SDL_Rect::y
int y
Definition: SDL_rect.h:66
SDL_WindowEvent::windowID
Uint32 windowID
Definition: SDL_events.h:175
SDL_FPoint::x
float x
Definition: SDL_sysrender.h:36
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_Event::type
Uint32 type
Definition: SDL_events.h:523
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

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 1619 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:1636
SDL_RenderGetViewport
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
Definition: SDL_render.c:1239
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

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 1636 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:1564
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:130
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_Renderer::RenderFillRects
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Definition: SDL_sysrender.h:108
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:326
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:42
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:327
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

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 1270 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:151
SDL_Renderer::clip_rect
SDL_Rect clip_rect
Definition: SDL_sysrender.h:143
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

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 1206 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;
}
}
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:134
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:133
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946

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 1300 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:151
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

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

Get the drawing area for the current target.

See also
  SDL_RenderSetViewport()

Definition at line 1239 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:151
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:139
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_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 1283 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;
}
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_FALSE
Definition: SDL_stdinc.h:128

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

Update the screen with rendering performed.

Definition at line 1830 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:130
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:117

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 1793 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);
}
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
SDL_Renderer::RenderReadPixels
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
Definition: SDL_sysrender.h:115
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:127
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:300
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:129
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
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:139
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_GetWindowPixelFormat
#define SDL_GetWindowPixelFormat
Definition: SDL_dynapi_overrides.h:517
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

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 1252 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:432
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_Renderer::clip_rect
SDL_Rect clip_rect
Definition: SDL_sysrender.h:143
SDL_floor
#define SDL_floor
Definition: SDL_dynapi_overrides.h:437
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:357
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_TRUE
Definition: SDL_stdinc.h:129
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_FALSE
Definition: SDL_stdinc.h:128
SDL_Renderer::UpdateClipRect
int(* UpdateClipRect)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:102
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:147
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

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 1186 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);
}
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:134
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:1219
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:1139
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:1290
NULL
#define NULL
Definition: begin_code.h:143
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:133
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946

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 1290 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:151
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

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 1219 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:432
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_floor
#define SDL_floor
Definition: SDL_dynapi_overrides.h:437
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:354
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:101
SDL_Rect::w
int w
Definition: SDL_rect.h:67
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:139
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_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 1055 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:126
SDL_RENDERER_TARGETTEXTURE
Definition: SDL_render.h:71
SDL_RendererInfo::flags
Uint32 flags
Definition: SDL_render.h:81
SDL_Renderer::SetRenderTarget
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:100
SDL_FALSE
Definition: SDL_stdinc.h:128

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 1347 of file SDL_render.c.

References blendMode, SDL_Renderer::blendMode, and CHECK_RENDERER_MAGIC.

{
CHECK_RENDERER_MAGIC(renderer, -1);
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:159

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 1313 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:2072
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:35
SDL_Renderer::g
Uint8 g
Definition: SDL_sysrender.h:158
SDL_Renderer::b
Uint8 b
Definition: SDL_sysrender.h:158
SDL_Renderer::r
Uint8 r
Definition: SDL_sysrender.h:158
SDL_Renderer::a
Uint8 a
Definition: SDL_sysrender.h:158
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

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 1064 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_RenderTargetSupported(), SDL_SetError, SDL_TEXTUREACCESS_TARGET, SDL_Unsupported, 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;
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:144
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:151
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:134
SDL_Renderer::clip_rect
SDL_Rect clip_rect
Definition: SDL_sysrender.h:143
SDL_Renderer::scale_backup
SDL_FPoint scale_backup
Definition: SDL_sysrender.h:152
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:156
SDL_Renderer::logical_w_backup
int logical_w_backup
Definition: SDL_sysrender.h:135
SDL_Renderer::logical_h_backup
int logical_h_backup
Definition: SDL_sysrender.h:136
SDL_Texture::w
int w
Definition: SDL_sysrender.h:54
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:100
SDL_Renderer::UpdateViewport
int(* UpdateViewport)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:101
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:1055
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:139
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:133
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Renderer::viewport_backup
SDL_Rect viewport_backup
Definition: SDL_sysrender.h:140
SDL_Renderer::UpdateClipRect
int(* UpdateClipRect)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:102
SDL_Renderer::clipping_enabled_backup
SDL_bool clipping_enabled_backup
Definition: SDL_sysrender.h:148
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:147
SDL_Texture::h
int h
Definition: SDL_sysrender.h:55
SDL_FPoint::y
float y
Definition: SDL_sysrender.h:37

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 657 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
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
SDL_TEXTUREMODULATE_ALPHA
Definition: SDL_render.h:105
SDL_SetTextureAlphaMod
int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha)
Set an additional alpha value used in render copy operations.
Definition: SDL_render.c:657
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
SDL_Renderer::SetTextureAlphaMod
int(* SetTextureAlphaMod)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:85
SDL_Texture::modMode
int modMode
Definition: SDL_sysrender.h:56
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63

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 691 of file SDL_render.c.

References blendMode, SDL_Texture::blendMode, CHECK_TEXTURE_MAGIC, SDL_Texture::native, renderer, SDL_Texture::renderer, and SDL_Renderer::SetTextureBlendMode.

Referenced by SDL_CreateTextureFromSurface().

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, -1);
renderer = texture->renderer;
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:87
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
SDL_SetTextureBlendMode
int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode)
Set the blend mode used for texture copy operations.
Definition: SDL_render.c:691
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63

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 614 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:2072
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
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
SDL_Renderer::SetTextureColorMod
int(* SetTextureColorMod)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:83
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:41
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:614
SDL_Texture::modMode
int modMode
Definition: SDL_sysrender.h:56
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
SDL_Texture::r
Uint8 r
Definition: SDL_sysrender.h:58

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

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

See also
  SDL_LockTexture()

Definition at line 1035 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:1014
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
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:99
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_UnlockTextureYUV
static void SDL_UnlockTextureYUV(SDL_Texture *texture)
Definition: SDL_render.c:993
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53

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

static

Definition at line 1014 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:127
SDL_Texture::locked_rect
SDL_Rect locked_rect
Definition: SDL_sysrender.h:67
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
SDL_Texture
Definition: SDL_sysrender.h:49
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
SDL_UnlockTexture
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL_render.c:1035
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:962
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:143
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:469
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

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

static

Definition at line 993 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:1035
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:962
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:143
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:1273
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

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.
  pitch | The number of bytes in a row of pixel data, including padding between lines.

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

Note
  This is a fairly slow function.

Definition at line 803 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
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
SDL_UpdateTextureNative
static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_render.c:766
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:89
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
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_UpdateTextureYUV
static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_render.c:720
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
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

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

static

Definition at line 766 of file SDL_render.c.

References SDL_Texture::access, SDL_Texture::format, SDL_Rect::h, SDL_Texture::native, 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 (texture->access == SDL_TEXTUREACCESS_STREAMING) {
/* We can lock the texture and copy to it */
void *native_pixels;
int native_pitch;
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 */
void *temp_pixels;
int temp_pitch;
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
temp_pixels = SDL_malloc(rect->h * temp_pitch);
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:127
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
SDL_Texture
Definition: SDL_sysrender.h:49
SDL_UnlockTexture
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL_render.c:1035
SDL_free
void SDL_free(void *mem)
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:962
SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:94
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:803
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:380
SDL_ConvertPixels
#define SDL_ConvertPixels
Definition: SDL_dynapi_overrides.h:469
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:63
SDL_Texture::access
int access
Definition: SDL_sysrender.h:53

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

static

Definition at line 720 of file SDL_render.c.

References SDL_Texture::access, SDL_Texture::format, SDL_Texture::h, SDL_Rect::h, SDL_Texture::native, 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;
int native_pitch;
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 */
void *temp_pixels;
int temp_pitch;
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
temp_pixels = SDL_malloc(rect->h * temp_pitch);
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:127
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
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:1114
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:1035
SDL_free
void SDL_free(void *mem)
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:962
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:803
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:1273
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:380
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

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 839 of file SDL_render.c.

References SDL_Texture::access, SDL_Texture::format, SDL_Texture::h, SDL_Rect::h, SDL_Texture::native, 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 (texture->access == SDL_TEXTUREACCESS_STREAMING) {
/* We can lock the texture and copy to it */
void *native_pixels;
int native_pitch;
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 */
void *temp_pixels;
int temp_pitch;
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
temp_pixels = SDL_malloc(rect->h * temp_pitch);
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:127
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:1035
SDL_free
void SDL_free(void *mem)
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:962
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:803
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:1188
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:1273
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:52
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:380
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

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 886 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 (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:839
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:92
renderer
SDL_Renderer * renderer
Definition: testautomation_render.c:27
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:167
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_Texture::renderer
SDL_Renderer * renderer
Definition: SDL_sysrender.h:60
SDL_PIXELFORMAT_YV12
Definition: SDL_pixels.h:263
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:41
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_PIXELFORMAT_IYUV
Definition: SDL_pixels.h:265
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

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

static

Definition at line 1139 of file SDL_render.c.

References SDL_Rect::h, SDL_Renderer::logical_h, SDL_Renderer::logical_w, NULL, SDL_ceil, SDL_fabs, SDL_GetRendererOutputSize(), SDL_RenderSetScale(), SDL_RenderSetViewport(), viewport, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_RendererEventWatch(), and SDL_RenderSetLogicalSize().

{
int w = 1, h = 1;
float want_aspect;
float real_aspect;
float scale;
SDL_Rect viewport;
if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) {
return -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 (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) {
/* 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 {
/* 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:432
SDL_fabs
#define SDL_fabs
Definition: SDL_dynapi_overrides.h:436
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:134
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:1219
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:354
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:1290
NULL
#define NULL
Definition: begin_code.h:143
SDL_Rect::h
int h
Definition: SDL_rect.h:67
viewport
SDL_Rect viewport
Definition: testviewport.c:28
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:133
SDL_Rect::y
int y
Definition: SDL_rect.h:66
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_Rect
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

## Variable Documentation

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 49 of file SDL_render.c.

char renderer_magic

static

Definition at line 75 of file SDL_render.c.

Referenced by SDL_CreateRenderer(), and SDL_CreateSoftwareRenderer().

char texture_magic

static

Definition at line 76 of file SDL_render.c.

Referenced by SDL_CreateTexture().