1 // Created on: 2011-10-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
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.
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.
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.
21 #include <OpenGl_GraphicDriver.hxx>
23 #include <OpenGl_Group.hxx>
24 #include <OpenGl_PrimitiveArray.hxx>
26 #include <OpenGl_CView.hxx>
28 void OpenGl_GraphicDriver::SetDepthTestEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
30 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
32 aCView->WS->UseDepthTest() = isEnabled;
35 Standard_Boolean OpenGl_GraphicDriver::IsDepthTestEnabled( const Graphic3d_CView& ACView ) const
37 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
39 return aCView->WS->UseDepthTest();
40 return Standard_False;
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
50 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
52 aCView->WS->ReadDepths(x, y, width, height, (float*) buffer);
55 void OpenGl_GraphicDriver::SetGLLightEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
57 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
59 aCView->WS->UseGLLight() = isEnabled;
62 Standard_Boolean OpenGl_GraphicDriver::IsGLLightEnabled( const Graphic3d_CView& ACView ) const
64 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
66 return aCView->WS->UseGLLight();
67 return Standard_False;
70 void OpenGl_GraphicDriver::PrimitiveArray( const Graphic3d_CGroup& ACGroup,
71 const Graphic3d_PrimitiveArray& parray,
72 const Standard_Boolean /*EvalMinMax*/ )
74 if ( ACGroup.ptrGroup && parray )
76 OpenGl_PrimitiveArray *aparray = new OpenGl_PrimitiveArray( (CALL_DEF_PARRAY *) parray );
77 ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelParray, aparray );
81 void OpenGl_GraphicDriver::UserDraw (const Graphic3d_CGroup& theCGroup,
82 const Graphic3d_CUserDraw& theUserDraw)
84 if (theCGroup.ptrGroup != NULL
85 && myUserDrawCallback != NULL)
87 OpenGl_Element* aUserDraw = myUserDrawCallback(&theUserDraw);
88 if (aUserDraw != NULL)
90 ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelUserdraw, aUserDraw);