|
Size: 1954
Comment: Updated with content from header file.
|
← Revision 14 as of 2016-10-08 22:48:20 ⇥
Size: 1982
Comment: Changed line comments to block comments in example.
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 29: | Line 29: |
| // Initialize SDL. | /* Initialize SDL. */ |
| Line 33: | Line 33: |
| // Create the window where we will draw. | /* Create the window where we will draw. */ |
| Line 39: | Line 39: |
| // We must call SDL_CreateRenderer in order for draw calls to affect this window. | /* We must call SDL_CreateRenderer in order for draw calls to affect this window. */ |
| Line 42: | Line 42: |
| // Select the color for drawing. It is set to red here. | /* Select the color for drawing. It is set to red here. */ |
| Line 45: | Line 45: |
| // Clear the entire screen to our selected color. | /* Clear the entire screen to our selected color. */ |
| Line 48: | Line 48: |
| // Up until now everything was drawn behind the scenes. // This will show the new, red contents of the window. |
/* Up until now everything was drawn behind the scenes. This will show the new, red contents of the window. */ |
| Line 52: | Line 52: |
| // Give us time to see the window. | /* Give us time to see the window. */ |
| Line 55: | Line 55: |
| // Always be sure to clean up | /* Always be sure to clean up */ |
| Line 64: | Line 64: |
| Line 66: | Line 67: |
SDL_RenderClear
Use this function to clear the current rendering target with the drawing color.
Contents
Syntax
int SDL_RenderClear(SDL_Renderer* renderer)
Function Parameters
renderer |
the rendering context |
Return Value
Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.
Code Examples
#include "SDL.h"
int main(int argc, char* argv[])
{
SDL_Window* window;
SDL_Renderer* renderer;
/* Initialize SDL. */
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return 1;
/* Create the window where we will draw. */
window = SDL_CreateWindow("SDL_RenderClear",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
512, 512,
0);
/* We must call SDL_CreateRenderer in order for draw calls to affect this window. */
renderer = SDL_CreateRenderer(window, -1, 0);
/* Select the color for drawing. It is set to red here. */
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
/* Clear the entire screen to our selected color. */
SDL_RenderClear(renderer);
/* Up until now everything was drawn behind the scenes.
This will show the new, red contents of the window. */
SDL_RenderPresent(renderer);
/* Give us time to see the window. */
SDL_Delay(5000);
/* Always be sure to clean up */
SDL_Quit();
return 0;
}
Remarks
This function clears the entire rendering target, ignoring the viewport and the clip rectangle.
Version
This function is available since SDL 2.0.0.
