SDL_render.h File Reference
`#include "SDL_stdinc.h"`
`#include "SDL_rect.h"`
`#include "SDL_video.h"`
`#include "begin_code.h"`
`#include "close_code.h"`
Include dependency graph for SDL_render.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | SDL_RendererInfo
| Information on the capabilities of a render driver or context. More...

## Enumerations

enum | SDL_RendererFlags { SDL_RENDERER_SOFTWARE = 0x00000001, SDL_RENDERER_ACCELERATED = 0x00000002, SDL_RENDERER_PRESENTVSYNC = 0x00000004, SDL_RENDERER_TARGETTEXTURE = 0x00000008 }
| Flags used when creating a rendering context. More...
enum | SDL_TextureAccess { SDL_TEXTUREACCESS_STATIC, SDL_TEXTUREACCESS_STREAMING, SDL_TEXTUREACCESS_TARGET }
| The access pattern allowed for a texture. More...
enum | SDL_TextureModulate { SDL_TEXTUREMODULATE_NONE = 0x00000000, SDL_TEXTUREMODULATE_COLOR = 0x00000001, SDL_TEXTUREMODULATE_ALPHA = 0x00000002 }
| The texture channel modulation used in SDL_RenderCopy(). More...
enum | SDL_RendererFlip { SDL_FLIP_NONE = 0x00000000, SDL_FLIP_HORIZONTAL = 0x00000001, SDL_FLIP_VERTICAL = 0x00000002 }
| Flip constants for SDL_RenderCopyEx. More...

## Functions

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...
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...
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...
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...
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...
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...
void | SDL_UnlockTexture (SDL_Texture *texture)
| Unlock a texture, uploading the changes to video memory, if needed. More...
SDL_bool | SDL_RenderTargetSupported (SDL_Renderer *renderer)
| Determines whether a window supports the use of render targets. More...
int | SDL_SetRenderTarget (SDL_Renderer *renderer, SDL_Texture *texture)
| Set a texture as the current rendering target. More...
SDL_Texture * | SDL_GetRenderTarget (SDL_Renderer *renderer)
| Get the current render target or NULL for the default render target. More...
int | SDL_RenderSetLogicalSize (SDL_Renderer *renderer, int w, int h)
| Set device independent resolution for rendering. More...
void | SDL_RenderGetLogicalSize (SDL_Renderer *renderer, int *w, int *h)
| Get device independent resolution for rendering. More...
int | SDL_RenderSetIntegerScale (SDL_Renderer *renderer, SDL_bool enable)
| Set whether to force integer scales for resolution-independent rendering. More...
SDL_bool | SDL_RenderGetIntegerScale (SDL_Renderer *renderer)
| Get whether integer scales are forced for resolution-independent rendering. More...
int | SDL_RenderSetViewport (SDL_Renderer *renderer, const SDL_Rect *rect)
| Set the drawing area for rendering on the current target. More...
void | SDL_RenderGetViewport (SDL_Renderer *renderer, SDL_Rect *rect)
| Get the drawing area for the current target. More...
int | SDL_RenderSetClipRect (SDL_Renderer *renderer, const SDL_Rect *rect)
| Set the clip rectangle for the current target. More...
void | SDL_RenderGetClipRect (SDL_Renderer *renderer, SDL_Rect *rect)
| Get the clip rectangle for the current target. More...
SDL_bool | SDL_RenderIsClipEnabled (SDL_Renderer *renderer)
| Get whether clipping is enabled on the given renderer. More...
int | SDL_RenderSetScale (SDL_Renderer *renderer, float scaleX, float scaleY)
| Set the drawing scale for rendering on the current target. More...
void | SDL_RenderGetScale (SDL_Renderer *renderer, float *scaleX, float *scaleY)
| Get the drawing scale for the current target. More...
int | SDL_SetRenderDrawColor (SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
| Set the color used for drawing operations (Rect, Line and Clear). More...
int | SDL_GetRenderDrawColor (SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
| Get the color used for drawing operations (Rect, Line and Clear). More...
int | SDL_SetRenderDrawBlendMode (SDL_Renderer *renderer, SDL_BlendMode blendMode)
| Set the blend mode used for drawing operations (Fill and Line). More...
int | SDL_GetRenderDrawBlendMode (SDL_Renderer *renderer, SDL_BlendMode *blendMode)
| Get the blend mode used for drawing operations. More...
int | SDL_RenderClear (SDL_Renderer *renderer)
| Clear the current rendering target with the drawing color. More...
int | SDL_RenderDrawPoint (SDL_Renderer *renderer, int x, int y)
| Draw a point on the current rendering target. More...
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...
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_RenderDrawPointF (SDL_Renderer *renderer, float x, float y)
| Draw a point on the current rendering target. More...
int | SDL_RenderDrawPointsF (SDL_Renderer *renderer, const SDL_FPoint *points, int count)
| Draw multiple points on the current rendering target. More...
int | SDL_RenderDrawLineF (SDL_Renderer *renderer, float x1, float y1, float x2, float y2)
| Draw a line on the current rendering target. More...
int | SDL_RenderDrawLinesF (SDL_Renderer *renderer, const SDL_FPoint *points, int count)
| Draw a series of connected lines on the current rendering target. More...
int | SDL_RenderDrawRectF (SDL_Renderer *renderer, const SDL_FRect *rect)
| Draw a rectangle on the current rendering target. More...
int | SDL_RenderDrawRectsF (SDL_Renderer *renderer, const SDL_FRect *rects, int count)
| Draw some number of rectangles on the current rendering target. More...
int | SDL_RenderFillRectF (SDL_Renderer *renderer, const SDL_FRect *rect)
| Fill a rectangle on the current rendering target with the drawing color. More...
int | SDL_RenderFillRectsF (SDL_Renderer *renderer, const SDL_FRect *rects, int count)
| Fill some number of rectangles on the current rendering target with the drawing color. More...
int | SDL_RenderCopyF (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
| Copy a portion of the texture to the current rendering target. More...
int | SDL_RenderCopyExF (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *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_RenderFlush (SDL_Renderer *renderer)
| Force the rendering context to flush any pending commands to the underlying rendering API. More...
int | SDL_GL_BindTexture (SDL_Texture *texture, float *texw, float *texh)
| Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions. More...
int | SDL_GL_UnbindTexture (SDL_Texture *texture)
| Unbind a texture from the current OpenGL/ES/ES2 context. More...
void * | SDL_RenderGetMetalLayer (SDL_Renderer *renderer)
| Get the CAMetalLayer associated with the given Metal renderer. More...
void * | SDL_RenderGetMetalCommandEncoder (SDL_Renderer *renderer)
| Get the Metal command encoder for the current frame. More...

## Detailed Description

Header file for SDL 2D rendering functions.

This API supports the following features:

- single pixel points
- single pixel lines
- filled rectangles
- texture images

The primitives may be drawn in opaque, blended, or additive modes.

The texture images may be drawn in opaque, blended, or additive modes. They can have an additional color tint or alpha modulation applied to them, and may also be stretched with linear interpolation.

This API is designed to accelerate simple 2D operations. You may want more functionality such as polygons and particle effects and in that case you should use SDL's OpenGL/Direct3D support or one of the many good 3D engines.

These functions must be called from the main thread. See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995

Definition in file SDL_render.h.

## Enumeration Type Documentation

## SDL_RendererFlags

enum SDL_RendererFlags

Flags used when creating a rendering context.

Enumerator
SDL_RENDERER_SOFTWARE | The renderer is a software fallback
SDL_RENDERER_ACCELERATED | The renderer uses hardware acceleration
SDL_RENDERER_PRESENTVSYNC | Present is synchronized with the refresh rate
SDL_RENDERER_TARGETTEXTURE | The renderer supports rendering to texture

Definition at line 64 of file SDL_render.h.

{
SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */
SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware
acceleration */
SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized
with the refresh rate */
SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports
rendering to texture */
} SDL_RendererFlags;

## SDL_RendererFlip

enum const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) g int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool return int int return SDL_AudioDeviceID const void Uint32 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32 return const char SDL_bool return int return SDL_Joystick return SDL_Joystick return SDL_GameController return return int return int return int return SDL_RWops size_t int return SDL_BlendFactor SDL_BlendFactor SDL_BlendOperation SDL_BlendFactor SDL_BlendFactor SDL_BlendOperation return const char return SDL_Window VkInstance VkSurfaceKHR return SDL_malloc_func SDL_calloc_func SDL_realloc_func SDL_free_func return SDL_AudioStream const void int return SDL_AudioStream SDL_AudioStream float return float return float return float return float return float int return float float return return SDL_Renderer return double return int return double return const wchar_t return SDL_Joystick Uint16 Uint16 Uint32 return int return int return int return SDL_Sensor return SDL_Sensor return SDL_Sensor float int return int return SDL_ThreadFunction const char const size_t void return SDL_Joystick return SDL_Renderer return SDL_Renderer const SDL_FPoint int return SDL_Renderer const SDL_FPoint int return SDL_Renderer const SDL_FRect int return SDL_Renderer const SDL_FRect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_FRect const double const SDL_FPoint const SDL_RendererFlip

Flip constants for SDL_RenderCopyEx.

Enumerator
SDL_FLIP_NONE | Do not flip
SDL_FLIP_HORIZONTAL | flip horizontally
SDL_FLIP_VERTICAL | flip vertically

Definition at line 111 of file SDL_render.h.

{
SDL_FLIP_NONE = 0x00000000, /**< Do not flip */
SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */
SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */
} SDL_RendererFlip;

## SDL_TextureAccess

enum SDL_TextureAccess

The access pattern allowed for a texture.

Enumerator
SDL_TEXTUREACCESS_STATIC | Changes rarely, not lockable
SDL_TEXTUREACCESS_STREAMING | Changes frequently, lockable
SDL_TEXTUREACCESS_TARGET | Texture can be used as a render target

Definition at line 91 of file SDL_render.h.

{
SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
} SDL_TextureAccess;

## SDL_TextureModulate

enum SDL_TextureModulate

The texture channel modulation used in SDL_RenderCopy().

Enumerator
SDL_TEXTUREMODULATE_NONE | No modulation
SDL_TEXTUREMODULATE_COLOR | srcC = srcC * color
SDL_TEXTUREMODULATE_ALPHA | srcA = srcA * alpha

Definition at line 101 of file SDL_render.h.

{
SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */
SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */
SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */
} SDL_TextureModulate;

## Function Documentation

## SDL_CreateRenderer()

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

Create a 2D rendering context for a window.

Parameters

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

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

See also
  SDL_CreateSoftwareRenderer()
  SDL_GetRendererInfo()
  SDL_DestroyRenderer()

Definition at line 835 of file SDL_render.c.

{
#if !SDL_RENDER_DISABLED
SDL_Renderer *renderer = NULL;
int n = SDL_GetNumRenderDrivers();
SDL_bool batching = SDL_TRUE;
const char *hint;
#if defined(__ANDROID__)
Android_ActivityMutex_Lock_Running();
#endif
if (!window) {
SDL_SetError("Invalid window");
goto error;
}
if (SDL_GetRenderer(window)) {
SDL_SetError("Renderer already associated with window");
goto error;
}
if (SDL_GetHint(SDL_HINT_RENDER_VSYNC)) {
if (SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)) {
flags |= SDL_RENDERER_PRESENTVSYNC;
} else {
flags &= ~SDL_RENDERER_PRESENTVSYNC;
}
}
if (index < 0) {
hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
if (hint) {
for (index = 0; index < n; ++index) {
const SDL_RenderDriver *driver = render_drivers[index];
if (SDL_strcasecmp(hint, driver->info.name) == 0) {
/* Create a new renderer instance */
renderer = driver->CreateRenderer(window, flags);
if (renderer) {
batching = SDL_FALSE;
}
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");
goto error;
}
} else {
if (index >= SDL_GetNumRenderDrivers()) {
SDL_SetError("index must be -1 or in the range of 0 - %d",
SDL_GetNumRenderDrivers() - 1);
goto error;
}
/* Create a new renderer instance */
renderer = render_drivers[index]->CreateRenderer(window, flags);
batching = SDL_FALSE;
}
if (!renderer) {
goto error;
}
VerifyDrawQueueFunctions(renderer);
/* let app/user override batching decisions. */
if (renderer->always_batch) {
batching = SDL_TRUE;
} else if (SDL_GetHint(SDL_HINT_RENDER_BATCHING)) {
batching = SDL_GetHintBoolean(SDL_HINT_RENDER_BATCHING, SDL_TRUE);
}
renderer->batching = batching;
renderer->magic = &renderer_magic;
renderer->window = window;
renderer->target_mutex = SDL_CreateMutex();
renderer->scale.x = 1.0f;
renderer->scale.y = 1.0f;
renderer->dpi_scale.x = 1.0f;
renderer->dpi_scale.y = 1.0f;
/* new textures start at zero, so we start at 1 so first render doesn't flush by accident. */
renderer->render_command_generation = 1;
if (window && renderer->GetOutputSize) {
int window_w, window_h;
int output_w, output_h;
if (renderer->GetOutputSize(renderer, &output_w, &output_h) == 0) {
SDL_GetWindowSize(renderer->window, &window_w, &window_h);
renderer->dpi_scale.x = (float)window_w / output_w;
renderer->dpi_scale.y = (float)window_h / output_h;
}
}
if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN|SDL_WINDOW_MINIMIZED)) {
renderer->hidden = SDL_TRUE;
} else {
renderer->hidden = SDL_FALSE;
}
SDL_SetWindowData(window, SDL_WINDOWRENDERDATA, renderer);
SDL_RenderSetViewport(renderer, NULL);
SDL_AddEventWatch(SDL_RendererEventWatch, renderer);
SDL_LogInfo(SDL_LOG_CATEGORY_RENDER,
"Created renderer: %s", renderer->info.name);
#if defined(__ANDROID__)
Android_ActivityMutex_Unlock();
#endif
return renderer;
error:
#if defined(__ANDROID__)
Android_ActivityMutex_Unlock();
#endif
return NULL;
#else
SDL_SetError("SDL not built with rendering support");
return NULL;
#endif
}

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

Referenced by SDL_CreateWindowAndRenderer().

## SDL_CreateSoftwareRenderer()

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

Create a 2D software rendering context for a surface.

Parameters

  surface | The surface where rendering is done.

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

See also
  SDL_CreateRenderer()
  SDL_DestroyRenderer()

Definition at line 980 of file SDL_render.c.

{
#if !SDL_RENDER_DISABLED
SDL_Renderer *renderer;
renderer = SW_CreateRendererForSurface(surface);
if (renderer) {
VerifyDrawQueueFunctions(renderer);
renderer->magic = &renderer_magic;
renderer->target_mutex = SDL_CreateMutex();
renderer->scale.x = 1.0f;
renderer->scale.y = 1.0f;
/* new textures start at zero, so we start at 1 so first render doesn't flush by accident. */
renderer->render_command_generation = 1;
SDL_RenderSetViewport(renderer, NULL);
}
return renderer;
#else
SDL_SetError("SDL not built with rendering support");
return NULL;
#endif /* !SDL_RENDER_DISABLED */
}

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

## SDL_CreateTexture()

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

Create a texture for a rendering context.

Parameters

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

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

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

See also
  SDL_QueryTexture()
  SDL_UpdateTexture()
  SDL_DestroyTexture()

Definition at line 1112 of file SDL_render.c.

{
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->scaleMode = SDL_GetScaleMode();
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;
}

References CHECK_RENDERER_MAGIC, SDL_Renderer::CreateTexture, GetClosestSupportedFormat(), SDL_Renderer::info, IsSupportedFormat(), SDL_RendererInfo::max_texture_height, SDL_RendererInfo::max_texture_width, NULL, SDL_Texture::prev, renderer, SDL_BYTESPERPIXEL, SDL_calloc, SDL_DestroyTexture(), SDL_GetScaleMode(), SDL_ISPIXELFORMAT_FOURCC, SDL_ISPIXELFORMAT_INDEXED, SDL_OutOfMemory, SDL_SetError, SDL_SW_CreateYUVTexture(), SDL_TEXTUREACCESS_STREAMING, SDL_RendererInfo::texture_formats, texture_magic, and SDL_Renderer::textures.

Referenced by SDL_CreateTextureFromSurface().

## SDL_CreateTextureFromSurface()

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

Create a texture from an existing surface.

Parameters

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

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

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

See also
  SDL_QueryTexture()
  SDL_DestroyTexture()

Definition at line 1207 of file SDL_render.c.

{
const SDL_PixelFormat *fmt;
SDL_bool needAlpha;
SDL_bool direct_update;
int i;
Uint32 format = SDL_PIXELFORMAT_UNKNOWN;
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_HasColorKey(surface)) {
needAlpha = SDL_TRUE;
} else {
needAlpha = SDL_FALSE;
}
/* If Palette contains alpha values, promotes to alpha format */
if (fmt->palette) {
for (i = 0; i < fmt->palette->ncolors; i++) {
Uint8 alpha_value = fmt->palette->colors[i].a;
if (alpha_value != 0 || alpha_value != SDL_ALPHA_OPAQUE) {
needAlpha = SDL_TRUE;
break;
}
}
}
/* Try to have the best pixel format for the texture */
/* No alpha, but a colorkey => promote to alpha */
if (!fmt->Amask && SDL_HasColorKey(surface)) {
if (fmt->format == SDL_PIXELFORMAT_RGB888) {
for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) {
if (renderer->info.texture_formats[i] == SDL_PIXELFORMAT_ARGB8888) {
format = SDL_PIXELFORMAT_ARGB8888;
break;
}
}
} else if (fmt->format == SDL_PIXELFORMAT_BGR888) {
for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) {
if (renderer->info.texture_formats[i] == SDL_PIXELFORMAT_ABGR8888) {
format = SDL_PIXELFORMAT_ABGR8888;
break;
}
}
}
} else {
/* Exact match would be fine */
for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) {
if (renderer->info.texture_formats[i] == fmt->format) {
format = fmt->format;
break;
}
}
}
/* Fallback, choose a valid pixel format */
if (format == SDL_PIXELFORMAT_UNKNOWN) {
format = renderer->info.texture_formats[0];
for (i = 0; i < (int)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 (surface->format->Amask && SDL_HasColorKey(surface)) {
/* Surface and Renderer formats are identicals.
* Intermediate conversion is needed to convert color key to alpha (SDL_ConvertColorkeyToAlpha()). */
direct_update = SDL_FALSE;
} else {
/* Update Texture directly */
direct_update = SDL_TRUE;
}
} else {
/* Surface and Renderer formats are differents, it needs an intermediate conversion. */
direct_update = SDL_FALSE;
}
if (direct_update) {
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_HasColorKey(surface)) {
/* 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;
}

References SDL_Color::a, SDL_PixelFormat::Amask, blendMode, CHECK_RENDERER_MAGIC, SDL_Palette::colors, SDL_PixelFormat::format, i, SDL_Renderer::info, SDL_Palette::ncolors, NULL, SDL_RendererInfo::num_texture_formats, SDL_PixelFormat::palette, SDL_Surface::pitch, SDL_Surface::pixels, renderer, SDL_AllocFormat, SDL_ALPHA_OPAQUE, SDL_BLENDMODE_BLEND, SDL_ConvertSurface, SDL_CreateTexture(), SDL_DestroyTexture(), SDL_FALSE, SDL_FreeFormat, SDL_FreeSurface, SDL_GetSurfaceAlphaMod, SDL_GetSurfaceBlendMode, SDL_GetSurfaceColorMod, SDL_HasColorKey, SDL_ISPIXELFORMAT_ALPHA, SDL_ISPIXELFORMAT_FOURCC, SDL_LockSurface, SDL_MUSTLOCK, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_UNKNOWN, SDL_SetError, SDL_SetTextureAlphaMod(), SDL_SetTextureBlendMode(), SDL_SetTextureColorMod(), SDL_TEXTUREACCESS_STATIC, SDL_TRUE, SDL_UnlockSurface, SDL_UpdateTexture(), and SDL_RendererInfo::texture_formats.

## SDL_CreateWindowAndRenderer()

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

Create a window and default renderer.

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 801 of file SDL_render.c.

{
*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;
}

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

## SDL_DestroyRenderer()

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

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

See also
  SDL_CreateRenderer()

Definition at line 3177 of file SDL_render.c.

{
SDL_RenderCommand *cmd;
SDL_AllocVertGap *gap;
SDL_AllocVertGap *nextgap;
CHECK_RENDERER_MAGIC(renderer, );
SDL_DelEventWatch(SDL_RendererEventWatch, renderer);
if (renderer->render_commands_tail != NULL) {
renderer->render_commands_tail->next = renderer->render_commands_pool;
cmd = renderer->render_commands;
} else {
cmd = renderer->render_commands_pool;
}
renderer->render_commands_pool = NULL;
renderer->render_commands_tail = NULL;
renderer->render_commands = NULL;
while (cmd != NULL) {
SDL_RenderCommand *next = cmd->next;
SDL_free(cmd);
cmd = next;
}
SDL_free(renderer->vertex_data);
for (gap = renderer->vertex_data_gaps.next; gap; gap = nextgap) {
nextgap = gap->next;
SDL_free(gap);
}
for (gap = renderer->vertex_data_gaps_pool; gap; gap = nextgap) {
nextgap = gap->next;
SDL_free(gap);
}
/* Free existing textures for this renderer */
while (renderer->textures) {
SDL_Texture *tex = renderer->textures; (void) tex;
SDL_DestroyTexture(renderer->textures);
SDL_assert(tex != renderer->textures); /* satisfy static analysis. */
}
if (renderer->window) {
SDL_SetWindowData(renderer->window, SDL_WINDOWRENDERDATA, NULL);
}
/* It's no longer magical... */
renderer->magic = NULL;
/* Free the target mutex */
SDL_DestroyMutex(renderer->target_mutex);
renderer->target_mutex = NULL;
/* Free the renderer instance */
renderer->DestroyRenderer(renderer);
}

References CHECK_RENDERER_MAGIC, SDL_Renderer::DestroyRenderer, SDL_Renderer::magic, SDL_RenderCommand::next, SDL_AllocVertGap::next, NULL, SDL_Renderer::render_commands, SDL_Renderer::render_commands_pool, SDL_Renderer::render_commands_tail, renderer, SDL_assert, SDL_DelEventWatch, SDL_DestroyMutex, SDL_DestroyTexture(), SDL_free, SDL_RendererEventWatch(), SDL_SetWindowData, SDL_WINDOWRENDERDATA, SDL_Renderer::target_mutex, SDL_Renderer::textures, SDL_Renderer::vertex_data, SDL_Renderer::vertex_data_gaps, SDL_Renderer::vertex_data_gaps_pool, void, and SDL_Renderer::window.

## SDL_DestroyTexture()

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

Destroy the specified texture.

See also
  SDL_CreateTexture()
  SDL_CreateTextureFromSurface()

Definition at line 3140 of file SDL_render.c.

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, );
renderer = texture->renderer;
if (texture == renderer->target) {
SDL_SetRenderTarget(renderer, NULL); /* implies command queue flush */
} else {
FlushRenderCommandsIfTextureNeeded(texture);
}
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);
}

References CHECK_TEXTURE_MAGIC, SDL_Renderer::DestroyTexture, FlushRenderCommandsIfTextureNeeded(), SDL_Texture::next, NULL, renderer, SDL_free, SDL_SetRenderTarget(), SDL_SW_DestroyYUVTexture(), SDL_Renderer::target, and SDL_Renderer::textures.

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

## SDL_GetNumRenderDrivers()

int SDL_GetNumRenderDrivers | ( | void |  | ) |

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

A render driver is a set of code that handles rendering and texture management on a particular display. Normally there is only one, but some drivers may have several available with different capabilities.

See also
  SDL_GetRenderDriverInfo()
  SDL_CreateRenderer()

Definition at line 329 of file SDL_dynapi_procs.h.

References render_drivers, and SDL_arraysize.

Referenced by SDL_CreateRenderer(), and SDL_GetRenderDriverInfo().

## SDL_GetRenderDrawBlendMode()

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

Get the blend mode used for drawing operations.

Parameters

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

Returns
  0 on success, or -1 on error

See also
  SDL_SetRenderDrawBlendMode()

Definition at line 2223 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, -1);
*blendMode = renderer->blendMode;
return 0;
}

References blendMode, SDL_Renderer::blendMode, CHECK_RENDERER_MAGIC, and renderer.

## SDL_GetRenderDrawColor()

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

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

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2190 of file SDL_render.c.

{
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;
}

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

## SDL_GetRenderDriverInfo()

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

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

Parameters

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

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

See also
  SDL_CreateRenderer()

Definition at line 637 of file SDL_render.c.

{
#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
}

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

## SDL_GetRenderer()

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

Get the renderer associated with a window.

Definition at line 1007 of file SDL_render.c.

{
return (SDL_Renderer *)SDL_GetWindowData(window, SDL_WINDOWRENDERDATA);
}

References SDL_GetWindowData, and SDL_WINDOWRENDERDATA.

Referenced by SDL_CreateRenderer().

## SDL_GetRendererInfo()

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

Get information about a rendering context.

Definition at line 1013 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, -1);
*info = renderer->info;
return 0;
}

References CHECK_RENDERER_MAGIC, SDL_Renderer::info, and renderer.

## SDL_GetRendererOutputSize()

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

Get the output size in pixels of a rendering context.

Definition at line 1022 of file SDL_render.c.

{
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");
}
}

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

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

## SDL_GetRenderTarget()

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

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

Returns
  The current render target

See also
  SDL_SetRenderTarget()

Definition at line 1912 of file SDL_render.c.

{
return renderer->target;
}

References renderer, and SDL_Renderer::target.

Referenced by SDL_RendererEventWatch().

## SDL_GetTextureAlphaMod()

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

Get the additional alpha value used in render copy operations.

Parameters

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

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

See also
  SDL_SetTextureAlphaMod()

Definition at line 1428 of file SDL_render.c.

{
CHECK_TEXTURE_MAGIC(texture, -1);
if (alpha) {
*alpha = texture->a;
}
return 0;
}

References CHECK_TEXTURE_MAGIC.

## SDL_GetTextureBlendMode()

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

Get the blend mode used for texture copy operations.

Parameters

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

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

See also
  SDL_SetTextureBlendMode()

Definition at line 1457 of file SDL_render.c.

{
CHECK_TEXTURE_MAGIC(texture, -1);
if (blendMode) {
*blendMode = texture->blendMode;
}
return 0;
}

References blendMode, and CHECK_TEXTURE_MAGIC.

## SDL_GetTextureColorMod()

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

Get the additional color value used in render copy operations.

Parameters

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

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

See also
  SDL_SetTextureColorMod()

Definition at line 1393 of file SDL_render.c.

{
CHECK_TEXTURE_MAGIC(texture, -1);
if (r) {
*r = texture->r;
}
if (g) {
*g = texture->g;
}
if (b) {
*b = texture->b;
}
return 0;
}

References CHECK_TEXTURE_MAGIC.

## SDL_GL_BindTexture()

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

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

Parameters

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

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

Definition at line 3238 of file SDL_render.c.

{
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) {
FlushRenderCommandsIfTextureNeeded(texture); /* in case the app is going to mess with it. */
return renderer->GL_BindTexture(renderer, texture, texw, texh);
} else {
return SDL_Unsupported();
}
}

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Renderer::GL_BindTexture, renderer, and SDL_Unsupported.

## SDL_GL_UnbindTexture()

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

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

Parameters

  texture | The SDL texture to unbind

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

Definition at line 3254 of file SDL_render.c.

{
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) {
FlushRenderCommandsIfTextureNeeded(texture); /* in case the app messed with it. */
return renderer->GL_UnbindTexture(renderer, texture);
}
return SDL_Unsupported();
}

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Renderer::GL_UnbindTexture, renderer, and SDL_Unsupported.

## SDL_LockTexture()

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

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

Parameters

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

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

See also
  SDL_UnlockTexture()

Definition at line 1727 of file SDL_render.c.

{
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) {
if (FlushRenderCommandsIfTextureNeeded(texture) < 0) {
return -1;
}
return SDL_LockTextureYUV(texture, rect, pixels, pitch);
} else if (texture->native) {
/* Calls a real SDL_LockTexture/SDL_UnlockTexture on unlock, flushing then. */
return SDL_LockTextureNative(texture, rect, pixels, pitch);
} else {
SDL_Renderer *renderer = texture->renderer;
if (FlushRenderCommandsIfTextureNeeded(texture) < 0) {
return -1;
}
return renderer->LockTexture(renderer, texture, rect, pixels, pitch);
}
}

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Rect::h, SDL_Renderer::LockTexture, rect, renderer, SDL_LockTextureNative(), SDL_LockTextureYUV(), SDL_SetError, SDL_TEXTUREACCESS_STREAMING, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

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

## SDL_QueryTexture()

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

Query the attributes of a texture.

Parameters

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

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

Definition at line 1353 of file SDL_render.c.

{
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;
}

References CHECK_TEXTURE_MAGIC.

Referenced by SDL_GetRendererOutputSize().

## SDL_RenderClear()

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

Clear the current rendering target with the drawing color.

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

Returns
  0 on success, or -1 on error

Definition at line 2232 of file SDL_render.c.

{
int retval;
CHECK_RENDERER_MAGIC(renderer, -1);
retval = QueueCmdClear(renderer);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), QueueCmdClear(), renderer, and retval.

## SDL_RenderCopy()

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

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

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2908 of file SDL_render.c.

{
SDL_FRect dstfrect;
SDL_FRect *pdstfrect = NULL;
if (dstrect) {
dstfrect.x = (float) dstrect->x;
dstfrect.y = (float) dstrect->y;
dstfrect.w = (float) dstrect->w;
dstfrect.h = (float) dstrect->h;
pdstfrect = &dstfrect;
}
return SDL_RenderCopyF(renderer, texture, srcrect, pdstfrect);
}

References SDL_Rect::h, SDL_FRect::h, NULL, renderer, SDL_RenderCopyF(), SDL_Rect::w, SDL_FRect::w, SDL_Rect::x, SDL_FRect::x, SDL_Rect::y, and SDL_FRect::y.

## SDL_RenderCopyEx()

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

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

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2983 of file SDL_render.c.

{
SDL_FRect dstfrect;
SDL_FRect *pdstfrect = NULL;
SDL_FPoint fcenter;
SDL_FPoint *pfcenter = NULL;
if (dstrect) {
dstfrect.x = (float) dstrect->x;
dstfrect.y = (float) dstrect->y;
dstfrect.w = (float) dstrect->w;
dstfrect.h = (float) dstrect->h;
pdstfrect = &dstfrect;
}
if (center) {
fcenter.x = (float) center->x;
fcenter.y = (float) center->y;
pfcenter = &fcenter;
}
return SDL_RenderCopyExF(renderer, texture, srcrect, pdstfrect, angle, pfcenter, flip);
}

References SDL_Rect::h, SDL_FRect::h, NULL, renderer, SDL_RenderCopyExF(), SDL_Rect::w, SDL_FRect::w, SDL_Point::x, SDL_FPoint::x, SDL_Rect::x, SDL_FRect::x, SDL_Point::y, SDL_FPoint::y, SDL_Rect::y, and SDL_FRect::y.

## SDL_RenderCopyExF()

int SDL_RenderCopyExF | ( | SDL_Renderer * | renderer,
|  | SDL_Texture * | texture,
|  | const SDL_Rect * | srcrect,
|  | const SDL_FRect * | dstrect,
|  | const double | angle,
|  | const SDL_FPoint * | center,
|  | const SDL_RendererFlip | flip
| ) |  |

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

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 3010 of file SDL_render.c.

{
SDL_Rect real_srcrect;
SDL_FRect real_dstrect;
SDL_FPoint real_center;
int retval;
if (flip == SDL_FLIP_NONE && (int)(angle/360) == angle/360) { /* fast path when we don't need rotation or flipping */
return SDL_RenderCopyF(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->QueueCopyEx) {
return SDL_SetError("Renderer does not support RenderCopyEx");
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
real_srcrect.x = 0;
real_srcrect.y = 0;
real_srcrect.w = texture->w;
real_srcrect.h = texture->h;
if (srcrect) {
if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
return 0;
}
}
/* We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we? */
if (dstrect) {
real_dstrect = *dstrect;
} else {
SDL_Rect r;
SDL_zero(r);
SDL_RenderGetViewport(renderer, &r);
real_dstrect.x = 0.0f;
real_dstrect.y = 0.0f;
real_dstrect.w = (float) r.w;
real_dstrect.h = (float) r.h;
}
if (texture->native) {
texture = texture->native;
}
if (center) {
real_center = *center;
} else {
real_center.x = real_dstrect.w / 2.0f;
real_center.y = real_dstrect.h / 2.0f;
}
real_dstrect.x *= renderer->scale.x;
real_dstrect.y *= renderer->scale.y;
real_dstrect.w *= renderer->scale.x;
real_dstrect.h *= renderer->scale.y;
real_center.x *= renderer->scale.x;
real_center.y *= renderer->scale.y;
texture->last_command_generation = renderer->render_command_generation;
retval = QueueCmdCopyEx(renderer, texture, &real_srcrect, &real_dstrect, angle, &real_center, flip);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Rect::h, SDL_FRect::h, SDL_Renderer::hidden, QueueCmdCopyEx(), SDL_Renderer::QueueCopyEx, SDL_Renderer::render_command_generation, renderer, retval, SDL_Renderer::scale, SDL_FLIP_NONE, SDL_IntersectRect, SDL_RenderCopyF(), SDL_RenderGetViewport(), SDL_SetError, SDL_zero, SDL_Rect::w, SDL_FRect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FRect::x, SDL_FPoint::y, SDL_Rect::y, and SDL_FRect::y.

Referenced by SDL_RenderCopyEx().

## SDL_RenderCopyF()

int SDL_RenderCopyF | ( | SDL_Renderer * | renderer,
|  | SDL_Texture * | texture,
|  | const SDL_Rect * | srcrect,
|  | const SDL_FRect * | 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 2924 of file SDL_render.c.

{
SDL_Rect real_srcrect;
SDL_FRect real_dstrect;
SDL_Rect r;
int retval;
CHECK_RENDERER_MAGIC(renderer, -1);
CHECK_TEXTURE_MAGIC(texture, -1);
if (renderer != texture->renderer) {
return SDL_SetError("Texture was not created with this renderer");
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
real_srcrect.x = 0;
real_srcrect.y = 0;
real_srcrect.w = texture->w;
real_srcrect.h = texture->h;
if (srcrect) {
if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
return 0;
}
}
SDL_zero(r);
SDL_RenderGetViewport(renderer, &r);
real_dstrect.x = 0.0f;
real_dstrect.y = 0.0f;
real_dstrect.w = (float) r.w;
real_dstrect.h = (float) r.h;
if (dstrect) {
if (!SDL_HasIntersectionF(dstrect, &real_dstrect)) {
return 0;
}
real_dstrect = *dstrect;
}
if (texture->native) {
texture = texture->native;
}
real_dstrect.x *= renderer->scale.x;
real_dstrect.y *= renderer->scale.y;
real_dstrect.w *= renderer->scale.x;
real_dstrect.h *= renderer->scale.y;
texture->last_command_generation = renderer->render_command_generation;
retval = QueueCmdCopy(renderer, texture, &real_srcrect, &real_dstrect);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Rect::h, SDL_FRect::h, SDL_Renderer::hidden, QueueCmdCopy(), SDL_Renderer::render_command_generation, renderer, retval, SDL_Renderer::scale, SDL_HasIntersectionF(), SDL_IntersectRect, SDL_RenderGetViewport(), SDL_SetError, SDL_zero, SDL_Rect::w, SDL_FRect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FRect::x, SDL_FPoint::y, SDL_Rect::y, and SDL_FRect::y.

Referenced by SDL_RenderCopy(), and SDL_RenderCopyExF().

## SDL_RenderDrawLine()

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

Draw a line on the current rendering target.

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2403 of file SDL_render.c.

{
SDL_FPoint points[2];
points[0].x = (float) x1;
points[0].y = (float) y1;
points[1].x = (float) x2;
points[1].y = (float) y2;
return SDL_RenderDrawLinesF(renderer, points, 2);
}

References renderer, SDL_RenderDrawLinesF(), and SDL_FPoint::x.

## SDL_RenderDrawLineF()

int SDL_RenderDrawLineF | ( | SDL_Renderer * | renderer,
|  | float | x1,
|  | float | y1,
|  | float | x2,
|  | float | 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 2414 of file SDL_render.c.

{
SDL_FPoint points[2];
points[0].x = x1;
points[0].y = y1;
points[1].x = x2;
points[1].y = y2;
return SDL_RenderDrawLinesF(renderer, points, 2);
}

References renderer, SDL_RenderDrawLinesF(), and SDL_FPoint::x.

## SDL_RenderDrawLines()

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

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

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2535 of file SDL_render.c.

{
SDL_FPoint *fpoints;
int i;
int retval;
SDL_bool isstack;
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_small_alloc(SDL_FPoint, count, &isstack);
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;
}
retval = QueueCmdDrawLines(renderer, fpoints, count);
SDL_small_free(fpoints, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Renderer::hidden, i, QueueCmdDrawLines(), RenderDrawLinesWithRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FPoint::x, and SDL_FPoint::y.

## SDL_RenderDrawLinesF()

int SDL_RenderDrawLinesF | ( | SDL_Renderer * | renderer,
|  | const SDL_FPoint * | 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 2578 of file SDL_render.c.

{
SDL_FPoint *fpoints;
int i;
int retval;
SDL_bool isstack;
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 RenderDrawLinesWithRectsF(renderer, points, count);
}
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
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;
}
retval = QueueCmdDrawLines(renderer, fpoints, count);
SDL_small_free(fpoints, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Renderer::hidden, i, QueueCmdDrawLines(), RenderDrawLinesWithRectsF(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FPoint::x, and SDL_FPoint::y.

Referenced by SDL_RenderDrawLine(), SDL_RenderDrawLineF(), and SDL_RenderDrawRectF().

## SDL_RenderDrawPoint()

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

Draw a point on the current rendering target.

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2245 of file SDL_render.c.

{
SDL_FPoint fpoint;
fpoint.x = (float) x;
fpoint.y = (float) y;
return SDL_RenderDrawPointsF(renderer, &fpoint, 1);
}

References renderer, SDL_RenderDrawPointsF(), SDL_FPoint::x, and SDL_FPoint::y.

## SDL_RenderDrawPointF()

int SDL_RenderDrawPointF | ( | SDL_Renderer * | renderer,
|  | float | x,
|  | float | 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 2254 of file SDL_render.c.

{
SDL_FPoint fpoint;
fpoint.x = x;
fpoint.y = y;
return SDL_RenderDrawPointsF(renderer, &fpoint, 1);
}

References renderer, SDL_RenderDrawPointsF(), SDL_FPoint::x, and SDL_FPoint::y.

## SDL_RenderDrawPoints()

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

Draw multiple points on the current rendering target.

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2290 of file SDL_render.c.

{
SDL_FPoint *fpoints;
int i;
int retval;
SDL_bool isstack;
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_small_alloc(SDL_FPoint, count, &isstack);
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;
}
retval = QueueCmdDrawPoints(renderer, fpoints, count);
SDL_small_free(fpoints, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Renderer::hidden, i, QueueCmdDrawPoints(), RenderDrawPointsWithRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FPoint::x, and SDL_FPoint::y.

## SDL_RenderDrawPointsF()

int SDL_RenderDrawPointsF | ( | SDL_Renderer * | renderer,
|  | const SDL_FPoint * | 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 2360 of file SDL_render.c.

{
SDL_FPoint *fpoints;
int i;
int retval;
SDL_bool isstack;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!points) {
return SDL_SetError("SDL_RenderDrawFPoints(): 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 RenderDrawPointsWithRectsF(renderer, points, count);
}
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
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;
}
retval = QueueCmdDrawPoints(renderer, fpoints, count);
SDL_small_free(fpoints, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Renderer::hidden, i, QueueCmdDrawPoints(), RenderDrawPointsWithRectsF(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FPoint::x, and SDL_FPoint::y.

Referenced by SDL_RenderDrawPoint(), and SDL_RenderDrawPointF().

## SDL_RenderDrawRect()

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

Draw a rectangle on the current rendering target.

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2621 of file SDL_render.c.

{
SDL_FRect frect;
SDL_FRect *prect = NULL;
if (rect) {
frect.x = (float) rect->x;
frect.y = (float) rect->y;
frect.w = (float) rect->w;
frect.h = (float) rect->h;
prect = &frect;
}
return SDL_RenderDrawRectF(renderer, prect);
}

References SDL_Rect::h, SDL_FRect::h, NULL, rect, renderer, SDL_RenderDrawRectF(), SDL_Rect::w, SDL_FRect::w, SDL_Rect::x, SDL_FRect::x, SDL_Rect::y, and SDL_FRect::y.

Referenced by SDL_RenderDrawRects().

## SDL_RenderDrawRectF()

int SDL_RenderDrawRectF | ( | SDL_Renderer * | renderer,
|  | const SDL_FRect * | 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 2638 of file SDL_render.c.

{
SDL_FRect frect;
SDL_FPoint points[5];
CHECK_RENDERER_MAGIC(renderer, -1);
/* If 'rect' == NULL, then outline the whole surface */
if (!rect) {
SDL_Rect r;
SDL_RenderGetViewport(renderer, &r);
frect.x = 0.0f;
frect.y = 0.0f;
frect.w = (float) r.w;
frect.h = (float) r.h;
rect = &frect;
}
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_RenderDrawLinesF(renderer, points, 5);
}

References CHECK_RENDERER_MAGIC, SDL_Rect::h, SDL_FRect::h, rect, renderer, SDL_RenderDrawLinesF(), SDL_RenderGetViewport(), SDL_Rect::w, SDL_FRect::w, SDL_Rect::x, SDL_FRect::x, SDL_Rect::y, and SDL_FRect::y.

Referenced by SDL_RenderDrawRect(), and SDL_RenderDrawRectsF().

## SDL_RenderDrawRects()

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

Draw some number of rectangles on the current rendering target.

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2670 of file SDL_render.c.

{
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;
}

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

## SDL_RenderDrawRectsF()

int SDL_RenderDrawRectsF | ( | SDL_Renderer * | renderer,
|  | const SDL_FRect * | 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 2698 of file SDL_render.c.

{
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_RenderDrawRectF(renderer, &rects[i]) < 0) {
return -1;
}
}
return 0;
}

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

## SDL_RenderFillRect()

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

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

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2726 of file SDL_render.c.

{
SDL_FRect frect;
CHECK_RENDERER_MAGIC(renderer, -1);
/* If 'rect' == NULL, then outline the whole surface */
if (rect) {
frect.x = (float) rect->x;
frect.y = (float) rect->y;
frect.w = (float) rect->w;
frect.h = (float) rect->h;
} else {
SDL_Rect r;
SDL_zero(r);
SDL_RenderGetViewport(renderer, &r);
frect.x = 0.0f;
frect.y = 0.0f;
frect.w = (float) r.w;
frect.h = (float) r.h;
}
return SDL_RenderFillRectsF(renderer, &frect, 1);
}

References CHECK_RENDERER_MAGIC, SDL_Rect::h, SDL_FRect::h, rect, renderer, SDL_RenderFillRectsF(), SDL_RenderGetViewport(), SDL_zero, SDL_Rect::w, SDL_FRect::w, SDL_Rect::x, SDL_FRect::x, SDL_Rect::y, and SDL_FRect::y.

## SDL_RenderFillRectF()

int SDL_RenderFillRectF | ( | SDL_Renderer * | renderer,
|  | const SDL_FRect * | 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 2751 of file SDL_render.c.

{
SDL_FRect frect;
CHECK_RENDERER_MAGIC(renderer, -1);
/* If 'rect' == NULL, then outline the whole surface */
if (!rect) {
SDL_Rect r;
SDL_zero(r);
SDL_RenderGetViewport(renderer, &r);
frect.x = 0.0f;
frect.y = 0.0f;
frect.w = (float) r.w;
frect.h = (float) r.h;
rect = &frect;
}
return SDL_RenderFillRectsF(renderer, rect, 1);
}

References CHECK_RENDERER_MAGIC, SDL_FRect::h, rect, renderer, SDL_RenderFillRectsF(), SDL_RenderGetViewport(), SDL_zero, SDL_FRect::w, SDL_FRect::x, and SDL_FRect::y.

## SDL_RenderFillRects()

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

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

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2772 of file SDL_render.c.

{
SDL_FRect *frects;
int i;
int retval;
SDL_bool isstack;
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_small_alloc(SDL_FRect, count, &isstack);
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;
}
retval = QueueCmdFillRects(renderer, frects, count);
SDL_small_free(frects, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_FRect::h, SDL_Renderer::hidden, i, QueueCmdFillRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_FPoint::y, and SDL_FRect::y.

## SDL_RenderFillRectsF()

int SDL_RenderFillRectsF | ( | SDL_Renderer * | renderer,
|  | const SDL_FRect * | 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 2813 of file SDL_render.c.

{
SDL_FRect *frects;
int i;
int retval;
SDL_bool isstack;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!rects) {
return SDL_SetError("SDL_RenderFillFRects(): Passed NULL rects");
}
if (count < 1) {
return 0;
}
/* Don't draw while we're hidden */
if (renderer->hidden) {
return 0;
}
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
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;
}
retval = QueueCmdFillRects(renderer, frects, count);
SDL_small_free(frects, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_FRect::h, SDL_Renderer::hidden, i, QueueCmdFillRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_FPoint::y, and SDL_FRect::y.

Referenced by SDL_RenderFillRect(), and SDL_RenderFillRectF().

## SDL_RenderFlush()

int SDL_RenderFlush | ( | SDL_Renderer * | renderer | ) |

Force the rendering context to flush any pending commands to the underlying rendering API.

You do not need to (and in fact, shouldn't) call this function unless you are planning to call into OpenGL/Direct3D/Metal/whatever directly in addition to using an SDL_Renderer.

This is for a very-specific case: if you are using SDL's render API, you asked for a specific renderer backend (OpenGL, Direct3D, etc), you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of this applies, you should call SDL_RenderFlush() between calls to SDL's render API and the low-level API you're using in cooperation.

In all other cases, you can ignore this function. This is only here to get maximum performance out of a specific situation. In all other cases, SDL will do the right thing, perhaps at a performance loss.

This function is first available in SDL 2.0.10, and is not needed in 2.0.9 and earlier, as earlier versions did not queue rendering commands at all, instead flushing them to the OS immediately.

Definition at line 261 of file SDL_render.c.

{
return FlushRenderCommands(renderer);
}

References FlushRenderCommands(), and renderer.

## SDL_RenderGetClipRect()

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

Get the clip rectangle for the current target.

Parameters

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

See also
  SDL_RenderSetClipRect()

Definition at line 2134 of file SDL_render.c.

{
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);
}
}

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

## SDL_RenderGetIntegerScale()

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

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

Parameters

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

See also
  SDL_RenderSetIntegerScale()

Definition at line 2070 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, SDL_FALSE);
return renderer->integer_scale;
}

References CHECK_RENDERER_MAGIC, SDL_Renderer::integer_scale, renderer, and SDL_FALSE.

## SDL_RenderGetLogicalSize()

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

Get device independent resolution for rendering.

Parameters

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

See also
  SDL_RenderSetLogicalSize()

Definition at line 2047 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, );
if (w) {
*w = renderer->logical_w;
}
if (h) {
*h = renderer->logical_h;
}
}

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

## SDL_RenderGetMetalCommandEncoder()

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

Get the Metal command encoder for the current frame.

Parameters

  renderer | The renderer to query

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

See also
  SDL_RenderGetMetalLayer()

Definition at line 3283 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, NULL);
if (renderer->GetMetalCommandEncoder) {
FlushRenderCommands(renderer); /* in case the app is going to mess with it. */
return renderer->GetMetalCommandEncoder(renderer);
}
return NULL;
}

References CHECK_RENDERER_MAGIC, FlushRenderCommands(), SDL_Renderer::GetMetalCommandEncoder, NULL, and renderer.

## SDL_RenderGetMetalLayer()

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

Get the CAMetalLayer associated with the given Metal renderer.

Parameters

  renderer | The renderer to query

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

See also
  SDL_RenderGetMetalCommandEncoder()

Definition at line 3271 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, NULL);
if (renderer->GetMetalLayer) {
FlushRenderCommands(renderer); /* in case the app is going to mess with it. */
return renderer->GetMetalLayer(renderer);
}
return NULL;
}

References CHECK_RENDERER_MAGIC, FlushRenderCommands(), SDL_Renderer::GetMetalLayer, NULL, and renderer.

## SDL_RenderGetScale()

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

Get the drawing scale for the current target.

Parameters

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

See also
  SDL_RenderSetScale()

Definition at line 2164 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, );
if (scaleX) {
*scaleX = renderer->scale.x;
}
if (scaleY) {
*scaleY = renderer->scale.y;
}
}

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

## SDL_RenderGetViewport()

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

Get the drawing area for the current target.

See also
  SDL_RenderSetViewport()

Definition at line 2100 of file SDL_render.c.

{
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);
}
}

References CHECK_RENDERER_MAGIC, SDL_Rect::h, rect, renderer, 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_RenderCopyExF(), SDL_RenderCopyF(), SDL_RenderDrawRectF(), SDL_RenderFillRect(), and SDL_RenderFillRectF().

## SDL_RenderIsClipEnabled()

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

Get whether clipping is enabled on the given renderer.

Parameters

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

See also
  SDL_RenderGetClipRect()

Definition at line 2147 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, SDL_FALSE)
return renderer->clipping_enabled;
}

References CHECK_RENDERER_MAGIC, SDL_Renderer::clipping_enabled, renderer, and SDL_FALSE.

## SDL_RenderPresent()

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

Update the screen with rendering performed.

Definition at line 3126 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, );
FlushRenderCommands(renderer); /* time to send everything to the GPU! */
/* Don't present while we're hidden */
if (renderer->hidden) {
return;
}
renderer->RenderPresent(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommands(), SDL_Renderer::hidden, renderer, and SDL_Renderer::RenderPresent.

## SDL_RenderReadPixels()

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

Read pixels from the current rendering target.

Parameters

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

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

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

Definition at line 3087 of file SDL_render.c.

{
SDL_Rect real_rect;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!renderer->RenderReadPixels) {
return SDL_Unsupported();
}
FlushRenderCommands(renderer); /* we need to render before we read the results. */
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);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommands(), SDL_Rect::h, rect, renderer, 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_RenderSetClipRect()

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

Set the clip rectangle for the current target.

Parameters

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

Returns
  0 on success, or -1 on error

See also
  SDL_RenderGetClipRect()

Definition at line 2113 of file SDL_render.c.

{
int retval;
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);
}
retval = QueueCmdSetClipRect(renderer);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, SDL_Renderer::clip_rect, SDL_Renderer::clipping_enabled, FlushRenderCommandsIfNotBatching(), SDL_Rect::h, QueueCmdSetClipRect(), rect, renderer, retval, SDL_Renderer::scale, SDL_ceil, SDL_FALSE, SDL_floor, SDL_TRUE, SDL_zero, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

## SDL_RenderSetIntegerScale()

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

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

Parameters

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

This function restricts the logical viewport to integer values - that is, when a resolution is between two multiples of a logical size, the viewport size is rounded down to the lower multiple.

See also
  SDL_RenderSetLogicalSize()

Definition at line 2060 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, -1);
renderer->integer_scale = enable;
return UpdateLogicalSize(renderer);
}

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

## SDL_RenderSetLogicalSize()

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

Set device independent resolution for rendering.

Parameters

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

This function uses the viewport and scaling functionality to allow a fixed logical resolution for rendering, regardless of the actual output resolution. If the actual output resolution doesn't have the same aspect ratio the output rendering will be centered within the output display.

If the output display is a window, mouse events in the window will be filtered and scaled so they seem to arrive within the logical resolution.

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

See also
  SDL_RenderGetLogicalSize()
  SDL_RenderSetScale()
  SDL_RenderSetViewport()

Definition at line 2027 of file SDL_render.c.

{
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);
}

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

## SDL_RenderSetScale()

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

Set the drawing scale for rendering on the current target.

Parameters

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

The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer. This allows resolution independent drawing with a single coordinate system.

Note
  If this results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints. For best results use integer scaling factors.

See also
  SDL_RenderGetScale()
  SDL_RenderSetLogicalSize()

Definition at line 2154 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, -1);
renderer->scale.x = scaleX;
renderer->scale.y = scaleY;
return 0;
}

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

Referenced by SDL_RenderSetLogicalSize(), and UpdateLogicalSize().

## SDL_RenderSetViewport()

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

Set the drawing area for rendering on the current target.

Parameters

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

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

Returns
  0 on success, or -1 on error

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

See also
  SDL_RenderGetViewport()
  SDL_RenderSetLogicalSize()

Definition at line 2078 of file SDL_render.c.

{
int retval;
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;
}
}
retval = QueueCmdSetViewport(renderer);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Rect::h, QueueCmdSetViewport(), rect, renderer, retval, SDL_Renderer::scale, SDL_ceil, SDL_floor, SDL_GetRendererOutputSize(), 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().

## SDL_RenderTargetSupported()

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

Determines whether a window supports the use of render targets.

Parameters

  renderer | The renderer that will be checked

Returns
  SDL_TRUE if supported, SDL_FALSE if not.

Definition at line 1824 of file SDL_render.c.

{
if (!renderer || !renderer->SetRenderTarget) {
return SDL_FALSE;
}
return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0;
}

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

Referenced by SDL_SetRenderTarget().

## SDL_SetRenderDrawBlendMode()

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

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

Parameters

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

Returns
  0 on success, or -1 on error

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

See also
  SDL_GetRenderDrawBlendMode()

Definition at line 2211 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, -1);
if (!IsSupportedBlendMode(renderer, blendMode)) {
return SDL_Unsupported();
}
renderer->blendMode = blendMode;
return 0;
}

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

## SDL_SetRenderDrawColor()

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

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

Parameters

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

Returns
  0 on success, or -1 on error

Definition at line 2177 of file SDL_render.c.

{
CHECK_RENDERER_MAGIC(renderer, -1);
renderer->r = r;
renderer->g = g;
renderer->b = b;
renderer->a = a;
return 0;
}

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

## SDL_SetRenderTarget()

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

Set a texture as the current rendering target.

Parameters

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

Returns
  0 on success, or -1 on error

See also
  SDL_GetRenderTarget()

Definition at line 1833 of file SDL_render.c.

{
if (!SDL_RenderTargetSupported(renderer)) {
return SDL_Unsupported();
}
if (texture == renderer->target) {
/* Nothing to do! */
return 0;
}
FlushRenderCommands(renderer); /* time to send everything to the GPU! */
/* 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;
}
}
SDL_LockMutex(renderer->target_mutex);
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) {
SDL_UnlockMutex(renderer->target_mutex);
return -1;
}
if (texture) {
renderer->viewport.x = 0;
renderer->viewport.y = 0;
renderer->viewport.w = texture->w;
renderer->viewport.h = texture->h;
SDL_zero(renderer->clip_rect);
renderer->clipping_enabled = SDL_FALSE;
renderer->scale.x = 1.0f;
renderer->scale.y = 1.0f;
renderer->logical_w = texture->w;
renderer->logical_h = texture->h;
} else {
renderer->viewport = renderer->viewport_backup;
renderer->clip_rect = renderer->clip_rect_backup;
renderer->clipping_enabled = renderer->clipping_enabled_backup;
renderer->scale = renderer->scale_backup;
renderer->logical_w = renderer->logical_w_backup;
renderer->logical_h = renderer->logical_h_backup;
}
SDL_UnlockMutex(renderer->target_mutex);
if (QueueCmdSetViewport(renderer) < 0) {
return -1;
}
if (QueueCmdSetClipRect(renderer) < 0) {
return -1;
}
/* All set! */
return FlushRenderCommandsIfNotBatching(renderer);
}

References CHECK_TEXTURE_MAGIC, SDL_Renderer::clip_rect, SDL_Renderer::clip_rect_backup, SDL_Renderer::clipping_enabled, SDL_Renderer::clipping_enabled_backup, FlushRenderCommands(), FlushRenderCommandsIfNotBatching(), SDL_Rect::h, SDL_Renderer::logical_h, SDL_Renderer::logical_h_backup, SDL_Renderer::logical_w, SDL_Renderer::logical_w_backup, QueueCmdSetClipRect(), QueueCmdSetViewport(), renderer, SDL_Renderer::scale, SDL_Renderer::scale_backup, SDL_FALSE, SDL_LockMutex, SDL_RenderTargetSupported(), SDL_SetError, SDL_TEXTUREACCESS_TARGET, SDL_UnlockMutex, SDL_Unsupported, SDL_zero, SDL_Renderer::SetRenderTarget, SDL_Renderer::target, SDL_Renderer::target_mutex, SDL_Renderer::viewport, SDL_Renderer::viewport_backup, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

Referenced by SDL_DestroyTexture(), and SDL_RendererEventWatch().

## SDL_SetTextureAlphaMod()

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

Set an additional alpha value used in render copy operations.

Parameters

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

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

See also
  SDL_GetTextureAlphaMod()

Definition at line 1411 of file SDL_render.c.

{
CHECK_TEXTURE_MAGIC(texture, -1);
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);
}
return 0;
}

References CHECK_TEXTURE_MAGIC, and SDL_TEXTUREMODULATE_ALPHA.

Referenced by SDL_CreateTextureFromSurface().

## SDL_SetTextureBlendMode()

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

Set the blend mode used for texture copy operations.

Parameters

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

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

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

See also
  SDL_GetTextureBlendMode()

Definition at line 1439 of file SDL_render.c.

{
SDL_Renderer *renderer;
CHECK_TEXTURE_MAGIC(texture, -1);
renderer = texture->renderer;
if (!IsSupportedBlendMode(renderer, blendMode)) {
return SDL_Unsupported();
}
texture->blendMode = blendMode;
if (texture->native) {
return SDL_SetTextureBlendMode(texture->native, blendMode);
}
return 0;
}

References blendMode, CHECK_TEXTURE_MAGIC, IsSupportedBlendMode(), renderer, and SDL_Unsupported.

Referenced by SDL_CreateTextureFromSurface().

## SDL_SetTextureColorMod()

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

Set an additional color value used in render copy operations.

Parameters

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

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

See also
  SDL_GetTextureColorMod()

Definition at line 1374 of file SDL_render.c.

{
CHECK_TEXTURE_MAGIC(texture, -1);
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);
}
return 0;
}

References CHECK_TEXTURE_MAGIC, and SDL_TEXTUREMODULATE_COLOR.

Referenced by SDL_CreateTextureFromSurface().

## SDL_UnlockTexture()

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

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

See also
  SDL_LockTexture()

Definition at line 1806 of file SDL_render.c.

{
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 {
SDL_Renderer *renderer = texture->renderer;
renderer->UnlockTexture(renderer, texture);
}
}

References CHECK_TEXTURE_MAGIC, renderer, SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTextureNative(), SDL_UnlockTextureYUV(), and SDL_Renderer::UnlockTexture.

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

## SDL_UpdateTexture()

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

Update the given texture rectangle with new pixel data.

Parameters

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

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

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

Note
  This is a fairly slow function.

Definition at line 1555 of file SDL_render.c.

{
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 {
SDL_Renderer *renderer = texture->renderer;
if (FlushRenderCommandsIfTextureNeeded(texture) < 0) {
return -1;
}
return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
}
}

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Rect::h, rect, renderer, SDL_InvalidParamError, SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), SDL_Renderer::UpdateTexture, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

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

## SDL_UpdateYUVTexture()

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

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

Parameters

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

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

Note
  You can use SDL_UpdateTexture() as long as your pixel data is a contiguous block of Y and U/V planes in the proper order, but this function is available if your pixel data is not contiguous.

Definition at line 1644 of file SDL_render.c.

{
SDL_Renderer *renderer;
SDL_Rect full_rect;
CHECK_TEXTURE_MAGIC(texture, -1);
if (!Yplane) {
return SDL_InvalidParamError("Yplane");
}
if (!Ypitch) {
return SDL_InvalidParamError("Ypitch");
}
if (!Uplane) {
return SDL_InvalidParamError("Uplane");
}
if (!Upitch) {
return SDL_InvalidParamError("Upitch");
}
if (!Vplane) {
return SDL_InvalidParamError("Vplane");
}
if (!Vpitch) {
return SDL_InvalidParamError("Vpitch");
}
if (texture->format != SDL_PIXELFORMAT_YV12 &&
texture->format != SDL_PIXELFORMAT_IYUV) {
return SDL_SetError("Texture format must by YV12 or IYUV");
}
if (!rect) {
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = texture->w;
full_rect.h = texture->h;
rect = &full_rect;
}
if (!rect->w || !rect->h) {
return 0; /* nothing to do. */
}
if (texture->yuv) {
return SDL_UpdateTextureYUVPlanar(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
} else {
SDL_assert(!texture->native);
renderer = texture->renderer;
SDL_assert(renderer->UpdateTextureYUV);
if (renderer->UpdateTextureYUV) {
if (FlushRenderCommandsIfTextureNeeded(texture) < 0) {
return -1;
}
return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
} else {
return SDL_Unsupported();
}
}
}

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Rect::h, rect, renderer, SDL_assert, SDL_InvalidParamError, SDL_PIXELFORMAT_IYUV, SDL_PIXELFORMAT_YV12, SDL_SetError, SDL_Unsupported, SDL_UpdateTextureYUVPlanar(), SDL_Renderer::UpdateTextureYUV, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

QueueCmdSetViewport
static int QueueCmdSetViewport(SDL_Renderer *renderer)
Definition: SDL_render.c:400
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
SDL_UnlockSurface
#define SDL_UnlockSurface
Definition: SDL_dynapi_overrides.h:449
SDL_SetRenderTarget
int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
Set a texture as the current rendering target.
Definition: SDL_render.c:1833
SDL_Renderer::blendMode
SDL_BlendMode blendMode
Definition: SDL_sysrender.h:210
SW_CreateRendererForSurface
SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface *surface)
Definition: SDL_render_sw.c:802
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
points
GLfixed GLfixed GLint GLint GLfixed points
Definition: SDL_opengl_glext.h:4558
SDL_Point::x
int x
Definition: SDL_rect.h:50
RenderDrawPointsWithRectsF
static int RenderDrawPointsWithRectsF(SDL_Renderer *renderer, const SDL_FPoint *fpoints, const int count)
Definition: SDL_render.c:2333
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_Renderer::GL_UnbindTexture
int(* GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:164
SDL_RenderCopyExF
int SDL_RenderCopyExF(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
Copy a portion of the source texture to the current rendering target, rotating it by angle around the...
Definition: SDL_render.c:3010
SDL_HINT_RENDER_VSYNC
#define SDL_HINT_RENDER_VSYNC
A variable controlling whether updates to the SDL screen surface should be synchronized with the vert...
Definition: SDL_hints.h:154
SDL_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:1112
SDL_Renderer::clip_rect_backup
SDL_Rect clip_rect_backup
Definition: SDL_sysrender.h:191
SDL_small_free
#define SDL_small_free(ptr, isstack)
Definition: SDL_internal.h:40
FlushRenderCommands
static int FlushRenderCommands(SDL_Renderer *renderer)
Definition: SDL_render.c:203
SDL_HINT_RENDER_BATCHING
#define SDL_HINT_RENDER_BATCHING
A variable controlling whether the 2D render API is compatible or efficient.
Definition: SDL_hints.h:1087
SDL_GL_UnbindTexture
int SDL_GL_UnbindTexture(SDL_Texture *texture)
Unbind a texture from the current OpenGL/ES/ES2 context.
Definition: SDL_render.c:3254
SDL_GetWindowData
#define SDL_GetWindowData
Definition: SDL_dynapi_overrides.h:523
SDL_Palette::ncolors
int ncolors
Definition: SDL_pixels.h:306
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_SetTextureAlphaMod
int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha)
Set an additional alpha value used in render copy operations.
Definition: SDL_render.c:1411
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
SDL_Renderer::render_command_generation
Uint32 render_command_generation
Definition: SDL_sysrender.h:217
SDL_UpdateTextureYUV
static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_render.c:1468
SDL_Renderer::GetMetalLayer
void *(* GetMetalLayer)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:166
SDL_WINDOW_MINIMIZED
@ SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:106
VerifyDrawQueueFunctions
static SDL_INLINE void VerifyDrawQueueFunctions(const SDL_Renderer *renderer)
Definition: SDL_render.c:821
SDL_Renderer::QueueCopyEx
int(* QueueCopyEx)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, 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:140
IsSupportedBlendMode
static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
Definition: SDL_render.c:1040
SDL_PIXELFORMAT_RGB888
@ SDL_PIXELFORMAT_RGB888
Definition: SDL_pixels.h:236
SDL_RenderTargetSupported
SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer)
Determines whether a window supports the use of render targets.
Definition: SDL_render.c:1824
SDL_TEXTUREMODULATE_COLOR
@ SDL_TEXTUREMODULATE_COLOR
Definition: SDL_render.h:104
SDL_LockMutex
#define SDL_LockMutex
Definition: SDL_dynapi_overrides.h:260
SDL_RendererFlags
SDL_RendererFlags
Flags used when creating a rendering context.
Definition: SDL_render.h:64
window_w
int window_w
Definition: testoverlay2.c:143
SDL_FPoint::x
float x
Definition: SDL_rect.h:62
SDL_ceil
#define SDL_ceil
Definition: SDL_dynapi_overrides.h:426
SDL_FRect::h
float h
Definition: SDL_rect.h:92
NULL
#define NULL
Definition: begin_code.h:167
surface
EGLSurface surface
Definition: eglext.h:248
SDL_PixelFormat::format
Uint32 format
Definition: SDL_pixels.h:317
SDL_ALPHA_OPAQUE
#define SDL_ALPHA_OPAQUE
Definition: SDL_pixels.h:46
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
SDL_Renderer::SetRenderTarget
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:155
enable
GLboolean enable
Definition: SDL_opengl_glext.h:4996
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
SDL_Surface::pixels
void * pixels
Definition: SDL_surface.h:76
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1109
access
GLuint GLint GLboolean GLint GLenum access
Definition: SDL_opengl_glext.h:2162
render_drivers
static const SDL_RenderDriver * render_drivers[]
Definition: SDL_render.c:79
SDL_Renderer::g
Uint8 g
Definition: SDL_sysrender.h:209
SDL_UpdateTextureNative
static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_render.c:1514
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_UnlockTextureNative
static void SDL_UnlockTextureNative(SDL_Texture *texture)
Definition: SDL_render.c:1785
SDL_GetWindowFlags
#define SDL_GetWindowFlags
Definition: SDL_dynapi_overrides.h:518
SDL_RenderDrawLinesF
int SDL_RenderDrawLinesF(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Draw a series of connected lines on the current rendering target.
Definition: SDL_render.c:2578
SDL_RenderCommand::next
struct SDL_RenderCommand * next
Definition: SDL_sysrender.h:110
SDL_PIXELFORMAT_BGR888
@ SDL_PIXELFORMAT_BGR888
Definition: SDL_pixels.h:242
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:174
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:198
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_AllocVertGap
Definition: SDL_sysrender.h:113
SDL_ConvertSurface
#define SDL_ConvertSurface
Definition: SDL_dynapi_overrides.h:463
SDL_InvalidParamError
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_CreateMutex
#define SDL_CreateMutex
Definition: SDL_dynapi_overrides.h:259
SDL_WINDOWPOS_UNDEFINED
#define SDL_WINDOWPOS_UNDEFINED
Definition: SDL_video.h:130
SDL_MUSTLOCK
#define SDL_MUSTLOCK(S)
Definition: SDL_surface.h:62
SDL_Renderer::vertex_data
void * vertex_data
Definition: SDL_sysrender.h:226
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:294
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:1593
SDL_floor
#define SDL_floor
Definition: SDL_dynapi_overrides.h:431
SDL_RenderDriver
Definition: SDL_sysrender.h:236
SDL_FRect::x
float x
Definition: SDL_rect.h:89
SDL_ISPIXELFORMAT_INDEXED
#define SDL_ISPIXELFORMAT_INDEXED(format)
Definition: SDL_pixels.h:134
SDL_Renderer::dpi_scale
SDL_FPoint dpi_scale
Definition: SDL_sysrender.h:202
SDL_Renderer::textures
SDL_Texture * textures
Definition: SDL_sysrender.h:205
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:1022
index
GLuint index
Definition: SDL_opengl_glext.h:660
SDL_FPoint::y
float y
Definition: SDL_rect.h:63
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
SDL_Renderer::vertex_data_gaps
SDL_AllocVertGap vertex_data_gaps
Definition: SDL_sysrender.h:229
SDL_CreateWindow
#define SDL_CreateWindow
Definition: SDL_dynapi_overrides.h:514
renderer_magic
static char renderer_magic
Definition: SDL_render.c:108
SDL_AllocVertGap::next
struct SDL_AllocVertGap * next
Definition: SDL_sysrender.h:117
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946
SDL_RendererFlip
SDL_RendererFlip
Flip constants for SDL_RenderCopyEx.
Definition: SDL_render.h:111
SDL_small_alloc
#define SDL_small_alloc(type, count, pisstack)
Definition: SDL_internal.h:39
SDL_Renderer::target_mutex
SDL_mutex * target_mutex
Definition: SDL_sysrender.h:207
SDL_GetSurfaceBlendMode
#define SDL_GetSurfaceBlendMode
Definition: SDL_dynapi_overrides.h:460
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:1353
SDL_Rect::x
int x
Definition: SDL_rect.h:79
FlushRenderCommandsIfTextureNeeded
static int FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture)
Definition: SDL_render.c:244
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:835
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:177
SDL_Renderer::viewport_backup
SDL_Rect viewport_backup
Definition: SDL_sysrender.h:187
SDL_PIXELFORMAT_IYUV
@ SDL_PIXELFORMAT_IYUV
Definition: SDL_pixels.h:279
SDL_AllocFormat
#define SDL_AllocFormat
Definition: SDL_dynapi_overrides.h:280
SDL_RenderFillRectsF
int SDL_RenderFillRectsF(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Fill some number of rectangles on the current rendering target with the drawing color.
Definition: SDL_render.c:2813
SDL_Texture::prev
SDL_Texture * prev
Definition: SDL_sysrender.h:68
SDL_GetNumRenderDrivers
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
Definition: SDL_render.c:627
SDL_Rect::w
int w
Definition: SDL_rect.h:80
SDL_TEXTUREMODULATE_NONE
@ SDL_TEXTUREMODULATE_NONE
Definition: SDL_render.h:103
SDL_Color::a
Uint8 a
Definition: SDL_pixels.h:300
n
GLdouble n
Definition: SDL_opengl_glext.h:1952
SDL_RenderGetViewport
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
Definition: SDL_render.c:2100
SDL_strcasecmp
#define SDL_strcasecmp
Definition: SDL_dynapi_overrides.h:419
SDL_TextureModulate
SDL_TextureModulate
The texture channel modulation used in SDL_RenderCopy().
Definition: SDL_render.h:101
alpha
GLfloat GLfloat GLfloat alpha
Definition: SDL_opengl_glext.h:412
SDL_RenderDriver::CreateRenderer
SDL_Renderer *(* CreateRenderer)(SDL_Window *window, Uint32 flags)
Definition: SDL_sysrender.h:238
SDL_GetWindowSize
#define SDL_GetWindowSize
Definition: SDL_dynapi_overrides.h:527
QueueCmdClear
static int QueueCmdClear(SDL_Renderer *renderer)
Definition: SDL_render.c:474
SDL_LockTextureNative
static int SDL_LockTextureNative(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_render.c:1715
SDL_Surface::pitch
int pitch
Definition: SDL_surface.h:75
SDL_RENDERER_SOFTWARE
@ SDL_RENDERER_SOFTWARE
Definition: SDL_render.h:66
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:186
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:2154
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
SDL_Renderer
Definition: SDL_sysrender.h:122
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
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:3238
SDL_FPoint
The structure that defines a point (floating point)
Definition: SDL_rect.h:60
SDL_Palette::colors
SDL_Color * colors
Definition: SDL_pixels.h:307
SDL_FRect::y
float y
Definition: SDL_rect.h:90
SDL_Renderer::integer_scale
SDL_bool integer_scale
Definition: SDL_sysrender.h:183
SDL_Renderer::b
Uint8 b
Definition: SDL_sysrender.h:209
Android_ActivityMutex_Lock_Running
void Android_ActivityMutex_Lock_Running(void)
SDL_FRect::w
float w
Definition: SDL_rect.h:91
retval
SDL_bool retval
Definition: testgamecontroller.c:65
SDL_Renderer::scale_backup
SDL_FPoint scale_backup
Definition: SDL_sysrender.h:199
SDL_FLIP_HORIZONTAL
@ SDL_FLIP_HORIZONTAL
Definition: SDL_render.h:114
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
window_h
int window_h
Definition: testoverlay2.c:144
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_SetWindowData
#define SDL_SetWindowData
Definition: SDL_dynapi_overrides.h:522
SDL_RendererInfo::flags
Uint32 flags
Definition: SDL_render.h:81
SDL_Rect::y
int y
Definition: SDL_rect.h:79
SDL_Renderer::render_commands_tail
SDL_RenderCommand * render_commands_tail
Definition: SDL_sysrender.h:215
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:1555
SDL_Rect::h
int h
Definition: SDL_rect.h:80
SDL_Renderer::logical_h_backup
int logical_h_backup
Definition: SDL_sysrender.h:180
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
f
GLfloat f
Definition: SDL_opengl_glext.h:1870
SDL_TEXTUREACCESS_STATIC
@ SDL_TEXTUREACCESS_STATIC
Definition: SDL_render.h:93
QueueCmdFillRects
static int QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, const int count)
Definition: SDL_render.c:557
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
UpdateLogicalSize
static int UpdateLogicalSize(SDL_Renderer *renderer)
Definition: SDL_render.c:1918
SDL_RENDERER_PRESENTVSYNC
@ SDL_RENDERER_PRESENTVSYNC
Definition: SDL_render.h:69
SDL_DestroyTexture
void SDL_DestroyTexture(SDL_Texture *texture)
Destroy the specified texture.
Definition: SDL_render.c:3140
rect
SDL_Rect rect
Definition: testrelative.c:27
SDL_FreeSurface
#define SDL_FreeSurface
Definition: SDL_dynapi_overrides.h:446
SDL_PixelFormat::palette
SDL_Palette * palette
Definition: SDL_pixels.h:318
SDL_Renderer::render_commands
SDL_RenderCommand * render_commands
Definition: SDL_sysrender.h:214
SDL_LockTextureYUV
static int SDL_LockTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_render.c:1708
SDL_SW_DestroyYUVTexture
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
Definition: SDL_yuv_sw.c:404
SDL_HasIntersectionF
static SDL_bool SDL_HasIntersectionF(const SDL_FRect *A, const SDL_FRect *B)
Definition: SDL_render.c:2861
RenderDrawPointsWithRects
static int RenderDrawPointsWithRects(SDL_Renderer *renderer, const SDL_Point *points, const int count)
Definition: SDL_render.c:2263
SDL_Renderer::always_batch
SDL_bool always_batch
Definition: SDL_sysrender.h:212
FlushRenderCommandsIfNotBatching
static SDL_INLINE int FlushRenderCommandsIfNotBatching(SDL_Renderer *renderer)
Definition: SDL_render.c:255
SDL_UnlockTextureYUV
static void SDL_UnlockTextureYUV(SDL_Texture *texture)
Definition: SDL_render.c:1764
RenderDrawLinesWithRectsF
static int RenderDrawLinesWithRectsF(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
Definition: SDL_render.c:2480
SDL_FreeFormat
#define SDL_FreeFormat
Definition: SDL_dynapi_overrides.h:281
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:325
SDL_Texture::next
SDL_Texture * next
Definition: SDL_sysrender.h:69
SDL_Renderer::GL_BindTexture
int(* GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
Definition: SDL_sysrender.h:163
QueueCmdCopyEx
static int QueueCmdCopyEx(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_render.c:607
SDL_Renderer::batching
SDL_bool batching
Definition: SDL_sysrender.h:213
SDL_PIXELFORMAT_ARGB8888
@ SDL_PIXELFORMAT_ARGB8888
Definition: SDL_pixels.h:248
SDL_PixelFormat
Definition: SDL_pixels.h:315
SDL_Renderer::vertex_data_gaps_pool
SDL_AllocVertGap * vertex_data_gaps_pool
Definition: SDL_sysrender.h:230
SDL_TEXTUREMODULATE_ALPHA
@ SDL_TEXTUREMODULATE_ALPHA
Definition: SDL_render.h:105
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_Renderer::GetOutputSize
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
Definition: SDL_sysrender.h:127
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_Renderer::CreateTexture
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:129
SDL_BLENDMODE_BLEND
@ SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_LOG_CATEGORY_RENDER
@ SDL_LOG_CATEGORY_RENDER
Definition: SDL_log.h:72
SDL_LockSurface
#define SDL_LockSurface
Definition: SDL_dynapi_overrides.h:448
SDL_Renderer::DestroyRenderer
void(* DestroyRenderer)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:161
SDL_Renderer::LockTexture
int(* LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_sysrender.h:152
SDL_Renderer::GetMetalCommandEncoder
void *(* GetMetalCommandEncoder)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:167
SDL_SW_CreateYUVTexture
SDL_SW_YUVTexture * SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
Definition: SDL_yuv_sw.c:31
SDL_GetSurfaceAlphaMod
#define SDL_GetSurfaceAlphaMod
Definition: SDL_dynapi_overrides.h:458
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:178
SDL_LogInfo
#define SDL_LogInfo
Definition: SDL_dynapi_overrides.h:34
SDL_Renderer::RenderReadPixels
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
Definition: SDL_sysrender.h:156
QueueCmdSetClipRect
static int QueueCmdSetClipRect(SDL_Renderer *renderer)
Definition: SDL_render.c:423
Android_ActivityMutex_Unlock
void Android_ActivityMutex_Unlock(void)
SDL_RenderCommand
Definition: SDL_sysrender.h:86
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
RenderDrawLinesWithRects
static int RenderDrawLinesWithRects(SDL_Renderer *renderer, const SDL_Point *points, const int count)
Definition: SDL_render.c:2425
QueueCmdDrawPoints
static int QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
Definition: SDL_render.c:529
SDL_WINDOW_HIDDEN
@ SDL_WINDOW_HIDDEN
Definition: SDL_video.h:103
SDL_ISPIXELFORMAT_FOURCC
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:167
SDL_GetRenderer
SDL_Renderer * SDL_GetRenderer(SDL_Window *window)
Get the renderer associated with a window.
Definition: SDL_render.c:1007
SDL_RenderDrawRectF
int SDL_RenderDrawRectF(SDL_Renderer *renderer, const SDL_FRect *rect)
Draw a rectangle on the current rendering target.
Definition: SDL_render.c:2638
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:170
SDL_RENDERER_TARGETTEXTURE
@ SDL_RENDERER_TARGETTEXTURE
Definition: SDL_render.h:71
SDL_GetWindowPixelFormat
#define SDL_GetWindowPixelFormat
Definition: SDL_dynapi_overrides.h:513
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:45
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Renderer::RenderPresent
void(* RenderPresent)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:158
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
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:2078
SDL_Rect
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77
SDL_RendererInfo::max_texture_width
int max_texture_width
Definition: SDL_render.h:84
SDL_GetScaleMode
static SDL_ScaleMode SDL_GetScaleMode(void)
Definition: SDL_render.c:1096
IsSupportedFormat
static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, Uint32 format)
Definition: SDL_render.c:1057
SDL_Texture
Definition: SDL_sysrender.h:43
SDL_Renderer::UpdateTexture
int(* UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_sysrender.h:144
SDL_TEXTUREACCESS_TARGET
@ SDL_TEXTUREACCESS_TARGET
Definition: SDL_render.h:95
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
SDL_FLIP_NONE
@ SDL_FLIP_NONE
Definition: SDL_render.h:113
SDL_DestroyMutex
#define SDL_DestroyMutex
Definition: SDL_dynapi_overrides.h:263
SDL_PIXELFORMAT_UNKNOWN
@ SDL_PIXELFORMAT_UNKNOWN
Definition: SDL_pixels.h:173
SDL_RendererEventWatch
static int SDL_RendererEventWatch(void *userdata, SDL_Event *event)
Definition: SDL_render.c:662
SDL_AddEventWatch
#define SDL_AddEventWatch
Definition: SDL_dynapi_overrides.h:128
SDL_FRect
A rectangle, with the origin at the upper left (floating point).
Definition: SDL_rect.h:87
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
SDL_GetSurfaceColorMod
#define SDL_GetSurfaceColorMod
Definition: SDL_dynapi_overrides.h:456
SDL_RenderDriver::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:241
angle
GLfloat angle
Definition: SDL_opengl_glext.h:6097
SDL_FLIP_VERTICAL
@ SDL_FLIP_VERTICAL
Definition: SDL_render.h:115
SDL_Renderer::logical_w_backup
int logical_w_backup
Definition: SDL_sysrender.h:179
SDL_Renderer::clipping_enabled
SDL_bool clipping_enabled
Definition: SDL_sysrender.h:194
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:124
SDL_RenderCopyF
int SDL_RenderCopyF(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
Copy a portion of the texture to the current rendering target.
Definition: SDL_render.c:2924
SDL_RendererInfo::name
const char * name
Definition: SDL_render.h:80
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:1374
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:38
SDL_HINT_RENDER_DRIVER
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
Definition: SDL_hints.h:85
SDL_ISPIXELFORMAT_ALPHA
#define SDL_ISPIXELFORMAT_ALPHA(format)
Definition: SDL_pixels.h:154
SDL_Renderer::r
Uint8 r
Definition: SDL_sysrender.h:209
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_Renderer::render_commands_pool
SDL_RenderCommand * render_commands_pool
Definition: SDL_sysrender.h:216
SDL_Renderer::a
Uint8 a
Definition: SDL_sysrender.h:209
SDL_SetTextureBlendMode
int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode)
Set the blend mode used for texture copy operations.
Definition: SDL_render.c:1439
SDL_RENDERER_ACCELERATED
@ SDL_RENDERER_ACCELERATED
Definition: SDL_render.h:67
SDL_RendererInfo::texture_formats
Uint32 texture_formats[16]
Definition: SDL_render.h:83
SDL_RendererInfo::max_texture_height
int max_texture_height
Definition: SDL_render.h:85
void
const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
Definition: SDL_dynapi_procs.h:89
SDL_PIXELFORMAT_YV12
@ SDL_PIXELFORMAT_YV12
Definition: SDL_pixels.h:277
SDL_UnlockMutex
#define SDL_UnlockMutex
Definition: SDL_dynapi_overrides.h:262
flags
GLbitfield flags
Definition: SDL_opengl_glext.h:1480
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:173
SDL_TEXTUREACCESS_STREAMING
@ SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:94
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:206
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1178
texture_magic
static char texture_magic
Definition: SDL_render.c:109
QueueCmdCopy
static int QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
Definition: SDL_render.c:593
rects
EGLSurface EGLint * rects
Definition: eglext.h:282
SDL_RenderDrawPointsF
int SDL_RenderDrawPointsF(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Draw multiple points on the current rendering target.
Definition: SDL_render.c:2360
SDL_PIXELFORMAT_ABGR8888
@ SDL_PIXELFORMAT_ABGR8888
Definition: SDL_pixels.h:254
SDL_TextureAccess
SDL_TextureAccess
The access pattern allowed for a texture.
Definition: SDL_render.h:91
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_RenderDrawRect
int SDL_RenderDrawRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Draw a rectangle on the current rendering target.
Definition: SDL_render.c:2621
SDL_Renderer::clipping_enabled_backup
SDL_bool clipping_enabled_backup
Definition: SDL_sysrender.h:195
SDL_HasColorKey
#define SDL_HasColorKey
Definition: SDL_dynapi_overrides.h:699
SDL_Renderer::clip_rect
SDL_Rect clip_rect
Definition: SDL_sysrender.h:190
QueueCmdDrawLines
static int QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
Definition: SDL_render.c:543
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_WINDOWRENDERDATA
#define SDL_WINDOWRENDERDATA
Definition: SDL_render.c:36
GetClosestSupportedFormat
static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, Uint32 format)
Definition: SDL_render.c:1070
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
SDL_Renderer::UnlockTexture
void(* UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:154
SDL_RendererInfo::num_texture_formats
Uint32 num_texture_formats
Definition: SDL_render.h:82
SDL_DelEventWatch
#define SDL_DelEventWatch
Definition: SDL_dynapi_overrides.h:129
SDL_Renderer::DestroyTexture
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:159
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:147
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179