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]
RenderState.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 RenderState_INCLUDE_ONCE
33 #define RenderState_INCLUDE_ONCE
34 
35 #include <vlCore/Object.hpp>
36 #include <vlCore/vlnamespace.hpp>
37 
38 namespace vl
39 {
40  class Camera;
41  class OpenGLContext;
42  //------------------------------------------------------------------------------
43  // RenderState
44  //------------------------------------------------------------------------------
51  {
53 
54  public:
56  {
57  VL_DEBUG_SET_OBJECT_NAME()
58  }
59  virtual ERenderState type() const { return RS_NONE; }
60 
62  virtual void apply(int index, const Camera* camera, OpenGLContext* ctx) const = 0;
63 
64  virtual ref<RenderState> clone() const = 0;
65  };
66  //------------------------------------------------------------------------------
67  // RenderStateIndexed
68  //------------------------------------------------------------------------------
71  {
73 
74  public:
76  {
77  VL_DEBUG_SET_OBJECT_NAME()
78  }
79  };
80  //------------------------------------------------------------------------------
81  // RenderStateNonIndexed
82  //------------------------------------------------------------------------------
85  {
87 
88  public:
90  {
91  VL_DEBUG_SET_OBJECT_NAME()
92  }
93  };
94  //------------------------------------------------------------------------------
96  {
97  RenderStateSlot(): mRS(NULL), mIndex(-1) {}
98  RenderStateSlot(RenderState* rs, int index): mRS(rs), mIndex(index) {}
99  virtual ~RenderStateSlot() {}
100 
101  virtual void apply(const Camera* camera, OpenGLContext* ctx) const { mRS->apply( mIndex, camera, ctx ); }
102 
104  {
105  if (mIndex > 0)
106  return (ERenderState)(mRS->type() + mIndex);
107  else
108  return mRS->type();
109  }
110 
112  int mIndex;
113  };
114  //------------------------------------------------------------------------------
115 }
116 
117 #endif
ERenderState
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
Base class for those render states which have more than one binding points like lights, clipping planes and texture unit states.
Definition: RenderState.hpp:70
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
Base class for those render states which have only one binding point (the vast majority).
Definition: RenderState.hpp:84
virtual ~RenderStateSlot()
Definition: RenderState.hpp:99
virtual void apply(const Camera *camera, OpenGLContext *ctx) const
#define NULL
Definition: OpenGLDefs.hpp:81
RenderStateSlot(RenderState *rs, int index)
Definition: RenderState.hpp:98
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:145
ERenderState type() const
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
virtual ERenderState type() const
Definition: RenderState.hpp:59
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:50
Visualization Library&#39;s enums in the &#39;vl&#39; namespace.
ref< RenderState > mRS