Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-08-05 |
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 | ||
2166f0fa | 20 | |
5f8b738e | 21 | #include <OpenGl_GlCore11.hxx> |
22 | ||
2166f0fa SK |
23 | #include <OpenGl_Workspace.hxx> |
24 | ||
25 | #include <OpenGl_AspectLine.hxx> | |
26 | #include <OpenGl_AspectFace.hxx> | |
27 | #include <OpenGl_AspectMarker.hxx> | |
28 | #include <OpenGl_AspectText.hxx> | |
30f0ad28 | 29 | #include <OpenGl_Context.hxx> |
30 | #include <OpenGl_ShaderManager.hxx> | |
0f8c0fb8 | 31 | #include <OpenGl_telem_util.hxx> |
2166f0fa | 32 | |
498ce577 | 33 | #ifdef HAVE_CONFIG_H |
34 | # include <config.h> | |
35 | #endif | |
36 | ||
2166f0fa SK |
37 | /* OCC22218 NOTE: project dependency on gl2ps is specified by macro */ |
38 | #ifdef HAVE_GL2PS | |
39 | #include <gl2ps.h> | |
bf75be98 | 40 | /* OCC22216 NOTE: linker dependency can be switched off by undefining macro. |
41 | Pragma comment for gl2ps.lib is defined only here. */ | |
42 | #ifdef _MSC_VER | |
2166f0fa SK |
43 | #pragma comment( lib, "gl2ps.lib" ) |
44 | #endif | |
45 | #endif | |
46 | ||
2166f0fa | 47 | #include <Aspect_PolygonOffsetMode.hxx> |
2166f0fa SK |
48 | #include <OpenGl_View.hxx> |
49 | ||
50 | /*----------------------------------------------------------------------*/ | |
51 | ||
52 | static void TelUpdatePolygonOffsets( const TEL_POFFSET_PARAM *pdata ) | |
53 | { | |
54 | if ( ( pdata->mode & Aspect_POM_Fill ) == Aspect_POM_Fill ) | |
55 | glEnable ( GL_POLYGON_OFFSET_FILL ); | |
bf75be98 | 56 | else |
2166f0fa SK |
57 | glDisable ( GL_POLYGON_OFFSET_FILL ); |
58 | ||
59 | if ( ( pdata->mode & Aspect_POM_Line ) == Aspect_POM_Line ) | |
60 | glEnable ( GL_POLYGON_OFFSET_LINE ); | |
61 | else | |
62 | glDisable( GL_POLYGON_OFFSET_LINE ); | |
63 | ||
64 | if ( ( pdata->mode & Aspect_POM_Point ) == Aspect_POM_Point ) | |
65 | glEnable ( GL_POLYGON_OFFSET_POINT ); | |
66 | else | |
67 | glDisable( GL_POLYGON_OFFSET_POINT ); | |
68 | ||
69 | glPolygonOffset( pdata->factor, pdata->units ); | |
70 | } | |
71 | ||
72 | /*----------------------------------------------------------------------*/ | |
73 | ||
74 | void OpenGl_Workspace::UpdateMaterial( const int flag ) | |
75 | { | |
fd4a6963 | 76 | // Case of hidden line |
77 | if (AspectFace_set->InteriorStyle() == Aspect_IS_HIDDENLINE) | |
2166f0fa | 78 | { |
fd4a6963 | 79 | myAspectFaceHl = *AspectFace_set; // copy all values including line edge aspect |
80 | myAspectFaceHl.ChangeIntFront().matcol = BackgroundColor(); | |
81 | myAspectFaceHl.ChangeIntFront().color_mask = 0; | |
82 | myAspectFaceHl.ChangeIntFront().color_mask = 0; | |
2166f0fa | 83 | |
fd4a6963 | 84 | AspectFace_set = &myAspectFaceHl; |
2166f0fa SK |
85 | return; |
86 | } | |
87 | ||
88 | const OPENGL_SURF_PROP *prop = NULL; | |
89 | GLenum face = 0; | |
90 | if ( flag == TEL_FRONT_MATERIAL ) | |
91 | { | |
fd4a6963 | 92 | prop = &AspectFace_set->IntFront(); |
2166f0fa SK |
93 | face = GL_FRONT_AND_BACK; |
94 | } | |
95 | else | |
96 | { | |
fd4a6963 | 97 | prop = &AspectFace_set->IntBack(); |
2166f0fa SK |
98 | face = GL_BACK; |
99 | } | |
100 | ||
2166f0fa SK |
101 | // Handling transparency |
102 | if ( (NamedStatus & OPENGL_NS_2NDPASSDO) == 0 ) | |
103 | { | |
104 | if ( myUseTransparency && prop->trans != 1.0F ) | |
105 | { | |
106 | // Render transparent | |
bf75be98 | 107 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2166f0fa SK |
108 | glEnable (GL_BLEND); |
109 | glDepthMask (GL_FALSE); | |
110 | } | |
bf75be98 | 111 | else |
2166f0fa SK |
112 | { |
113 | // Render opaque | |
114 | if ( (NamedStatus & OPENGL_NS_ANTIALIASING) == 0 ) | |
115 | { | |
116 | glBlendFunc (GL_ONE, GL_ZERO); | |
117 | glDisable (GL_BLEND); | |
118 | } | |
119 | glDepthMask (GL_TRUE); | |
bf75be98 | 120 | } |
2166f0fa SK |
121 | } |
122 | ||
3f65725b | 123 | // Obtaining reflection mode flags to update GL material properties |
124 | const unsigned int aReflectionMode = prop->color_mask; | |
125 | ||
126 | // Do not update material properties in case of zero reflection mode, | |
127 | // because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() | |
128 | // anyway. | |
129 | if ( !aReflectionMode ) return; | |
130 | ||
2166f0fa SK |
131 | static float mAmb[4]; |
132 | static float mDiff[4]; | |
133 | static float mSpec[4]; | |
134 | static float mEmsv[4]; | |
135 | static float mShin; | |
136 | ||
137 | static const float defspeccol[4] = { 1.F, 1.F, 1.F, 1.F }; | |
138 | ||
139 | // Reset material | |
140 | if ( NamedStatus & OPENGL_NS_RESMAT ) | |
bf75be98 | 141 | { |
2166f0fa | 142 | // Ambient component |
3f65725b | 143 | if( aReflectionMode & OPENGL_AMBIENT_MASK ) |
2166f0fa SK |
144 | { |
145 | const float *c = prop->isphysic? prop->ambcol.rgb : prop->matcol.rgb; | |
146 | ||
147 | mAmb[0] = prop->amb * c[0]; | |
148 | mAmb[1] = prop->amb * c[1]; | |
149 | mAmb[2] = prop->amb * c[2]; | |
150 | } | |
151 | else | |
152 | { | |
153 | mAmb[0] = 0.F; | |
154 | mAmb[1] = 0.F; | |
155 | mAmb[2] = 0.F; | |
156 | } | |
157 | mAmb[3] = 1.F; | |
158 | ||
159 | // Diffusion component | |
3f65725b | 160 | if( aReflectionMode & OPENGL_DIFFUSE_MASK ) |
2166f0fa SK |
161 | { |
162 | const float *c = prop->isphysic? prop->difcol.rgb : prop->matcol.rgb; | |
163 | ||
164 | mDiff[0] = prop->diff * c[0]; | |
165 | mDiff[1] = prop->diff * c[1]; | |
166 | mDiff[2] = prop->diff * c[2]; | |
167 | } | |
168 | else | |
169 | { | |
170 | mDiff[0] = 0.F; | |
171 | mDiff[1] = 0.F; | |
172 | mDiff[2] = 0.F; | |
173 | } | |
174 | mDiff[3] = 1.F; | |
175 | ||
176 | if (NamedStatus & OPENGL_NS_2NDPASSDO) | |
177 | { | |
bf75be98 | 178 | mDiff[3] = prop->env_reflexion; |
2166f0fa SK |
179 | } |
180 | else | |
181 | { | |
182 | if (myUseTransparency) mDiff[3] = prop->trans; | |
183 | // If the material reflects the environment scene, the second pass is needed | |
184 | if (prop->env_reflexion != 0.0) NamedStatus |= OPENGL_NS_2NDPASSNEED; | |
185 | } | |
186 | ||
187 | // Specular component | |
3f65725b | 188 | if( aReflectionMode & OPENGL_SPECULAR_MASK ) |
2166f0fa SK |
189 | { |
190 | const float *c = prop->isphysic? prop->speccol.rgb : defspeccol; | |
191 | ||
192 | mSpec[0] = prop->spec * c[0]; | |
193 | mSpec[1] = prop->spec * c[1]; | |
194 | mSpec[2] = prop->spec * c[2]; | |
bf75be98 | 195 | } |
2166f0fa SK |
196 | else { |
197 | mSpec[0] = 0.F; | |
198 | mSpec[1] = 0.F; | |
199 | mSpec[2] = 0.F; | |
200 | } | |
201 | mSpec[3] = 1.F; | |
202 | ||
203 | // Emissive component | |
3f65725b | 204 | if( aReflectionMode & OPENGL_EMISSIVE_MASK ) |
bf75be98 | 205 | { |
2166f0fa SK |
206 | const float *c = prop->isphysic? prop->emscol.rgb : prop->matcol.rgb; |
207 | ||
208 | mEmsv[0] = prop->emsv * c[0]; | |
209 | mEmsv[1] = prop->emsv * c[1]; | |
210 | mEmsv[2] = prop->emsv * c[2]; | |
211 | } | |
212 | else { | |
213 | mEmsv[0] = 0.F; | |
214 | mEmsv[1] = 0.F; | |
215 | mEmsv[2] = 0.F; | |
216 | } | |
217 | mEmsv[3] = 1.F; | |
218 | ||
219 | /* Coeficient de brillance */ | |
220 | mShin = prop->shine; | |
221 | ||
222 | glMaterialfv(face, GL_AMBIENT, mAmb ); | |
223 | glMaterialfv(face, GL_DIFFUSE, mDiff ); | |
224 | glMaterialfv(face, GL_SPECULAR, mSpec); | |
225 | glMaterialfv(face, GL_EMISSION, mEmsv); | |
226 | glMaterialf(face, GL_SHININESS, mShin); | |
227 | ||
228 | NamedStatus &= ~OPENGL_NS_RESMAT; | |
bf75be98 | 229 | } |
2166f0fa SK |
230 | |
231 | // Set Material Optimize | |
bf75be98 | 232 | else |
2166f0fa SK |
233 | { |
234 | // Ambient component | |
3f65725b | 235 | if( aReflectionMode & OPENGL_AMBIENT_MASK ) |
2166f0fa SK |
236 | { |
237 | const float *c = prop->isphysic? prop->ambcol.rgb : prop->matcol.rgb; | |
238 | ||
239 | if (mAmb[0] != prop->amb * c[0] || | |
240 | mAmb[1] != prop->amb * c[1] || | |
241 | mAmb[2] != prop->amb * c[2] ) | |
242 | { | |
243 | mAmb[0] = prop->amb * c[0]; | |
244 | mAmb[1] = prop->amb * c[1]; | |
245 | mAmb[2] = prop->amb * c[2]; | |
246 | mAmb[3] = 1.F; | |
247 | ||
248 | glMaterialfv(face, GL_AMBIENT, mAmb); | |
249 | } | |
250 | } | |
251 | else | |
252 | { | |
253 | if ( mAmb[0] != 0.F || mAmb[1] != 0.F || mAmb[2] != 0.F ) | |
254 | { | |
255 | mAmb[0] = 0.F; | |
256 | mAmb[1] = 0.F; | |
257 | mAmb[2] = 0.F; | |
258 | mAmb[3] = 1.F; | |
259 | ||
260 | glMaterialfv(face, GL_AMBIENT, mAmb); | |
261 | } | |
262 | } | |
263 | ||
264 | // Diffusion component | |
3f65725b | 265 | if( aReflectionMode & OPENGL_DIFFUSE_MASK ) |
2166f0fa SK |
266 | { |
267 | const float *c = prop->isphysic? prop->difcol.rgb : prop->matcol.rgb; | |
268 | ||
269 | if (mDiff[0] != prop->diff * c[0] || | |
270 | mDiff[1] != prop->diff * c[1] || | |
271 | mDiff[2] != prop->diff * c[2] || | |
272 | mDiff[3] != ((NamedStatus & OPENGL_NS_2NDPASSDO)? prop->env_reflexion : (myUseTransparency? prop->trans : 1.0F))) | |
273 | { | |
274 | mDiff[0] = prop->diff * c[0]; | |
275 | mDiff[1] = prop->diff * c[1]; | |
276 | mDiff[2] = prop->diff * c[2]; | |
277 | mDiff[3] = 1.F; | |
278 | ||
279 | if (NamedStatus & OPENGL_NS_2NDPASSDO) | |
280 | { | |
bf75be98 | 281 | mDiff[3] = prop->env_reflexion; |
2166f0fa SK |
282 | } |
283 | else | |
284 | { | |
285 | if (myUseTransparency) mDiff[3] = prop->trans; | |
286 | // If the material reflects the environment scene, the second pass is needed | |
287 | if (prop->env_reflexion != 0.0) NamedStatus |= OPENGL_NS_2NDPASSNEED; | |
288 | } | |
289 | ||
290 | glMaterialfv(face, GL_DIFFUSE, mDiff ); | |
291 | } | |
292 | } | |
293 | else | |
294 | { | |
295 | Tfloat newDiff3 = 1.F; | |
296 | ||
297 | if (NamedStatus & OPENGL_NS_2NDPASSDO) | |
298 | { | |
bf75be98 | 299 | newDiff3 = prop->env_reflexion; |
2166f0fa SK |
300 | } |
301 | else | |
302 | { | |
303 | if (myUseTransparency) newDiff3 = prop->trans; | |
304 | // If the material reflects the environment scene, the second pass is needed | |
305 | if (prop->env_reflexion != 0.0) NamedStatus |= OPENGL_NS_2NDPASSNEED; | |
306 | } | |
307 | ||
308 | /* OCC19915: Even if diffuse reflectance is disabled, | |
309 | still trying to update the current transparency if it | |
310 | differs from the previous value */ | |
311 | if ( mDiff[0] != 0.F || mDiff[1] != 0.F || mDiff[2] != 0.F || fabs(mDiff[3] - newDiff3) > 0.01F ) | |
312 | { | |
313 | mDiff[0] = 0.F; | |
314 | mDiff[1] = 0.F; | |
315 | mDiff[2] = 0.F; | |
316 | mDiff[3] = newDiff3; | |
317 | ||
318 | glMaterialfv(face, GL_DIFFUSE, mDiff); | |
319 | } | |
320 | } | |
321 | ||
322 | // Specular component | |
3f65725b | 323 | if( aReflectionMode & OPENGL_SPECULAR_MASK ) |
bf75be98 | 324 | { |
2166f0fa SK |
325 | const float *c = prop->isphysic? prop->speccol.rgb : defspeccol; |
326 | ||
327 | if (mSpec[0] != prop->spec * c[0] || | |
328 | mSpec[1] != prop->spec * c[1] || | |
329 | mSpec[2] != prop->spec * c[2]) | |
330 | { | |
331 | mSpec[0] = prop->spec * c[0]; | |
332 | mSpec[1] = prop->spec * c[1]; | |
333 | mSpec[2] = prop->spec * c[2]; | |
334 | mSpec[3] = 1.F; | |
335 | ||
336 | glMaterialfv(face, GL_SPECULAR, mSpec); | |
337 | } | |
338 | } | |
339 | else | |
340 | { | |
341 | if ( mSpec[0] != 0.F || mSpec[1] != 0.F || mSpec[2] != 0.F ) | |
342 | { | |
343 | mSpec[0] = 0.F; | |
344 | mSpec[1] = 0.F; | |
345 | mSpec[2] = 0.F; | |
346 | mSpec[3] = 1.F; | |
347 | ||
348 | glMaterialfv(face, GL_SPECULAR, mSpec); | |
349 | } | |
350 | } | |
351 | ||
352 | // Emissive component | |
3f65725b | 353 | if( aReflectionMode & OPENGL_EMISSIVE_MASK ) |
2166f0fa SK |
354 | { |
355 | const float *c = prop->isphysic? prop->emscol.rgb : prop->matcol.rgb; | |
356 | ||
357 | if (mEmsv[0] != prop->emsv * c[0] || | |
358 | mEmsv[1] != prop->emsv * c[1] || | |
359 | mEmsv[2] != prop->emsv * c[2]) | |
360 | { | |
361 | mEmsv[0] = prop->emsv * c[0]; | |
362 | mEmsv[1] = prop->emsv * c[1]; | |
363 | mEmsv[2] = prop->emsv * c[2]; | |
364 | mEmsv[3] = 1.F; | |
365 | ||
366 | glMaterialfv(face, GL_EMISSION, mEmsv); | |
367 | } | |
368 | } | |
bf75be98 | 369 | else |
370 | { | |
2166f0fa SK |
371 | if ( mEmsv[0] != 0.F || mEmsv[1] != 0.F || mEmsv[2] != 0.F ) |
372 | { | |
373 | mEmsv[0] = 0.F; | |
374 | mEmsv[1] = 0.F; | |
375 | mEmsv[2] = 0.F; | |
376 | mEmsv[3] = 1.F; | |
377 | ||
378 | glMaterialfv(face, GL_EMISSION, mEmsv); | |
379 | } | |
380 | } | |
381 | ||
382 | // Shining coefficient | |
383 | if( mShin != prop->shine ) | |
384 | { | |
385 | mShin = prop->shine; | |
386 | glMaterialf(face, GL_SHININESS, mShin); | |
387 | } | |
388 | } | |
389 | } | |
390 | ||
391 | /*----------------------------------------------------------------------*/ | |
392 | ||
393 | const OpenGl_AspectLine * OpenGl_Workspace::SetAspectLine(const OpenGl_AspectLine *AnAspect) | |
394 | { | |
395 | const OpenGl_AspectLine *AspectLine_old = AspectLine_set; | |
396 | AspectLine_set = AnAspect; | |
397 | return AspectLine_old; | |
398 | } | |
399 | ||
400 | /*----------------------------------------------------------------------*/ | |
401 | ||
402 | const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace(const OpenGl_AspectFace *AnAspect) | |
403 | { | |
404 | const OpenGl_AspectFace *AspectFace_old = AspectFace_set; | |
405 | AspectFace_set = AnAspect; | |
406 | return AspectFace_old; | |
407 | } | |
408 | ||
409 | /*----------------------------------------------------------------------*/ | |
410 | ||
411 | const OpenGl_AspectMarker * OpenGl_Workspace::SetAspectMarker(const OpenGl_AspectMarker *AnAspect) | |
412 | { | |
413 | const OpenGl_AspectMarker *AspectMarker_old = AspectMarker_set; | |
414 | AspectMarker_set = AnAspect; | |
415 | return AspectMarker_old; | |
416 | } | |
417 | ||
418 | /*----------------------------------------------------------------------*/ | |
419 | ||
420 | const OpenGl_AspectText * OpenGl_Workspace::SetAspectText(const OpenGl_AspectText *AnAspect) | |
421 | { | |
422 | const OpenGl_AspectText *AspectText_old = AspectText_set; | |
423 | AspectText_set = AnAspect; | |
424 | return AspectText_old; | |
425 | } | |
426 | ||
427 | /*----------------------------------------------------------------------*/ | |
428 | ||
0f8c0fb8 | 429 | const OpenGl_Matrix * OpenGl_Workspace::SetViewMatrix (const OpenGl_Matrix *AMatrix) |
2166f0fa SK |
430 | { |
431 | const OpenGl_Matrix *ViewMatrix_old = ViewMatrix_applied; | |
432 | ViewMatrix_applied = AMatrix; | |
433 | ||
0f8c0fb8 | 434 | // Update model-view matrix with new view matrix |
435 | UpdateModelViewMatrix(); | |
2166f0fa SK |
436 | |
437 | return ViewMatrix_old; | |
438 | } | |
439 | ||
440 | /*----------------------------------------------------------------------*/ | |
441 | ||
30f0ad28 | 442 | const OpenGl_Matrix * OpenGl_Workspace::SetStructureMatrix (const OpenGl_Matrix *AMatrix, bool aRevert) |
2166f0fa SK |
443 | { |
444 | const OpenGl_Matrix *StructureMatrix_old = StructureMatrix_applied; | |
445 | StructureMatrix_applied = AMatrix; | |
446 | ||
447 | OpenGl_Matrix lmat; | |
448 | OpenGl_Transposemat3( &lmat, AMatrix ); | |
449 | ||
0f8c0fb8 | 450 | // Update model-view matrix with new structure matrix |
451 | UpdateModelViewMatrix(); | |
2166f0fa | 452 | |
30f0ad28 | 453 | if (!myGlContext->ShaderManager()->IsEmpty()) |
454 | { | |
455 | if (aRevert) | |
392ac980 | 456 | { |
30f0ad28 | 457 | myGlContext->ShaderManager()->RevertModelWorldStateTo (lmat.mat); |
392ac980 | 458 | } |
459 | else | |
460 | { | |
461 | myGlContext->ShaderManager()->UpdateModelWorldStateTo (lmat.mat); | |
462 | } | |
30f0ad28 | 463 | } |
464 | ||
2166f0fa SK |
465 | return StructureMatrix_old; |
466 | } | |
467 | ||
468 | /*----------------------------------------------------------------------*/ | |
469 | ||
0f8c0fb8 | 470 | const void OpenGl_Workspace::UpdateModelViewMatrix() |
471 | { | |
472 | OpenGl_Matrix aStructureMatT; | |
473 | OpenGl_Transposemat3( &aStructureMatT, StructureMatrix_applied); | |
474 | ||
475 | glMatrixMode (GL_MODELVIEW); | |
476 | OpenGl_Multiplymat3 (&myModelViewMatrix, &aStructureMatT, ViewMatrix_applied); | |
477 | glLoadMatrixf ((const GLfloat* )&myModelViewMatrix.mat); | |
478 | } | |
479 | ||
480 | /*----------------------------------------------------------------------*/ | |
481 | ||
2166f0fa SK |
482 | const OpenGl_AspectLine * OpenGl_Workspace::AspectLine(const Standard_Boolean WithApply) |
483 | { | |
484 | if ( WithApply && (AspectLine_set != AspectLine_applied) ) | |
485 | { | |
486 | glColor3fv(AspectLine_set->Color().rgb); | |
487 | ||
488 | if ( !AspectLine_applied || (AspectLine_set->Type() != AspectLine_applied->Type() ) ) | |
489 | { | |
490 | myDisplay->SetTypeOfLine(AspectLine_set->Type()); | |
491 | } | |
492 | ||
493 | if ( !AspectLine_applied || ( AspectLine_set->Width() != AspectLine_applied->Width() ) ) | |
494 | { | |
495 | glLineWidth( (GLfloat)AspectLine_set->Width() ); | |
496 | #ifdef HAVE_GL2PS | |
497 | gl2psLineWidth( (GLfloat)AspectLine_set->Width() ); | |
498 | #endif | |
499 | } | |
500 | ||
501 | AspectLine_applied = AspectLine_set; | |
502 | } | |
503 | return AspectLine_set; | |
504 | } | |
505 | ||
506 | /*----------------------------------------------------------------------*/ | |
507 | ||
bf75be98 | 508 | const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean theToApply) |
2166f0fa | 509 | { |
bf75be98 | 510 | if (!theToApply || (AspectFace_set == AspectFace_applied)) |
511 | { | |
512 | return AspectFace_set; | |
513 | } | |
514 | ||
fd4a6963 | 515 | const Aspect_InteriorStyle anIntstyle = AspectFace_set->InteriorStyle(); |
516 | if (AspectFace_applied == NULL || AspectFace_applied->InteriorStyle() != anIntstyle) | |
2166f0fa | 517 | { |
bf75be98 | 518 | switch (anIntstyle) |
2166f0fa | 519 | { |
bf75be98 | 520 | case Aspect_IS_EMPTY: |
521 | case Aspect_IS_HOLLOW: | |
2166f0fa | 522 | { |
bf75be98 | 523 | glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); |
524 | break; | |
2166f0fa | 525 | } |
bf75be98 | 526 | case Aspect_IS_HATCH: |
527 | { | |
528 | glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); | |
fd4a6963 | 529 | myDisplay->SetTypeOfHatch (AspectFace_applied != NULL ? AspectFace_applied->Hatch() : TEL_HS_SOLID); |
bf75be98 | 530 | break; |
531 | } | |
532 | case Aspect_IS_SOLID: | |
533 | case Aspect_IS_HIDDENLINE: | |
534 | { | |
535 | glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); | |
536 | glDisable (GL_POLYGON_STIPPLE); | |
537 | break; | |
538 | } | |
498ce76b | 539 | case Aspect_IS_POINT: //szvgl - no corresponding enumeration item Aspect_IS_POINT // = 5 |
2166f0fa | 540 | { |
bf75be98 | 541 | glPolygonMode(GL_FRONT_AND_BACK,GL_POINT); |
542 | break; | |
2166f0fa SK |
543 | } |
544 | } | |
bf75be98 | 545 | } |
546 | ||
547 | if (anIntstyle == Aspect_IS_HATCH) | |
548 | { | |
fd4a6963 | 549 | const Tint hatchstyle = AspectFace_set->Hatch(); |
550 | if (AspectFace_applied == NULL || AspectFace_applied->Hatch() != hatchstyle) | |
bf75be98 | 551 | { |
552 | myDisplay->SetTypeOfHatch(hatchstyle); | |
553 | } | |
554 | } | |
555 | ||
556 | if (!ActiveView()->Backfacing()) | |
557 | { | |
fd4a6963 | 558 | const Tint aCullingMode = AspectFace_set->CullingMode(); |
559 | if (AspectFace_applied == NULL || AspectFace_applied->CullingMode() != aCullingMode) | |
2166f0fa | 560 | { |
bf75be98 | 561 | switch ((TelCullMode )aCullingMode) |
2166f0fa | 562 | { |
bf75be98 | 563 | case TelCullNone: |
2166f0fa | 564 | { |
bf75be98 | 565 | glDisable (GL_CULL_FACE); |
566 | break; | |
567 | } | |
568 | case TelCullFront: | |
569 | { | |
570 | glCullFace (GL_FRONT); | |
571 | glEnable (GL_CULL_FACE); | |
572 | break; | |
573 | } | |
574 | case TelCullBack: | |
575 | { | |
576 | glCullFace (GL_BACK); | |
577 | glEnable (GL_CULL_FACE); | |
578 | break; | |
2166f0fa SK |
579 | } |
580 | } | |
581 | } | |
bf75be98 | 582 | } |
2166f0fa | 583 | |
bf75be98 | 584 | // Aspect_POM_None means: do not change current settings |
fd4a6963 | 585 | if ((AspectFace_set->PolygonOffset().mode & Aspect_POM_None) != Aspect_POM_None) |
bf75be98 | 586 | { |
587 | if (PolygonOffset_applied == NULL | |
fd4a6963 | 588 | || PolygonOffset_applied->mode != AspectFace_set->PolygonOffset().mode |
589 | || PolygonOffset_applied->factor != AspectFace_set->PolygonOffset().factor | |
590 | || PolygonOffset_applied->units != AspectFace_set->PolygonOffset().units) | |
2166f0fa | 591 | { |
fd4a6963 | 592 | PolygonOffset_applied = &AspectFace_set->PolygonOffset(); |
bf75be98 | 593 | TelUpdatePolygonOffsets (PolygonOffset_applied); |
2166f0fa | 594 | } |
bf75be98 | 595 | } |
2166f0fa | 596 | |
bf75be98 | 597 | UpdateMaterial (TEL_FRONT_MATERIAL); |
fd4a6963 | 598 | if (AspectFace_set->DistinguishingMode() == TOn) |
bf75be98 | 599 | { |
600 | UpdateMaterial (TEL_BACK_MATERIAL); | |
601 | } | |
2166f0fa | 602 | |
bf75be98 | 603 | if ((NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0) |
604 | { | |
fd4a6963 | 605 | if (AspectFace_set->DoTextureMap()) |
bf75be98 | 606 | { |
fd4a6963 | 607 | EnableTexture (AspectFace_set->TextureRes (this), |
608 | AspectFace_set->TextureParams()); | |
bf75be98 | 609 | } |
610 | else | |
2166f0fa SK |
611 | { |
612 | DisableTexture(); | |
2166f0fa | 613 | } |
2166f0fa | 614 | } |
bf75be98 | 615 | |
616 | AspectFace_applied = AspectFace_set; | |
2166f0fa SK |
617 | return AspectFace_set; |
618 | } | |
619 | ||
620 | /*----------------------------------------------------------------------*/ | |
621 | ||
17f65eb2 | 622 | const OpenGl_AspectMarker* OpenGl_Workspace::AspectMarker (const Standard_Boolean theToApply) |
2166f0fa | 623 | { |
17f65eb2 | 624 | if (theToApply && (AspectMarker_set != AspectMarker_applied)) |
2166f0fa | 625 | { |
17f65eb2 | 626 | if (!AspectMarker_applied || (AspectMarker_set->Scale() != AspectMarker_applied->Scale())) |
627 | { | |
628 | glPointSize (AspectMarker_set->Scale()); | |
629 | #ifdef HAVE_GL2PS | |
630 | gl2psPointSize (AspectMarker_set->Scale()); | |
631 | #endif | |
632 | } | |
2166f0fa SK |
633 | AspectMarker_applied = AspectMarker_set; |
634 | } | |
635 | return AspectMarker_set; | |
636 | } | |
637 | ||
638 | /*----------------------------------------------------------------------*/ | |
639 | ||
a174a3c5 | 640 | const OpenGl_AspectText* OpenGl_Workspace::AspectText (const Standard_Boolean theWithApply) |
2166f0fa | 641 | { |
a174a3c5 | 642 | if (theWithApply) |
2166f0fa | 643 | { |
a174a3c5 | 644 | AspectText_applied = AspectText_set; |
645 | TextParam_applied = TextParam_set; | |
2166f0fa | 646 | } |
a174a3c5 | 647 | |
2166f0fa SK |
648 | return AspectText_set; |
649 | } |