# SDL_CreateTextureFromSurface not working

Code:

SDL_Surface* tmpSurface = IMG_Load("Assets/Player.png");
playerTex = SDL_CreateTextureFromSurface(renderer, tmpSurface);
SDL_FreeSurface(tmpSurface);


Rendering the Texture:

SDL_RenderCopy(renderer, playerTex, NULL, NULL);


I did check to see if any of them returned null and playerTex is still null even though it is being set to a texture, im not sure why can anyone help

• What does SDL_GetError() say? – Tyyppi_77 Sep 14 '20 at 9:03

Using SDL_GetError helped me figure this out.