Wiki Page Content


Use this function to update the screen with any rendering performed since the previous call.


void SDL_RenderPresent(SDL_Renderer* renderer)

Function Parameters


the rendering context

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",
                        512, 512,

        /* 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. */

        /* Up until now everything was drawn behind the scenes.
           This will show the new, red contents of the window. */

        /* Give us time to see the window. */

        /* Always be sure to clean up */
        return 0;


SDL's rendering functions operate on a backbuffer; that is, calling a rendering function such as SDL_RenderDrawLine() does not directly put a line on the screen, but rather updates the backbuffer. As such, you compose your entire scene and present the composed backbuffer to the screen as a complete picture.

Therefore, when using SDL's rendering API, one does all drawing intended for the frame, and then calls this function once per frame to present the final drawing to the user.

The backbuffer should be considered invalidated after each present; do not assume that previous contents will exist between frames. You are strongly encouraged to call SDL_RenderClear() to initialize the backbuffer before starting each new frame's drawing, even if you plan to overwrite every pixel.

CategoryAPI, CategoryRender

None: SDL_RenderPresent (last edited 2015-02-19 20:26:23 by PhilippWiesemann)

Please include your contact information if you'd like to receive a reply.