Update of header of files in context of License text
[occt.git] / src / OpenGl / OpenGl_Layer.cxx
CommitLineData
c5751993 1// Created on: 2014-03-31
2// Created by: Danila ULYANOV
3// Copyright (c) 2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
0a36ca0a 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
c5751993 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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <OpenGl_Layer.hxx>
550f3b8b 17#include <OpenGl_Workspace.hxx>
c5751993 18#include <OpenGl_GlCore11.hxx>
19
20//=======================================================================
21//function : OpenGl_Layer
22//purpose :
23//=======================================================================
24OpenGl_Layer::OpenGl_Layer (const Standard_Integer theNbPriorities)
25 : myPriorityList (theNbPriorities)
26{
27 //
28}
29
30//=======================================================================
31//function : Render
32//purpose :
33//=======================================================================
550f3b8b 34void OpenGl_Layer::Render (const Handle(OpenGl_Workspace) &theWorkspace, const OpenGl_GlobalLayerSettings& theDefaultSettings) const
c5751993 35{
550f3b8b 36 TEL_POFFSET_PARAM anAppliedOffsetParams = theWorkspace->AppliedPolygonOffset();
37
c5751993 38 // separate depth buffers
39 if (IsSettingEnabled (Graphic3d_ZLayerDepthClear))
40 {
41 glClear (GL_DEPTH_BUFFER_BIT);
42 }
550f3b8b 43
c5751993 44 // handle depth test
45 if (IsSettingEnabled (Graphic3d_ZLayerDepthTest))
46 {
550f3b8b 47 // assuming depth test is enabled by default
48 glDepthFunc (theDefaultSettings.DepthFunc);
c5751993 49 }
50 else
51 {
52 glDepthFunc (GL_ALWAYS);
53 }
550f3b8b 54
c5751993 55 // handle depth offset
56 if (IsSettingEnabled (Graphic3d_ZLayerDepthOffset))
57 {
550f3b8b 58 theWorkspace->SetPolygonOffset (Aspect_POM_Fill,
59 myLayerSettings.DepthOffsetFactor,
60 myLayerSettings.DepthOffsetUnits);
c5751993 61 }
62 else
63 {
550f3b8b 64 theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode,
65 anAppliedOffsetParams.factor,
66 anAppliedOffsetParams.units);
c5751993 67 }
68
69 // handle depth write
70 if (IsSettingEnabled (Graphic3d_ZLayerDepthWrite))
71 {
72 glDepthMask (GL_TRUE);
73 }
74 else
75 {
76 glDepthMask (GL_FALSE);
77 }
78
79 // render priority list
550f3b8b 80 myPriorityList.Render (theWorkspace);
81
82 // always restore polygon offset between layers rendering
83 theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode,
84 anAppliedOffsetParams.factor,
85 anAppliedOffsetParams.units);
c5751993 86}