1 // Created on: 2011-09-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-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 #ifndef _OpenGl_LineAttributes_Header
17 #define _OpenGl_LineAttributes_Header
19 #include <OpenGl_Resource.hxx>
21 #include <Aspect_TypeOfLine.hxx>
22 #include <Aspect_TypeOfMarker.hxx>
23 #include <Font_FontAspect.hxx>
27 #define TEL_HS_USER_DEF_START 15
29 //! Utility class to manage OpenGL state of polygon hatching rasterization
30 //! and keeping its cached state. The hatching rasterization is implemented
31 //! using glPolygonStipple function of OpenGL. State of hatching is controlled
32 //! by two parameters - type of hatching and IsEnabled parameter.
33 //! The hatching rasterization is enabled only if non-zero index pattern type
34 //! is selected (zero by default is reserved for solid filling) and if
35 //! IsEnabled flag is set to true. The IsEnabled parameter is useful for temporarily
36 //! turning on/off the hatching rasterization without making any costly GL calls
37 //! for changing the hatch pattern. This is a sharable resource class - it creates
38 //! OpenGL context objects for each hatch pattern to achieve quicker switching between
39 //! them, thesse GL objects are freed when the resource is released by owner context.
40 //! @note The implementation is not supported by Core Profile and by ES version.
41 class OpenGl_LineAttributes : public OpenGl_Resource
45 //! Default constructor.
46 //! By default the parameters are:
47 //! - IsEnabled (true),
48 //! - TypeOfHatch (0).
49 OpenGl_LineAttributes();
51 //! Default destructor.
52 virtual ~OpenGl_LineAttributes();
54 //! Initialize hatch patterns as GL resources.
55 //! Call this method before using hatching.
56 void Init (const OpenGl_Context* theGlCtx);
58 //! Release GL resources.
59 virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
61 //! Index of currently selected type of hatch.
62 int TypeOfHatch() const { return myTypeOfHatch; }
64 //! Sets type of the hatch.
65 int SetTypeOfHatch (const OpenGl_Context* theGlCtx, const int theType);
67 //! Current enabled state of the hatching rasterization.
68 bool IsEnabled() const { return myIsEnabled; }
70 //! Turns on/off the hatching rasterization rasterization.
71 bool SetEnabled (const OpenGl_Context* theGlCtx, const bool theToEnable);
75 unsigned int myPatternBase; //!< Base index for predefined hatch patterns
76 int myTypeOfHatch; //!< Currently activated type of hatch
77 bool myIsEnabled; //!< Current enabled state of hatching rasterization.
81 DEFINE_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource)
84 DEFINE_STANDARD_HANDLE(OpenGl_LineAttributes, OpenGl_Resource)
86 #endif // _OpenGl_LineAttributes_Header