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 
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_Array<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_Array<RE_Light *> &lights);
49  void enableLights(const UT_Set<int> &lights,
50  bool use_headlight_if_none = false);
51  void enableHeadlight();
52 
53  bool isLightEnabled(int index) const;
54 
55  // This will also set the RE_UNIFORM_LIGHT_MASK uniform
56  void bindForShader(RE_Render *r, RE_Shader *sh) const;
57  void bindMaskForShader(RE_Render *r) const;
58 
59  // For shadow passes, the light the shadow pass is for.
60  void setShadowLight(RE_Light *light) { myShadowLight = light; }
61  const RE_Light *getShadowLight() const { return myShadowLight; }
62 
63 private:
64  int myUniqueId;
65  int mySerial;
66  UT_Map<int, int> myLightTable;
67  UT_Array<RE_Light *> myLights;
68  RE_Light *myShadowLight;
69  int myMaxLights;
70  int myLightMask;
71  bool myUseHeadlight;
72 
73  // modified by bindForShader() only
74  mutable RE_UniformBlockHandle myLightBlockGL4;
75 };
76 
77 inline bool
79 {
80  return (myLightMask & (1<<index));
81 }
82 
83 #endif
#define RE_API
Definition: RE_API.h:10
int getNumLights() const
Definition: RE_LightList.h:42
GLint GLuint mask
Definition: glcorearb.h:124
int getLightMask() const
Definition: RE_LightList.h:46
GLuint index
Definition: glcorearb.h:786
bool isLightEnabled(int index) const
Definition: RE_LightList.h:78
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:61
GLboolean r
Definition: glcorearb.h:1222
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:60