21 #include "../SDL_internal.h"
29 #include "../video/SDL_pixels_c.h"
31 #if defined(__ANDROID__)
32 # include "../core/android/SDL_android.h"
35 #define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData"
37 #define CHECK_RENDERER_MAGIC(renderer, retval) \
38 SDL_assert(renderer && renderer->magic == &renderer_magic); \
39 if (!renderer || renderer->magic != &renderer_magic) { \
40 SDL_SetError("Invalid renderer"); \
44 #define CHECK_TEXTURE_MAGIC(texture, retval) \
45 SDL_assert(texture && texture->magic == &texture_magic); \
46 if (!texture || texture->magic != &texture_magic) { \
47 SDL_SetError("Invalid texture"); \
52 #define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, \
53 srcAlphaFactor, dstAlphaFactor, alphaOperation) \
54 (SDL_BlendMode)(((Uint32)colorOperation << 0) | \
55 ((Uint32)srcColorFactor << 4) | \
56 ((Uint32)dstColorFactor << 8) | \
57 ((Uint32)alphaOperation << 16) | \
58 ((Uint32)srcAlphaFactor << 20) | \
59 ((Uint32)dstAlphaFactor << 24))
61 #define SDL_BLENDMODE_NONE_FULL \
62 SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD, \
63 SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD)
65 #define SDL_BLENDMODE_BLEND_FULL \
66 SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \
67 SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD)
69 #define SDL_BLENDMODE_ADD_FULL \
70 SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, \
71 SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
73 #define SDL_BLENDMODE_MOD_FULL \
74 SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_SRC_COLOR, SDL_BLENDOPERATION_ADD, \
75 SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
77 #define SDL_BLENDMODE_MUL_FULL \
78 SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_DST_COLOR, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \
79 SDL_BLENDFACTOR_DST_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD)
81 #if !SDL_RENDER_DISABLED
83 #if SDL_VIDEO_RENDER_D3D
86 #if SDL_VIDEO_RENDER_D3D11
89 #if SDL_VIDEO_RENDER_METAL
92 #if SDL_VIDEO_RENDER_OGL
95 #if SDL_VIDEO_RENDER_OGL_ES2
98 #if SDL_VIDEO_RENDER_OGL_ES
101 #if SDL_VIDEO_RENDER_DIRECTFB
104 #if SDL_VIDEO_RENDER_PSP
107 #if SDL_VIDEO_RENDER_SW
121 SDL_Log(
"Render commands to flush:");
129 SDL_Log(
" %u. set viewport (first=%u, rect={(%d, %d), %dx%d})",
i++,
136 SDL_Log(
" %u. set cliprect (enabled=%s, rect={(%d, %d), %dx%d})",
i++,
143 SDL_Log(
" %u. set draw color (first=%u, r=%d, g=%d, b=%d, a=%d)",
i++,
150 SDL_Log(
" %u. clear (first=%u, r=%d, g=%d, b=%d, a=%d)",
i++,
157 SDL_Log(
" %u. draw points (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d)",
i++,
158 (
unsigned int) cmd->
data.
draw.first,
159 (
unsigned int) cmd->
data.
draw.count,
166 SDL_Log(
" %u. draw lines (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d)",
i++,
167 (
unsigned int) cmd->
data.
draw.first,
168 (
unsigned int) cmd->
data.
draw.count,
175 SDL_Log(
" %u. fill rects (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d)",
i++,
176 (
unsigned int) cmd->
data.
draw.first,
177 (
unsigned int) cmd->
data.
draw.count,
184 SDL_Log(
" %u. copy (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d, tex=%p)",
i++,
185 (
unsigned int) cmd->
data.
draw.first,
186 (
unsigned int) cmd->
data.
draw.count,
194 SDL_Log(
" %u. copyex (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d, tex=%p)",
i++,
195 (
unsigned int) cmd->
data.
draw.first,
196 (
unsigned int) cmd->
data.
draw.count,
267 size_t aligner = (alignment && ((current_offset & (alignment - 1)) != 0)) ? (alignment - (current_offset & (alignment - 1))) : 0;
268 size_t aligned = current_offset + aligner;
272 size_t newsize = current_allocation * 2;
274 while (newsize < needed) {
554 #if !SDL_RENDER_DISABLED
564 #if !SDL_RENDER_DISABLED
566 return SDL_SetError(
"index must be in the range of 0 - %d",
572 return SDL_SetError(
"SDL not built with rendering support");
653 int logical_w, logical_h;
666 event->motion.xrel = (
Sint32) trunc;
672 event->motion.yrel = (
Sint32) trunc;
680 int logical_w, logical_h;
694 int logical_w, logical_h;
695 float physical_w, physical_h;
710 physical_w = (float)
w;
711 physical_h = (float)
h;
719 if (physical_w == 0.0f) {
720 event->tfinger.x = 0.5f;
722 const float normalized_viewport_x = ((float)
viewport.
x) / physical_w;
723 const float normalized_viewport_w = ((float)
viewport.
w) / physical_w;
724 if (
event->tfinger.x <= normalized_viewport_x) {
725 event->tfinger.x = 0.0f;
726 }
else if (
event->tfinger.x >= (normalized_viewport_x + normalized_viewport_w)) {
727 event->tfinger.x = 1.0f;
729 event->tfinger.x = (
event->tfinger.x - normalized_viewport_x) / normalized_viewport_w;
733 if (physical_h == 0.0f) {
734 event->tfinger.y = 0.5f;
736 const float normalized_viewport_y = ((float)
viewport.
y) / physical_h;
737 const float normalized_viewport_h = ((float)
viewport.
h) / physical_h;
738 if (
event->tfinger.y <= normalized_viewport_y) {
739 event->tfinger.y = 0.0f;
740 }
else if (
event->tfinger.y >= (normalized_viewport_y + normalized_viewport_h)) {
741 event->tfinger.y = 1.0f;
743 event->tfinger.y = (
event->tfinger.y - normalized_viewport_y) / normalized_viewport_h;
788 #if !SDL_RENDER_DISABLED
794 #if defined(__ANDROID__)
804 SDL_SetError(
"Renderer already associated with window");
853 SDL_SetError(
"index must be -1 or in the range of 0 - %d",
889 int output_w, output_h;
914 #if defined(__ANDROID__)
921 #if defined(__ANDROID__)
935 #if !SDL_RENDER_DISABLED && SDL_VIDEO_RENDER_SW
988 return SDL_SetError(
"Renderer doesn't support querying output size");
1083 if (
w <= 0 ||
h <= 0) {
1177 SDL_SetError(
"SDL_CreateTextureFromSurface() passed NULL surface");
1191 SDL_bool is_opaque, has_alpha_channel;
1258 if (direct_update) {
1334 if (
r < 255 ||
g < 255 ||
b < 255) {
1432 texture->scaleMode = scaleMode;
1445 *scaleMode =
texture->scaleMode;
1453 const void *
pixels,
int pitch)
1470 void *native_pixels =
NULL;
1471 int native_pitch = 0;
1477 rect->
w,
rect->
h, native_pixels, native_pitch);
1482 const size_t alloclen =
rect->
h * temp_pitch;
1500 const void *
pixels,
int pitch)
1510 void *native_pixels =
NULL;
1511 int native_pitch = 0;
1518 native->
format, native_pixels, native_pitch);
1523 const size_t alloclen =
rect->
h * temp_pitch;
1531 native->
format, temp_pixels, temp_pitch);
1541 const void *
pixels,
int pitch)
1582 const Uint8 *Yplane,
int Ypitch,
1583 const Uint8 *Uplane,
int Upitch,
1584 const Uint8 *Vplane,
int Vpitch)
1605 void *native_pixels =
NULL;
1606 int native_pitch = 0;
1612 rect->
w,
rect->
h, native_pixels, native_pitch);
1617 const size_t alloclen =
rect->
h * temp_pitch;
1634 const Uint8 *Yplane,
int Ypitch,
1635 const Uint8 *Uplane,
int Upitch,
1636 const Uint8 *Vplane,
int Vpitch)
1665 return SDL_SetError(
"Texture format must by YV12 or IYUV");
1703 void **
pixels,
int *pitch)
1711 void **
pixels,
int *pitch)
1723 void **
pixels,
int *pitch)
1730 return SDL_SetError(
"SDL_LockTexture(): texture must be streaming");
1803 void *native_pixels =
NULL;
1804 int native_pitch = 0;
1816 rect.
w,
rect.
h, native_pixels, native_pitch);
1825 void *native_pixels =
NULL;
1826 int native_pitch = 0;
1838 native->
format, native_pixels, native_pitch);
1886 return SDL_SetError(
"Texture was not created with this renderer");
1889 return SDL_SetError(
"Texture not created with SDL_TEXTUREACCESS_TARGET");
1970 int scale_policy = 0;
1981 if (hint && (*hint ==
'1' ||
SDL_strcasecmp(hint,
"overscan") == 0)) {
1982 #if SDL_VIDEO_RENDER_D3D
1990 if (overscan_supported) {
1999 real_aspect = (
float)
w /
h;
2005 if (want_aspect > real_aspect) {
2016 }
else if (
SDL_fabs(want_aspect-real_aspect) < 0.0001) {
2020 }
else if (want_aspect > real_aspect) {
2021 if (scale_policy == 1) {
2042 if (scale_policy == 1) {
2292 fpoint.
x = (float)
x;
2293 fpoint.
y = (float)
y;
2345 return SDL_SetError(
"SDL_RenderDrawPoints(): Passed NULL points");
2415 return SDL_SetError(
"SDL_RenderDrawFPoints(): Passed NULL points");
2489 frect = &frects[nrects++];
2498 frect = &frects[nrects++];
2544 frect = &frects[nrects++];
2553 frect = &frects[nrects++];
2590 return SDL_SetError(
"SDL_RenderDrawLines(): Passed NULL points");
2633 return SDL_SetError(
"SDL_RenderDrawLines(): Passed NULL points");
2671 frect.
x = (float)
rect->
x;
2672 frect.
y = (
float)
rect->
y;
2673 frect.
w = (float)
rect->
w;
2674 frect.
h = (
float)
rect->
h;
2695 frect.
w = (float)
r.w;
2696 frect.
h = (
float)
r.h;
2722 return SDL_SetError(
"SDL_RenderDrawRects(): Passed NULL rects");
2750 return SDL_SetError(
"SDL_RenderDrawRects(): Passed NULL rects");
2778 frect.
x = (float)
rect->
x;
2779 frect.
y = (
float)
rect->
y;
2780 frect.
w = (float)
rect->
w;
2781 frect.
h = (
float)
rect->
h;
2788 frect.
w = (float)
r.w;
2789 frect.
h = (
float)
r.h;
2808 frect.
w = (float)
r.w;
2809 frect.
h = (
float)
r.h;
2827 return SDL_SetError(
"SDL_RenderFillRects(): Passed NULL rects");
2868 return SDL_SetError(
"SDL_RenderFillFRects(): Passed NULL rects");
2907 float Amin, Amax, Bmin, Bmax;
2958 dstfrect.
x = (float) dstrect->
x;
2959 dstfrect.
y = (
float) dstrect->
y;
2960 dstfrect.
w = (float) dstrect->
w;
2961 dstfrect.
h = (
float) dstrect->
h;
2962 pdstfrect = &dstfrect;
2980 return SDL_SetError(
"Texture was not created with this renderer");
3000 real_dstrect.
x = 0.0f;
3001 real_dstrect.
y = 0.0f;
3002 real_dstrect.
w = (float)
r.w;
3003 real_dstrect.
h = (
float)
r.h;
3008 real_dstrect = *dstrect;
3037 dstfrect.
x = (float) dstrect->
x;
3038 dstfrect.
y = (
float) dstrect->
y;
3039 dstfrect.
w = (float) dstrect->
w;
3040 dstfrect.
h = (
float) dstrect->
h;
3041 pdstfrect = &dstfrect;
3045 fcenter.
x = (float) center->
x;
3046 fcenter.
y = (
float) center->
y;
3047 pfcenter = &fcenter;
3071 return SDL_SetError(
"Texture was not created with this renderer");
3074 return SDL_SetError(
"Renderer does not support RenderCopyEx");
3094 real_dstrect = *dstrect;
3099 real_dstrect.
x = 0.0f;
3100 real_dstrect.
y = 0.0f;
3101 real_dstrect.
w = (float)
r.w;
3102 real_dstrect.
h = (
float)
r.h;
3110 real_center = *center;
3112 real_center.
x = real_dstrect.
w / 2.0f;
3113 real_center.
y = real_dstrect.
h / 2.0f;
3156 if (real_rect.
y >
rect->
y) {
3159 if (real_rect.
x >
rect->
x) {
3246 while (cmd !=
NULL) {
3381 srcAlphaFactor, dstAlphaFactor, alphaOperation);
void Android_ActivityMutex_Unlock(void)
void Android_ActivityMutex_Lock_Running(void)
#define SDL_assert(condition)
SDL_BlendOperation
The blend operation used when combining source and destination pixel components.
SDL_BlendFactor
The normalized factor used to multiply pixel components.
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
#define SDL_GetWindowSize
#define SDL_GetSurfaceBlendMode
#define SDL_GetCurrentVideoDriver
#define SDL_GetWindowData
#define SDL_GetSurfaceAlphaMod
#define SDL_GetWindowFlags
#define SDL_GetWindowPixelFormat
#define SDL_DelEventWatch
#define SDL_AddEventWatch
#define SDL_UnlockSurface
#define SDL_GetWindowFromID
#define SDL_SetWindowData
#define SDL_GetHintBoolean
#define SDL_GetSurfaceColorMod
#define SDL_IntersectRect
#define SDL_CreateRGBSurfaceWithFormatFrom
#define SDL_ConvertPixels
#define SDL_ConvertSurface
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_OutOfMemory()
#define SDL_Unsupported()
#define SDL_InvalidParamError(param)
#define SDL_HINT_RENDER_SCALE_QUALITY
A variable controlling the scaling quality.
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
#define SDL_HINT_RENDER_LOGICAL_SIZE_MODE
A variable controlling the scaling policy for SDL_RenderSetLogicalSize.
#define SDL_HINT_MOUSE_RELATIVE_SCALING
A variable controlling whether relative mouse motion is affected by renderer scaling.
#define SDL_HINT_RENDER_VSYNC
A variable controlling whether updates to the SDL screen surface should be synchronized with the vert...
#define SDL_HINT_RENDER_BATCHING
A variable controlling whether the 2D render API is compatible or efficient.
#define SDL_small_alloc(type, count, pisstack)
#define SDL_small_free(ptr, isstack)
@ SDL_LOG_CATEGORY_RENDER
GLint GLint GLint GLint GLint GLint y
GLuint GLuint GLsizei count
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
GLint GLint GLsizei width
GLdouble GLdouble GLdouble r
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLboolean GLboolean GLboolean b
GLfixed GLfixed GLint GLint GLfixed points
GLenum GLenum GLenum GLenum GLenum scale
GLfixed GLfixed GLfixed y2
GLuint GLfloat GLfloat GLfloat x1
GLboolean GLboolean GLboolean GLboolean a
GLuint GLint GLboolean GLint GLenum access
GLenum GLenum GLuint texture
GLfloat GLfloat GLfloat alpha
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel)
#define SDL_BYTESPERPIXEL(X)
#define SDL_ISPIXELFORMAT_ALPHA(format)
#define SDL_ISPIXELFORMAT_INDEXED(format)
@ SDL_PIXELFORMAT_ABGR8888
@ SDL_PIXELFORMAT_ARGB8888
@ SDL_PIXELFORMAT_UNKNOWN
#define SDL_ISPIXELFORMAT_FOURCC(format)
void SDL_DestroyTexture(SDL_Texture *texture)
Destroy the specified texture.
static void SDL_UnlockTextureNative(SDL_Texture *texture)
SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode)
int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
Set a texture as the current rendering target.
void SDL_RenderGetScale(SDL_Renderer *renderer, float *scaleX, float *scaleY)
Get the drawing scale for the current target.
static const SDL_RenderDriver * render_drivers[]
SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode)
static int QueueCmdSetDrawColor(SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
int SDL_RenderDrawPoint(SDL_Renderer *renderer, int x, int y)
Draw a point on the current rendering target.
static int QueueCmdSetViewport(SDL_Renderer *renderer)
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.
static int PrepQueueCmdDraw(SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
int SDL_RenderClear(SDL_Renderer *renderer)
Clear the current rendering target with the drawing color.
void * SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset)
int SDL_RenderDrawLineF(SDL_Renderer *renderer, float x1, float y1, float x2, float y2)
Draw a line on the current rendering target.
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.
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).
int SDL_QueryTexture(SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h)
Query the attributes of a texture.
void SDL_DestroyRenderer(SDL_Renderer *renderer)
Destroy the rendering context for a window and free associated textures.
SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode)
SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode)
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed. If SDL_LockTextureToSurface() was...
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
SDL_Texture * SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int h)
Create a texture for a rendering context.
static SDL_RenderCommand * PrepQueueCmdDrawTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_RenderCommandType cmdtype)
#define SDL_WINDOWRENDERDATA
void * SDL_RenderGetMetalCommandEncoder(SDL_Renderer *renderer)
Get the Metal command encoder for the current frame.
int SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
Read pixels from the current rendering target.
int SDL_RenderDrawLinesF(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Draw a series of connected lines on the current rendering target.
void SDL_RenderPresent(SDL_Renderer *renderer)
Update the screen with rendering performed.
int SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode)
Get the blend mode used for texture copy operations.
static int QueueCmdSetClipRect(SDL_Renderer *renderer)
int SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode)
Get the scale mode used for texture scale operations.
int SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in render copy operations.
int SDL_GL_UnbindTexture(SDL_Texture *texture)
Unbind a texture from the current OpenGL/ES/ES2 context.
int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the drawing area for rendering on the current target.
SDL_Texture * SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
Create a texture from an existing surface.
static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
static int RenderDrawPointsWithRectsF(SDL_Renderer *renderer, const SDL_FPoint *fpoints, const int count)
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
int SDL_RenderDrawPointF(SDL_Renderer *renderer, float x, float y)
Draw a point on the current rendering target.
#define CHECK_TEXTURE_MAGIC(texture, retval)
SDL_bool SDL_RenderIsClipEnabled(SDL_Renderer *renderer)
Get whether clipping is enabled on the given renderer.
int SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer)
Determines whether a window supports the use of render targets.
static int FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture)
void SDL_RenderGetClipRect(SDL_Renderer *renderer, SDL_Rect *rect)
Get the clip rectangle for the current target.
int SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_RendererInfo *info)
Get information about a rendering context.
int SDL_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count)
Draw multiple points on the current rendering target.
int SDL_RenderSetClipRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the clip rectangle for the current target.
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)
int SDL_RenderDrawPointsF(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Draw multiple points on the current rendering target.
static int UpdateLogicalSize(SDL_Renderer *renderer)
int SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Fill a rectangle on the current rendering target with the drawing color.
SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode)
int SDL_GetRendererOutputSize(SDL_Renderer *renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
int SDL_RenderSetIntegerScale(SDL_Renderer *renderer, SDL_bool enable)
Set whether to force integer scales for resolution-independent rendering.
int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha)
Set an additional alpha value used in render copy operations.
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.
int SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, SDL_Window **window, SDL_Renderer **renderer)
Create a window and default renderer.
void * SDL_RenderGetMetalLayer(SDL_Renderer *renderer)
Get the CAMetalLayer associated with the given Metal renderer.
static int SDL_RendererEventWatch(void *userdata, SDL_Event *event)
static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, Uint32 format)
static SDL_bool SDL_HasIntersectionF(const SDL_FRect *A, const SDL_FRect *B)
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...
SDL_bool SDL_RenderGetIntegerScale(SDL_Renderer *renderer)
Get whether integer scales are forced for resolution-independent rendering.
int SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
int SDL_RenderSetScale(SDL_Renderer *renderer, float scaleX, float scaleY)
Set the drawing scale for rendering on the current target.
static void GetWindowViewportValues(SDL_Renderer *renderer, int *logical_w, int *logical_h, SDL_Rect *viewport, SDL_FPoint *scale)
#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
static int FlushRenderCommands(SDL_Renderer *renderer)
static int RenderDrawPointsWithRects(SDL_Renderer *renderer, const SDL_Point *points, const int count)
#define SDL_BLENDMODE_NONE_FULL
static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, Uint32 format)
int SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in render copy operations.
static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
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.
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).
int SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode)
Get the blend mode used for drawing operations.
SDL_Texture * SDL_GetRenderTarget(SDL_Renderer *renderer)
Get the current render target or NULL for the default render target.
static SDL_INLINE int FlushRenderCommandsIfNotBatching(SDL_Renderer *renderer)
int SDL_RenderFlush(SDL_Renderer *renderer)
Force the rendering context to flush any pending commands to the underlying rendering API.
static int QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
#define SDL_BLENDMODE_MOD_FULL
static int QueueCmdClear(SDL_Renderer *renderer)
#define SDL_BLENDMODE_ADD_FULL
static SDL_RenderCommand * PrepQueueCmdDrawSolid(SDL_Renderer *renderer, const SDL_RenderCommandType cmdtype)
int SDL_RenderDrawRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count)
Draw some number of rectangles on the current rendering target.
static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface)
Lock a portion of the texture for write-only pixel access. Expose it as a SDL surface.
static int RenderDrawLinesWithRectsF(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
void SDL_RenderGetLogicalSize(SDL_Renderer *renderer, int *w, int *h)
Get device independent resolution for rendering.
int SDL_RenderFillRectF(SDL_Renderer *renderer, const SDL_FRect *rect)
Fill a rectangle on the current rendering target with the drawing color.
static SDL_BlendMode SDL_GetShortBlendMode(SDL_BlendMode blendMode)
int SDL_RenderDrawRectF(SDL_Renderer *renderer, const SDL_FRect *rect)
Draw a rectangle on the current rendering target.
SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode)
static int SDL_LockTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
SDL_Renderer * SDL_CreateSoftwareRenderer(SDL_Surface *surface)
Create a 2D software rendering context for a surface.
#define CHECK_RENDERER_MAGIC(renderer, retval)
static int QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
static int RenderDrawLinesWithRects(SDL_Renderer *renderer, const SDL_Point *points, const int count)
int SDL_RenderDrawRectsF(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Draw some number of rectangles on the current rendering target.
static int QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
int SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha)
Get the additional alpha value used in render copy operations.
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.
static SDL_INLINE void VerifyDrawQueueFunctions(const SDL_Renderer *renderer)
SDL_BlendMode SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor, SDL_BlendOperation colorOperation, SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor dstAlphaFactor, SDL_BlendOperation alphaOperation)
Create a custom blend mode, which may or may not be supported by a given renderer.
int SDL_RenderDrawLine(SDL_Renderer *renderer, int x1, int y1, int x2, int y2)
Draw a line on the current rendering target.
int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode)
Set the blend mode used for texture copy operations.
SDL_Renderer * SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags)
Create a 2D rendering context for a window.
#define SDL_BLENDMODE_MUL_FULL
int SDL_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count)
Draw a series of connected lines on the current rendering target.
static SDL_RenderCommand * AllocateRenderCommand(SDL_Renderer *renderer)
static SDL_INLINE void DebugLogRenderCommands(const SDL_RenderCommand *cmd)
static void SDL_UnlockTextureYUV(SDL_Texture *texture)
static SDL_ScaleMode SDL_GetScaleMode(void)
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.
int SDL_RenderSetLogicalSize(SDL_Renderer *renderer, int w, int h)
Set device independent resolution for rendering.
static int QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, const int count)
#define SDL_BLENDMODE_BLEND_FULL
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.
int SDL_RenderDrawRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Draw a rectangle on the current rendering target.
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...
SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
static int SDL_LockTextureNative(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
int SDL_GetRenderDriverInfo(int index, SDL_RendererInfo *info)
Get information about a specific 2D rendering driver for the current display.
SDL_Renderer * SDL_GetRenderer(SDL_Window *window)
Get the renderer associated with a window.
static char renderer_magic
static char texture_magic
@ SDL_RENDERER_PRESENTVSYNC
@ SDL_RENDERER_TARGETTEXTURE
SDL_RendererFlip
Flip constants for SDL_RenderCopyEx.
@ SDL_TEXTUREACCESS_STATIC
@ SDL_TEXTUREACCESS_STREAMING
@ SDL_TEXTUREACCESS_TARGET
@ SDL_TEXTUREMODULATE_ALPHA
@ SDL_TEXTUREMODULATE_COLOR
SDL_ScaleMode
The scaling mode for a texture.
SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface *surface)
#define SDL_arraysize(array)
SDL_RenderDriver PSP_RenderDriver
SDL_RenderDriver METAL_RenderDriver
SDL_RenderDriver DirectFB_RenderDriver
SDL_RenderDriver GLES2_RenderDriver
SDL_RenderDriver GL_RenderDriver
SDL_RenderDriver SW_RenderDriver
SDL_RenderDriver D3D_RenderDriver
SDL_RenderDriver GLES_RenderDriver
SDL_RenderDriver D3D11_RenderDriver
@ SDL_RENDERCMD_SETCLIPRECT
@ SDL_RENDERCMD_DRAW_LINES
@ SDL_RENDERCMD_SETVIEWPORT
@ SDL_RENDERCMD_DRAW_POINTS
@ SDL_RENDERCMD_FILL_RECTS
@ SDL_RENDERCMD_SETDRAWCOLOR
#define SDL_WINDOWPOS_UNDEFINED
@ SDL_WINDOWEVENT_MINIMIZED
@ SDL_WINDOWEVENT_MAXIMIZED
@ SDL_WINDOWEVENT_SIZE_CHANGED
@ SDL_WINDOWEVENT_RESTORED
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)
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
SDL_SW_YUVTexture * SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, Uint32 target_format, int w, int h, void *pixels, int pitch)
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch)
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, void **pixels, int *pitch)
EGLSurface EGLNativeWindowType * window
EGLSurface EGLint * rects
GLfloat GLfloat GLfloat GLfloat GLfloat maxY
GLfloat GLfloat GLfloat GLfloat maxX
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst numbytes
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
The structure that defines a point (floating point)
A rectangle, with the origin at the upper left (floating point).
The structure that defines a point (integer)
A rectangle, with the origin at the upper left (integer).
struct SDL_RenderCommand::@38::@42 color
struct SDL_RenderCommand * next
struct SDL_RenderCommand::@38::@39 viewport
struct SDL_RenderCommand::@38::@41 draw
SDL_RenderCommandType command
union SDL_RenderCommand::@38 data
struct SDL_RenderCommand::@38::@40 cliprect
SDL_Renderer *(* CreateRenderer)(SDL_Window *window, Uint32 flags)
int(* QueueCopy)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
SDL_Rect last_queued_viewport
int(* LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
SDL_bool clipping_enabled
SDL_Rect clip_rect_backup
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)
int(* QueueDrawLines)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
void(* SetTextureScaleMode)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
SDL_RenderCommand * render_commands
void(* UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
void(* DestroyRenderer)(SDL_Renderer *renderer)
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
size_t vertex_data_allocation
SDL_RenderCommand * render_commands_tail
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
SDL_bool(* SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode)
void(* RenderPresent)(SDL_Renderer *renderer)
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
SDL_RenderCommand * render_commands_pool
int(* QueueDrawPoints)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
int(* QueueFillRects)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
void(* WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event)
int(* RunCommandQueue)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
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)
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
SDL_Rect last_queued_cliprect
Uint32 render_command_generation
int(* GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
SDL_bool last_queued_cliprect_enabled
void *(* GetMetalLayer)(SDL_Renderer *renderer)
void *(* GetMetalCommandEncoder)(SDL_Renderer *renderer)
SDL_bool clipping_enabled_backup
SDL_bool relative_scaling
int(* QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
Information on the capabilities of a render driver or context.
Uint32 texture_formats[16]
Uint32 num_texture_formats
A collection of pixels used in software blitting.
The type used to identify a window.
static SDL_Renderer * renderer
static SDL_BlendMode blendMode
typedef int(__stdcall *FARPROC)()