Visualization Library 2.0.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
RenderStateSet.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 RenderStateSet_INCLUDE_ONCE
33 #define RenderStateSet_INCLUDE_ONCE
34 
36 #include <vlCore/Object.hpp>
37 #include <vlCore/vlnamespace.hpp>
39 #include <vector>
40 
41 namespace vl
42 {
43  class GLSLProgram;
44  class RenderState;
45 
49  {
51 
52  public:
53  RenderStateSet(): mGLSLProgram(NULL)
54  {
55  VL_DEBUG_SET_OBJECT_NAME()
56  }
57 
58  RenderStateSet& deepCopyFrom(const RenderStateSet& other);
59 
60  RenderStateSet& shallowCopyFrom(const RenderStateSet& other) { mRenderStates = other.mRenderStates; mGLSLProgram = other.mGLSLProgram; return *this; }
61 
62  // renderstates getters and setters
63 
64  void setRenderState(RenderState* renderstate, int index);
65 
66  RenderState* renderState( ERenderState type, int index=-1 );
67 
68  const RenderState* renderState( ERenderState type, int index=-1 ) const;
69 
70  size_t renderStatesCount() const { return mRenderStates.size(); }
71 
72  const RenderStateSlot* renderStates() const { if (mRenderStates.empty()) return NULL; else return &mRenderStates[0]; }
73 
74  RenderStateSlot* renderStates() { if (mRenderStates.empty()) return NULL; else return &mRenderStates[0]; }
75 
77  void eraseRenderState(ERenderState type, int index);
78 
79  void eraseAllRenderStates() { mRenderStates.clear(); mGLSLProgram = NULL; }
80 
82  const GLSLProgram* glslProgram() const { return mGLSLProgram; }
83 
85  GLSLProgram* glslProgram() { return mGLSLProgram; }
86 
87  protected:
88  std::vector< RenderStateSlot > mRenderStates;
90  };
91 }
92 
93 #endif
std::vector< RenderStateSlot > mRenderStates
GLSLProgram * mGLSLProgram
ERenderState
size_t renderStatesCount() const
RenderStateSlot * renderStates()
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. ...
Definition: GLSL.hpp:233
RenderStateSet & shallowCopyFrom(const RenderStateSet &other)
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
const GLSLProgram * glslProgram() const
Returns the GLSLProgram associated to a RenderStateSet (if any)
Visualization Library main namespace.
Base class for most of the OpenGL render state wrapper classes.
Definition: RenderState.hpp:50
The base class for all the reference counted objects.
Definition: Object.hpp:158
#define NULL
Definition: OpenGLDefs.hpp:81
A set of RenderState objects managed by a Shader.
const RenderStateSlot * renderStates() const
GLSLProgram * glslProgram()
Returns the GLSLProgram associated to a RenderStateSet (if any)
Visualization Library&#39;s enums in the &#39;vl&#39; namespace.