HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_LightList.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RE_LightList.h ( RE Library, C++)
7  *
8  * COMMENTS:
9  * A list of lights which keeps track of those shaders which have already
10  * had them bound as buffer objects. This is not intended to persist over
11  * multiple redraws.
12  */
13 #ifndef RE_LightList_h
14 #define RE_LightList_h
15 
16 class RE_Shader;
17 class RE_Render;
18 class RE_Light;
19 
20 #include <UT/UT_ValArray.h>
21 #include <UT/UT_Map.h>
22 
23 #include "RE_API.h"
24 #include "RE_Types.h"
25 #include "RE_UniformBlock.h"
26 
28 {
29 public:
30  RE_LightList(int max_lights);
31  ~RE_LightList();
32 
33  // requires lights to be re-added if the max is lowered under the current
34  // # of lights.
35  void setMaxLights(int max);
36 
37  void setLights(UT_ValArray<RE_Light *> &lights,
38  int light_offset = 0,
39  bool include_zeroed_lights = false);
40  void addLight(RE_Light *light);
41 
42  int getNumLights() const { return myLights.entries(); }
43  RE_Light *getLight(int i) const { return myLights(i); }
44 
45  void enableLights(const UT_ValArray<RE_Light *> &lights);
46  void enableHeadlight();
47 
48  bool isLightEnabled(int index) const;
49 
50  // This will also set the RE_UNIFORM_LIGHT_MASK uniform
51  void bindForShader(RE_Render *r, RE_Shader *sh) const;
52  void bindMaskForShader(RE_Render *r) const;
53 
54 private:
55  int myUniqueId;
56  int mySerial;
57  UT_Map<RE_Light *, int> myLightTable;
58  UT_ValArray<RE_Light *> myLights;
59  int myMaxLights;
60  int myLightMask;
61  bool myUseHeadlight;
62 
63  // modified by bindForShader() only
64  mutable RE_UniformBlockHandle myLightBlockGL4;
65 };
66 
67 inline bool
69 {
70  return (myLightMask & (1<<index));
71 }
72 
73 #endif
#define RE_API
Definition: RE_API.h:10
int getNumLights() const
Definition: RE_LightList.h:42
png_uint_32 i
Definition: png.h:2877
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:133
GLuint index
Definition: glcorearb.h:785
bool isLightEnabled(int index) const
Definition: RE_LightList.h:68
GLboolean r
Definition: glcorearb.h:1221
RE_Light * getLight(int i) const
Definition: RE_LightList.h:43