Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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 namespace InSpace {
00026 
00027 class ScreenGrab
00028 {
00029  public:
00030   
00031   ScreenGrab() { 
00032     _grabOne = 0; 
00033     _grabContinuous = 0;
00034     _startx = 0;
00035     _starty = 0;
00036     _width  = ISVREngine::instance()->displayWidthPixels();
00037     _height = ISVREngine::instance()->displayHeightPixels();
00038     _index = 1;
00039   };
00040 
00041   virtual ~ScreenGrab() {};
00042 
00043   void grabNextFrame() { _grabOne = 1; }
00044   void toggleContinuousGrab() { _grabContinuous = !_grabContinuous; }
00045 
00046 
00047   // call once each frame after all drawing has completed
00048   void frameDone() {
00049     if ((_grabOne) || (_grabContinuous)) {
00050       cout << "Saving frame buffer:" << endl;
00051       
00052       // set which GL buffer to read from..  
00053       //glReadBuffer();
00054 
00055       int context = ISVREngine::instance()->currentGlContext();
00056       int node = CONFIGval("CLUSTER_NODE_ID",0,false);
00057 
00058       char s[256];      
00059       if (_index < 10)
00060     sprintf(s,"screengrab%d_%d_000%d.tga",node,context,_index);
00061       else if (_index < 100)
00062     sprintf(s,"screengrab%d_%d_00%d.tga",node,context,_index);
00063       else if (_index < 1000)
00064     sprintf(s,"screengrab%d_%d_0%d.tga",node,context,_index);
00065       else
00066     sprintf(s,"screengrab%d_%d_%d.tga",node,context,_index);
00067       
00068       Texture *t = new Texture(s,TEX_RGB,_width,_height);
00069       glReadPixels(_startx,_starty,_width,_height,GL_RGB,GL_FLOAT,
00070            t->pixelPtr(0,0));
00071       t->save(s);
00072 
00073       _grabOne = 0;
00074       _index++;
00075     }
00076   }
00077 
00078  protected:
00079 
00080   int _grabOne;
00081   int _grabContinuous;
00082   int _startx;
00083   int _starty;
00084   int _width;
00085   int _height;
00086   int _index;
00087 };
00088 
00089 
00090 class ScreenGrabInt : public Interactor<ScreenGrabInt>
00091 {
00092  public:
00093 
00094   ScreenGrabInt(ScreenGrab *sc);
00095   virtual ~ScreenGrabInt() {}
00096   
00097  protected:
00098 
00099   void grab_single_frame(cEVENTbtnptr &evt, STATE *&);
00100   void toggle_cont_grab(cEVENTbtnptr &evt, STATE *&);
00101 
00102   EVENTbtnptr _grabsinglebtn;
00103   EVENTbtnptr _contgrabbtn;
00104 
00105   ScreenGrab *_screenGrab;
00106 
00107 };
00108 
00109 } // namespace
00110 #endif

Generated on Thu Jul 8 15:19:29 2004 for inspace by doxygen 1.3.4