Search code examples
c++sdl

SDL_GetVideoSurface() equivalent function in SDL 2.0


I'm remaking a pong game, which I did in SDL 1.2, but in SDL 1.2, I had a function SDL_GetVideoSurface(), to take the surface of the screen (or I'm wrong about that?), however...

A little example in how I've used the function in my game(SDL 1.2)

void paddle::show() 
{
    SDL_BlitSurface(image, NULL, SDL_GetVideoSurface(), &box);
}

I want to know if there is an equivalent function to SDL_GetVideoSurface() in SDL 2.0, I've searched, but found nothing. And if it didn't exists, how can I blit a surface? The surface is my paddle in the pong game.


Solution

  • I want to know if there is a equivalent function to SDL_GetVideoSurface() in SDL 2.0

    There isn't one.

    If you're feeling insane you could iterate over the entire Uint32 range and use SDL_GetWindowFromID() to search for the window(s) you created.

    Keeping track of the SDL_Window*s returned by SDL_CreateWindow() like keltar suggested is the better option.