I'm using SDL 2 to create a small 2D game. Based on the docs, this is what I would do:
SDL_Surface *surface = SDL_LoadBMP("image.bmp"); SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_FreeSurface(surface); ... SDL_RenderCopy(renderer, texture, NULL, &dest);
Since I have every single sprite in a different bmp, this would cause hundreds of texture objects to be created.
Another solution would be to create a single SDL_Surface based on all the bmp files, create a single texture object from it and then blit it with something like this:
SDL_RenderCopy(renderer, texture, &src, &dest);
src to select the sprite I'm interested into blitting.
I know SDL 2 takes advantage of 3D acceleration and I'm not an expert of 3D graphics programming, but I do know that selecting the current texture is an operation that is very expensive. However, I'm not sure that a SDL texture is translated into a real Texture.
So my question is: are these 2 approaches the same in terms of performance, when using SDL 2?