loads the happyface graphic into a texture */
| 103 | loads the happyface graphic into a texture |
| 104 | */ |
| 105 | void |
| 106 | initializeTexture(SDL_Renderer *renderer) |
| 107 | { |
| 108 | SDL_Surface *bmp_surface; |
| 109 | /* load the bmp */ |
| 110 | bmp_surface = SDL_LoadBMP("icon.bmp"); |
| 111 | if (bmp_surface == NULL) { |
| 112 | fatalError("could not load bmp"); |
| 113 | } |
| 114 | /* set white to transparent on the happyface */ |
| 115 | SDL_SetColorKey(bmp_surface, 1, |
| 116 | SDL_MapRGB(bmp_surface->format, 255, 255, 255)); |
| 117 | |
| 118 | /* convert RGBA surface to texture */ |
| 119 | texture = SDL_CreateTextureFromSurface(renderer, bmp_surface); |
| 120 | if (texture == 0) { |
| 121 | fatalError("could not create texture"); |
| 122 | } |
| 123 | SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); |
| 124 | |
| 125 | /* free up allocated memory */ |
| 126 | SDL_FreeSurface(bmp_surface); |
| 127 | } |
| 128 | |
| 129 | int |
| 130 | main(int argc, char *argv[]) |
no test coverage detected