26#ifdef G4VIS_BUILD_OI_DRIVER
39#include <Inventor/elements/SoViewportRegionElement.h>
40#include <Inventor/errors/SoDebugError.h>
53 static bool first =
true;
61 const SbViewportRegion& aViewPortRegion
63:SoGLRenderAction(aViewPortRegion)
68 setFileName(
"out.ps");
77 fFile = ::fopen(fFileName,
"w");
79 SoDebugError::post(
"SoGL2PSAction::enableFileWriting",
85 const SbViewportRegion& vpr = getViewportRegion();
86 SoViewportRegionElement::set(getState(),vpr);
117 if(!fFile)
return false;
119 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,&valid);
120 if(!valid)
return false;
122 glGetFloatv(GL_CURRENT_RASTER_POSITION,pos);
123 int xoff = -(int)(aXmove + aXorig);
124 int yoff = -(int)(aYmove + aYorig);
125 int x = (int)(pos[0] + xoff);
126 int y = (int)(pos[1] + yoff);
129 glGetIntegerv(GL_VIEWPORT,vp);
132 if(x+w>(vp[0]+vp[2])) w = vp[0]+vp[2]-x;
133 if(y+h>(vp[1]+vp[3])) h = vp[1]+vp[3]-y;
135 if(s<=0)
return false;
136 float* image = (
float*)::malloc(s *
sizeof(
float));
137 if(!image)
return false;
138 glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
152 const SbViewportRegion& vpr = getViewportRegion();
153 SoViewportRegionElement::set(getState(),vpr);
159 SoGLRenderAction::beginTraversal(aNode);
163 SoGLRenderAction::beginTraversal(aNode);
SoGL2PSAction(const SbViewportRegion &)
bool addBitmap(int, int, float=0, float=0, float=0, float=0)
void disableFileWriting()
virtual void beginTraversal(SoNode *)