Back to index

extremetuxracer  0.5beta
Functions | Variables
screenshot.cpp File Reference
#include "etracer.h"
#include "screenshot.h"
#include "ppgltk/images/image.h"

Go to the source code of this file.

Functions

void screenshot ()
bool take_screenshot (char *fileName)

Variables

static int screenshot_num = 0

Function Documentation

void screenshot ( )

Definition at line 29 of file screenshot.cpp.

{
    char buff[20];
    sprintf( buff, "tux_sshot_%d.ppm", screenshot_num++ );
    if(!take_screenshot( buff )){
        fprintf( stderr, "Couldn't save screenshot\n");
    };
} 

Here is the call graph for this function:

Here is the caller graph for this function:

bool take_screenshot ( char *  fileName)

Definition at line 38 of file screenshot.cpp.

                                        {

       int viewport[4];
       glGetIntegerv( GL_VIEWPORT, (GLint*)viewport );
       glReadBuffer( GL_FRONT );
       
       pp::Image image(viewport[2],viewport[3],3);
       
       image.width=viewport[2];
       image.height=viewport[3];
       image.depth=3;
       
       for (int i=0; i<viewport[3]; i++){
              glReadPixels(viewport[0], viewport[1]+viewport[3]-1-i,
                     viewport[2], 1, GL_RGB, 
                     GL_UNSIGNED_BYTE, image.data+viewport[2]*i*3
                     );
       }
       
       return image.writeToFile(fileName);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int screenshot_num = 0 [static]

Definition at line 27 of file screenshot.cpp.