- // 2. OpenGL textures make more sense within the coordinate system when
- // they are "upside down," so let's flip it.
-
- Uint8 line[image->pitch];
-
- Uint8 *pixels = static_cast<Uint8*>(image->pixels);
- Uint16 pitch = image->pitch;
- int ybegin = 0;
- int yend = image->h - 1;
-
- if (SDL_MUSTLOCK(image)) SDL_LockSurface(image);
- while (ybegin < yend)
- {
- memcpy(line, pixels + pitch * ybegin, pitch);
- memcpy(pixels + pitch * ybegin, pixels + pitch * yend, pitch);
- memcpy(pixels + pitch * yend, line, pitch);
- ybegin++;
- yend--;
- }
- if (SDL_MUSTLOCK(image)) SDL_UnlockSurface(image);
-