SDL2 renderer is giving me problems
<p>I'm following <a href="http://lazyfoo.net/tutorials/SDL/index.php" rel="nofollow">this tutorial</a> that teaches how to use SDL2 with the final goal of learning C++ in a more fun and interactive way.</p>

<p>For this, I only need to be able to draw lines, polygons and circles.</p>

<p>So, after reading part 1 that explains how to create a window on the screen and part 3 that introduces event handling, I headed torward part 7 and 8 that explain, respectively, how to create a renderer and how to draw a rectangle on the screen. This is the code I've got so far (it isn't exactly the same as the code on the tutorial: I've introduced a struct to pass SDL objects around and removed all the error handling which was confusing):</p>

<pre><code>#include &lt;SDL2/SDL.h&gt;

//screen dimensions costants
#define SCREEN_WIDTH 540
#define SCREEN_HEIGHT 960

//data structure holding the objects needed to create a window and draw on it
struct interface {
    SDL_Window * window = NULL;
    SDL_Surface * surface = NULL;
    SDL_Renderer * renderer = NULL;
};

//function which inits the sdl and creates an interface object
interface init() {
    interface screen;
    SDL_Init(SDL_INIT_VIDEO);
    screen.window = SDL_CreateWindow("", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
    screen.surface = SDL_GetWindowSurface(screen.window);
    screen.renderer = SDL_CreateRenderer(screen.window, -1, SDL_RENDERER_ACCELERATED);
    return screen;
}

//function to free the memory and close the sdl application
void close(interface screen) {
    SDL_DestroyRenderer(screen.renderer);
    SDL_DestroyWindow(screen.window);
    screen.renderer = NULL;
    screen.window = NULL;
    SDL_Quit();
}

int main(int argc, char* args[]) {

    //start the application
    interface screen = init();

    //setup for event handling
    bool quit = false;
    SDL_Event event;

    //the shape to render
    SDL_Rect fillRect = { SCREEN_WIDTH / 4, SCREEN_HEIGHT / 4, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 };

    //main loop which first handles events
    while (!quit) {
        while (SDL_PollEvent(&amp;event) != 0) {
            if (event.type == SDL_QUIT)
                quit = true;
        }
        //should draw a red rectangle on the screen
        SDL_SetRenderDrawColor(screen.renderer, 0xFF, 0xFF, 0xFF, 0xFF);
        SDL_RenderClear(screen.renderer);
        SDL_SetRenderDrawColor(screen.renderer, 0xFF, 0x00, 0x00, 0xFF);
        SDL_RenderFillRect(screen.renderer, &amp;fillRect);
    }

    //End the application
    close(screen);
    return 0;
}
</code></pre>

<p>The problem is that, as it is, the program draws nothing to the screen (which remains black), and if I remove the line <code>screen.surface = SDL_GetWindowSurface(screen.window);</code> it also begins lagging a lot in a manner I even find difficult to exit the application.</p>

<p>Note that I'm programming on Android using C4droid and the SDL Plugin for C4droid.</p>

<p>Why is that happening? What am I doing wrong?</p>

<p><strong>EDIT</strong> Problem solved by renaming <code>close</code> to <code>end</code> and by including a call to <code>SDL_RenderPresent(screen.renderer);</code> at the end of the main loop. With this setup the screen surface <strong>has to be deleted</strong> or the program won't draw anything.</p>

<p>Thanks to @keltar and @Wutipong Wongsakuldej for answering the question in the comments </p>