… | |
… | |
114 | ~view (); |
114 | ~view (); |
115 | }; |
115 | }; |
116 | |
116 | |
117 | struct light : view |
117 | struct light : view |
118 | { |
118 | { |
119 | shader::uniform_4f lightpos; |
119 | // the following variables are valid in the fragment shader as well as in the vertex shader |
|
|
120 | bool has_lightvec; // is a light vector available? |
|
|
121 | shader::temp_3f sh_lightvec; // not defined unless has_lightvec is true |
|
|
122 | shader::temp_3f sh_colour; // always available for any light |
120 | |
123 | |
121 | // vertex shader |
124 | // vertex shader |
122 | virtual void vsh () = 0; |
125 | virtual void vsh () = 0; |
123 | // fragment shader |
126 | // fragment shader |
124 | virtual shader::temp_3f operator ()() = 0; |
127 | virtual void fsh () = 0; |
125 | |
128 | |
126 | virtual void enable (); |
129 | virtual void enable (); |
127 | virtual void disable (); |
130 | virtual void disable (); |
|
|
131 | |
|
|
132 | protected: |
|
|
133 | shader::uniform_3f lightpos; // or direction |
128 | }; |
134 | }; |
129 | |
135 | |
130 | struct linear_light : light |
136 | struct linear_light : light |
131 | { |
137 | { |
132 | colour c; |
138 | colour c; |
133 | GLfloat intensity; |
139 | GLfloat intensity; |
134 | GLfloat radius; |
140 | GLfloat radius; |
135 | |
141 | |
136 | void vsh (); |
142 | void vsh (); |
137 | shader::temp_3f operator ()(); |
143 | void fsh (); |
138 | }; |
144 | }; |
139 | |
145 | |
140 | #endif |
146 | #endif |
141 | |
147 | |