1
votes

I am studying the basics of SDL, then I fell into this doubt. I learned that SDL texture is the GPU counterpart of SDL surface which uses CPU. But for getting a surface no renderer argument is given, simply the asset to be loaded was given as the argument. But for converting a surface to texture renderer argument was needed. What am I missing here?

SDL_Surface* pTempSurface=SDL_LoadBMP("image.bmp");
SDL_Texture* pTexture=SDL_CreateTextureFromSurface(m_pRenderer,pTempSurface);
1

1 Answers

2
votes

SDL_Surface doesn't use SDL_Renderer, it's only used by/for SDL_Texture. SDL_Surfaces are copied from memory to the screen buffer with SDL_Flip. So when loading a bitmap into a surface no renderer is needed (indeed renderers did not exist before SDL 2.0), but when you use CreateTextureFromSurface you need to tell the function the renderer context into which the texture should be loaded.

Maybe not the best explanation, but I hope you get the difference.

If you are familiar with SDL 1.2 but not 2.0 the Migration guide should help you.