/[gzz]/gzz/gfx/libpaper/Paper.cxx
ViewVC logotype

Diff of /gzz/gfx/libpaper/Paper.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by jvk, Wed Sep 11 11:47:39 2002 UTC revision 1.11 by humppake, Sat Sep 28 10:22:22 2002 UTC
# Line 29  namespace Paper { Line 29  namespace Paper {
29          this->tex_mat[15] = 1;          this->tex_mat[15] = 1;
30      }      }
31    
32      void TexGen::setUpVP(int unit, LightParam * param) {      void TexGen::setUp_VP(int unit, LightParam * param) {
33        // XXX: This could also be implemented as CallGL code        // XXX: This could also be implemented as CallGL code
34  #ifdef GL_VERTEX_PROGRAM_NV  #ifdef GL_VERTEX_PROGRAM_NV
35        GLuint base = unit * 4 + tex_addr_base;        GLuint base = unit * 4 + tex_addr_base;
# Line 75  namespace Paper { Line 75  namespace Paper {
75          glPopMatrix();          glPopMatrix();
76        }        }
77    
78        void TexGenEmboss::setUpVP(int unit, LightParam *param) {        void TexGenEmboss::setUp_VP(int unit, LightParam *param) {
79          // Suppose          // Suppose
80          //   x = vertex position          //   x = vertex position
81          //   p = paper coordinates          //   p = paper coordinates
# Line 226  namespace Paper { Line 226  namespace Paper {
226        }        }
227    
228    
229      void PaperPass::setUp_texgen(LightParam *param) {
       void PaperPass::setUp(LightParam *param) {  
230          setupcode();          setupcode();
231            
232          /* Set up TexGen for each texture unit */          /* Set up TexGen for each texture unit */
233          GLenum unit = GL_TEXTURE0_ARB;          GLenum unit = GL_TEXTURE0_ARB;
234          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) {
# Line 237  namespace Paper { Line 236  namespace Paper {
236            if (it->get()) (*it)->setUp(param);            if (it->get()) (*it)->setUp(param);
237            else std::cerr << "Warning: ignoring null TexGen\n";            else std::cerr << "Warning: ignoring null TexGen\n";
238          }          }
239            
240          /* Do general parametric setup */          /* Do general parametric setup */
241          for (vector<shared_ptr<LightSetup> >::iterator it = setup.begin(); it != setup.end(); ++it) {          for (vector<shared_ptr<LightSetup> >::iterator it = setup.begin(); it != setup.end(); ++it) {
242            if (it->get()) (*it)->setUp(param);            if (it->get()) (*it)->setUp(param);
243            else std::cerr << "Warning: ignoring null LightSetup\n";            else std::cerr << "Warning: ignoring null LightSetup\n";
244          }          }
245        }    }
246      
247    void PaperPass::loadVP() {    void PaperPass::loadVP() {
248      std::ostringstream code;      std::ostringstream code;
249            
250      code << "!!VP1.1 OPTION NV_position_invariant;\n"      code << "!!VP1.1 OPTION NV_position_invariant;\n"
251           << "MOV o[COL0], v[COL0];\n"           << "MOV o[COL0], v[COL0];\n"
252           << "MOV o[COL1], v[COL1];\n";                   << "MOV o[COL1], v[COL1];\n";
253            
254      int unit = 0;      int unit = 0;
255      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) {
256        if (it->get()) code << (*it)->getVPCode(unit);        if (it->get()) code << (*it)->getVPCode(unit);
257        else std::cerr << "Warning: ignoring null TexGen\n";        else std::cerr << "Warning: ignoring null TexGen\n";
258        unit++;        unit++;
259      }      }
260            
261      code << "END\n";      code << "END\n";
262            
263      //std::cerr << "Creating VPCode with the source " << code.str() << "\n";      //std::cerr << "Creating VPCode with the source " << code.str() << "\n";
264            
265      texgenvp = VPCode(code.str().c_str());      texgenvp = VPCode(code.str().c_str());
266    }    }
267      
268    void PaperPass::setUpVP(LightParam *param) {    void PaperPass::setUp_VP(LightParam *param) {
269          if (texgenvp.getSource().length() == 0)          if (texgenvp.getSource().length() == 0) loadVP();
270            loadVP();          
   
271          setupcode();          setupcode();
272            
273          /* Set up VP TexGen parameters for each texture unit */          /* Set up VP TexGen parameters for each texture unit */
274          int unit = 0;          int unit = 0;
275          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) {
276            if (it->get()) (*it)->setUpVP(unit, param);            if (it->get()) (*it)->setUp_VP(unit, param);
277            else std::cerr << "Warning: ignoring null TexGen\n";            else std::cerr << "Warning: ignoring null TexGen\n";
278            unit++;            unit++;
279          }          }
280            
281          /* Do general parametric setup */          /* Do general parametric setup */
282          for (vector<shared_ptr<LightSetup> >::iterator it = setup.begin(); it != setup.end(); ++it) {          for (vector<shared_ptr<LightSetup> >::iterator it = setup.begin(); it != setup.end(); ++it) {
283            if (it->get()) (*it)->setUp(param);            if (it->get()) (*it)->setUp(param);
284            else std::cerr << "Warning: ignoring null LightSetup\n";            else std::cerr << "Warning: ignoring null LightSetup\n";
285          }          }
286            
287          texgenvp(); // Bind vertex program          texgenvp(); // Bind vertex program
288  #ifdef GL_VERTEX_PROGRAM_NV  #ifdef GL_VERTEX_PROGRAM_NV
289          glEnable(GL_VERTEX_PROGRAM_NV);          glEnable(GL_VERTEX_PROGRAM_NV);
290  #endif  #endif
291    }    }
292      
293    void PaperPass::tearDownVP() {    void PaperPass::tearDown_VP() {
294      teardowncode();      teardowncode();
295  #ifdef GL_VERTEX_PROGRAM_NV  #ifdef GL_VERTEX_PROGRAM_NV
296      glDisable(GL_VERTEX_PROGRAM_NV);      glDisable(GL_VERTEX_PROGRAM_NV);
297  #endif  #endif
298    }    }
   
299  }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26