143 |
virtual void setUp(LightParam *param) ; |
virtual void setUp(LightParam *param) ; |
144 |
}; |
}; |
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, _choose one_ |
* but when using a ready-made PaperPass, _choose one_ |
149 |
* (and only one) of the following ways to use it: |
* (and only one) of the following ways to use it: |
150 |
* |
* |
151 |
* 1) using texgen |
* 1) using texgen |
152 |
* - call setUp_texgen() with LightParam to use |
* - call setUp_texgen() with LightParam to use |
153 |
* - call glVertex*() directly from the context |
* - call glVertex*() directly from the context |
154 |
* - teardown_texgen() |
* - teardown_texgen() |
155 |
* |
* |
156 |
* 2) using a vertex program |
* 2) using a vertex program |
157 |
* - call setUp_VP with LightParam to use |
* - call setUp_VP with LightParam to use |
158 |
* - call glTexCoord*() and glVertex*() directly from |
* - call glTexCoord*() and glVertex*() directly from |
159 |
* the context, use vertex arrays _or_ call vector_VP() |
* the context, use vertex arrays _or_ call vector_VP() |
160 |
* with vertex and texture coordinates in arrays |
* with vertex and texture coordinates in arrays |
161 |
* of 4 floats. |
* of 4 floats. |
162 |
* - call teardown_VP() |
* - call teardown_VP() |
163 |
* |
* |
164 |
* 3) using explicit coordinates |
* 3) using explicit coordinates |
165 |
* - call setUp_explicit with LightParam to use |
* - call setUp_explicit with LightParam to use |
166 |
* - ???? without? with texcoords? with texcoord and vertex? |
* - ???? without? with texcoords? with texcoord and vertex? |
167 |
* - call teardown_explicit() |
* - call teardown_explicit() |
168 |
*/ |
*/ |
169 |
class PaperPass { |
class PaperPass { |
170 |
private: |
private: |
171 |
/** Generates and loads the texgen vertex program. |
/** Generates and loads the texgen vertex program. |
172 |
* This is automatically called on first setUp_VP |
* This is automatically called on first setUp_VP |
173 |
* unless it's already loaded. |
* unless it's already loaded. |
174 |
*/ |
*/ |
175 |
void loadVP(); |
void loadVP(); |
176 |
|
|
177 |
public: |
public: |
178 |
/** The code to call before beginning to render the pass. */ |
/** The code to call before beginning to render the pass. */ |
179 |
CallGLCode setupcode; |
CallGLCode setupcode; |
180 |
/** The code to call after rendering the pass. */ |
/** The code to call after rendering the pass. */ |
181 |
CallGLCode teardowncode; |
CallGLCode teardowncode; |
182 |
|
|
183 |
/** The TexGen objects for the different texture units. */ |
/** The TexGen objects for the different texture units. */ |
184 |
vector<shared_ptr<TexGen> > texgen; |
vector<shared_ptr<TexGen> > texgen; |
185 |
/** The non-texgen light setup routines. */ |
/** The non-texgen light setup routines. */ |
186 |
vector<shared_ptr<LightSetup> > setup; |
vector<shared_ptr<LightSetup> > setup; |
187 |
|
|
188 |
/*** Texgen version of the renderinf interface. */ |
/*** Texgen version of the renderinf interface. */ |
189 |
/** Calls setupcode, texgen and setup for the texture. |
/** Calls setupcode, texgen and setup for the texture. |
190 |
* |
* |
191 |
* @param param light parameters (LightParam object) |
* @param param light parameters (LightParam object) |
192 |
*/ |
*/ |
193 |
void setUp_texgen(LightParam *param); |
void setUp_texgen(LightParam *param); |
194 |
|
|
195 |
/** Calls teardowncode. |
/** Calls teardowncode. |
196 |
*/ |
*/ |
197 |
void tearDown_texgen () { teardowncode(); } |
void tearDown_texgen () { teardowncode(); } |
198 |
|
|
199 |
/*** Vertex program version of the rendering interface */ |
/*** Vertex program version of the rendering interface */ |
200 |
/** Calls setupcode, texgen and setup for the texture. |
/** Calls setupcode, texgen and setup for the texture. |
201 |
* |
* |
202 |
* @param param light parameters (LightParam object) |
* @param param light parameters (LightParam object) |
203 |
*/ |
*/ |
204 |
void setUp_VP(LightParam *param); |
void setUp_VP(LightParam *param); |
205 |
|
|
206 |
/** Calls teardowncode. |
/** Calls teardowncode. |
207 |
*/ |
*/ |
208 |
void tearDown_VP(); |
void tearDown_VP(); |
209 |
|
|
210 |
/** Vertex program version of the paperpass vertex |
/** Vertex program version of the paperpass vertex |
211 |
* Calling vertex_VP() is optional. It's possible to call |
* Calling vertex_VP() is optional. It's possible to call |
212 |
* glTexCoord*() and glVertex*() directly from the context |
* glTexCoord*() and glVertex*() directly from the context |
213 |
* and choose the best function variant or use vertex arrays |
* and choose the best function variant or use vertex arrays |
214 |
* (vertex_VP() forces to pass coordinates in arrays of 4 floats). |
* (vertex_VP() forces to pass coordinates in arrays of 4 floats). |
215 |
* |
* |
216 |
* @param pos vertex position (array of 4 floats) |
* @param pos vertex position (array of 4 floats) |
217 |
* @param ppos position within paper (array of 4 floats) |
* @param ppos position within paper (array of 4 floats) |
218 |
*/ |
*/ |
219 |
void vertex_VP(float *pos, float *ppos) { |
void vertex_VP(float *pos, float *ppos) { |
220 |
glTexCoord4fv(ppos); |
glTexCoord4fv(ppos); |
221 |
glVertex4fv(pos); |
glVertex4fv(pos); |
222 |
} |
} |
223 |
|
|
224 |
/*** Explicit version of the rendering interface */ |
/*** Explicit version of the rendering interface */ |
225 |
/** Calls setupcode, texgen and setup for the texture. |
/** Calls setupcode, texgen and setup for the texture. |
226 |
* |
* |
227 |
* @param param light parameters (LightParam object) |
* @param param light parameters (LightParam object) |
228 |
*/ |
*/ |
229 |
void setUp_explicit(LightParam *param) {} |
void setUp_explicit(LightParam *param) {} |
230 |
|
|
231 |
/** Calls teardowncode. |
/** Calls teardowncode. |
232 |
*/ |
*/ |
233 |
void tearDown_explicit() {} |
void tearDown_explicit() {} |
234 |
|
|
235 |
/** Explicit version of the paperpass vertex |
/** Explicit version of the paperpass vertex |
236 |
*/ |
*/ |
237 |
void vertex_explicit() {} |
void vertex_explicit() {} |
238 |
void vertex_explicit(float *ppos) {} |
void vertex_explicit(float *ppos) {} |
239 |
void vertex_explicit(float *pos, float *ppos) {} |
void vertex_explicit(float *pos, float *ppos) {} |
240 |
|
|
241 |
protected: |
protected: |
242 |
/* Vertex program code */ |
/* Vertex program code */ |
243 |
VPCode texgenvp; |
VPCode texgenvp; |
244 |
}; |
}; |
245 |
|
|
246 |
/** A paper is simply a vector of passes. |
/** A paper is simply a vector of passes. |
247 |
*/ |
*/ |