I'm currently following Lets Make Games' tutorial series for making a game in C++ with SDL2. In the episode, he uses this method to create a texture:
SDL_Renderer* renderer;
SDL_Texture* tex;
SDL_Surface* tmpSurface = IMG_LOAD("name")
tex = SDL_CreateTextureFromSurface(renderer, tmp);
SDL_FreeSurface(tmpSurface);
I was a little confused about this when I saw it in the video, as I feel like you should make the texture directly? This doesn't feel very memory safe to me, so I was just wondering what the best solution would be.
Im on Windows 11 using Visual Studio 2022, with C++ 11.
I used the method in the video but I don't know the impact on performance yet.