Answers for "sdl load image Unknown pixel format"

C
0

sdl load image Unknown pixel format

SDL_Surface *image =  SDL_LoadBMP(path);
    SDL_Texture *texture;
    
    texture = SDL_CreateTextureFromSurface(renderer, image);

    if (!texture)
    {
        return false;
    }
    SDL_FreeSurface(image);

    SDL_Rect rect = {pos.x, pos.y, size.width, size.height};
    if (SDL_QueryTexture(texture, NULL, NULL, &rect.w, &rect.h))
    {
        return false;
    }
    if (SDL_RenderCopy(renderer, texture, NULL, &rect))
    {
        return false;
    }
    SDL_DestroyTexture(texture);
Posted by: Guest on March-06-2021

Code answers related to "C"

Browse Popular Code Answers by Language