SDL  2.0
SDL_render.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 /**
23  * \file SDL_render.h
24  *
25  * Header file for SDL 2D rendering functions.
26  *
27  * This API supports the following features:
28  * * single pixel points
29  * * single pixel lines
30  * * filled rectangles
31  * * texture images
32  *
33  * The primitives may be drawn in opaque, blended, or additive modes.
34  *
35  * The texture images may be drawn in opaque, blended, or additive modes.
36  * They can have an additional color tint or alpha modulation applied to
37  * them, and may also be stretched with linear interpolation.
38  *
39  * This API is designed to accelerate simple 2D operations. You may
40  * want more functionality such as polygons and particle effects and
41  * in that case you should use SDL's OpenGL/Direct3D support or one
42  * of the many good 3D engines.
43  *
44  * These functions must be called from the main thread.
45  * See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995
46  */
47 
48 #ifndef _SDL_render_h
49 #define _SDL_render_h
50 
51 #include "SDL_stdinc.h"
52 #include "SDL_rect.h"
53 #include "SDL_video.h"
54 
55 #include "begin_code.h"
56 /* Set up for C function definitions, even when using C++ */
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 /**
62  * \brief Flags used when creating a rendering context
63  */
64 typedef enum
65 {
66  SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */
67  SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware
68  acceleration */
69  SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized
70  with the refresh rate */
71  SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports
72  rendering to texture */
74 
75 /**
76  * \brief Information on the capabilities of a render driver or context.
77  */
78 typedef struct SDL_RendererInfo
79 {
80  const char *name; /**< The name of the renderer */
81  Uint32 flags; /**< Supported ::SDL_RendererFlags */
82  Uint32 num_texture_formats; /**< The number of available texture formats */
83  Uint32 texture_formats[16]; /**< The available texture formats */
84  int max_texture_width; /**< The maximum texture width */
85  int max_texture_height; /**< The maximum texture height */
87 
88 /**
89  * \brief The access pattern allowed for a texture.
90  */
91 typedef enum
92 {
93  SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
94  SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
95  SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
97 
98 /**
99  * \brief The texture channel modulation used in SDL_RenderCopy().
100  */
101 typedef enum
102 {
103  SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */
104  SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */
105  SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * sw_64 */
107 
108 /**
109  * \brief Flip constants for SDL_RenderCopyEx
110  */
111 typedef enum
112 {
113  SDL_FLIP_NONE = 0x00000000, /**< Do not flip */
114  SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */
115  SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */
117 
118 /**
119  * \brief A structure representing rendering state
120  */
121 struct SDL_Renderer;
122 typedef struct SDL_Renderer SDL_Renderer;
123 
124 /**
125  * \brief An efficient driver-specific representation of pixel data
126  */
127 struct SDL_Texture;
128 typedef struct SDL_Texture SDL_Texture;
129 
130 
131 /* Function prototypes */
132 
133 /**
134  * \brief Get the number of 2D rendering drivers available for the current
135  * display.
136  *
137  * A render driver is a set of code that handles rendering and texture
138  * management on a particular display. Normally there is only one, but
139  * some drivers may have several available with different capabilities.
140  *
141  * \sa SDL_GetRenderDriverInfo()
142  * \sa SDL_CreateRenderer()
143  */
144 extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
145 
146 /**
147  * \brief Get information about a specific 2D rendering driver for the current
148  * display.
149  *
150  * \param index The index of the driver to query information about.
151  * \param info A pointer to an SDL_RendererInfo struct to be filled with
152  * information on the rendering driver.
153  *
154  * \return 0 on success, -1 if the index was out of range.
155  *
156  * \sa SDL_CreateRenderer()
157  */
159  SDL_RendererInfo * info);
160 
161 /**
162  * \brief Create a window and default renderer
163  *
164  * \param width The width of the window
165  * \param height The height of the window
166  * \param window_flags The flags used to create the window
167  * \param window A pointer filled with the window, or NULL on error
168  * \param renderer A pointer filled with the renderer, or NULL on error
169  *
170  * \return 0 on success, or -1 on error
171  */
173  int width, int height, Uint32 window_flags,
175 
176 
177 /**
178  * \brief Create a 2D rendering context for a window.
179  *
180  * \param window The window where rendering is displayed.
181  * \param index The index of the rendering driver to initialize, or -1 to
182  * initialize the first one supporting the requested flags.
183  * \param flags ::SDL_RendererFlags.
184  *
185  * \return A valid rendering context or NULL if there was an error.
186  *
187  * \sa SDL_CreateSoftwareRenderer()
188  * \sa SDL_GetRendererInfo()
189  * \sa SDL_DestroyRenderer()
190  */
192  int index, Uint32 flags);
193 
194 /**
195  * \brief Create a 2D software rendering context for a surface.
196  *
197  * \param surface The surface where rendering is done.
198  *
199  * \return A valid rendering context or NULL if there was an error.
200  *
201  * \sa SDL_CreateRenderer()
202  * \sa SDL_DestroyRenderer()
203  */
205 
206 /**
207  * \brief Get the renderer associated with a window.
208  */
210 
211 /**
212  * \brief Get information about a rendering context.
213  */
215  SDL_RendererInfo * info);
216 
217 /**
218  * \brief Get the output size in pixels of a rendering context.
219  */
221  int *w, int *h);
222 
223 /**
224  * \brief Create a texture for a rendering context.
225  *
226  * \param renderer The renderer.
227  * \param format The format of the texture.
228  * \param access One of the enumerated values in ::SDL_TextureAccess.
229  * \param w The width of the texture in pixels.
230  * \param h The height of the texture in pixels.
231  *
232  * \return The created texture is returned, or NULL if no rendering context was
233  * active, the format was unsupported, or the width or height were out
234  * of range.
235  *
236  * \sa SDL_QueryTexture()
237  * \sa SDL_UpdateTexture()
238  * \sa SDL_DestroyTexture()
239  */
241  Uint32 format,
242  int access, int w,
243  int h);
244 
245 /**
246  * \brief Create a texture from an existing surface.
247  *
248  * \param renderer The renderer.
249  * \param surface The surface containing pixel data used to fill the texture.
250  *
251  * \return The created texture is returned, or NULL on error.
252  *
253  * \note The surface is not modified or freed by this function.
254  *
255  * \sa SDL_QueryTexture()
256  * \sa SDL_DestroyTexture()
257  */
259 
260 /**
261  * \brief Query the attributes of a texture
262  *
263  * \param texture A texture to be queried.
264  * \param format A pointer filled in with the raw format of the texture. The
265  * actual format may differ, but pixel transfers will use this
266  * format.
267  * \param access A pointer filled in with the actual access to the texture.
268  * \param w A pointer filled in with the width of the texture in pixels.
269  * \param h A pointer filled in with the height of the texture in pixels.
270  *
271  * \return 0 on success, or -1 if the texture is not valid.
272  */
274  Uint32 * format, int *access,
275  int *w, int *h);
276 
277 /**
278  * \brief Set an additional color value used in render copy operations.
279  *
280  * \param texture The texture to update.
281  * \param r The red color value multiplied into copy operations.
282  * \param g The green color value multiplied into copy operations.
283  * \param b The blue color value multiplied into copy operations.
284  *
285  * \return 0 on success, or -1 if the texture is not valid or color modulation
286  * is not supported.
287  *
288  * \sa SDL_GetTextureColorMod()
289  */
291  Uint8 r, Uint8 g, Uint8 b);
292 
293 
294 /**
295  * \brief Get the additional color value used in render copy operations.
296  *
297  * \param texture The texture to query.
298  * \param r A pointer filled in with the current red color value.
299  * \param g A pointer filled in with the current green color value.
300  * \param b A pointer filled in with the current blue color value.
301  *
302  * \return 0 on success, or -1 if the texture is not valid.
303  *
304  * \sa SDL_SetTextureColorMod()
305  */
307  Uint8 * r, Uint8 * g,
308  Uint8 * b);
309 
310 /**
311  * \brief Set an additional alpha value used in render copy operations.
312  *
313  * \param texture The texture to update.
314  * \param alpha The alpha value multiplied into copy operations.
315  *
316  * \return 0 on success, or -1 if the texture is not valid or alpha modulation
317  * is not supported.
318  *
319  * \sa SDL_GetTextureAlphaMod()
320  */
322  Uint8 sw_64);
323 
324 /**
325  * \brief Get the additional alpha value used in render copy operations.
326  *
327  * \param texture The texture to query.
328  * \param alpha A pointer filled in with the current alpha value.
329  *
330  * \return 0 on success, or -1 if the texture is not valid.
331  *
332  * \sa SDL_SetTextureAlphaMod()
333  */
335  Uint8 * sw_64);
336 
337 /**
338  * \brief Set the blend mode used for texture copy operations.
339  *
340  * \param texture The texture to update.
341  * \param blendMode ::SDL_BlendMode to use for texture blending.
342  *
343  * \return 0 on success, or -1 if the texture is not valid or the blend mode is
344  * not supported.
345  *
346  * \note If the blend mode is not supported, the closest supported mode is
347  * chosen.
348  *
349  * \sa SDL_GetTextureBlendMode()
350  */
353 
354 /**
355  * \brief Get the blend mode used for texture copy operations.
356  *
357  * \param texture The texture to query.
358  * \param blendMode A pointer filled in with the current blend mode.
359  *
360  * \return 0 on success, or -1 if the texture is not valid.
361  *
362  * \sa SDL_SetTextureBlendMode()
363  */
366 
367 /**
368  * \brief Update the given texture rectangle with new pixel data.
369  *
370  * \param texture The texture to update
371  * \param rect A pointer to the rectangle of pixels to update, or NULL to
372  * update the entire texture.
373  * \param pixels The raw pixel data.
374  * \param pitch The number of bytes in a row of pixel data, including padding between lines.
375  *
376  * \return 0 on success, or -1 if the texture is not valid.
377  *
378  * \note This is a fairly slow function.
379  */
381  const SDL_Rect * rect,
382  const void *pixels, int pitch);
383 
384 /**
385  * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
386  *
387  * \param texture The texture to update
388  * \param rect A pointer to the rectangle of pixels to update, or NULL to
389  * update the entire texture.
390  * \param Yplane The raw pixel data for the Y plane.
391  * \param Ypitch The number of bytes between rows of pixel data for the Y plane.
392  * \param Uplane The raw pixel data for the U plane.
393  * \param Upitch The number of bytes between rows of pixel data for the U plane.
394  * \param Vplane The raw pixel data for the V plane.
395  * \param Vpitch The number of bytes between rows of pixel data for the V plane.
396  *
397  * \return 0 on success, or -1 if the texture is not valid.
398  *
399  * \note You can use SDL_UpdateTexture() as long as your pixel data is
400  * a contiguous block of Y and U/V planes in the proper order, but
401  * this function is available if your pixel data is not contiguous.
402  */
404  const SDL_Rect * rect,
405  const Uint8 *Yplane, int Ypitch,
406  const Uint8 *Uplane, int Upitch,
407  const Uint8 *Vplane, int Vpitch);
408 
409 /**
410  * \brief Lock a portion of the texture for write-only pixel access.
411  *
412  * \param texture The texture to lock for access, which was created with
413  * ::SDL_TEXTUREACCESS_STREAMING.
414  * \param rect A pointer to the rectangle to lock for access. If the rect
415  * is NULL, the entire texture will be locked.
416  * \param pixels This is filled in with a pointer to the locked pixels,
417  * appropriately offset by the locked area.
418  * \param pitch This is filled in with the pitch of the locked pixels.
419  *
420  * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
421  *
422  * \sa SDL_UnlockTexture()
423  */
425  const SDL_Rect * rect,
426  void **pixels, int *pitch);
427 
428 /**
429  * \brief Unlock a texture, uploading the changes to video memory, if needed.
430  *
431  * \sa SDL_LockTexture()
432  */
434 
435 /**
436  * \brief Determines whether a window supports the use of render targets
437  *
438  * \param renderer The renderer that will be checked
439  *
440  * \return SDL_TRUE if supported, SDL_FALSE if not.
441  */
443 
444 /**
445  * \brief Set a texture as the current rendering target.
446  *
447  * \param renderer The renderer.
448  * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
449  *
450  * \return 0 on success, or -1 on error
451  *
452  * \sa SDL_GetRenderTarget()
453  */
456 
457 /**
458  * \brief Get the current render target or NULL for the default render target.
459  *
460  * \return The current render target
461  *
462  * \sa SDL_SetRenderTarget()
463  */
465 
466 /**
467  * \brief Set device independent resolution for rendering
468  *
469  * \param renderer The renderer for which resolution should be set.
470  * \param w The width of the logical resolution
471  * \param h The height of the logical resolution
472  *
473  * This function uses the viewport and scaling functionality to allow a fixed logical
474  * resolution for rendering, regardless of the actual output resolution. If the actual
475  * output resolution doesn't have the same aspect ratio the output rendering will be
476  * centered within the output display.
477  *
478  * If the output display is a window, mouse events in the window will be filtered
479  * and scaled so they seem to arrive within the logical resolution.
480  *
481  * \note If this function results in scaling or subpixel drawing by the
482  * rendering backend, it will be handled using the appropriate
483  * quality hints.
484  *
485  * \sa SDL_RenderGetLogicalSize()
486  * \sa SDL_RenderSetScale()
487  * \sa SDL_RenderSetViewport()
488  */
490 
491 /**
492  * \brief Get device independent resolution for rendering
493  *
494  * \param renderer The renderer from which resolution should be queried.
495  * \param w A pointer filled with the width of the logical resolution
496  * \param h A pointer filled with the height of the logical resolution
497  *
498  * \sa SDL_RenderSetLogicalSize()
499  */
501 
502 /**
503  * \brief Set the drawing area for rendering on the current target.
504  *
505  * \param renderer The renderer for which the drawing area should be set.
506  * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target.
507  *
508  * The x,y of the viewport rect represents the origin for rendering.
509  *
510  * \return 0 on success, or -1 on error
511  *
512  * \note If the window associated with the renderer is resized, the viewport is automatically reset.
513  *
514  * \sa SDL_RenderGetViewport()
515  * \sa SDL_RenderSetLogicalSize()
516  */
518  const SDL_Rect * rect);
519 
520 /**
521  * \brief Get the drawing area for the current target.
522  *
523  * \sa SDL_RenderSetViewport()
524  */
526  SDL_Rect * rect);
527 
528 /**
529  * \brief Set the clip rectangle for the current target.
530  *
531  * \param renderer The renderer for which clip rectangle should be set.
532  * \param rect A pointer to the rectangle to set as the clip rectangle, or
533  * NULL to disable clipping.
534  *
535  * \return 0 on success, or -1 on error
536  *
537  * \sa SDL_RenderGetClipRect()
538  */
540  const SDL_Rect * rect);
541 
542 /**
543  * \brief Get the clip rectangle for the current target.
544  *
545  * \param renderer The renderer from which clip rectangle should be queried.
546  * \param rect A pointer filled in with the current clip rectangle, or
547  * an empty rectangle if clipping is disabled.
548  *
549  * \sa SDL_RenderSetClipRect()
550  */
552  SDL_Rect * rect);
553 
554 /**
555  * \brief Get whether clipping is enabled on the given renderer.
556  *
557  * \param renderer The renderer from which clip state should be queried.
558  *
559  * \sa SDL_RenderGetClipRect()
560  */
562 
563 
564 /**
565  * \brief Set the drawing scale for rendering on the current target.
566  *
567  * \param renderer The renderer for which the drawing scale should be set.
568  * \param scaleX The horizontal scaling factor
569  * \param scaleY The vertical scaling factor
570  *
571  * The drawing coordinates are scaled by the x/y scaling factors
572  * before they are used by the renderer. This allows resolution
573  * independent drawing with a single coordinate system.
574  *
575  * \note If this results in scaling or subpixel drawing by the
576  * rendering backend, it will be handled using the appropriate
577  * quality hints. For best results use integer scaling factors.
578  *
579  * \sa SDL_RenderGetScale()
580  * \sa SDL_RenderSetLogicalSize()
581  */
583  float scaleX, float scaleY);
584 
585 /**
586  * \brief Get the drawing scale for the current target.
587  *
588  * \param renderer The renderer from which drawing scale should be queried.
589  * \param scaleX A pointer filled in with the horizontal scaling factor
590  * \param scaleY A pointer filled in with the vertical scaling factor
591  *
592  * \sa SDL_RenderSetScale()
593  */
595  float *scaleX, float *scaleY);
596 
597 /**
598  * \brief Set the color used for drawing operations (Rect, Line and Clear).
599  *
600  * \param renderer The renderer for which drawing color should be set.
601  * \param r The red value used to draw on the rendering target.
602  * \param g The green value used to draw on the rendering target.
603  * \param b The blue value used to draw on the rendering target.
604  * \param a The alpha value used to draw on the rendering target, usually
605  * ::SDL_ALPHA_OPAQUE (255).
606  *
607  * \return 0 on success, or -1 on error
608  */
610  Uint8 r, Uint8 g, Uint8 b,
611  Uint8 a);
612 
613 /**
614  * \brief Get the color used for drawing operations (Rect, Line and Clear).
615  *
616  * \param renderer The renderer from which drawing color should be queried.
617  * \param r A pointer to the red value used to draw on the rendering target.
618  * \param g A pointer to the green value used to draw on the rendering target.
619  * \param b A pointer to the blue value used to draw on the rendering target.
620  * \param a A pointer to the alpha value used to draw on the rendering target,
621  * usually ::SDL_ALPHA_OPAQUE (255).
622  *
623  * \return 0 on success, or -1 on error
624  */
626  Uint8 * r, Uint8 * g, Uint8 * b,
627  Uint8 * a);
628 
629 /**
630  * \brief Set the blend mode used for drawing operations (Fill and Line).
631  *
632  * \param renderer The renderer for which blend mode should be set.
633  * \param blendMode ::SDL_BlendMode to use for blending.
634  *
635  * \return 0 on success, or -1 on error
636  *
637  * \note If the blend mode is not supported, the closest supported mode is
638  * chosen.
639  *
640  * \sa SDL_GetRenderDrawBlendMode()
641  */
644 
645 /**
646  * \brief Get the blend mode used for drawing operations.
647  *
648  * \param renderer The renderer from which blend mode should be queried.
649  * \param blendMode A pointer filled in with the current blend mode.
650  *
651  * \return 0 on success, or -1 on error
652  *
653  * \sa SDL_SetRenderDrawBlendMode()
654  */
657 
658 /**
659  * \brief Clear the current rendering target with the drawing color
660  *
661  * This function clears the entire rendering target, ignoring the viewport.
662  *
663  * \return 0 on success, or -1 on error
664  */
666 
667 /**
668  * \brief Draw a point on the current rendering target.
669  *
670  * \param renderer The renderer which should draw a point.
671  * \param x The x coordinate of the point.
672  * \param y The y coordinate of the point.
673  *
674  * \return 0 on success, or -1 on error
675  */
677  int x, int y);
678 
679 /**
680  * \brief Draw multiple points on the current rendering target.
681  *
682  * \param renderer The renderer which should draw multiple points.
683  * \param points The points to draw
684  * \param count The number of points to draw
685  *
686  * \return 0 on success, or -1 on error
687  */
689  const SDL_Point * points,
690  int count);
691 
692 /**
693  * \brief Draw a line on the current rendering target.
694  *
695  * \param renderer The renderer which should draw a line.
696  * \param x1 The x coordinate of the start point.
697  * \param y1 The y coordinate of the start point.
698  * \param x2 The x coordinate of the end point.
699  * \param y2 The y coordinate of the end point.
700  *
701  * \return 0 on success, or -1 on error
702  */
704  int x1, int y1, int x2, int y2);
705 
706 /**
707  * \brief Draw a series of connected lines on the current rendering target.
708  *
709  * \param renderer The renderer which should draw multiple lines.
710  * \param points The points along the lines
711  * \param count The number of points, drawing count-1 lines
712  *
713  * \return 0 on success, or -1 on error
714  */
716  const SDL_Point * points,
717  int count);
718 
719 /**
720  * \brief Draw a rectangle on the current rendering target.
721  *
722  * \param renderer The renderer which should draw a rectangle.
723  * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
724  *
725  * \return 0 on success, or -1 on error
726  */
728  const SDL_Rect * rect);
729 
730 /**
731  * \brief Draw some number of rectangles on the current rendering target.
732  *
733  * \param renderer The renderer which should draw multiple rectangles.
734  * \param rects A pointer to an array of destination rectangles.
735  * \param count The number of rectangles.
736  *
737  * \return 0 on success, or -1 on error
738  */
740  const SDL_Rect * rects,
741  int count);
742 
743 /**
744  * \brief Fill a rectangle on the current rendering target with the drawing color.
745  *
746  * \param renderer The renderer which should fill a rectangle.
747  * \param rect A pointer to the destination rectangle, or NULL for the entire
748  * rendering target.
749  *
750  * \return 0 on success, or -1 on error
751  */
753  const SDL_Rect * rect);
754 
755 /**
756  * \brief Fill some number of rectangles on the current rendering target with the drawing color.
757  *
758  * \param renderer The renderer which should fill multiple rectangles.
759  * \param rects A pointer to an array of destination rectangles.
760  * \param count The number of rectangles.
761  *
762  * \return 0 on success, or -1 on error
763  */
765  const SDL_Rect * rects,
766  int count);
767 
768 /**
769  * \brief Copy a portion of the texture to the current rendering target.
770  *
771  * \param renderer The renderer which should copy parts of a texture.
772  * \param texture The source texture.
773  * \param srcrect A pointer to the source rectangle, or NULL for the entire
774  * texture.
775  * \param dstrect A pointer to the destination rectangle, or NULL for the
776  * entire rendering target.
777  *
778  * \return 0 on success, or -1 on error
779  */
782  const SDL_Rect * srcrect,
783  const SDL_Rect * dstrect);
784 
785 /**
786  * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
787  *
788  * \param renderer The renderer which should copy parts of a texture.
789  * \param texture The source texture.
790  * \param srcrect A pointer to the source rectangle, or NULL for the entire
791  * texture.
792  * \param dstrect A pointer to the destination rectangle, or NULL for the
793  * entire rendering target.
794  * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect
795  * \param 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).
796  * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture
797  *
798  * \return 0 on success, or -1 on error
799  */
802  const SDL_Rect * srcrect,
803  const SDL_Rect * dstrect,
804  const double angle,
805  const SDL_Point *center,
806  const SDL_RendererFlip flip);
807 
808 /**
809  * \brief Read pixels from the current rendering target.
810  *
811  * \param renderer The renderer from which pixels should be read.
812  * \param rect A pointer to the rectangle to read, or NULL for the entire
813  * render target.
814  * \param format The desired format of the pixel data, or 0 to use the format
815  * of the rendering target
816  * \param pixels A pointer to be filled in with the pixel data
817  * \param pitch The pitch of the pixels parameter.
818  *
819  * \return 0 on success, or -1 if pixel reading is not supported.
820  *
821  * \warning This is a very slow operation, and should not be used frequently.
822  */
824  const SDL_Rect * rect,
825  Uint32 format,
826  void *pixels, int pitch);
827 
828 /**
829  * \brief Update the screen with rendering performed.
830  */
832 
833 /**
834  * \brief Destroy the specified texture.
835  *
836  * \sa SDL_CreateTexture()
837  * \sa SDL_CreateTextureFromSurface()
838  */
840 
841 /**
842  * \brief Destroy the rendering context for a window and free associated
843  * textures.
844  *
845  * \sa SDL_CreateRenderer()
846  */
848 
849 
850 /**
851  * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with
852  * OpenGL instructions.
853  *
854  * \param texture The SDL texture to bind
855  * \param texw A pointer to a float that will be filled with the texture width
856  * \param texh A pointer to a float that will be filled with the texture height
857  *
858  * \return 0 on success, or -1 if the operation is not supported
859  */
860 extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
861 
862 /**
863  * \brief Unbind a texture from the current OpenGL/ES/ES2 context.
864  *
865  * \param texture The SDL texture to unbind
866  *
867  * \return 0 on success, or -1 if the operation is not supported
868  */
870 
871 
872 /* Ends C function definitions when using C++ */
873 #ifdef __cplusplus
874 }
875 #endif
876 #include "close_code.h"
877 
878 #endif /* _SDL_render_h */
879 
880 /* vi: set ts=4 sw=4 expandtab: */
int SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode)
Get the blend mode used for drawing operations.
Definition: SDL_render.c:1356
int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode)
Set the blend mode used for texture copy operations.
Definition: SDL_render.c:691
SDL_TextureModulate
The texture channel modulation used in SDL_RenderCopy().
Definition: SDL_render.h:101
SDL_Renderer * SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags)
Create a 2D rendering context for a window.
Definition: SDL_render.c:220
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
int SDL_RenderSetClipRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the clip rectangle for the current target.
Definition: SDL_render.c:1252
int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the drawing area for rendering on the current target.
Definition: SDL_render.c:1219
GLuint GLfloat GLfloat GLfloat x1
void SDL_RenderGetClipRect(SDL_Renderer *renderer, SDL_Rect *rect)
Get the clip rectangle for the current target.
Definition: SDL_render.c:1270
int SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *sw_64)
Get the additional alpha value used in render copy operations.
Definition: SDL_render.c:680
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
SDL_Rect rect
Definition: testrelative.c:27
SDL_Window * window
SDL_RendererFlags
Flags used when creating a rendering context.
Definition: SDL_render.h:64
GLenum GLenum GLuint texture
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
Definition: SDL_render.c:1239
GLfixed GLfixed GLfixed y2
The structure that defines a point.
Definition: SDL_rect.h:48
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
Uint32 texture_formats[16]
Definition: SDL_render.h:83
int SDL_RenderDrawPoint(SDL_Renderer *renderer, int x, int y)
Draw a point on the current rendering target.
Definition: SDL_render.c:1377
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...
Definition: SDL_render.c:1728
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
SDL_Renderer * SDL_CreateSoftwareRenderer(SDL_Surface *surface)
Create a 2D software rendering context for a surface.
Definition: SDL_render.c:317
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1565
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
Definition: SDL_render.c:81
SDL_Renderer * SDL_GetRenderer(SDL_Window *window)
Get the renderer associated with a window.
Definition: SDL_render.c:339
int SDL_RenderSetLogicalSize(SDL_Renderer *renderer, int w, int h)
Set device independent resolution for rendering.
Definition: SDL_render.c:1186
const char * name
Definition: SDL_render.h:80
int SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, SDL_Window **window, SDL_Renderer **renderer)
Create a window and default renderer.
Definition: SDL_render.c:200
int max_texture_height
Definition: SDL_render.h:85
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
GLfixed GLfixed x2
int SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
Set the blend mode used for drawing operations (Fill and Line).
Definition: SDL_render.c:1347
GLuint GLint GLboolean GLint GLenum access
GLfixed GLfixed GLint GLint GLfixed points
void SDL_RenderPresent(SDL_Renderer *renderer)
Update the screen with rendering performed.
Definition: SDL_render.c:1830
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).
Definition: SDL_render.c:1313
int SDL_GL_UnbindTexture(SDL_Texture *texture)
Unbind a texture from the current OpenGL/ES/ES2 context.
Definition: SDL_render.c:1914
GLfixed y1
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_bool
Definition: SDL_stdinc.h:126
GLboolean GLboolean g
int SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in render copy operations.
Definition: SDL_render.c:639
SDL_Renderer * renderer
int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 sw_64)
Set an additional alpha value used in render copy operations.
Definition: SDL_render.c:657
int SDL_RenderDrawLine(SDL_Renderer *renderer, int x1, int y1, int x2, int y2)
Draw a line on the current rendering target.
Definition: SDL_render.c:1454
int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL_render.c:803
#define DECLSPEC
Definition: SDL_internal.h:30
int SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
Read pixels from the current rendering target.
Definition: SDL_render.c:1793
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
SDL_bool SDL_RenderIsClipEnabled(SDL_Renderer *renderer)
Get whether clipping is enabled on the given renderer.
Definition: SDL_render.c:1283
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
int SDL_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect)
Copy a portion of the texture to the current rendering target.
Definition: SDL_render.c:1675
int SDL_GetRendererOutputSize(SDL_Renderer *renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
Definition: SDL_render.c:354
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed.
Definition: SDL_render.c:1035
void SDL_RenderGetScale(SDL_Renderer *renderer, float *scaleX, float *scaleY)
Get the drawing scale for the current target.
Definition: SDL_render.c:1300
SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer)
Determines whether a window supports the use of render targets.
Definition: SDL_render.c:1055
int SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_RendererInfo *info)
Get information about a rendering context.
Definition: SDL_render.c:345
void SDL_DestroyTexture(SDL_Texture *texture)
Destroy the specified texture.
Definition: SDL_render.c:1842
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).
Definition: SDL_render.c:1326
GLuint index
void SDL_RenderGetLogicalSize(SDL_Renderer *renderer, int *w, int *h)
Get device independent resolution for rendering.
Definition: SDL_render.c:1206
int SDL_RenderClear(SDL_Renderer *renderer)
Clear the current rendering target with the drawing color.
Definition: SDL_render.c:1365
SDL_RendererFlip
Flip constants for SDL_RenderCopyEx.
Definition: SDL_render.h:111
int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
Set a texture as the current rendering target.
Definition: SDL_render.c:1064
SDL_TextureAccess
The access pattern allowed for a texture.
Definition: SDL_render.h:91
int SDL_RenderSetScale(SDL_Renderer *renderer, float scaleX, float scaleY)
Set the drawing scale for rendering on the current target.
Definition: SDL_render.c:1290
int SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode)
Get the blend mode used for texture copy operations.
Definition: SDL_render.c:709
int SDL_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count)
Draw a series of connected lines on the current rendering target.
Definition: SDL_render.c:1522
int SDL_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count)
Draw multiple points on the current rendering target.
Definition: SDL_render.c:1413
Information on the capabilities of a render driver or context.
Definition: SDL_render.h:78
int SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count)
Fill some number of rectangles on the current rendering target with the drawing color.
Definition: SDL_render.c:1636
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
int SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Fill a rectangle on the current rendering target with the drawing color.
Definition: SDL_render.c:1619
SDL_Texture * SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
Create a texture from an existing surface.
Definition: SDL_render.c:505
int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh)
Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions.
Definition: SDL_render.c:1899
int SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in render copy operations.
Definition: SDL_render.c:614
The type used to identify a window.
Definition: SDL_sysvideo.h:71
SDL_Rect rects[MAX_RECTS]
int SDL_RenderDrawRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Draw a rectangle on the current rendering target.
Definition: SDL_render.c:1563
SDL_Texture * SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int h)
Create a texture for a rendering context.
Definition: SDL_render.c:411
int SDL_RenderDrawRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count)
Draw some number of rectangles on the current rendering target.
Definition: SDL_render.c:1592
GLfloat angle
Uint32 num_texture_formats
Definition: SDL_render.h:82
int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL_render.c:962
GLbitfield flags
GLfloat GLfloat GLfloat sw_64
GLubyte GLubyte GLubyte GLubyte w
int SDL_QueryTexture(SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h)
Query the attributes of a texture.
Definition: SDL_render.c:593
GLboolean GLboolean GLboolean GLboolean a
#define SDLCALL
Definition: SDL_internal.h:31
GLboolean GLboolean GLboolean b
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.
Definition: SDL_render.c:886
GLfloat GLfloat GLfloat GLfloat h
int SDL_GetRenderDriverInfo(int index, SDL_RendererInfo *info)
Get information about a specific 2D rendering driver for the current display.
Definition: SDL_render.c:91
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_Texture * SDL_GetRenderTarget(SDL_Renderer *renderer)
Get the current render target or NULL for the default render target.
Definition: SDL_render.c:1133
void SDL_DestroyRenderer(SDL_Renderer *renderer)
Destroy the rendering context for a window and free associated textures.
Definition: SDL_render.c:1877