Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-09-20 |
2 | // Created by: Sergey ZERCHANINOV | |
973c2be1 | 3 | // Copyright (c) 2011-2014 OPEN CASCADE SAS |
b311480e | 4 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
d5f74e42 | 7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
11 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
b311480e | 15 | |
c357e426 | 16 | #include <OpenGl_Workspace.hxx> |
5f8b738e | 17 | |
c357e426 | 18 | #include <OpenGl_ArbFBO.hxx> |
bf5f0ca2 | 19 | #include <OpenGl_Aspects.hxx> |
bf75be98 | 20 | #include <OpenGl_Context.hxx> |
679ecdee | 21 | #include <OpenGl_Element.hxx> |
a174a3c5 | 22 | #include <OpenGl_FrameBuffer.hxx> |
c357e426 | 23 | #include <OpenGl_GlCore15.hxx> |
24 | #include <OpenGl_SceneGeometry.hxx> | |
679ecdee | 25 | #include <OpenGl_Structure.hxx> |
25ef750e | 26 | #include <OpenGl_Sampler.hxx> |
8613985b | 27 | #include <OpenGl_ShaderManager.hxx> |
bf75be98 | 28 | #include <OpenGl_Texture.hxx> |
e276548b | 29 | #include <OpenGl_View.hxx> |
c357e426 | 30 | #include <OpenGl_Window.hxx> |
2166f0fa | 31 | |
bf75be98 | 32 | #include <Graphic3d_TextureParams.hxx> |
825aa485 | 33 | #include <Graphic3d_TransformUtils.hxx> |
2166f0fa | 34 | |
92efcf78 | 35 | IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient) |
92efcf78 | 36 | |
2166f0fa SK |
37 | namespace |
38 | { | |
b6472664 | 39 | static const OpenGl_Vec4 THE_WHITE_COLOR (1.0f, 1.0f, 1.0f, 1.0f); |
40 | static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f); | |
2166f0fa | 41 | |
2166f0fa SK |
42 | static const OpenGl_Matrix myDefaultMatrix = |
43 | { | |
44 | {{ 1.0F, 0.0F, 0.0F, 0.0F }, | |
45 | { 0.0F, 1.0F, 0.0F, 0.0F }, | |
46 | { 0.0F, 0.0F, 1.0F, 0.0F }, | |
47 | { 0.0F, 0.0F, 0.0F, 1.0F }} | |
48 | }; | |
bf75be98 | 49 | |
a3f6f591 | 50 | } |
2166f0fa | 51 | |
0adbd30f | 52 | // ======================================================================= |
53 | // function : Init | |
54 | // purpose : | |
55 | // ======================================================================= | |
ba00aab7 | 56 | void OpenGl_Material::Init (const OpenGl_Context& theCtx, |
57 | const Graphic3d_MaterialAspect& theMat, | |
58 | const Quantity_Color& theInteriorColor) | |
0adbd30f | 59 | { |
67312b79 | 60 | Common.ChangeShine() = 128.0f * theMat.Shininess(); |
61 | Common.ChangeTransparency() = theMat.Alpha(); | |
62 | ||
63 | Pbr.ChangeMetallic() = theMat.PBRMaterial().Metallic(); | |
64 | Pbr.ChangeRoughness() = theMat.PBRMaterial().NormalizedRoughness(); | |
65 | Pbr.EmissionIOR = Graphic3d_Vec4 (theMat.PBRMaterial().Emission(), theMat.PBRMaterial().IOR()); | |
b6472664 | 66 | |
61168418 | 67 | const OpenGl_Vec3& aSrcAmb = theMat.AmbientColor(); |
68 | const OpenGl_Vec3& aSrcDif = theMat.DiffuseColor(); | |
69 | const OpenGl_Vec3& aSrcSpe = theMat.SpecularColor(); | |
70 | const OpenGl_Vec3& aSrcEms = theMat.EmissiveColor(); | |
67312b79 | 71 | Common.Specular.SetValues (aSrcSpe, 1.0f); // interior color is ignored for Specular |
61168418 | 72 | switch (theMat.MaterialType()) |
0adbd30f | 73 | { |
61168418 | 74 | case Graphic3d_MATERIAL_ASPECT: |
75 | { | |
67312b79 | 76 | Common.Ambient .SetValues (aSrcAmb * theInteriorColor, 1.0f); |
77 | Common.Diffuse .SetValues (aSrcDif * theInteriorColor, 1.0f); | |
78 | Common.Emission.SetValues (aSrcEms * theInteriorColor, 1.0f); | |
79 | Pbr .BaseColor.SetValues (theInteriorColor, theMat.Alpha()); | |
61168418 | 80 | break; |
81 | } | |
82 | case Graphic3d_MATERIAL_PHYSIC: | |
83 | { | |
67312b79 | 84 | Common.Ambient .SetValues (aSrcAmb, 1.0f); |
85 | Common.Diffuse .SetValues (aSrcDif, 1.0f); | |
86 | Common.Emission.SetValues (aSrcEms, 1.0f); | |
87 | Pbr.BaseColor = theMat.PBRMaterial().Color(); | |
61168418 | 88 | break; |
89 | } | |
0adbd30f | 90 | } |
ba00aab7 | 91 | |
67312b79 | 92 | Common.Ambient = theCtx.Vec4FromQuantityColor (Common.Ambient); |
93 | Common.Diffuse = theCtx.Vec4FromQuantityColor (Common.Diffuse); | |
94 | Common.Specular = theCtx.Vec4FromQuantityColor (Common.Specular); | |
95 | Common.Emission = theCtx.Vec4FromQuantityColor (Common.Emission); | |
0adbd30f | 96 | } |
97 | ||
2166f0fa SK |
98 | // ======================================================================= |
99 | // function : OpenGl_Workspace | |
100 | // purpose : | |
101 | // ======================================================================= | |
c357e426 | 102 | OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Window)& theWindow) |
1a0dfc1b | 103 | : myView (theView), |
c357e426 | 104 | myWindow (theWindow), |
105 | myGlContext (!theWindow.IsNull() ? theWindow->GetGlContext() : NULL), | |
eae454e3 | 106 | myUseZBuffer (Standard_True), |
107 | myUseDepthWrite (Standard_True), | |
2166f0fa | 108 | // |
1b661a81 | 109 | myNbSkippedTranspElems (0), |
110 | myRenderFilter (OpenGl_RenderFilter_Empty), | |
111 | // | |
bf5f0ca2 | 112 | myAspectsSet (&myDefaultAspects), |
f9ba5c4d | 113 | // |
2166f0fa SK |
114 | ViewMatrix_applied (&myDefaultMatrix), |
115 | StructureMatrix_applied (&myDefaultMatrix), | |
b6472664 | 116 | myToAllowFaceCulling (false), |
b6472664 | 117 | myModelViewMatrix (myDefaultMatrix) |
2166f0fa | 118 | { |
c357e426 | 119 | if (!myGlContext.IsNull() && myGlContext->MakeCurrent()) |
73192b37 | 120 | { |
c357e426 | 121 | myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
2166f0fa | 122 | |
c357e426 | 123 | // General initialization of the context |
c357e426 | 124 | #if !defined(GL_ES_VERSION_2_0) |
125 | if (myGlContext->core11 != NULL) | |
126 | { | |
dd1ae9df | 127 | // enable two-side lighting by default |
c357e426 | 128 | glLightModeli ((GLenum )GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
dd1ae9df | 129 | glHint (GL_POINT_SMOOTH_HINT, GL_FASTEST); |
130 | if (myGlContext->caps->ffpEnable) | |
131 | { | |
132 | glHint (GL_FOG_HINT, GL_FASTEST); | |
133 | } | |
c357e426 | 134 | } |
2166f0fa | 135 | |
c357e426 | 136 | glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST); |
137 | glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST); | |
1202160b | 138 | if (myGlContext->Vendor() == "microsoft corporation" |
139 | && !myGlContext->IsGlGreaterEqual (1, 2)) | |
140 | { | |
141 | // this software implementation causes too slow rendering into GL_FRONT on modern Windows | |
142 | theView->SetImmediateModeDrawToFront (false); | |
143 | } | |
c357e426 | 144 | #endif |
73192b37 | 145 | } |
f8ae3605 | 146 | |
b6472664 | 147 | myNoneCulling .Aspect()->SetSuppressBackFaces (false); |
148 | myNoneCulling .Aspect()->SetDrawEdges (false); | |
c40eb6b9 | 149 | myNoneCulling .Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque); |
150 | ||
b6472664 | 151 | myFrontCulling.Aspect()->SetSuppressBackFaces (true); |
152 | myFrontCulling.Aspect()->SetDrawEdges (false); | |
c40eb6b9 | 153 | myFrontCulling.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque); |
2166f0fa SK |
154 | } |
155 | ||
2166f0fa SK |
156 | // ======================================================================= |
157 | // function : Activate | |
158 | // purpose : | |
159 | // ======================================================================= | |
160 | Standard_Boolean OpenGl_Workspace::Activate() | |
161 | { | |
c357e426 | 162 | if (myWindow.IsNull() || !myWindow->Activate()) |
163 | { | |
2166f0fa | 164 | return Standard_False; |
c357e426 | 165 | } |
2166f0fa | 166 | |
2166f0fa SK |
167 | ViewMatrix_applied = &myDefaultMatrix; |
168 | StructureMatrix_applied = &myDefaultMatrix; | |
26395493 | 169 | |
92996979 | 170 | if (myGlContext->core11 == NULL) |
171 | { | |
172 | if (myGlContext->caps->ffpEnable) | |
173 | { | |
174 | #if defined(GL_ES_VERSION_2_0) | |
175 | Message::SendWarning ("Warning: FFP is unsupported by OpenGL ES"); | |
176 | #else | |
177 | Message::SendWarning ("Warning: FFP is unsupported by OpenGL Core Profile"); | |
178 | #endif | |
179 | myGlContext->caps->ffpEnable = false; | |
180 | } | |
181 | } | |
182 | ||
26395493 | 183 | ResetAppliedAspect(); |
184 | ||
8613985b | 185 | // reset state for safety |
186 | myGlContext->BindProgram (Handle(OpenGl_ShaderProgram)()); | |
187 | if (myGlContext->core20fwd != NULL) | |
188 | { | |
189 | myGlContext->core20fwd->glUseProgram (OpenGl_ShaderProgram::NO_PROGRAM); | |
190 | } | |
dd1ae9df | 191 | if (myGlContext->caps->ffpEnable) |
192 | { | |
193 | myGlContext->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)()); | |
194 | } | |
26395493 | 195 | return Standard_True; |
2166f0fa SK |
196 | } |
197 | ||
26395493 | 198 | //======================================================================= |
199 | //function : ResetAppliedAspect | |
200 | //purpose : Sets default values of GL parameters in accordance with default aspects | |
201 | //======================================================================= | |
202 | void OpenGl_Workspace::ResetAppliedAspect() | |
203 | { | |
4e1523ef | 204 | myGlContext->BindDefaultVao(); |
205 | ||
f838dac4 | 206 | myHighlightStyle.Nullify(); |
b6472664 | 207 | myToAllowFaceCulling = false; |
bf5f0ca2 | 208 | myAspectsSet = &myDefaultAspects; |
209 | myAspectsApplied.Nullify(); | |
8d1a539c | 210 | myGlContext->SetPolygonOffset (Graphic3d_PolygonOffset()); |
26395493 | 211 | |
bf5f0ca2 | 212 | ApplyAspects(); |
3f1675c9 | 213 | myGlContext->SetLineStipple(myDefaultAspects.Aspect()->LinePattern()); |
bf5f0ca2 | 214 | myGlContext->SetLineWidth (myDefaultAspects.Aspect()->LineWidth()); |
0c33a0bf | 215 | if (myGlContext->core15fwd != NULL) |
216 | { | |
217 | myGlContext->core15fwd->glActiveTexture (GL_TEXTURE0); | |
218 | } | |
26395493 | 219 | } |
bf75be98 | 220 | |
a6df1715 | 221 | // ======================================================================= |
222 | // function : SetDefaultPolygonOffset | |
223 | // purpose : | |
224 | // ======================================================================= | |
225 | Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset) | |
226 | { | |
bf5f0ca2 | 227 | Graphic3d_PolygonOffset aPrev = myDefaultAspects.Aspect()->PolygonOffset(); |
228 | myDefaultAspects.Aspect()->SetPolygonOffset (theOffset); | |
229 | if (myAspectsApplied == myDefaultAspects.Aspect() | |
230 | || myAspectsApplied.IsNull() | |
231 | || (myAspectsApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None) | |
a6df1715 | 232 | { |
233 | myGlContext->SetPolygonOffset (theOffset); | |
234 | } | |
235 | return aPrev; | |
236 | } | |
237 | ||
38a0206f | 238 | // ======================================================================= |
bf5f0ca2 | 239 | // function : SetAspects |
c357e426 | 240 | // purpose : |
241 | // ======================================================================= | |
bf5f0ca2 | 242 | const OpenGl_Aspects* OpenGl_Workspace::SetAspects (const OpenGl_Aspects* theAspect) |
c357e426 | 243 | { |
bf5f0ca2 | 244 | const OpenGl_Aspects* aPrevAspects = myAspectsSet; |
245 | myAspectsSet = theAspect; | |
246 | return aPrevAspects; | |
c357e426 | 247 | } |
f978241f | 248 | |
c357e426 | 249 | // ======================================================================= |
bf5f0ca2 | 250 | // function : ApplyAspects |
c357e426 | 251 | // purpose : |
252 | // ======================================================================= | |
72f6dc61 | 253 | const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects (bool theToBindTextures) |
c357e426 | 254 | { |
c357e426 | 255 | if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC) |
38a0206f | 256 | { |
b6472664 | 257 | bool toSuppressBackFaces = myToAllowFaceCulling |
bf5f0ca2 | 258 | && myAspectsSet->Aspect()->ToSuppressBackFaces(); |
b6472664 | 259 | if (toSuppressBackFaces) |
f978241f | 260 | { |
bf5f0ca2 | 261 | if (myAspectsSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH |
262 | || myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend | |
263 | || myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask | |
33425a46 | 264 | || myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_MaskBlend |
bf5f0ca2 | 265 | || (myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_BlendAuto |
266 | && myAspectsSet->Aspect()->FrontMaterial().Transparency() != 0.0f)) | |
c357e426 | 267 | { |
b6472664 | 268 | // disable culling in case of translucent shading aspect |
269 | toSuppressBackFaces = false; | |
f978241f | 270 | } |
f978241f | 271 | } |
b6472664 | 272 | myGlContext->SetCullBackFaces (toSuppressBackFaces); |
f978241f | 273 | } |
274 | ||
bf5f0ca2 | 275 | if (myAspectsSet->Aspect() == myAspectsApplied |
8613985b | 276 | && myHighlightStyle == myAspectFaceAppliedWithHL) |
a2e4f780 | 277 | { |
bf5f0ca2 | 278 | return myAspectsSet; |
a2e4f780 | 279 | } |
8613985b | 280 | myAspectFaceAppliedWithHL = myHighlightStyle; |
a2e4f780 | 281 | |
2a332745 | 282 | // Aspect_POM_None means: do not change current settings |
bf5f0ca2 | 283 | if ((myAspectsSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None) |
2a332745 | 284 | { |
bf5f0ca2 | 285 | myGlContext->SetPolygonOffset (myAspectsSet->Aspect()->PolygonOffset()); |
2a332745 | 286 | } |
287 | ||
bf5f0ca2 | 288 | const Aspect_InteriorStyle anIntstyle = myAspectsSet->Aspect()->InteriorStyle(); |
289 | if (myAspectsApplied.IsNull() | |
290 | || myAspectsApplied->InteriorStyle() != anIntstyle) | |
b86bb3df | 291 | { |
2a332745 | 292 | #if !defined(GL_ES_VERSION_2_0) |
293 | myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL); | |
294 | myGlContext->SetPolygonHatchEnabled (anIntstyle == Aspect_IS_HATCH); | |
295 | #endif | |
91c60b57 | 296 | } |
e276548b | 297 | |
2a332745 | 298 | #if !defined(GL_ES_VERSION_2_0) |
c357e426 | 299 | if (anIntstyle == Aspect_IS_HATCH) |
91c60b57 | 300 | { |
bf5f0ca2 | 301 | myGlContext->SetPolygonHatchStyle (myAspectsSet->Aspect()->HatchStyle()); |
c357e426 | 302 | } |
303 | #endif | |
38a0206f | 304 | |
8613985b | 305 | // Case of hidden line |
2a332745 | 306 | if (anIntstyle == Aspect_IS_HIDDENLINE) |
8613985b | 307 | { |
308 | // copy all values including line edge aspect | |
bf5f0ca2 | 309 | *myAspectFaceHl.Aspect() = *myAspectsSet->Aspect(); |
dc89236f | 310 | myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT); |
8613985b | 311 | myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB()); |
2a332745 | 312 | myAspectFaceHl.Aspect()->SetDistinguish (false); |
dc89236f | 313 | myAspectFaceHl.SetNoLighting(); |
bf5f0ca2 | 314 | myAspectsSet = &myAspectFaceHl; |
8613985b | 315 | } |
316 | else | |
a174a3c5 | 317 | { |
bf5f0ca2 | 318 | myGlContext->SetShadingMaterial (myAspectsSet, myHighlightStyle); |
c357e426 | 319 | } |
62e1beed | 320 | |
72f6dc61 | 321 | if (theToBindTextures) |
c357e426 | 322 | { |
72f6dc61 | 323 | const Handle(OpenGl_TextureSet)& aTextureSet = TextureSet(); |
324 | myGlContext->BindTextures (aTextureSet, Handle(OpenGl_ShaderProgram)()); | |
a174a3c5 | 325 | } |
326 | ||
67312b79 | 327 | if ((myView->myShadingModel == Graphic3d_TOSM_PBR |
328 | || myView->myShadingModel == Graphic3d_TOSM_PBR_FACET) | |
329 | && !myView->myPBREnvironment.IsNull() | |
330 | && myView->myPBREnvironment->IsNeededToBeBound()) | |
331 | { | |
332 | myView->myPBREnvironment->Bind (myGlContext); | |
333 | } | |
334 | ||
bf5f0ca2 | 335 | myAspectsApplied = myAspectsSet->Aspect(); |
336 | return myAspectsSet; | |
679ecdee | 337 | } |
338 | ||
339 | // ======================================================================= | |
c357e426 | 340 | // function : Width |
679ecdee | 341 | // purpose : |
342 | // ======================================================================= | |
c357e426 | 343 | Standard_Integer OpenGl_Workspace::Width() const |
679ecdee | 344 | { |
c357e426 | 345 | return !myView->GlWindow().IsNull() ? myView->GlWindow()->Width() : 0; |
346 | } | |
679ecdee | 347 | |
c357e426 | 348 | // ======================================================================= |
349 | // function : Height | |
350 | // purpose : | |
351 | // ======================================================================= | |
352 | Standard_Integer OpenGl_Workspace::Height() const | |
353 | { | |
354 | return !myView->GlWindow().IsNull() ? myView->GlWindow()->Height() : 0; | |
355 | } | |
679ecdee | 356 | |
679ecdee | 357 | // ======================================================================= |
c357e426 | 358 | // function : FBOCreate |
679ecdee | 359 | // purpose : |
360 | // ======================================================================= | |
b128c892 | 361 | Handle(OpenGl_FrameBuffer) OpenGl_Workspace::FBOCreate (const Standard_Integer theWidth, |
362 | const Standard_Integer theHeight) | |
679ecdee | 363 | { |
c357e426 | 364 | // activate OpenGL context |
365 | if (!Activate()) | |
b128c892 | 366 | return Handle(OpenGl_FrameBuffer)(); |
c357e426 | 367 | |
368 | // create the FBO | |
369 | const Handle(OpenGl_Context)& aCtx = GetGlContext(); | |
72f6dc61 | 370 | aCtx->BindTextures (Handle(OpenGl_TextureSet)(), Handle(OpenGl_ShaderProgram)()); |
b128c892 | 371 | Handle(OpenGl_FrameBuffer) aFrameBuffer = new OpenGl_FrameBuffer(); |
ba00aab7 | 372 | if (!aFrameBuffer->Init (aCtx, theWidth, theHeight, GL_SRGB8_ALPHA8, GL_DEPTH24_STENCIL8, 0)) |
679ecdee | 373 | { |
c357e426 | 374 | aFrameBuffer->Release (aCtx.operator->()); |
b128c892 | 375 | return Handle(OpenGl_FrameBuffer)(); |
679ecdee | 376 | } |
b128c892 | 377 | return aFrameBuffer; |
679ecdee | 378 | } |
379 | ||
380 | // ======================================================================= | |
c357e426 | 381 | // function : FBORelease |
679ecdee | 382 | // purpose : |
383 | // ======================================================================= | |
b128c892 | 384 | void OpenGl_Workspace::FBORelease (Handle(OpenGl_FrameBuffer)& theFbo) |
679ecdee | 385 | { |
c357e426 | 386 | // activate OpenGL context |
387 | if (!Activate() | |
b128c892 | 388 | || theFbo.IsNull()) |
62e1beed | 389 | { |
62e1beed | 390 | return; |
391 | } | |
c357e426 | 392 | |
b128c892 | 393 | theFbo->Release (GetGlContext().operator->()); |
394 | theFbo.Nullify(); | |
c357e426 | 395 | } |
62e1beed | 396 | |
f9f740d6 | 397 | // ======================================================================= |
398 | // function : BufferDump | |
399 | // purpose : | |
400 | // ======================================================================= | |
401 | Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)& theFbo, | |
402 | Image_PixMap& theImage, | |
403 | const Graphic3d_BufferType& theBufferType) | |
c357e426 | 404 | { |
6cde53c4 | 405 | return !theImage.IsEmpty() |
406 | && Activate() | |
407 | && OpenGl_FrameBuffer::BufferDump (GetGlContext(), theFbo, theImage, theBufferType); | |
679ecdee | 408 | } |
91c60b57 | 409 | |
91c60b57 | 410 | // ======================================================================= |
a1073ae2 | 411 | // function : ShouldRender |
91c60b57 | 412 | // purpose : |
413 | // ======================================================================= | |
4552cb85 | 414 | bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement, |
415 | const OpenGl_Group* theGroup) | |
91c60b57 | 416 | { |
1b661a81 | 417 | // render only non-raytracable elements when RayTracing is enabled |
418 | if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0) | |
419 | { | |
4552cb85 | 420 | if (!theGroup->HasPersistence() && OpenGl_Raytrace::IsRaytracedElement (theElement)) |
1b661a81 | 421 | { |
422 | return false; | |
423 | } | |
424 | } | |
425 | else if ((myRenderFilter & OpenGl_RenderFilter_FillModeOnly) != 0) | |
426 | { | |
427 | if (!theElement->IsFillDrawMode()) | |
428 | { | |
429 | return false; | |
430 | } | |
431 | } | |
432 | ||
433 | // handle opaque/transparency render passes | |
434 | if ((myRenderFilter & OpenGl_RenderFilter_OpaqueOnly) != 0) | |
435 | { | |
436 | if (!theElement->IsFillDrawMode()) | |
437 | { | |
438 | return true; | |
439 | } | |
440 | ||
bf5f0ca2 | 441 | if (OpenGl_Context::CheckIsTransparent (myAspectsSet, myHighlightStyle)) |
1b661a81 | 442 | { |
443 | ++myNbSkippedTranspElems; | |
444 | return false; | |
445 | } | |
446 | } | |
447 | else if ((myRenderFilter & OpenGl_RenderFilter_TransparentOnly) != 0) | |
91c60b57 | 448 | { |
1b661a81 | 449 | if (!theElement->IsFillDrawMode()) |
450 | { | |
bf5f0ca2 | 451 | if (dynamic_cast<const OpenGl_Aspects*> (theElement) == NULL) |
1b661a81 | 452 | { |
453 | return false; | |
454 | } | |
455 | } | |
bf5f0ca2 | 456 | else if (!OpenGl_Context::CheckIsTransparent (myAspectsSet, myHighlightStyle)) |
1b661a81 | 457 | { |
458 | return false; | |
459 | } | |
91c60b57 | 460 | } |
1b661a81 | 461 | return true; |
91c60b57 | 462 | } |
bc73b006 | 463 | |
464 | // ======================================================================= | |
465 | // function : DumpJson | |
466 | // purpose : | |
467 | // ======================================================================= | |
468 | void OpenGl_Workspace::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const | |
469 | { | |
470 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) | |
471 | ||
472 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUseZBuffer) | |
473 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUseDepthWrite) | |
474 | ||
475 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myNoneCulling) | |
476 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myFrontCulling) | |
477 | ||
478 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbSkippedTranspElems) | |
479 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRenderFilter) | |
480 | ||
481 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultAspects) | |
482 | ||
483 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspectsSet) | |
484 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspectsApplied.get()) | |
485 | ||
486 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToAllowFaceCulling) | |
487 | ||
488 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myAspectFaceHl) | |
489 | } |