What is the easiest and fastest way to display an SDL_Surface in a window with SDL2?

Posted by Semmu on Game Development See other posts from Game Development or by Semmu
Published on 2014-08-22T22:26:13Z Indexed on 2014/08/22 22:35 UTC
Read the original article Hit count: 108

Filed under:
|
|

I would like to have an SDL_Surface representing the contents of the window, just like in the old days with SDL1.2. What is the best and fastest way to do it in SDL2?

What I found is that I need an SDL_Window, an SDL_Renderer for that window, an SDL_Texture to render, and an SDL_Surface to create a texture from. This seems a bit too much to me, since I just want to display a single image on the screen.

Not to mention the impact on the performance. On my machine (Lenovo Y510p laptop) this whole procedure takes 9ms, without any memory allocation, only using pre-allocated variables and totally black SDL_Surface.

Is there a way I could speed up things?

© Game Development or respective owner

Related posts about 2d

Related posts about graphics