SDL_Surface* tmpSurface = IMG_Load("Assets/Player.png");
playerTex = SDL_CreateTextureFromSurface(renderer, 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

  • 1
    \$\begingroup\$ What does SDL_GetError() say? \$\endgroup\$ – Tyyppi_77 Sep 14 at 9:03

I fixed this: I was creating a new renderer when I was initializing the texture instead of reusing the public one.

Using SDL_GetError helped me figure this out.

| improve this answer | |
  • 1
    \$\begingroup\$ You might want to consider marking this as the accepted answer if it solves the issue. \$\endgroup\$ – Vaillancourt Oct 14 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.