#include "viewCapturePPM.h"
#include <maya/MSimple.h>
#include <maya/MObject.h>
#include <maya/MGlobal.h>
#include <maya/M3dView.h>
#include <maya/MGL.h>
#include <stdlib.h>
#include <maya/MIOStream.h>
{
if ( args.length() != 1 ) {
}
args.get( 0, fileName );
glPushAttrib( GL_PIXEL_MODE_BIT );
GLfloat * red = new GLfloat[width*height];
GLfloat * green = new GLfloat[width*height];
GLfloat * blue = new GLfloat[width*height];
glReadBuffer( GL_FRONT );
glReadPixels( 0, 0, width, height, GL_RED, GL_FLOAT, red );
glReadPixels( 0, 0, width, height, GL_GREEN, GL_FLOAT, green );
glReadPixels( 0, 0, width, height, GL_BLUE, GL_FLOAT, blue );
glPopAttrib();
Pic_Pixel * line = PixelAlloc( width );
int idx;
Pic * file = PicOpen( fileName.
asChar(), (short) width, (
short) height );
if ( NULL != file ) {
for ( int row = height - 1; row >= 0; row-- ) {
for ( int col = 0; col < width; col++ ) {
idx = ( row * width ) + ( col );
line[col].r = (Pic_byte)( red[idx] * 255.0 );
line[col].g = (Pic_byte)( green[idx] * 255.0 );
line[col].b = (Pic_byte)( blue[idx] * 255.0 );
}
if ( !PicWriteLine( file, line ) ) {
}
}
PicClose( file );
}
delete []red;
delete []green;
delete []blue;
PixelFree( line );
return status;
}