diff -rNu vmd_orig/configure vmd2/configure --- vmd_orig/configure Sun Jul 13 21:15:48 2003 +++ vmd2/configure Sun Jul 13 21:30:47 2003 @@ -927,6 +927,7 @@ 'PlainTextInterp.C', 'PluginMgr.C', 'POV3DisplayDevice.C', + 'PPMDisplayDevice.C', 'PSDisplayDevice.C', 'VMDQuat.C', 'RadianceDisplayDevice.C', @@ -1045,6 +1046,7 @@ 'PluginMgr.h', 'PointerTool.h', 'POV3DisplayDevice.h', + 'PPMDisplayDevice.h', 'PSDisplayDevice.h', 'VMDQuat.h', 'RadianceDisplayDevice.h', diff -rNu vmd_orig/src/FileRenderList.C vmd2/src/FileRenderList.C --- vmd_orig/src/FileRenderList.C Sun Jul 13 21:15:40 2003 +++ vmd2/src/FileRenderList.C Sun Jul 13 21:35:32 2003 @@ -46,6 +46,7 @@ #include "RenderManDisplayDevice.h" // RenderMan interface #include "VrmlDisplayDevice.h" // VRML 1.0 #include "Vrml2DisplayDevice.h" // VRML 2.0 +#include "PPMDisplayDevice.h" // PPM #if defined(VMDLIBTACHYON) #include "LibTachyonDisplayDevice.h" // Built-in Tachyon ray tracer @@ -68,6 +69,7 @@ add(new RadianceDisplayDevice()); add(new R3dDisplayDevice()); add(new VrmlDisplayDevice()); + add(new PPMDisplayDevice(app->display)); } // destructor, deallocate all the info diff -rNu vmd_orig/src/PPMDisplayDevice.C vmd2/src/PPMDisplayDevice.C --- vmd_orig/src/PPMDisplayDevice.C Wed Dec 31 19:00:00 1969 +++ vmd2/src/PPMDisplayDevice.C Sun Jul 13 21:34:27 2003 @@ -0,0 +1,78 @@ + +/*************************************************************************** + *cr + *cr (C) Copyright 1995-2003 The Board of Trustees of the + *cr University of Illinois + *cr All Rights Reserved + *cr + ***************************************************************************/ + +/*************************************************************************** + * RCS INFORMATION: + * + * $RCSfile: PPMDisplayDevice.C,v $ + * $Author: brad noyes $ $Locker: $ $State: Exp $ + * $Revision: 1.2 $ $Date: 2003/06/19 18:16:50 $ + * + *************************************************************************** + * DESCRIPTION: + * + * + ***************************************************************************/ +#include +#include +#include "PPMDisplayDevice.h" +#include "Inform.h" + +PPMDisplayDevice::PPMDisplayDevice(DisplayDevice *d) : + FileRenderer("ppm", "snap.ppm", "gimp %s") { + display = d; +} + +int PPMDisplayDevice::open_file(const char * filename) +{ + if ((outfile = fopen(filename, "wb")) == NULL) { + msgErr << "Could not open file " << filename + << " in current directory for writing!" << sendmsg; + return FALSE; + } + my_filename = stringdup(filename); + isOpened = TRUE; + return TRUE; +} + +void PPMDisplayDevice::render(const VMDDisplayList *) +{ + int i; + int height = display->ySize; + int width = display->xSize; + GLubyte* pixelbuffer; + + /* got code from newsgroup post */ + glReadBuffer(GL_FRONT); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + msgInfo << "Height= "<= 0; i--) + { + fwrite(pixelbuffer + i*width*3, 1, width*3,outfile); + } + + free(pixelbuffer); + return; + +} + +void PPMDisplayDevice::close_file(void) +{ + fclose(outfile); + outfile = NULL; + delete [] my_filename; + my_filename = NULL; + isOpened = FALSE; +} diff -rNu vmd_orig/src/PPMDisplayDevice.h vmd2/src/PPMDisplayDevice.h --- vmd_orig/src/PPMDisplayDevice.h Wed Dec 31 19:00:00 1969 +++ vmd2/src/PPMDisplayDevice.h Sun Jul 13 21:32:37 2003 @@ -0,0 +1,44 @@ +/*************************************************************************** + *cr + *cr (C) Copyright 1995-2003 The Board of Trustees of the + *cr University of Illinois + *cr All Rights Reserved + *cr + ***************************************************************************/ + +/*************************************************************************** + * RCS INFORMATION: + * + * $RCSfile: PPMDisplayDevice.h,v $ + * $Author: brad noyes $ $Locker: $ $State: Exp $ + * $Revision: 1.2 $ $Date: 2003/06/19 18:16:50 $ + * + *************************************************************************** + * DESCRIPTION: + * + * + ***************************************************************************/ + + +#ifndef PPMDISPLAYDEVICE_H +#define PPMDISPLAYDEVICE_H + +#include "FileRenderer.h" + +class PPMDisplayDevice : public FileRenderer { +private: + DisplayDevice *display; +public: + + PPMDisplayDevice(DisplayDevice *); + + virtual int open_file(const char *filename); + + // ignore the renders + virtual void render(const VMDDisplayList*); + + virtual void close_file(void); + +}; + +#endif