All pastes #578150 Raw Edit

Anonymous

public cpp v1 · immutable
·published 2007-06-20 06:04 UTC
rendered paste body
void screenshot(){    SDL_Surface *image;    SDL_Surface *temp;    int idx;    if((image = SDL_CreateRGBSurface(SDL_SWSURFACE, scr_w, scr_h, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0)))    {        if((temp = SDL_CreateRGBSurface(SDL_SWSURFACE, scr_w, scr_h, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0)))        {            glReadPixels(0, 0, scr_w, scr_h, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);            for (idx = 0; idx<scr_h; idx++)            {                char *dest = (char *)temp->pixels+temp->pitch*idx;                memcpy(dest, (char *)image->pixels+image->pitch*(scr_h-1-idx), 3*scr_w);                endianswap(dest, 3, scr_w);            }            s_sprintfd(buf)("screenshot_%d.bmp", lastmillis);            SDL_SaveBMP(temp, buf);            SDL_FreeSurface(temp);        }        SDL_FreeSurface(image);    }}