Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
EnableSet.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef EnableSet_INCLUDE_ONCE
33 #define EnableSet_INCLUDE_ONCE
34 
35 #include <vlCore/Object.hpp>
36 #include <vlCore/vlnamespace.hpp>
37 #include <vector>
38 
39 namespace vl
40 {
47  class EnableSet: public Object
48  {
50 
51  public:
53  {
54  VL_DEBUG_SET_OBJECT_NAME()
55  // these two are enabled by default
56  mEnables.push_back(EN_DITHER);
57  // only OpenGL ES 2 does not support GL_MULTISAMPLE
58 #if !defined(VL_OPENGL_ES2)
59  mEnables.push_back(EN_MULTISAMPLE);
60 #endif
61  }
62 
63  // enable getter and setters
64 
65  void enable(EEnable capability)
66  {
67  if (capability == EN_BLEND)
68  mBlendingEnabled = true;
69  for(unsigned i=0; i<mEnables.size(); ++i)
70  if (mEnables[i] == capability)
71  return;
72  mEnables.push_back( capability );
73  }
74 
75  void disable(EEnable capability)
76  {
77  if (capability == EN_BLEND)
78  mBlendingEnabled = false;
79  for(unsigned i=0; i<mEnables.size(); ++i)
80  {
81  if (mEnables[i] == capability)
82  {
83  mEnables.erase( mEnables.begin() + i );
84  return;
85  }
86  }
87  }
88 
89  const std::vector<EEnable>& enables() const { return mEnables; }
90 
91  int isEnabled(EEnable capability) const
92  {
93  for(unsigned i=0; i<mEnables.size(); ++i)
94  if (mEnables[i] == capability)
95  return true;
96  return false;
97  }
98 
99  void disableAll() { mEnables.clear(); mBlendingEnabled=false; }
100 
101  bool isBlendingEnabled() const { return mBlendingEnabled; }
102 
103  protected:
104  std::vector<EEnable> mEnables;
106  };
107 }
108 
109 #endif
If enabled, blend the incoming RGBA color values with the values in the color buffers, see also BlendFunc for more information.
If enabled, dither color components or indices before they are written to the color buffer...
void disable(EEnable capability)
Definition: EnableSet.hpp:75
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
Visualization Library main namespace.
The base class for all the reference counted objects.
Definition: Object.hpp:158
int isEnabled(EEnable capability) const
Definition: EnableSet.hpp:91
EEnable
Constant that enable/disable a specific OpenGL feature, see also Shader, Shader::enable(), Shader::disable(), Shader::isEnabled()
If enabled, use multiple fragment samples in computing the final color of a pixel.
void disableAll()
Definition: EnableSet.hpp:99
void enable(EEnable capability)
Definition: EnableSet.hpp:65
Visualization Library&#39;s enums in the &#39;vl&#39; namespace.
std::vector< EEnable > mEnables
Definition: EnableSet.hpp:104
A set of enables managed by Shader.
Definition: EnableSet.hpp:47
const std::vector< EEnable > & enables() const
Definition: EnableSet.hpp:89
bool mBlendingEnabled
Definition: EnableSet.hpp:105
bool isBlendingEnabled() const
Definition: EnableSet.hpp:101