Wiki Page Content

Differences between revisions 6 and 7
Revision 6 as of 2011-02-15 19:34:06
Size: 1474
Editor: SheenaSmith
Comment: update content - 2/14 changeset 5295 (as of 5145); moved to render.h
Revision 7 as of 2011-02-16 23:10:30
Size: 1564
Editor: SheenaSmith
Comment: update content - 2/16 changeset 5318 (as of 5147)
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
int SDL_RenderClear(void) int SDL_RenderClear(SDL_Renderer* renderer)
Line 13: Line 13:

== Function Parameters ==
||'''renderer'''||the rendering context||

SDL_RenderClear

Use this function to clear the current rendering target with the drawing color.

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/SDL.h>

int main(int argc, char** argv)
{
        // Initialize SDL.
        if (SDL_Init(SDL_INIT_VIDEO) < 0)
                return 1;
        
        // Create the window were we will draw.
        SDL_Window* window = 
                SDL_CreateWindow("SDL_RenderClear",
                SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                512, 512,
                SDL_WINDOW_SHOWN);
        
        // We must call SDL_CreateRenderer in order for draw calls to affect this window.
        SDL_CreateRenderer(window, -1, 0);
        
        // Select the color for drawing. It is set to red here.
        SDL_SetRenderDrawColor(255, 0, 0, 0);
        
        // Clear the entire screen to our selected color.
        SDL_RenderClear();
        
        // Up until now everything was drawn behind the scenes.
        // This will show the new, red contents of the window.
        SDL_RenderPresent();
        
        // Give us time to see the window.
        SDL_Delay(5000);
        
        // Always be sure to clean up
        SDL_Quit();
        return 0;
}

Remarks

You can add useful comments here


CategoryAPI, CategoryRender

None: SDL_RenderClear (last edited 2016-10-08 22:48:20 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit