1 /************************************************************************/
3 /************************************************************************/
5 #include <OpenGl_GraphicDriver.jxx>
6 #include <OSD_Localizer.hxx>
14 /************************************************************************/
16 /************************************************************************/
18 Standard_Boolean OpenGl_GraphicDriver::Export (const Standard_CString theFileName,
19 const Graphic3d_ExportFormat theFormat,
20 const Graphic3d_SortType theSortType,
21 const Standard_Integer theWidth,
22 const Standard_Integer theHeight,
23 const Graphic3d_CView& theView,
24 const Aspect_CLayer2d& theLayerUnder,
25 const Aspect_CLayer2d& theLayerOver,
26 const Standard_Real /*thePrecision*/,
27 const Standard_Address /*theProgressBarFunc*/,
28 const Standard_Address /*theProgressObject*/)
31 Standard_Integer aFormat = -1;
32 Standard_Integer aSortType = Graphic3d_ST_BSP_Tree;
35 case Graphic3d_EF_PostScript:
38 case Graphic3d_EF_EnhPostScript:
41 case Graphic3d_EF_TEX:
44 case Graphic3d_EF_PDF:
47 case Graphic3d_EF_SVG:
50 case Graphic3d_EF_PGF:
53 case Graphic3d_EF_EMF:
54 //aFormat = GL2PS_EMF;
55 aFormat = GL2PS_PGF + 1; // 6
59 return Standard_False;
64 case Graphic3d_ST_Simple:
65 aSortType = GL2PS_SIMPLE_SORT;
67 case Graphic3d_ST_BSP_Tree:
68 aSortType = GL2PS_BSP_SORT;
75 aViewport[2] = theWidth;
76 aViewport[3] = theHeight;
78 GLint aBufferSize = 1024 * 1024;
79 GLint anErrCode = GL2PS_SUCCESS;
81 // gl2ps uses standard write functions and do not check locale
82 OSD_Localizer locate (LC_NUMERIC, "C");
84 while (aBufferSize > 0)
86 // current patch for EMF support in gl2ps uses WinAPI functions to create file
87 FILE* aFileH = (theFormat != Graphic3d_EF_EMF) ? fopen (theFileName, "wb") : NULL;
88 anErrCode = gl2psBeginPage ("", "", aViewport, aFormat, aSortType,
89 GL2PS_DRAW_BACKGROUND | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT/* | GL2PS_SIMPLE_LINE_OFFSET*/,
91 0, 0, 0, aBufferSize, aFileH, theFileName);
92 if (anErrCode != GL2PS_SUCCESS)
94 // initialization failed
99 Redraw (theView, theLayerUnder, theLayerOver);
101 anErrCode = gl2psEndPage();
105 if (anErrCode == GL2PS_OVERFLOW)
112 return anErrCode == GL2PS_SUCCESS;
114 return Standard_False;