0024310: TKOpenGl - GLSL compatibility issues
[occt.git] / src / Graphic3d / Graphic3d_GraphicDriver.cxx
1 // Created on: 1997-01-28
2 // Created by: CAL
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21 //              11/97 ; CAL : retrait de la dependance avec math
22
23
24 //-Version  
25
26 //-Design Declaration des variables specifiques aux Drivers
27
28 //-Warning  Un driver encapsule les Pex, Phigs et OpenGl drivers
29
30 //-References 
31
32 //-Language C++ 2.0
33
34 //-Declarations
35
36 // for the class
37 #include <Graphic3d_GraphicDriver.ixx>
38
39 #include <Aspect_DriverDefinitionError.hxx>
40
41 //-Aliases
42
43 //-Global data definitions
44
45 //-Constructors
46
47 Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Standard_CString AShrName) {
48
49   SetTrace (0);
50   MySharedLibrary.SetName (AShrName);
51   myDeviceLostFlag = Standard_False;
52
53   //if (! MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
54   //Aspect_DriverDefinitionError::Raise (MySharedLibrary.DlError ());
55
56 }
57
58 //-Internal methods, in order
59
60 void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const {
61
62   cout << "\t" << AComment << " : "
63     << (AValue ? "True" : "False") << "\n";
64   cout << flush;
65
66 }
67
68 void Graphic3d_GraphicDriver::PrintCGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer AField) const {
69
70   if (AField) {
71     cout << "\tstruct id " << ACGroup.Struct->Id << "\n";
72     cout << "\tgroup\n";
73     cout << flush;
74   }
75
76 }
77
78 void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& theCLight,
79                                            const Standard_Integer  theField) const
80 {
81   if (theField)
82   {
83     switch (theCLight.Type) {
84     case 0 :
85       cout << "\tlight type : ambient\n";
86       break;
87     case 1 :
88       cout << "\tlight type : directional\n";
89       break;
90     case 2 :
91       cout << "\tlight type : positional\n";
92       break;
93     case 3 :
94       cout << "\tlight type : spot\n";
95       break;
96     default :
97       cout << "\tlight type : undefined, error\n";
98       break;
99     }
100     cout << flush;
101   }
102 }
103
104 void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
105
106   if (AField) {
107     cout << "\tws id " << ACPick.WsId
108       << " view id " << ACPick.ViewId << "\n";
109     cout << "\twindow id " << ACPick.DefWindow.XWindow << "\n";
110     cout << "\tposition " << ACPick.x << " , " << ACPick.y << "\n";
111     cout << flush;
112   }
113
114 }
115
116 void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
117
118   if (AField) {
119     cout << "\tstruct id " << ACStructure.Id << "\n";
120     cout << flush;
121   }
122
123 }
124
125 void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
126
127   if (AField) {
128     cout << "\tws id " << ACView.WsId << ", "
129       << "view id " << ACView.ViewId << "\n";
130     cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
131       << "activity " << ACView.Active << "\n";
132     cout << flush;
133   }
134
135 }
136
137 void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
138
139   cout << AFunc << "\n";
140   cout << flush;
141
142 }
143
144 void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
145
146   cout << "\t" << AComment << " : " << AValue << "\n";
147   cout << flush;
148
149 }
150
151 void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
152
153   cout << AFunc << " = " << AResult << "\n";
154   cout << flush;
155
156 }
157
158 void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
159
160   Standard_Integer lr, ur, lc, uc;
161   Standard_Integer i, j;
162
163   lr = AMatrix.LowerRow ();
164   ur = AMatrix.UpperRow ();
165   lc = AMatrix.LowerCol ();
166   uc = AMatrix.UpperCol ();
167
168   if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
169     Graphic3d_TransformError::Raise
170     ("PrintMatrix : not a 4x4 matrix");
171
172   cout << "\t" << AComment << " :\n";
173   for (i=lr; i<=ur; i++) {
174     for (j=lc; j<=uc; j++) {
175       cout << AMatrix (i, j) << " ";
176     }
177     cout << "\n";
178   }
179   cout << flush;
180
181 }
182
183 void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
184
185   cout << "\t" << AComment << " : " << AValue << "\n";
186   cout << flush;
187
188 }
189
190 void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
191
192   cout << "\t" << AComment << " : " << AString << "\n";
193   cout << flush;
194
195 }
196
197 void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
198
199   MyTraceLevel = ALevel;
200
201 }
202
203 Standard_Integer Graphic3d_GraphicDriver::Trace () const {
204
205   return MyTraceLevel;
206
207 }
208
209 const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
210 {
211   return myDisplayConnection;
212 }
213
214 Standard_Boolean Graphic3d_GraphicDriver::IsDeviceLost() const
215 {
216   return myDeviceLostFlag;
217 }
218
219 void Graphic3d_GraphicDriver::ResetDeviceLostFlag()
220 {
221   myDeviceLostFlag = Standard_False;
222 }