87 |
TexGen(const float *tex_mat) ; |
TexGen(const float *tex_mat) ; |
88 |
virtual void setUp(LightParam *param) ; |
virtual void setUp(LightParam *param) ; |
89 |
|
|
90 |
virtual void setUpVP(int unit, LightParam * param); |
virtual void setUp_VP(int unit, LightParam * param); |
91 |
virtual string getVPCode(int unit); |
virtual string getVPCode(int unit); |
92 |
}; |
}; |
93 |
|
|
108 |
|
|
109 |
virtual void setUp(LightParam *param) ; |
virtual void setUp(LightParam *param) ; |
110 |
|
|
111 |
virtual void setUpVP(int unit, LightParam * param); |
virtual void setUp_VP(int unit, LightParam * param); |
112 |
}; |
}; |
113 |
|
|
114 |
/** TexGen for transforming light intensity or direction map |
/** TexGen for transforming light intensity or direction map |
145 |
|
|
146 |
/** A single rendering pass. |
/** A single rendering pass. |
147 |
* The data members are public to allow modification, |
* The data members are public to allow modification, |
148 |
* but when using a ready-made PaperPass, only |
* but when using a ready-made PaperPass, _choose one_ |
149 |
* the setup() and tearDown() methods should be called. |
* (and only one) of the following ways to use it: |
150 |
|
* |
151 |
|
* 1) using texgen |
152 |
|
* - call setUp_texgen() with LightParam to use |
153 |
|
* - call glVertex*() directly from the context |
154 |
|
* - teardown_texgen() |
155 |
|
* |
156 |
|
* 2) using a vertex program |
157 |
|
* - call setUp_VP with LightParam to use |
158 |
|
* - call glTexCoord*() and glVertex*() directly from |
159 |
|
* the context _or_ call vector_VP() with vertex and |
160 |
|
* texture coordinates in vector arrays of 4 floats. |
161 |
|
* - call teardown_VP() |
162 |
|
* |
163 |
|
* 3) using explicit coordinates |
164 |
|
* - call setUp_explicit with LightParam to use |
165 |
|
* - ???? without? with texcoords? with texcoord and vertex? |
166 |
|
* - call teardown_explicit() |
167 |
*/ |
*/ |
168 |
class PaperPass { |
class PaperPass { |
169 |
|
private: |
170 |
|
/** Generates and loads the texgen vertex program. |
171 |
|
* This is automatically called on first setUp_VP |
172 |
|
* unless it's already loaded. |
173 |
|
*/ |
174 |
|
void loadVP(); |
175 |
|
|
176 |
public: |
public: |
177 |
/** The code to call before beginning to render the pass. |
/** The code to call before beginning to render the pass. */ |
|
*/ |
|
178 |
CallGLCode setupcode; |
CallGLCode setupcode; |
179 |
/** The code to call after rendering the pass. |
/** The code to call after rendering the pass. */ |
|
*/ |
|
180 |
CallGLCode teardowncode; |
CallGLCode teardowncode; |
181 |
|
|
182 |
/** The TexGen objects for the different texture units. |
/** The TexGen objects for the different texture units. */ |
|
*/ |
|
183 |
vector<shared_ptr<TexGen> > texgen; |
vector<shared_ptr<TexGen> > texgen; |
184 |
/** The non-texgen light setup routines. |
/** The non-texgen light setup routines. */ |
|
*/ |
|
185 |
vector<shared_ptr<LightSetup> > setup; |
vector<shared_ptr<LightSetup> > setup; |
186 |
|
|
187 |
/** Call setupcode, texgen and setup for the texture units with |
/*** Texgen version of the renderinf interface. */ |
188 |
* the given lightparams. |
/** Calls setupcode, texgen and setup for the texture. |
189 |
*/ |
* |
190 |
|
* @param param light parameters (LightParam object) |
191 |
void setUp(LightParam *param) ; |
*/ |
192 |
/** Call teardowncode. |
void setUp_texgen(LightParam *param); |
193 |
*/ |
|
194 |
void tearDown() { |
/** Calls teardowncode. |
195 |
teardowncode(); |
*/ |
196 |
} |
void tearDown_texgen () { teardowncode(); } |
197 |
|
|
198 |
|
/*** Vertex program version of the rendering interface */ |
199 |
/** Vertex Program Version of the rendering interface |
/** Calls setupcode, texgen and setup for the texture. |
200 |
*/ |
* |
201 |
void setUpVP(LightParam *param); |
* @param param light parameters (LightParam object) |
202 |
void tearDownVP(); |
*/ |
203 |
|
void setUp_VP(LightParam *param); |
204 |
/** Paperpass vertex |
|
205 |
|
/** Calls teardowncode. |
206 |
|
*/ |
207 |
|
void tearDown_VP(); |
208 |
|
|
209 |
|
/** Vertex program version of the paperpass vertex |
210 |
|
* Calling vertex_VP() is optional. It's possible to call |
211 |
|
* glTexCoord*() and glVertex*() directly from the context |
212 |
|
* and choose the best function variant (vertex_VP() forces |
213 |
|
* to pass coordinates in vector arrays of 4 floats). |
214 |
|
* |
215 |
* @param pos vertex position (vector of 4 floats) |
* @param pos vertex position (vector of 4 floats) |
216 |
* @param ppos position within paper (vector of 4 floats) |
* @param ppos position within paper (vector of 4 floats) |
217 |
*/ |
*/ |
218 |
void vertex(float *pos, float *ppos) { |
void vertex_VP(float *pos, float *ppos) { |
219 |
glTexCoord4fv(ppos); |
glTexCoord4fv(ppos); |
220 |
glVertex4fv(pos); |
glVertex4fv(pos); |
221 |
} |
} |
222 |
|
|
223 |
/** Generate and load the texgen vertex program |
/*** Explicit version of the rendering interface */ |
224 |
* Automatically called on first setUpVP unless already loaded */ |
/** Calls setupcode, texgen and setup for the texture. |
225 |
void loadVP(); |
* |
226 |
|
* @param param light parameters (LightParam object) |
227 |
|
*/ |
228 |
|
void setUp_explicit(LightParam *param) {} |
229 |
|
|
230 |
|
/** Calls teardowncode. |
231 |
|
*/ |
232 |
|
void tearDown_explicit() {} |
233 |
|
|
234 |
|
/** Explicit version of the paperpass vertex |
235 |
|
*/ |
236 |
|
void vertex_explicit() {} |
237 |
|
void vertex_explicit(float *ppos) {} |
238 |
|
void vertex_explicit(float *pos, float *ppos) {} |
239 |
|
|
240 |
protected: |
protected: |
241 |
|
/* Vertex program code */ |
242 |
VPCode texgenvp; |
VPCode texgenvp; |
243 |
}; |
}; |
244 |
|
|
245 |
/** A paper is simply a vector of passes. |
/** A paper is simply a vector of passes. |
246 |
*/ |
*/ |
247 |
class Paper : public vector<PaperPass> {}; |
class Paper : public vector<PaperPass> {}; |
248 |
|
|
249 |
} |
} |
250 |
|
|
251 |
#endif |
#endif |