1 // Created on: 2014-03-31
2 // Created by: Danila ULYANOV
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_Layer.hxx>
17 #include <OpenGl_Workspace.hxx>
18 #include <OpenGl_GlCore11.hxx>
20 //=======================================================================
21 //function : OpenGl_Layer
23 //=======================================================================
24 OpenGl_Layer::OpenGl_Layer (const Standard_Integer theNbPriorities)
25 : myPriorityList (theNbPriorities)
30 //=======================================================================
33 //=======================================================================
34 void OpenGl_Layer::Render (const Handle(OpenGl_Workspace) &theWorkspace, const OpenGl_GlobalLayerSettings& theDefaultSettings) const
36 TEL_POFFSET_PARAM anAppliedOffsetParams = theWorkspace->AppliedPolygonOffset();
38 // separate depth buffers
39 if (IsSettingEnabled (Graphic3d_ZLayerDepthClear))
41 glClear (GL_DEPTH_BUFFER_BIT);
45 if (IsSettingEnabled (Graphic3d_ZLayerDepthTest))
47 // assuming depth test is enabled by default
48 glDepthFunc (theDefaultSettings.DepthFunc);
52 glDepthFunc (GL_ALWAYS);
55 // handle depth offset
56 if (IsSettingEnabled (Graphic3d_ZLayerDepthOffset))
58 theWorkspace->SetPolygonOffset (Aspect_POM_Fill,
59 myLayerSettings.DepthOffsetFactor,
60 myLayerSettings.DepthOffsetUnits);
64 theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode,
65 anAppliedOffsetParams.factor,
66 anAppliedOffsetParams.units);
70 if (IsSettingEnabled (Graphic3d_ZLayerDepthWrite))
72 glDepthMask (GL_TRUE);
76 glDepthMask (GL_FALSE);
79 // render priority list
80 myPriorityList.Render (theWorkspace);
82 // always restore polygon offset between layers rendering
83 theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode,
84 anAppliedOffsetParams.factor,
85 anAppliedOffsetParams.units);