45 |
} |
} |
46 |
|
|
47 |
string TexGen::getVPCode(int unit) { |
string TexGen::getVPCode(int unit) { |
48 |
|
#if 0 |
49 |
|
// XXX: this code crashes when compiled with g++-3.1 -O3 -ffast-math |
50 |
std::ostringstream code; |
std::ostringstream code; |
51 |
|
|
52 |
GLuint base = unit * 4 + tex_addr_base; |
GLuint base = unit * 4 + tex_addr_base; |
56 |
<< "DP4 o[TEX" << unit << "].w, c[" << base + 3 << "], v[TEX0];\n"; |
<< "DP4 o[TEX" << unit << "].w, c[" << base + 3 << "], v[TEX0];\n"; |
57 |
|
|
58 |
return code.str(); |
return code.str(); |
59 |
|
#else |
60 |
|
GLuint base = unit * 4 + tex_addr_base; |
61 |
|
char str[1000]; |
62 |
|
sprintf(str, |
63 |
|
"DP4 o[TEX%d].x, c[%u], v[TEX0];\n" |
64 |
|
"DP4 o[TEX%d].y, c[%u], v[TEX0];\n" |
65 |
|
"DP4 o[TEX%d].z, c[%u], v[TEX0];\n" |
66 |
|
"DP4 o[TEX%d].w, c[%u], v[TEX0];\n", |
67 |
|
unit, base, unit, base + 1, unit, base + 2, unit, base + 3); |
68 |
|
return str; |
69 |
|
#endif |
70 |
} |
} |
71 |
|
|
72 |
void TexGen::setUp_explicit(LightParam * param) { |
void TexGen::setUp_explicit(LightParam * param) { |
270 |
} |
} |
271 |
|
|
272 |
void PaperPass::loadVP() { |
void PaperPass::loadVP() { |
273 |
std::ostringstream code; |
string code = |
274 |
|
"!!VP1.1 OPTION NV_position_invariant;\n" |
275 |
code << "!!VP1.1 OPTION NV_position_invariant;\n" |
"MOV o[COL0], v[COL0];\n" |
276 |
<< "MOV o[COL0], v[COL0];\n" |
"MOV o[COL1], v[COL1];\n"; |
|
<< "MOV o[COL1], v[COL1];\n"; |
|
277 |
|
|
278 |
int unit = 0; |
int unit = 0; |
279 |
for (vector<shared_ptr<TexGen> >::iterator it = texgen.begin(); it != texgen.end(); ++it) { |
for (vector<shared_ptr<TexGen> >::iterator it = texgen.begin(); it != texgen.end(); ++it) { |
280 |
if (it->get()) code << (*it)->getVPCode(unit); |
if (it->get()) code += (*it)->getVPCode(unit); |
281 |
else std::cerr << "Warning: ignoring null TexGen\n"; |
else std::cerr << "Warning: ignoring null TexGen\n"; |
282 |
unit++; |
unit++; |
283 |
} |
} |
284 |
|
|
285 |
code << "END\n"; |
code += "END\n"; |
286 |
|
|
287 |
//std::cerr << "Creating VPCode with the source " << code.str() << "\n"; |
//std::cerr << "Creating VPCode with the source " << code.str() << "\n"; |
288 |
|
|
289 |
texgenvp = VPCode(code.str().c_str()); |
texgenvp = VPCode(code.c_str()); |
290 |
} |
} |
291 |
|
|
292 |
void PaperPass::setUp_VP(LightParam *param) { |
void PaperPass::setUp_VP(LightParam *param) { |