0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_713.cxx
1 // Created on: 2011-10-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21 #include <OpenGl_GraphicDriver.hxx>
22
23 #include <OpenGl_Group.hxx>
24 #include <OpenGl_PrimitiveArray.hxx>
25
26 #include <OpenGl_CView.hxx>
27
28 void OpenGl_GraphicDriver::SetDepthTestEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
29 {
30   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
31   if (aCView)
32     aCView->WS->UseDepthTest() = isEnabled;
33 }
34
35 Standard_Boolean OpenGl_GraphicDriver::IsDepthTestEnabled( const Graphic3d_CView& ACView ) const
36 {
37   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
38   if (aCView)
39     return aCView->WS->UseDepthTest();
40   return Standard_False;
41 }
42
43 void OpenGl_GraphicDriver::ReadDepths( const Graphic3d_CView& ACView,
44                                       const Standard_Integer x,
45                                       const Standard_Integer y,
46                                       const Standard_Integer width,
47                                       const Standard_Integer height,
48                                       const Standard_Address buffer ) const
49 {
50   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
51   if (aCView)
52     aCView->WS->ReadDepths(x, y, width, height, (float*) buffer);
53 }
54
55 void OpenGl_GraphicDriver::SetGLLightEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
56 {
57   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
58   if (aCView)
59     aCView->WS->UseGLLight() = isEnabled;
60 }
61
62 Standard_Boolean OpenGl_GraphicDriver::IsGLLightEnabled( const Graphic3d_CView& ACView ) const
63 {
64   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
65   if (aCView)
66     return aCView->WS->UseGLLight();
67   return Standard_False;
68 }
69
70 void OpenGl_GraphicDriver::PrimitiveArray( const Graphic3d_CGroup& ACGroup,
71                                           const Graphic3d_PrimitiveArray& parray,
72                                           const Standard_Boolean /*EvalMinMax*/ )
73 {
74   if ( ACGroup.ptrGroup && parray )
75   {
76     OpenGl_PrimitiveArray *aparray = new OpenGl_PrimitiveArray( (CALL_DEF_PARRAY *) parray );
77     ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelParray, aparray );
78   }
79 }
80
81 void OpenGl_GraphicDriver::UserDraw (const Graphic3d_CGroup&    theCGroup,
82                                      const Graphic3d_CUserDraw& theUserDraw)
83 {
84   if (theCGroup.ptrGroup != NULL
85    && myUserDrawCallback != NULL)
86   {
87     OpenGl_Element* aUserDraw = myUserDrawCallback(&theUserDraw);
88     if (aUserDraw != NULL)
89     {
90       ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelUserdraw, aUserDraw);
91     }
92   }
93 }