0023418: Crash on the object displaying when running DRAW on remote station. OpenGL...
[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_Group.hxx>
24#include <OpenGl_PrimitiveArray.hxx>
7fd59977 25
2166f0fa 26#include <OpenGl_CView.hxx>
7fd59977 27
2166f0fa 28void OpenGl_GraphicDriver::SetDepthTestEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
7fd59977 29{
2166f0fa
SK
30 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
31 if (aCView)
32 aCView->WS->UseDepthTest() = isEnabled;
7fd59977 33}
34
2166f0fa 35Standard_Boolean OpenGl_GraphicDriver::IsDepthTestEnabled( const Graphic3d_CView& ACView ) const
7fd59977 36{
2166f0fa
SK
37 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
38 if (aCView)
39 return aCView->WS->UseDepthTest();
40 return Standard_False;
7fd59977 41}
42
2166f0fa
SK
43void 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
7fd59977 49{
2166f0fa
SK
50 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
51 if (aCView)
52 aCView->WS->ReadDepths(x, y, width, height, (float*) buffer);
7fd59977 53}
54
2166f0fa 55void OpenGl_GraphicDriver::SetGLLightEnabled( const Graphic3d_CView& ACView, const Standard_Boolean isEnabled ) const
7fd59977 56{
2166f0fa
SK
57 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
58 if (aCView)
59 aCView->WS->UseGLLight() = isEnabled;
7fd59977 60}
61
2166f0fa 62Standard_Boolean OpenGl_GraphicDriver::IsGLLightEnabled( const Graphic3d_CView& ACView ) const
7fd59977 63{
2166f0fa
SK
64 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
65 if (aCView)
66 return aCView->WS->UseGLLight();
67 return Standard_False;
7fd59977 68}
69
2166f0fa
SK
70void OpenGl_GraphicDriver::PrimitiveArray( const Graphic3d_CGroup& ACGroup,
71 const Graphic3d_PrimitiveArray& parray,
72 const Standard_Boolean EvalMinMax )
7fd59977 73{
2166f0fa
SK
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 }
7fd59977 79}
80
98178592
A
81//=======================================================================
82//function : RemovePrimitiveArray
83//purpose : Purpose: Clear visualization data in graphical driver and
84// stop displaying the primitives array of the graphical group
85// <theCGroup>. This method is internal and should be used by
86// Graphic3d_Group only.
87//=======================================================================
88
5e27df78 89void OpenGl_GraphicDriver::RemovePrimitiveArray (const Graphic3d_CGroup& theCGroup,
90 const Graphic3d_PrimitiveArray& thePArray)
98178592 91{
5e27df78 92 if (theCGroup.ptrGroup && thePArray)
2166f0fa 93 {
5e27df78 94 ((OpenGl_Group* )theCGroup.ptrGroup)->RemovePrimitiveArray (GetSharedContext(), thePArray);
2166f0fa 95 }
98178592 96}
7fd59977 97
5e27df78 98void OpenGl_GraphicDriver::UserDraw (const Graphic3d_CGroup& theCGroup,
99 const Graphic3d_CUserDraw& theUserDraw)
2166f0fa 100{
5e27df78 101 if (theCGroup.ptrGroup != NULL
102 && myUserDrawCallback != NULL)
2166f0fa 103 {
5e27df78 104 OpenGl_Element* aUserDraw = myUserDrawCallback(&theUserDraw);
105 if (aUserDraw != NULL)
106 {
107 ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelUserdraw, aUserDraw);
108 }
2166f0fa 109 }
7fd59977 110}