I’m porting a game from SDL 1.2 to SDL 2. The game frequently pops up small text messages onto the screen. In the past, I used SDL_UpdateRect to just refresh the area in question, but I have been unable to find an equivalent in SDL2. I have converted the text to surfaces to textures, but SDL_UpdateTexture appears to do something else.

Any suggestions on what to use?

I think you’re just supposed to draw everything that appears on the window each frame and then use SDL_RenderPresent to update the whole window.

The closest equivalent of SDL_UpdateRect in SDL2 is probably SDL_UpdateWindowSurfaceRects but that function is only meant to be used if you still use SDL_Surface, SDL_BlitSurface, etc. to draw to a “window surface”.

It would be easy enough to switch back to surfaces. I got the feeling that textures were preferred. Is that accurate?

Yes. Textures uses the GPU and should be much faster.

Transferring data to the GPU is slow. That meant it was difficult to get good frame rate if you used SDL_Flip to transfer the whole screen surface each time*. That’s why SDL_UpdateRect existed so that you didn’t have to transfer all the pixel data if only part of the screen surface had been updated.

With textures this is no longer needed because they are already on the GPU.

* In SDL 1.2 there was something called “hardware surface” which used the GPU but this was not supported on all platforms. In SDL 2 surfaces are purely CPU, they never use the GPU, so instead you would have to use textures to get the same performance.