0024785: Visualization - Modifying z-layers concept to gain more control over OpenGl...
[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//
7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public 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.
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>
17
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//=======================================================================
34void OpenGl_Layer::Render (const Handle(OpenGl_Workspace) &AWorkspace, int theDefaultDepthFunc) const
35{
36 // separate depth buffers
37 if (IsSettingEnabled (Graphic3d_ZLayerDepthClear))
38 {
39 glClear (GL_DEPTH_BUFFER_BIT);
40 }
41
42 // handle depth test
43 if (IsSettingEnabled (Graphic3d_ZLayerDepthTest))
44 {
45 glDepthFunc (theDefaultDepthFunc);
46 }
47 else
48 {
49 glDepthFunc (GL_ALWAYS);
50 }
51
52 // handle depth offset
53 if (IsSettingEnabled (Graphic3d_ZLayerDepthOffset))
54 {
55 glPolygonOffset (myLayerSettings.DepthOffsetFactor, myLayerSettings.DepthOffsetUnits);
56 }
57 else
58 {
59 glPolygonOffset (0.0f, 0.0f);
60 }
61
62 // handle depth write
63 if (IsSettingEnabled (Graphic3d_ZLayerDepthWrite))
64 {
65 glDepthMask (GL_TRUE);
66 }
67 else
68 {
69 glDepthMask (GL_FALSE);
70 }
71
72 // render priority list
73 myPriorityList.Render (AWorkspace);
74}