1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 /************************************************************************/
20 /************************************************************************/
22 #include <OpenGl_GraphicDriver.hxx>
23 #include <OSD_Localizer.hxx>
31 /************************************************************************/
33 /************************************************************************/
35 Standard_Boolean OpenGl_GraphicDriver::Export (const Standard_CString theFileName,
36 const Graphic3d_ExportFormat theFormat,
37 const Graphic3d_SortType theSortType,
38 const Standard_Integer theWidth,
39 const Standard_Integer theHeight,
40 const Graphic3d_CView& theView,
41 const Aspect_CLayer2d& theLayerUnder,
42 const Aspect_CLayer2d& theLayerOver,
43 const Standard_Real /*thePrecision*/,
44 const Standard_Address /*theProgressBarFunc*/,
45 const Standard_Address /*theProgressObject*/)
48 Standard_Integer aFormat = -1;
49 Standard_Integer aSortType = Graphic3d_ST_BSP_Tree;
52 case Graphic3d_EF_PostScript:
55 case Graphic3d_EF_EnhPostScript:
58 case Graphic3d_EF_TEX:
61 case Graphic3d_EF_PDF:
64 case Graphic3d_EF_SVG:
67 case Graphic3d_EF_PGF:
70 case Graphic3d_EF_EMF:
71 //aFormat = GL2PS_EMF;
72 aFormat = GL2PS_PGF + 1; // 6
76 return Standard_False;
81 case Graphic3d_ST_Simple:
82 aSortType = GL2PS_SIMPLE_SORT;
84 case Graphic3d_ST_BSP_Tree:
85 aSortType = GL2PS_BSP_SORT;
92 aViewport[2] = theWidth;
93 aViewport[3] = theHeight;
95 GLint aBufferSize = 1024 * 1024;
96 GLint anErrCode = GL2PS_SUCCESS;
98 // gl2ps uses standard write functions and do not check locale
99 OSD_Localizer locate (LC_NUMERIC, "C");
101 while (aBufferSize > 0)
103 // current patch for EMF support in gl2ps uses WinAPI functions to create file
104 FILE* aFileH = (theFormat != Graphic3d_EF_EMF) ? fopen (theFileName, "wb") : NULL;
105 anErrCode = gl2psBeginPage ("", "", aViewport, aFormat, aSortType,
106 GL2PS_DRAW_BACKGROUND | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT/* | GL2PS_SIMPLE_LINE_OFFSET*/,
108 0, 0, 0, aBufferSize, aFileH, theFileName);
109 if (anErrCode != GL2PS_SUCCESS)
111 // initialization failed
116 Redraw (theView, theLayerUnder, theLayerOver);
118 anErrCode = gl2psEndPage();
122 if (anErrCode == GL2PS_OVERFLOW)
129 return anErrCode == GL2PS_SUCCESS;
131 return Standard_False;