Jump to content

Failbound

Member
  • Posts

    1
  • Joined

  • Last visited

Awards

This user doesn't have any awards

1 Follower

Failbound's Achievements

  1. Alright, I'm rather new in the whole topic of using SDL to create images and take inputs in. I've been coding a simple program to just display a animated sprite loop, but I've come to an error "SDL Error: Invalid Renderer" I've narrowed down the specific area of code that is causing the error, as shown //If existing texture is there, free's and sets to NULL. Along with iWidth & iHeight = 0;freetexture();//final image textureSDL_Texture* niTexture = NULL;//Loads image at specified pathSDL_Surface* loadedSurface = IMG_Load(path.c_str());if (loadedSurface == NULL){printf("Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError());}else{printf("SpriteSheet :: Loaded\n");Init mkey;//Color key DOUBLE CHECK IF ERROR CHANGE TO ORIGINAL 0, 0xFF, 0xFFSDL_SetColorKey(loadedSurface, SDL_TRUE, SDL_MapRGB(loadedSurface->format, 50, 96, 166));//create texture from surface pixelsniTexture = SDL_CreateTextureFromSurface(mkey.Renderer, loadedSurface);if (niTexture == NULL){printf("Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError());} Specifically the line niTexture = SDL_CreateTextureFromSurface(mkey.Renderer, loadedSurface); is causing the Invalid Renderer error. Here is the renderer function //Create WindowWindow = SDL_CreateWindow("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, sw, sh, SDL_WINDOW_SHOWN);if (Window == NULL){printf("Window failed to be created\n");SDLSuccess = false;}else{printf("Window :: Created\n");//Create VYNC'd renderer for the windowRenderer = SDL_CreateRenderer(Window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);if (Renderer == NULL){printf("Renderer failed to be created\n");SDLSuccess = false;} Any suggestion on how to proceed and fix this problem?
×