| 111 | } |
| 112 | |
| 113 | void |
| 114 | initializeTextures(SDL_Renderer *renderer) |
| 115 | { |
| 116 | |
| 117 | SDL_Surface *bmp_surface; |
| 118 | |
| 119 | /* load the ship */ |
| 120 | bmp_surface = SDL_LoadBMP("ship.bmp"); |
| 121 | if (bmp_surface == NULL) { |
| 122 | fatalError("could not ship.bmp"); |
| 123 | } |
| 124 | /* set blue to transparent on the ship */ |
| 125 | SDL_SetColorKey(bmp_surface, 1, |
| 126 | SDL_MapRGB(bmp_surface->format, 0, 0, 255)); |
| 127 | |
| 128 | /* create ship texture from surface */ |
| 129 | ship = SDL_CreateTextureFromSurface(renderer, bmp_surface); |
| 130 | if (ship == 0) { |
| 131 | fatalError("could not create ship texture"); |
| 132 | } |
| 133 | SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND); |
| 134 | |
| 135 | /* set the width and height of the ship from the surface dimensions */ |
| 136 | shipData.rect.w = bmp_surface->w; |
| 137 | shipData.rect.h = bmp_surface->h; |
| 138 | |
| 139 | SDL_FreeSurface(bmp_surface); |
| 140 | |
| 141 | /* load the space background */ |
| 142 | bmp_surface = SDL_LoadBMP("space.bmp"); |
| 143 | if (bmp_surface == NULL) { |
| 144 | fatalError("could not load space.bmp"); |
| 145 | } |
| 146 | /* create space texture from surface */ |
| 147 | space = SDL_CreateTextureFromSurface(renderer, bmp_surface); |
| 148 | if (space == 0) { |
| 149 | fatalError("could not create space texture"); |
| 150 | } |
| 151 | SDL_FreeSurface(bmp_surface); |
| 152 | |
| 153 | } |
| 154 | |
| 155 | |
| 156 |
no test coverage detected