1 // File: OpenGl_GraphicDriver_713.cxx
2 // Created: 20 October 2011
3 // Author: Sergey ZERCHANINOV
4 // Copyright: OPEN CASCADE 2011
6 #include <OpenGl_GraphicDriver.hxx>
8 #include <OpenGl_Callback.hxx>
9 #include <OpenGl_Group.hxx>
10 #include <OpenGl_PrimitiveArray.hxx>
12 #include <OpenGl_CView.hxx>
14 void OpenGl_GraphicDriver::SetDepthTestEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
16 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
18 aCView->WS->UseDepthTest() = isEnabled;
21 Standard_Boolean OpenGl_GraphicDriver::IsDepthTestEnabled( const Graphic3d_CView& ACView ) const
23 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
25 return aCView->WS->UseDepthTest();
26 return Standard_False;
29 void OpenGl_GraphicDriver::ReadDepths( const Graphic3d_CView& ACView,
30 const Standard_Integer x,
31 const Standard_Integer y,
32 const Standard_Integer width,
33 const Standard_Integer height,
34 const Standard_Address buffer ) const
36 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
38 aCView->WS->ReadDepths(x, y, width, height, (float*) buffer);
41 void OpenGl_GraphicDriver::SetGLLightEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
43 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
45 aCView->WS->UseGLLight() = isEnabled;
48 Standard_Boolean OpenGl_GraphicDriver::IsGLLightEnabled( const Graphic3d_CView& ACView ) const
50 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
52 return aCView->WS->UseGLLight();
53 return Standard_False;
56 void OpenGl_GraphicDriver::PrimitiveArray( const Graphic3d_CGroup& ACGroup,
57 const Graphic3d_PrimitiveArray& parray,
58 const Standard_Boolean EvalMinMax )
60 if ( ACGroup.ptrGroup && parray )
62 OpenGl_PrimitiveArray *aparray = new OpenGl_PrimitiveArray( (CALL_DEF_PARRAY *) parray );
63 ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelParray, aparray );
67 //=======================================================================
68 //function : RemovePrimitiveArray
69 //purpose : Purpose: Clear visualization data in graphical driver and
70 // stop displaying the primitives array of the graphical group
71 // <theCGroup>. This method is internal and should be used by
72 // Graphic3d_Group only.
73 //=======================================================================
75 void OpenGl_GraphicDriver::RemovePrimitiveArray (const Graphic3d_CGroup& ACGroup,
76 const Graphic3d_PrimitiveArray& thePArray)
78 if ( ACGroup.ptrGroup && thePArray )
80 ((OpenGl_Group *)ACGroup.ptrGroup)->RemovePrimitiveArray( (CALL_DEF_PARRAY *) thePArray );
84 static OpenGl_UserDrawCallback MyUserDrawCallback = NULL;
86 OpenGl_UserDrawCallback& UserDrawCallback ()
88 return MyUserDrawCallback;
91 void OpenGl_GraphicDriver::UserDraw ( const Graphic3d_CGroup& ACGroup,
92 const Graphic3d_CUserDraw& AUserDraw )
94 if (ACGroup.ptrGroup && MyUserDrawCallback)
96 OpenGl_Element *auserdraw = (*MyUserDrawCallback)(&AUserDraw);
99 ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelUserdraw, auserdraw );