this function loads our font into an SDL_Texture and returns the SDL_Texture */
| 161 | |
| 162 | /* this function loads our font into an SDL_Texture and returns the SDL_Texture */ |
| 163 | SDL_Texture* |
| 164 | loadFont(void) |
| 165 | { |
| 166 | SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp"); |
| 167 | |
| 168 | if (!surface) { |
| 169 | printf("Error loading bitmap: %s\n", SDL_GetError()); |
| 170 | return 0; |
| 171 | } else { |
| 172 | /* set the transparent color for the bitmap font (hot pink) */ |
| 173 | SDL_SetColorKey(surface, 1, SDL_MapRGB(surface->format, 238, 0, 252)); |
| 174 | /* now we convert the surface to our desired pixel format */ |
| 175 | int format = SDL_PIXELFORMAT_ABGR8888; /* desired texture format */ |
| 176 | Uint32 Rmask, Gmask, Bmask, Amask; /* masks for desired format */ |
| 177 | int bpp; /* bits per pixel for desired format */ |
| 178 | SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, |
| 179 | &Amask); |
| 180 | SDL_Surface *converted = |
| 181 | SDL_CreateRGBSurface(0, surface->w, surface->h, bpp, Rmask, Gmask, |
| 182 | Bmask, Amask); |
| 183 | SDL_BlitSurface(surface, NULL, converted, NULL); |
| 184 | /* create our texture */ |
| 185 | texture = SDL_CreateTextureFromSurface(renderer, converted); |
| 186 | if (texture == 0) { |
| 187 | printf("texture creation failed: %s\n", SDL_GetError()); |
| 188 | } else { |
| 189 | /* set blend mode for our texture */ |
| 190 | SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); |
| 191 | } |
| 192 | SDL_FreeSurface(surface); |
| 193 | SDL_FreeSurface(converted); |
| 194 | return texture; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | void |
| 199 | draw() |
no test coverage detected