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(const 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 setLightMask(int mask) { myLightMask = mask; }
46  int getLightMask() const { return myLightMask; }
47 
48  void enableLights(const UT_ValArray<RE_Light *> &lights);
49  void enableHeadlight();
50 
51  bool isLightEnabled(int index) const;
52 
53  // This will also set the RE_UNIFORM_LIGHT_MASK uniform
54  void bindForShader(RE_Render *r, RE_Shader *sh) const;
55  void bindMaskForShader(RE_Render *r) const;
56 
57  // For shadow passes, the light the shadow pass is for.
58  void setShadowLight(RE_Light *light) { myShadowLight = light; }
59  const RE_Light *getShadowLight() const { return myShadowLight; }
60 
61 private:
62  int myUniqueId;
63  int mySerial;
64  UT_Map<RE_Light *, int> myLightTable;
65  UT_ValArray<RE_Light *> myLights;
66  RE_Light *myShadowLight;
67  int myMaxLights;
68  int myLightMask;
69  bool myUseHeadlight;
70 
71  // modified by bindForShader() only
72  mutable RE_UniformBlockHandle myLightBlockGL4;
73 };
74 
75 inline bool
77 {
78  return (myLightMask & (1<<index));
79 }
80 
81 #endif
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
#define RE_API
Definition: RE_API.h:10
GLuint index
Definition: glew.h:1814
int getNumLights() const
Definition: RE_LightList.h:42
GLenum GLint GLuint mask
Definition: glew.h:1845
int getLightMask() const
Definition: RE_LightList.h:46
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
bool isLightEnabled(int index) const
Definition: RE_LightList.h:76
const RE_Light * getShadowLight() const
Definition: RE_LightList.h:59
void setLightMask(int mask)
Definition: RE_LightList.h:45
RE_Light * getLight(int i) const
Definition: RE_LightList.h:43
void setShadowLight(RE_Light *light)
Definition: RE_LightList.h:58