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_Array.h>
21 #include <UT/UT_Map.h>
22 #include <UT/UT_Set.h>
23 
24 #include "RE_API.h"
25 #include "RE_Types.h"
26 #include "RE_UniformBlock.h"
27 
29 {
30 public:
31  RE_LightList(int max_lights);
32  ~RE_LightList();
33 
34  // requires lights to be re-added if the max is lowered under the current
35  // # of lights.
36  void setMaxLights(int max);
37 
38  void setLights(const UT_Array<RE_Light *> &lights,
39  int light_offset = 0,
40  bool include_zeroed_lights = false);
41  void addLight(RE_Light *light);
42 
43  int getNumLights() const { return myLights.entries(); }
44  RE_Light *getLight(int i) const { return myLights(i); }
45 
46  void setLightMask(int mask) { myLightMask = mask; }
47  int getLightMask() const { return myLightMask; }
48 
49  void enableLights(const UT_Array<RE_Light *> &lights);
50  void enableLights(const UT_Set<int> &lights,
51  bool use_headlight_if_none = false);
52  void enableHeadlight();
53 
54  bool isLightEnabled(int index) const;
55 
56  // This will also set the RE_UNIFORM_LIGHT_MASK uniform
57  void bindForShader(RE_Render *r, RE_Shader *sh) const;
58  void bindMaskForShader(RE_Render *r) const;
59 
60  // For shadow passes, the light the shadow pass is for.
61  void setShadowLight(RE_Light *light) { myShadowLight = light; }
62  const RE_Light *getShadowLight() const { return myShadowLight; }
63 
64 private:
65  int myUniqueId;
66  int mySerial;
67  UT_Map<int, int> myLightTable;
68  UT_Array<RE_Light *> myLights;
69  RE_Light *myShadowLight;
70  int myMaxLights;
71  int myLightMask;
72  bool myUseHeadlight;
73 
74  // modified by bindForShader() only
75  mutable RE_UniformBlockHandle myLightBlockGL4;
76 };
77 
78 inline bool
80 {
81  return (myLightMask & (1<<index));
82 }
83 
84 #endif
#define RE_API
Definition: RE_API.h:10
int getNumLights() const
Definition: RE_LightList.h:43
GLint GLuint mask
Definition: glcorearb.h:124
int getLightMask() const
Definition: RE_LightList.h:47
GLuint index
Definition: glcorearb.h:786
bool isLightEnabled(int index) const
Definition: RE_LightList.h:79
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
const RE_Light * getShadowLight() const
Definition: RE_LightList.h:62
GLboolean r
Definition: glcorearb.h:1222
void setLightMask(int mask)
Definition: RE_LightList.h:46
RE_Light * getLight(int i) const
Definition: RE_LightList.h:44
void setShadowLight(RE_Light *light)
Definition: RE_LightList.h:61