Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SDL_render.h
00001 /* 00002 Simple DirectMedia Layer 00003 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any damages 00007 arising from the use of this software. 00008 00009 Permission is granted to anyone to use this software for any purpose, 00010 including commercial applications, and to alter it and redistribute it 00011 freely, subject to the following restrictions: 00012 00013 1. The origin of this software must not be misrepresented; you must not 00014 claim that you wrote the original software. If you use this software 00015 in a product, an acknowledgment in the product documentation would be 00016 appreciated but is not required. 00017 2. Altered source versions must be plainly marked as such, and must not be 00018 misrepresented as being the original software. 00019 3. This notice may not be removed or altered from any source distribution. 00020 */ 00021 00022 /** 00023 * \file SDL_render.h 00024 * 00025 * Header file for SDL 2D rendering functions. 00026 * 00027 * This API supports the following features: 00028 * * single pixel points 00029 * * single pixel lines 00030 * * filled rectangles 00031 * * texture images 00032 * 00033 * The primitives may be drawn in opaque, blended, or additive modes. 00034 * 00035 * The texture images may be drawn in opaque, blended, or additive modes. 00036 * They can have an additional color tint or alpha modulation applied to 00037 * them, and may also be stretched with linear interpolation. 00038 * 00039 * This API is designed to accelerate simple 2D operations. You may 00040 * want more functionality such as polygons and particle effects and 00041 * in that case you should use SDL's OpenGL/Direct3D support or one 00042 * of the many good 3D engines. 00043 * 00044 * These functions must be called from the main thread. 00045 * See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995 00046 */ 00047 00048 #ifndef _SDL_render_h 00049 #define _SDL_render_h 00050 00051 #include "SDL_stdinc.h" 00052 #include "SDL_rect.h" 00053 #include "SDL_video.h" 00054 00055 #include "begin_code.h" 00056 /* Set up for C function definitions, even when using C++ */ 00057 #ifdef __cplusplus 00058 extern "C" { 00059 #endif 00060 00061 /** 00062 * \brief Flags used when creating a rendering context 00063 */ 00064 typedef enum 00065 { 00066 SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ 00067 SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware 00068 acceleration */ 00069 SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized 00070 with the refresh rate */ 00071 SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports 00072 rendering to texture */ 00073 } SDL_RendererFlags; 00074 00075 /** 00076 * \brief Information on the capabilities of a render driver or context. 00077 */ 00078 typedef struct SDL_RendererInfo 00079 { 00080 const char *name; /**< The name of the renderer */ 00081 Uint32 flags; /**< Supported ::SDL_RendererFlags */ 00082 Uint32 num_texture_formats; /**< The number of available texture formats */ 00083 Uint32 texture_formats[16]; /**< The available texture formats */ 00084 int max_texture_width; /**< The maximimum texture width */ 00085 int max_texture_height; /**< The maximimum texture height */ 00086 } SDL_RendererInfo; 00087 00088 /** 00089 * \brief The access pattern allowed for a texture. 00090 */ 00091 typedef enum 00092 { 00093 SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ 00094 SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ 00095 SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ 00096 } SDL_TextureAccess; 00097 00098 /** 00099 * \brief The texture channel modulation used in SDL_RenderCopy(). 00100 */ 00101 typedef enum 00102 { 00103 SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ 00104 SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ 00105 SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ 00106 } SDL_TextureModulate; 00107 00108 /** 00109 * \brief Flip constants for SDL_RenderCopyEx 00110 */ 00111 typedef enum 00112 { 00113 SDL_FLIP_NONE = 0x00000000, /**< Do not flip */ 00114 SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */ 00115 SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */ 00116 } SDL_RendererFlip; 00117 00118 /** 00119 * \brief A structure representing rendering state 00120 */ 00121 struct SDL_Renderer; 00122 typedef struct SDL_Renderer SDL_Renderer; 00123 00124 /** 00125 * \brief An efficient driver-specific representation of pixel data 00126 */ 00127 struct SDL_Texture; 00128 typedef struct SDL_Texture SDL_Texture; 00129 00130 00131 /* Function prototypes */ 00132 00133 /** 00134 * \brief Get the number of 2D rendering drivers available for the current 00135 * display. 00136 * 00137 * A render driver is a set of code that handles rendering and texture 00138 * management on a particular display. Normally there is only one, but 00139 * some drivers may have several available with different capabilities. 00140 * 00141 * \sa SDL_GetRenderDriverInfo() 00142 * \sa SDL_CreateRenderer() 00143 */ 00144 extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); 00145 00146 /** 00147 * \brief Get information about a specific 2D rendering driver for the current 00148 * display. 00149 * 00150 * \param index The index of the driver to query information about. 00151 * \param info A pointer to an SDL_RendererInfo struct to be filled with 00152 * information on the rendering driver. 00153 * 00154 * \return 0 on success, -1 if the index was out of range. 00155 * 00156 * \sa SDL_CreateRenderer() 00157 */ 00158 extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, 00159 SDL_RendererInfo * info); 00160 00161 /** 00162 * \brief Create a window and default renderer 00163 * 00164 * \param width The width of the window 00165 * \param height The height of the window 00166 * \param window_flags The flags used to create the window 00167 * \param window A pointer filled with the window, or NULL on error 00168 * \param renderer A pointer filled with the renderer, or NULL on error 00169 * 00170 * \return 0 on success, or -1 on error 00171 */ 00172 extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( 00173 int width, int height, Uint32 window_flags, 00174 SDL_Window **window, SDL_Renderer **renderer); 00175 00176 00177 /** 00178 * \brief Create a 2D rendering context for a window. 00179 * 00180 * \param window The window where rendering is displayed. 00181 * \param index The index of the rendering driver to initialize, or -1 to 00182 * initialize the first one supporting the requested flags. 00183 * \param flags ::SDL_RendererFlags. 00184 * 00185 * \return A valid rendering context or NULL if there was an error. 00186 * 00187 * \sa SDL_CreateSoftwareRenderer() 00188 * \sa SDL_GetRendererInfo() 00189 * \sa SDL_DestroyRenderer() 00190 */ 00191 extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, 00192 int index, Uint32 flags); 00193 00194 /** 00195 * \brief Create a 2D software rendering context for a surface. 00196 * 00197 * \param surface The surface where rendering is done. 00198 * 00199 * \return A valid rendering context or NULL if there was an error. 00200 * 00201 * \sa SDL_CreateRenderer() 00202 * \sa SDL_DestroyRenderer() 00203 */ 00204 extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); 00205 00206 /** 00207 * \brief Get the renderer associated with a window. 00208 */ 00209 extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); 00210 00211 /** 00212 * \brief Get information about a rendering context. 00213 */ 00214 extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, 00215 SDL_RendererInfo * info); 00216 00217 /** 00218 * \brief Get the output size of a rendering context. 00219 */ 00220 extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer, 00221 int *w, int *h); 00222 00223 /** 00224 * \brief Create a texture for a rendering context. 00225 * 00226 * \param renderer The renderer. 00227 * \param format The format of the texture. 00228 * \param access One of the enumerated values in ::SDL_TextureAccess. 00229 * \param w The width of the texture in pixels. 00230 * \param h The height of the texture in pixels. 00231 * 00232 * \return The created texture is returned, or 0 if no rendering context was 00233 * active, the format was unsupported, or the width or height were out 00234 * of range. 00235 * 00236 * \sa SDL_QueryTexture() 00237 * \sa SDL_UpdateTexture() 00238 * \sa SDL_DestroyTexture() 00239 */ 00240 extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, 00241 Uint32 format, 00242 int access, int w, 00243 int h); 00244 00245 /** 00246 * \brief Create a texture from an existing surface. 00247 * 00248 * \param renderer The renderer. 00249 * \param surface The surface containing pixel data used to fill the texture. 00250 * 00251 * \return The created texture is returned, or 0 on error. 00252 * 00253 * \note The surface is not modified or freed by this function. 00254 * 00255 * \sa SDL_QueryTexture() 00256 * \sa SDL_DestroyTexture() 00257 */ 00258 extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); 00259 00260 /** 00261 * \brief Query the attributes of a texture 00262 * 00263 * \param texture A texture to be queried. 00264 * \param format A pointer filled in with the raw format of the texture. The 00265 * actual format may differ, but pixel transfers will use this 00266 * format. 00267 * \param access A pointer filled in with the actual access to the texture. 00268 * \param w A pointer filled in with the width of the texture in pixels. 00269 * \param h A pointer filled in with the height of the texture in pixels. 00270 * 00271 * \return 0 on success, or -1 if the texture is not valid. 00272 */ 00273 extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, 00274 Uint32 * format, int *access, 00275 int *w, int *h); 00276 00277 /** 00278 * \brief Set an additional color value used in render copy operations. 00279 * 00280 * \param texture The texture to update. 00281 * \param r The red color value multiplied into copy operations. 00282 * \param g The green color value multiplied into copy operations. 00283 * \param b The blue color value multiplied into copy operations. 00284 * 00285 * \return 0 on success, or -1 if the texture is not valid or color modulation 00286 * is not supported. 00287 * 00288 * \sa SDL_GetTextureColorMod() 00289 */ 00290 extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, 00291 Uint8 r, Uint8 g, Uint8 b); 00292 00293 00294 /** 00295 * \brief Get the additional color value used in render copy operations. 00296 * 00297 * \param texture The texture to query. 00298 * \param r A pointer filled in with the current red color value. 00299 * \param g A pointer filled in with the current green color value. 00300 * \param b A pointer filled in with the current blue color value. 00301 * 00302 * \return 0 on success, or -1 if the texture is not valid. 00303 * 00304 * \sa SDL_SetTextureColorMod() 00305 */ 00306 extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, 00307 Uint8 * r, Uint8 * g, 00308 Uint8 * b); 00309 00310 /** 00311 * \brief Set an additional alpha value used in render copy operations. 00312 * 00313 * \param texture The texture to update. 00314 * \param alpha The alpha value multiplied into copy operations. 00315 * 00316 * \return 0 on success, or -1 if the texture is not valid or alpha modulation 00317 * is not supported. 00318 * 00319 * \sa SDL_GetTextureAlphaMod() 00320 */ 00321 extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, 00322 Uint8 alpha); 00323 00324 /** 00325 * \brief Get the additional alpha value used in render copy operations. 00326 * 00327 * \param texture The texture to query. 00328 * \param alpha A pointer filled in with the current alpha value. 00329 * 00330 * \return 0 on success, or -1 if the texture is not valid. 00331 * 00332 * \sa SDL_SetTextureAlphaMod() 00333 */ 00334 extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, 00335 Uint8 * alpha); 00336 00337 /** 00338 * \brief Set the blend mode used for texture copy operations. 00339 * 00340 * \param texture The texture to update. 00341 * \param blendMode ::SDL_BlendMode to use for texture blending. 00342 * 00343 * \return 0 on success, or -1 if the texture is not valid or the blend mode is 00344 * not supported. 00345 * 00346 * \note If the blend mode is not supported, the closest supported mode is 00347 * chosen. 00348 * 00349 * \sa SDL_GetTextureBlendMode() 00350 */ 00351 extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, 00352 SDL_BlendMode blendMode); 00353 00354 /** 00355 * \brief Get the blend mode used for texture copy operations. 00356 * 00357 * \param texture The texture to query. 00358 * \param blendMode A pointer filled in with the current blend mode. 00359 * 00360 * \return 0 on success, or -1 if the texture is not valid. 00361 * 00362 * \sa SDL_SetTextureBlendMode() 00363 */ 00364 extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, 00365 SDL_BlendMode *blendMode); 00366 00367 /** 00368 * \brief Update the given texture rectangle with new pixel data. 00369 * 00370 * \param texture The texture to update 00371 * \param rect A pointer to the rectangle of pixels to update, or NULL to 00372 * update the entire texture. 00373 * \param pixels The raw pixel data. 00374 * \param pitch The number of bytes between rows of pixel data. 00375 * 00376 * \return 0 on success, or -1 if the texture is not valid. 00377 * 00378 * \note This is a fairly slow function. 00379 */ 00380 extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, 00381 const SDL_Rect * rect, 00382 const void *pixels, int pitch); 00383 00384 /** 00385 * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. 00386 * 00387 * \param texture The texture to update 00388 * \param rect A pointer to the rectangle of pixels to update, or NULL to 00389 * update the entire texture. 00390 * \param Yplane The raw pixel data for the Y plane. 00391 * \param Ypitch The number of bytes between rows of pixel data for the Y plane. 00392 * \param Uplane The raw pixel data for the U plane. 00393 * \param Upitch The number of bytes between rows of pixel data for the U plane. 00394 * \param Vplane The raw pixel data for the V plane. 00395 * \param Vpitch The number of bytes between rows of pixel data for the V plane. 00396 * 00397 * \return 0 on success, or -1 if the texture is not valid. 00398 * 00399 * \note You can use SDL_UpdateTexture() as long as your pixel data is 00400 * a contiguous block of Y and U/V planes in the proper order, but 00401 * this function is available if your pixel data is not contiguous. 00402 */ 00403 extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, 00404 const SDL_Rect * rect, 00405 const Uint8 *Yplane, int Ypitch, 00406 const Uint8 *Uplane, int Upitch, 00407 const Uint8 *Vplane, int Vpitch); 00408 00409 /** 00410 * \brief Lock a portion of the texture for write-only pixel access. 00411 * 00412 * \param texture The texture to lock for access, which was created with 00413 * ::SDL_TEXTUREACCESS_STREAMING. 00414 * \param rect A pointer to the rectangle to lock for access. If the rect 00415 * is NULL, the entire texture will be locked. 00416 * \param pixels This is filled in with a pointer to the locked pixels, 00417 * appropriately offset by the locked area. 00418 * \param pitch This is filled in with the pitch of the locked pixels. 00419 * 00420 * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. 00421 * 00422 * \sa SDL_UnlockTexture() 00423 */ 00424 extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, 00425 const SDL_Rect * rect, 00426 void **pixels, int *pitch); 00427 00428 /** 00429 * \brief Unlock a texture, uploading the changes to video memory, if needed. 00430 * 00431 * \sa SDL_LockTexture() 00432 */ 00433 extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); 00434 00435 /** 00436 * \brief Determines whether a window supports the use of render targets 00437 * 00438 * \param renderer The renderer that will be checked 00439 * 00440 * \return SDL_TRUE if supported, SDL_FALSE if not. 00441 */ 00442 extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer); 00443 00444 /** 00445 * \brief Set a texture as the current rendering target. 00446 * 00447 * \param renderer The renderer. 00448 * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target 00449 * 00450 * \return 0 on success, or -1 on error 00451 * 00452 * \sa SDL_GetRenderTarget() 00453 */ 00454 extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, 00455 SDL_Texture *texture); 00456 00457 /** 00458 * \brief Get the current render target or NULL for the default render target. 00459 * 00460 * \return The current render target 00461 * 00462 * \sa SDL_SetRenderTarget() 00463 */ 00464 extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); 00465 00466 /** 00467 * \brief Set device independent resolution for rendering 00468 * 00469 * \param renderer The renderer for which resolution should be set. 00470 * \param w The width of the logical resolution 00471 * \param h The height of the logical resolution 00472 * 00473 * This function uses the viewport and scaling functionality to allow a fixed logical 00474 * resolution for rendering, regardless of the actual output resolution. If the actual 00475 * output resolution doesn't have the same aspect ratio the output rendering will be 00476 * centered within the output display. 00477 * 00478 * If the output display is a window, mouse events in the window will be filtered 00479 * and scaled so they seem to arrive within the logical resolution. 00480 * 00481 * \note If this function results in scaling or subpixel drawing by the 00482 * rendering backend, it will be handled using the appropriate 00483 * quality hints. 00484 * 00485 * \sa SDL_RenderGetLogicalSize() 00486 * \sa SDL_RenderSetScale() 00487 * \sa SDL_RenderSetViewport() 00488 */ 00489 extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h); 00490 00491 /** 00492 * \brief Get device independent resolution for rendering 00493 * 00494 * \param renderer The renderer from which resolution should be queried. 00495 * \param w A pointer filled with the width of the logical resolution 00496 * \param h A pointer filled with the height of the logical resolution 00497 * 00498 * \sa SDL_RenderSetLogicalSize() 00499 */ 00500 extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h); 00501 00502 /** 00503 * \brief Set the drawing area for rendering on the current target. 00504 * 00505 * \param renderer The renderer for which the drawing area should be set. 00506 * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target. 00507 * 00508 * The x,y of the viewport rect represents the origin for rendering. 00509 * 00510 * \return 0 on success, or -1 on error 00511 * 00512 * \note If the window associated with the renderer is resized, the viewport is automatically reset. 00513 * 00514 * \sa SDL_RenderGetViewport() 00515 * \sa SDL_RenderSetLogicalSize() 00516 */ 00517 extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, 00518 const SDL_Rect * rect); 00519 00520 /** 00521 * \brief Get the drawing area for the current target. 00522 * 00523 * \sa SDL_RenderSetViewport() 00524 */ 00525 extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, 00526 SDL_Rect * rect); 00527 00528 /** 00529 * \brief Set the clip rectangle for the current target. 00530 * 00531 * \param renderer The renderer for which clip rectangle should be set. 00532 * \param rect A pointer to the rectangle to set as the clip rectangle, or 00533 * NULL to disable clipping. 00534 * 00535 * \return 0 on success, or -1 on error 00536 * 00537 * \sa SDL_RenderGetClipRect() 00538 */ 00539 extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, 00540 const SDL_Rect * rect); 00541 00542 /** 00543 * \brief Get the clip rectangle for the current target. 00544 * 00545 * \param renderer The renderer from which clip rectangle should be queried. 00546 * \param rect A pointer filled in with the current clip rectangle, or 00547 * an empty rectangle if clipping is disabled. 00548 * 00549 * \sa SDL_RenderSetClipRect() 00550 */ 00551 extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, 00552 SDL_Rect * rect); 00553 00554 /** 00555 * \brief Set the drawing scale for rendering on the current target. 00556 * 00557 * \param renderer The renderer for which the drawing scale should be set. 00558 * \param scaleX The horizontal scaling factor 00559 * \param scaleY The vertical scaling factor 00560 * 00561 * The drawing coordinates are scaled by the x/y scaling factors 00562 * before they are used by the renderer. This allows resolution 00563 * independent drawing with a single coordinate system. 00564 * 00565 * \note If this results in scaling or subpixel drawing by the 00566 * rendering backend, it will be handled using the appropriate 00567 * quality hints. For best results use integer scaling factors. 00568 * 00569 * \sa SDL_RenderGetScale() 00570 * \sa SDL_RenderSetLogicalSize() 00571 */ 00572 extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer, 00573 float scaleX, float scaleY); 00574 00575 /** 00576 * \brief Get the drawing scale for the current target. 00577 * 00578 * \param renderer The renderer from which drawing scale should be queried. 00579 * \param scaleX A pointer filled in with the horizontal scaling factor 00580 * \param scaleY A pointer filled in with the vertical scaling factor 00581 * 00582 * \sa SDL_RenderSetScale() 00583 */ 00584 extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, 00585 float *scaleX, float *scaleY); 00586 00587 /** 00588 * \brief Set the color used for drawing operations (Rect, Line and Clear). 00589 * 00590 * \param renderer The renderer for which drawing color should be set. 00591 * \param r The red value used to draw on the rendering target. 00592 * \param g The green value used to draw on the rendering target. 00593 * \param b The blue value used to draw on the rendering target. 00594 * \param a The alpha value used to draw on the rendering target, usually 00595 * ::SDL_ALPHA_OPAQUE (255). 00596 * 00597 * \return 0 on success, or -1 on error 00598 */ 00599 extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer, 00600 Uint8 r, Uint8 g, Uint8 b, 00601 Uint8 a); 00602 00603 /** 00604 * \brief Get the color used for drawing operations (Rect, Line and Clear). 00605 * 00606 * \param renderer The renderer from which drawing color should be queried. 00607 * \param r A pointer to the red value used to draw on the rendering target. 00608 * \param g A pointer to the green value used to draw on the rendering target. 00609 * \param b A pointer to the blue value used to draw on the rendering target. 00610 * \param a A pointer to the alpha value used to draw on the rendering target, 00611 * usually ::SDL_ALPHA_OPAQUE (255). 00612 * 00613 * \return 0 on success, or -1 on error 00614 */ 00615 extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer, 00616 Uint8 * r, Uint8 * g, Uint8 * b, 00617 Uint8 * a); 00618 00619 /** 00620 * \brief Set the blend mode used for drawing operations (Fill and Line). 00621 * 00622 * \param renderer The renderer for which blend mode should be set. 00623 * \param blendMode ::SDL_BlendMode to use for blending. 00624 * 00625 * \return 0 on success, or -1 on error 00626 * 00627 * \note If the blend mode is not supported, the closest supported mode is 00628 * chosen. 00629 * 00630 * \sa SDL_GetRenderDrawBlendMode() 00631 */ 00632 extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, 00633 SDL_BlendMode blendMode); 00634 00635 /** 00636 * \brief Get the blend mode used for drawing operations. 00637 * 00638 * \param renderer The renderer from which blend mode should be queried. 00639 * \param blendMode A pointer filled in with the current blend mode. 00640 * 00641 * \return 0 on success, or -1 on error 00642 * 00643 * \sa SDL_SetRenderDrawBlendMode() 00644 */ 00645 extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, 00646 SDL_BlendMode *blendMode); 00647 00648 /** 00649 * \brief Clear the current rendering target with the drawing color 00650 * 00651 * This function clears the entire rendering target, ignoring the viewport. 00652 * 00653 * \return 0 on success, or -1 on error 00654 */ 00655 extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); 00656 00657 /** 00658 * \brief Draw a point on the current rendering target. 00659 * 00660 * \param renderer The renderer which should draw a point. 00661 * \param x The x coordinate of the point. 00662 * \param y The y coordinate of the point. 00663 * 00664 * \return 0 on success, or -1 on error 00665 */ 00666 extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, 00667 int x, int y); 00668 00669 /** 00670 * \brief Draw multiple points on the current rendering target. 00671 * 00672 * \param renderer The renderer which should draw multiple points. 00673 * \param points The points to draw 00674 * \param count The number of points to draw 00675 * 00676 * \return 0 on success, or -1 on error 00677 */ 00678 extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, 00679 const SDL_Point * points, 00680 int count); 00681 00682 /** 00683 * \brief Draw a line on the current rendering target. 00684 * 00685 * \param renderer The renderer which should draw a line. 00686 * \param x1 The x coordinate of the start point. 00687 * \param y1 The y coordinate of the start point. 00688 * \param x2 The x coordinate of the end point. 00689 * \param y2 The y coordinate of the end point. 00690 * 00691 * \return 0 on success, or -1 on error 00692 */ 00693 extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, 00694 int x1, int y1, int x2, int y2); 00695 00696 /** 00697 * \brief Draw a series of connected lines on the current rendering target. 00698 * 00699 * \param renderer The renderer which should draw multiple lines. 00700 * \param points The points along the lines 00701 * \param count The number of points, drawing count-1 lines 00702 * 00703 * \return 0 on success, or -1 on error 00704 */ 00705 extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, 00706 const SDL_Point * points, 00707 int count); 00708 00709 /** 00710 * \brief Draw a rectangle on the current rendering target. 00711 * 00712 * \param renderer The renderer which should draw a rectangle. 00713 * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. 00714 * 00715 * \return 0 on success, or -1 on error 00716 */ 00717 extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, 00718 const SDL_Rect * rect); 00719 00720 /** 00721 * \brief Draw some number of rectangles on the current rendering target. 00722 * 00723 * \param renderer The renderer which should draw multiple rectangles. 00724 * \param rects A pointer to an array of destination rectangles. 00725 * \param count The number of rectangles. 00726 * 00727 * \return 0 on success, or -1 on error 00728 */ 00729 extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, 00730 const SDL_Rect * rects, 00731 int count); 00732 00733 /** 00734 * \brief Fill a rectangle on the current rendering target with the drawing color. 00735 * 00736 * \param renderer The renderer which should fill a rectangle. 00737 * \param rect A pointer to the destination rectangle, or NULL for the entire 00738 * rendering target. 00739 * 00740 * \return 0 on success, or -1 on error 00741 */ 00742 extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, 00743 const SDL_Rect * rect); 00744 00745 /** 00746 * \brief Fill some number of rectangles on the current rendering target with the drawing color. 00747 * 00748 * \param renderer The renderer which should fill multiple rectangles. 00749 * \param rects A pointer to an array of destination rectangles. 00750 * \param count The number of rectangles. 00751 * 00752 * \return 0 on success, or -1 on error 00753 */ 00754 extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, 00755 const SDL_Rect * rects, 00756 int count); 00757 00758 /** 00759 * \brief Copy a portion of the texture to the current rendering target. 00760 * 00761 * \param renderer The renderer which should copy parts of a texture. 00762 * \param texture The source texture. 00763 * \param srcrect A pointer to the source rectangle, or NULL for the entire 00764 * texture. 00765 * \param dstrect A pointer to the destination rectangle, or NULL for the 00766 * entire rendering target. 00767 * 00768 * \return 0 on success, or -1 on error 00769 */ 00770 extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, 00771 SDL_Texture * texture, 00772 const SDL_Rect * srcrect, 00773 const SDL_Rect * dstrect); 00774 00775 /** 00776 * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center 00777 * 00778 * \param renderer The renderer which should copy parts of a texture. 00779 * \param texture The source texture. 00780 * \param srcrect A pointer to the source rectangle, or NULL for the entire 00781 * texture. 00782 * \param dstrect A pointer to the destination rectangle, or NULL for the 00783 * entire rendering target. 00784 * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect 00785 * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2) 00786 * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture 00787 * 00788 * \return 0 on success, or -1 on error 00789 */ 00790 extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, 00791 SDL_Texture * texture, 00792 const SDL_Rect * srcrect, 00793 const SDL_Rect * dstrect, 00794 const double angle, 00795 const SDL_Point *center, 00796 const SDL_RendererFlip flip); 00797 00798 /** 00799 * \brief Read pixels from the current rendering target. 00800 * 00801 * \param renderer The renderer from which pixels should be read. 00802 * \param rect A pointer to the rectangle to read, or NULL for the entire 00803 * render target. 00804 * \param format The desired format of the pixel data, or 0 to use the format 00805 * of the rendering target 00806 * \param pixels A pointer to be filled in with the pixel data 00807 * \param pitch The pitch of the pixels parameter. 00808 * 00809 * \return 0 on success, or -1 if pixel reading is not supported. 00810 * 00811 * \warning This is a very slow operation, and should not be used frequently. 00812 */ 00813 extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, 00814 const SDL_Rect * rect, 00815 Uint32 format, 00816 void *pixels, int pitch); 00817 00818 /** 00819 * \brief Update the screen with rendering performed. 00820 */ 00821 extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); 00822 00823 /** 00824 * \brief Destroy the specified texture. 00825 * 00826 * \sa SDL_CreateTexture() 00827 * \sa SDL_CreateTextureFromSurface() 00828 */ 00829 extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); 00830 00831 /** 00832 * \brief Destroy the rendering context for a window and free associated 00833 * textures. 00834 * 00835 * \sa SDL_CreateRenderer() 00836 */ 00837 extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); 00838 00839 00840 /** 00841 * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with 00842 * OpenGL instructions. 00843 * 00844 * \param texture The SDL texture to bind 00845 * \param texw A pointer to a float that will be filled with the texture width 00846 * \param texh A pointer to a float that will be filled with the texture height 00847 * 00848 * \return 0 on success, or -1 if the operation is not supported 00849 */ 00850 extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh); 00851 00852 /** 00853 * \brief Unbind a texture from the current OpenGL/ES/ES2 context. 00854 * 00855 * \param texture The SDL texture to unbind 00856 * 00857 * \return 0 on success, or -1 if the operation is not supported 00858 */ 00859 extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); 00860 00861 00862 /* Ends C function definitions when using C++ */ 00863 #ifdef __cplusplus 00864 } 00865 #endif 00866 #include "close_code.h" 00867 00868 #endif /* _SDL_render_h */ 00869 00870 /* vi: set ts=4 sw=4 expandtab: */
Generated on Tue Jul 12 2022 13:56:25 by
