0023186: Unable to display Graphic3d_ArrayOfPoints after migrating from OCCT 6.5.2
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_713.cxx
CommitLineData
b311480e 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
7fd59977 20
2166f0fa 21#include <OpenGl_GraphicDriver.hxx>
7fd59977 22
2166f0fa
SK
23#include <OpenGl_Callback.hxx>
24#include <OpenGl_Group.hxx>
25#include <OpenGl_PrimitiveArray.hxx>
7fd59977 26
2166f0fa 27#include <OpenGl_CView.hxx>
7fd59977 28
2166f0fa 29void OpenGl_GraphicDriver::SetDepthTestEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
7fd59977 30{
2166f0fa
SK
31 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
32 if (aCView)
33 aCView->WS->UseDepthTest() = isEnabled;
7fd59977 34}
35
2166f0fa 36Standard_Boolean OpenGl_GraphicDriver::IsDepthTestEnabled( const Graphic3d_CView& ACView ) const
7fd59977 37{
2166f0fa
SK
38 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
39 if (aCView)
40 return aCView->WS->UseDepthTest();
41 return Standard_False;
7fd59977 42}
43
2166f0fa
SK
44void OpenGl_GraphicDriver::ReadDepths( const Graphic3d_CView& ACView,
45 const Standard_Integer x,
46 const Standard_Integer y,
47 const Standard_Integer width,
48 const Standard_Integer height,
49 const Standard_Address buffer ) const
7fd59977 50{
2166f0fa
SK
51 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
52 if (aCView)
53 aCView->WS->ReadDepths(x, y, width, height, (float*) buffer);
7fd59977 54}
55
2166f0fa 56void OpenGl_GraphicDriver::SetGLLightEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
7fd59977 57{
2166f0fa
SK
58 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
59 if (aCView)
60 aCView->WS->UseGLLight() = isEnabled;
7fd59977 61}
62
2166f0fa 63Standard_Boolean OpenGl_GraphicDriver::IsGLLightEnabled( const Graphic3d_CView& ACView ) const
7fd59977 64{
2166f0fa
SK
65 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
66 if (aCView)
67 return aCView->WS->UseGLLight();
68 return Standard_False;
7fd59977 69}
70
2166f0fa
SK
71void OpenGl_GraphicDriver::PrimitiveArray( const Graphic3d_CGroup& ACGroup,
72 const Graphic3d_PrimitiveArray& parray,
73 const Standard_Boolean EvalMinMax )
7fd59977 74{
2166f0fa
SK
75 if ( ACGroup.ptrGroup && parray )
76 {
77 OpenGl_PrimitiveArray *aparray = new OpenGl_PrimitiveArray( (CALL_DEF_PARRAY *) parray );
78 ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelParray, aparray );
79 }
7fd59977 80}
81
98178592
A
82//=======================================================================
83//function : RemovePrimitiveArray
84//purpose : Purpose: Clear visualization data in graphical driver and
85// stop displaying the primitives array of the graphical group
86// <theCGroup>. This method is internal and should be used by
87// Graphic3d_Group only.
88//=======================================================================
89
2166f0fa
SK
90void OpenGl_GraphicDriver::RemovePrimitiveArray (const Graphic3d_CGroup& ACGroup,
91 const Graphic3d_PrimitiveArray& thePArray)
98178592 92{
2166f0fa
SK
93 if ( ACGroup.ptrGroup && thePArray )
94 {
95 ((OpenGl_Group *)ACGroup.ptrGroup)->RemovePrimitiveArray( (CALL_DEF_PARRAY *) thePArray );
96 }
98178592 97}
7fd59977 98
2166f0fa 99static OpenGl_UserDrawCallback MyUserDrawCallback = NULL;
7fd59977 100
2166f0fa
SK
101OpenGl_UserDrawCallback& UserDrawCallback ()
102{
103 return MyUserDrawCallback;
7fd59977 104}
105
2166f0fa
SK
106void OpenGl_GraphicDriver::UserDraw ( const Graphic3d_CGroup& ACGroup,
107 const Graphic3d_CUserDraw& AUserDraw )
7fd59977 108{
2166f0fa
SK
109 if (ACGroup.ptrGroup && MyUserDrawCallback)
110 {
111 OpenGl_Element *auserdraw = (*MyUserDrawCallback)(&AUserDraw);
112
113 if (auserdraw != 0)
114 ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelUserdraw, auserdraw );
115 }
7fd59977 116}