26 #ifdef G4VIS_BUILD_OI_DRIVER
39 #include <Inventor/elements/SoViewportRegionElement.h>
40 #include <Inventor/errors/SoDebugError.h>
57 const SbViewportRegion& aViewPortRegion
59 :SoGLRenderAction(aViewPortRegion)
64 setFileName(
"out.ps");
75 SoDebugError::post(
"SoGL2PSAction::enableFileWriting",
81 const SbViewportRegion& vpr = getViewportRegion();
82 SoViewportRegionElement::set(getState(),vpr);
113 if(!
fFile)
return false;
115 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,&valid);
116 if(!valid)
return false;
118 glGetFloatv(GL_CURRENT_RASTER_POSITION,pos);
119 int xoff = -(
int)(aXmove + aXorig);
120 int yoff = -(
int)(aYmove + aYorig);
121 int x = (
int)(pos[0] + xoff);
122 int y = (
int)(pos[1] + yoff);
125 glGetIntegerv(GL_VIEWPORT,vp);
128 if(x+w>(vp[0]+vp[2])) w = vp[0]+vp[2]-
x;
129 if(y+h>(vp[1]+vp[3])) h = vp[1]+vp[3]-
y;
131 if(s<=0)
return false;
132 float* image = (
float*)::malloc(s *
sizeof(
float));
133 if(!image)
return false;
134 glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
148 const SbViewportRegion& vpr = getViewportRegion();
149 SoViewportRegionElement::set(getState(),vpr);
155 SoGLRenderAction::beginTraversal(aNode);
159 SoGLRenderAction::beginTraversal(aNode);
virtual void beginTraversal(SoNode *)
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, GLint xorig, GLint yorig, GLenum format, GLenum type, const void *pixels)
static const G4double pos
GL2PSDLL_API GLint gl2psEndPage(void)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
bool addBitmap(int, int, float=0, float=0, float=0, float=0)
SoGL2PSAction(const SbViewportRegion &)
void disableFileWriting()
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData