Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ScreenGrabInt.H

Go to the documentation of this file.
00001 
00010 #ifndef SCREENGRABINT_H
00011 #define SCREENGRABINT_H
00012 
00013 // Gluebase includes
00014 #define OUTSIDE_GLUE_CORE
00015 #include <fsa/fsa.H>
00016 #include <dev/buttons.H>
00017 #include <config/config.H>
00018 #include <std/hash.H>
00019 
00020 
00021 #include "DrawMgr.H"
00022 #include "Texture.H"
00023 #include "ISVREngine.H"
00024 
00025 class ScreenGrab
00026 {
00027  public:
00028   
00029   ScreenGrab() { 
00030     _grabOne = 0; 
00031     _grabContinuous = 0;
00032     _startx = 0;
00033     _starty = 0;
00034     _width  = ISVREngine::instance()->displayWidthPixels();
00035     _height = ISVREngine::instance()->displayHeightPixels();
00036     _index = 1;
00037   };
00038 
00039   virtual ~ScreenGrab() {};
00040 
00041   void grabNextFrame() { _grabOne = 1; }
00042   void toggleContinuousGrab() { _grabContinuous = !_grabContinuous; }
00043 
00044 
00045   // call once each frame after all drawing has completed
00046   void frameDone() {
00047     if ((_grabOne) || (_grabContinuous)) {
00048       cout << "Saving frame buffer:" << endl;
00049       
00050       // set which GL buffer to read from..  
00051       //glReadBuffer();
00052 
00053       int context = ISVREngine::instance()->currentGlContext();
00054       int node = CONFIGval("CLUSTER_NODE_ID",0,false);
00055 
00056       char s[256];      
00057       if (_index < 10)
00058     sprintf(s,"screengrab%d%_d_000%d.tga",node,context,_index);
00059       else if (_index < 100)
00060     sprintf(s,"screengrab%d_%d_00%d.tga",node,context,_index);
00061       else if (_index < 1000)
00062     sprintf(s,"screengrab%d_%d_0%d.tga",node,context,_index);
00063       else
00064     sprintf(s,"screengrab%d_%d_%d.tga",node,context,_index);
00065       
00066       Texture *t = new Texture(s,TEX_RGB,_width,_height);
00067       glReadPixels(_startx,_starty,_width,_height,GL_RGB,GL_FLOAT,
00068            t->pixelPtr(0,0));
00069       t->save(s);
00070 
00071       _grabOne = 0;
00072       _index++;
00073     }
00074   }
00075 
00076  protected:
00077 
00078   int _grabOne;
00079   int _grabContinuous;
00080   int _startx;
00081   int _starty;
00082   int _width;
00083   int _height;
00084   int _index;
00085 };
00086 
00087 
00088 class ScreenGrabInt : public Interactor<ScreenGrabInt>
00089 {
00090  public:
00091 
00092   ScreenGrabInt(ScreenGrab *sc);
00093   virtual ~ScreenGrabInt() {}
00094   
00095  protected:
00096 
00097   void grab_single_frame(cEVENTbtnptr &evt, STATE *&);
00098   void toggle_cont_grab(cEVENTbtnptr &evt, STATE *&);
00099 
00100   EVENTbtnptr _grabsinglebtn;
00101   EVENTbtnptr _contgrabbtn;
00102 
00103   ScreenGrab *_screenGrab;
00104 
00105 };
00106 
00107 
00108 #endif

Generated on Mon Sep 15 16:27:56 2003 for inspace by doxygen1.2.18