* Generates a surface with a row of every single color currently * loaded in the game palette (like a rainbow). First used for * testing 8bpp functionality, still useful for debugging palette issues. * @return Test surface. */
| 147 | * @return Test surface. |
| 148 | */ |
| 149 | SDL_Surface *TestState::testSurface() |
| 150 | { |
| 151 | SDL_Surface *surface; |
| 152 | |
| 153 | // Create surface |
| 154 | surface = SDL_CreateRGBSurface(SDL_HWSURFACE, 256, 25, 8, 0, 0, 0, 0); |
| 155 | |
| 156 | if (surface == 0) |
| 157 | { |
| 158 | throw Exception(SDL_GetError()); |
| 159 | } |
| 160 | |
| 161 | // Lock the surface |
| 162 | SDL_LockSurface(surface); |
| 163 | |
| 164 | Uint8 *index = (Uint8 *)surface->pixels; |
| 165 | |
| 166 | for (int j = 0; j < 25; ++j) |
| 167 | for (int i = 0; i < 256; i++, ++index) |
| 168 | *index = i; |
| 169 | |
| 170 | // Unlock the surface |
| 171 | SDL_UnlockSurface(surface); |
| 172 | |
| 173 | return surface; |
| 174 | } |
| 175 | |
| 176 | } |