[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx libpaper/Paper.cxx libpaper/Paper.hxx l...
From: |
Asko Soukka |
Subject: |
[Gzz-commits] gzz/gfx libpaper/Paper.cxx libpaper/Paper.hxx l... |
Date: |
Sat, 28 Sep 2002 06:22:23 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Asko Soukka <address@hidden> 02/09/28 06:22:23
Modified files:
gfx/libpaper : Paper.cxx Paper.hxx
gfx/librenderables: renderables.py
Log message:
vertex => vertex_VP() + some docs. Hope that didn't broke anything.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/Paper.cxx.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/Paper.hxx.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.78&tr2=1.79&r1=text&r2=text
Patches:
Index: gzz/gfx/libpaper/Paper.cxx
diff -c gzz/gfx/libpaper/Paper.cxx:1.10 gzz/gfx/libpaper/Paper.cxx:1.11
*** gzz/gfx/libpaper/Paper.cxx:1.10 Wed Sep 11 07:47:39 2002
--- gzz/gfx/libpaper/Paper.cxx Sat Sep 28 06:22:22 2002
***************
*** 29,35 ****
this->tex_mat[15] = 1;
}
! void TexGen::setUpVP(int unit, LightParam * param) {
// XXX: This could also be implemented as CallGL code
#ifdef GL_VERTEX_PROGRAM_NV
GLuint base = unit * 4 + tex_addr_base;
--- 29,35 ----
this->tex_mat[15] = 1;
}
! void TexGen::setUp_VP(int unit, LightParam * param) {
// XXX: This could also be implemented as CallGL code
#ifdef GL_VERTEX_PROGRAM_NV
GLuint base = unit * 4 + tex_addr_base;
***************
*** 75,81 ****
glPopMatrix();
}
! void TexGenEmboss::setUpVP(int unit, LightParam *param) {
// Suppose
// x = vertex position
// p = paper coordinates
--- 75,81 ----
glPopMatrix();
}
! void TexGenEmboss::setUp_VP(int unit, LightParam *param) {
// Suppose
// x = vertex position
// p = paper coordinates
***************
*** 226,235 ****
}
!
! void PaperPass::setUp(LightParam *param) {
setupcode();
!
/* Set up TexGen for each texture unit */
GLenum unit = GL_TEXTURE0_ARB;
for (vector<shared_ptr<TexGen> >::iterator it = texgen.begin(); it !=
texgen.end(); ++it) {
--- 226,234 ----
}
! void PaperPass::setUp_texgen(LightParam *param) {
setupcode();
!
/* Set up TexGen for each texture unit */
GLenum unit = GL_TEXTURE0_ARB;
for (vector<shared_ptr<TexGen> >::iterator it = texgen.begin(); it !=
texgen.end(); ++it) {
***************
*** 237,302 ****
if (it->get()) (*it)->setUp(param);
else std::cerr << "Warning: ignoring null TexGen\n";
}
!
/* Do general parametric setup */
for (vector<shared_ptr<LightSetup> >::iterator it = setup.begin(); it
!= setup.end(); ++it) {
if (it->get()) (*it)->setUp(param);
else std::cerr << "Warning: ignoring null LightSetup\n";
}
! }
!
void PaperPass::loadVP() {
std::ostringstream code;
!
code << "!!VP1.1 OPTION NV_position_invariant;\n"
<< "MOV o[COL0], v[COL0];\n"
! << "MOV o[COL1], v[COL1];\n";
!
int unit = 0;
for (vector<shared_ptr<TexGen> >::iterator it = texgen.begin(); it !=
texgen.end(); ++it) {
if (it->get()) code << (*it)->getVPCode(unit);
else std::cerr << "Warning: ignoring null TexGen\n";
unit++;
}
!
code << "END\n";
!
//std::cerr << "Creating VPCode with the source " << code.str() << "\n";
!
texgenvp = VPCode(code.str().c_str());
}
!
! void PaperPass::setUpVP(LightParam *param) {
! if (texgenvp.getSource().length() == 0)
! loadVP();
!
setupcode();
!
/* Set up VP TexGen parameters for each texture unit */
! int unit = 0;
for (vector<shared_ptr<TexGen> >::iterator it = texgen.begin(); it !=
texgen.end(); ++it) {
! if (it->get()) (*it)->setUpVP(unit, param);
else std::cerr << "Warning: ignoring null TexGen\n";
unit++;
}
!
/* Do general parametric setup */
for (vector<shared_ptr<LightSetup> >::iterator it = setup.begin(); it
!= setup.end(); ++it) {
if (it->get()) (*it)->setUp(param);
else std::cerr << "Warning: ignoring null LightSetup\n";
}
!
texgenvp(); // Bind vertex program
#ifdef GL_VERTEX_PROGRAM_NV
glEnable(GL_VERTEX_PROGRAM_NV);
#endif
}
!
! void PaperPass::tearDownVP() {
teardowncode();
#ifdef GL_VERTEX_PROGRAM_NV
glDisable(GL_VERTEX_PROGRAM_NV);
#endif
}
-
}
--- 236,299 ----
if (it->get()) (*it)->setUp(param);
else std::cerr << "Warning: ignoring null TexGen\n";
}
!
/* Do general parametric setup */
for (vector<shared_ptr<LightSetup> >::iterator it = setup.begin(); it
!= setup.end(); ++it) {
if (it->get()) (*it)->setUp(param);
else std::cerr << "Warning: ignoring null LightSetup\n";
}
! }
!
void PaperPass::loadVP() {
std::ostringstream code;
!
code << "!!VP1.1 OPTION NV_position_invariant;\n"
<< "MOV o[COL0], v[COL0];\n"
! << "MOV o[COL1], v[COL1];\n";
!
int unit = 0;
for (vector<shared_ptr<TexGen> >::iterator it = texgen.begin(); it !=
texgen.end(); ++it) {
if (it->get()) code << (*it)->getVPCode(unit);
else std::cerr << "Warning: ignoring null TexGen\n";
unit++;
}
!
code << "END\n";
!
//std::cerr << "Creating VPCode with the source " << code.str() << "\n";
!
texgenvp = VPCode(code.str().c_str());
}
!
! void PaperPass::setUp_VP(LightParam *param) {
! if (texgenvp.getSource().length() == 0) loadVP();
!
setupcode();
!
/* Set up VP TexGen parameters for each texture unit */
! int unit = 0;
for (vector<shared_ptr<TexGen> >::iterator it = texgen.begin(); it !=
texgen.end(); ++it) {
! if (it->get()) (*it)->setUp_VP(unit, param);
else std::cerr << "Warning: ignoring null TexGen\n";
unit++;
}
!
/* Do general parametric setup */
for (vector<shared_ptr<LightSetup> >::iterator it = setup.begin(); it
!= setup.end(); ++it) {
if (it->get()) (*it)->setUp(param);
else std::cerr << "Warning: ignoring null LightSetup\n";
}
!
texgenvp(); // Bind vertex program
#ifdef GL_VERTEX_PROGRAM_NV
glEnable(GL_VERTEX_PROGRAM_NV);
#endif
}
!
! void PaperPass::tearDown_VP() {
teardowncode();
#ifdef GL_VERTEX_PROGRAM_NV
glDisable(GL_VERTEX_PROGRAM_NV);
#endif
}
}
Index: gzz/gfx/libpaper/Paper.hxx
diff -c gzz/gfx/libpaper/Paper.hxx:1.8 gzz/gfx/libpaper/Paper.hxx:1.9
*** gzz/gfx/libpaper/Paper.hxx:1.8 Tue Sep 10 10:56:00 2002
--- gzz/gfx/libpaper/Paper.hxx Sat Sep 28 06:22:22 2002
***************
*** 87,93 ****
TexGen(const float *tex_mat) ;
virtual void setUp(LightParam *param) ;
! virtual void setUpVP(int unit, LightParam * param);
virtual string getVPCode(int unit);
};
--- 87,93 ----
TexGen(const float *tex_mat) ;
virtual void setUp(LightParam *param) ;
! virtual void setUp_VP(int unit, LightParam * param);
virtual string getVPCode(int unit);
};
***************
*** 108,114 ****
virtual void setUp(LightParam *param) ;
! virtual void setUpVP(int unit, LightParam * param);
};
/** TexGen for transforming light intensity or direction map
--- 108,114 ----
virtual void setUp(LightParam *param) ;
! virtual void setUp_VP(int unit, LightParam * param);
};
/** TexGen for transforming light intensity or direction map
***************
*** 145,207 ****
/** A single rendering pass.
* The data members are public to allow modification,
! * but when using a ready-made PaperPass, only
! * the setup() and tearDown() methods should be called.
*/
class PaperPass {
public:
! /** The code to call before beginning to render the pass.
! */
CallGLCode setupcode;
! /** The code to call after rendering the pass.
! */
CallGLCode teardowncode;
! /** The TexGen objects for the different texture units.
! */
vector<shared_ptr<TexGen> > texgen;
! /** The non-texgen light setup routines.
! */
vector<shared_ptr<LightSetup> > setup;
!
! /** Call setupcode, texgen and setup for the texture units with
! * the given lightparams.
! */
!
! void setUp(LightParam *param) ;
! /** Call teardowncode.
! */
! void tearDown() {
! teardowncode();
! }
!
!
! /** Vertex Program Version of the rendering interface
! */
! void setUpVP(LightParam *param);
! void tearDownVP();
!
! /** Paperpass vertex
* @param pos vertex position (vector of 4 floats)
* @param ppos position within paper (vector of 4 floats)
*/
! void vertex(float *pos, float *ppos) {
! glTexCoord4fv(ppos);
! glVertex4fv(pos);
}
!
! /** Generate and load the texgen vertex program
! * Automatically called on first setUpVP unless already loaded */
! void loadVP();
!
protected:
VPCode texgenvp;
};
!
! /** A paper is simply a vector of passes.
! */
! class Paper : public vector<PaperPass> {};
!
}
#endif
--- 145,251 ----
/** A single rendering pass.
* The data members are public to allow modification,
! * but when using a ready-made PaperPass, _choose one_
! * (and only one) of the following ways to use it:
! *
! * 1) using texgen
! * - call setUp_texgen() with LightParam to use
! * - call glVertex*() directly from the context
! * - teardown_texgen()
! *
! * 2) using a vertex program
! * - call setUp_VP with LightParam to use
! * - call glTexCoord*() and glVertex*() directly from
! * the context _or_ call vector_VP() with vertex and
! * texture coordinates in vector arrays of 4 floats.
! * - call teardown_VP()
! *
! * 3) using explicit coordinates
! * - call setUp_explicit with LightParam to use
! * - ???? without? with texcoords? with texcoord and vertex?
! * - call teardown_explicit()
*/
class PaperPass {
+ private:
+ /** Generates and loads the texgen vertex program.
+ * This is automatically called on first setUp_VP
+ * unless it's already loaded.
+ */
+ void loadVP();
+
public:
! /** The code to call before beginning to render the pass. */
CallGLCode setupcode;
! /** The code to call after rendering the pass. */
CallGLCode teardowncode;
! /** The TexGen objects for the different texture units. */
vector<shared_ptr<TexGen> > texgen;
! /** The non-texgen light setup routines. */
vector<shared_ptr<LightSetup> > setup;
!
! /*** Texgen version of the renderinf interface. */
! /** Calls setupcode, texgen and setup for the texture.
! *
! * @param param light parameters (LightParam object)
! */
! void setUp_texgen(LightParam *param);
!
! /** Calls teardowncode.
! */
! void tearDown_texgen () { teardowncode(); }
!
! /*** Vertex program version of the rendering interface */
! /** Calls setupcode, texgen and setup for the texture.
! *
! * @param param light parameters (LightParam object)
! */
! void setUp_VP(LightParam *param);
!
! /** Calls teardowncode.
! */
! void tearDown_VP();
!
! /** Vertex program version of the paperpass vertex
! * Calling vertex_VP() is optional. It's possible to call
! * glTexCoord*() and glVertex*() directly from the context
! * and choose the best function variant (vertex_VP() forces
! * to pass coordinates in vector arrays of 4 floats).
! *
* @param pos vertex position (vector of 4 floats)
* @param ppos position within paper (vector of 4 floats)
*/
! void vertex_VP(float *pos, float *ppos) {
! glTexCoord4fv(ppos);
! glVertex4fv(pos);
}
!
! /*** Explicit version of the rendering interface */
! /** Calls setupcode, texgen and setup for the texture.
! *
! * @param param light parameters (LightParam object)
! */
! void setUp_explicit(LightParam *param) {}
!
! /** Calls teardowncode.
! */
! void tearDown_explicit() {}
!
! /** Explicit version of the paperpass vertex
! */
! void vertex_explicit() {}
! void vertex_explicit(float *ppos) {}
! void vertex_explicit(float *pos, float *ppos) {}
!
protected:
+ /* Vertex program code */
VPCode texgenvp;
};
!
! /** A paper is simply a vector of passes.
! */
! class Paper : public vector<PaperPass> {};
!
}
#endif
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.78
gzz/gfx/librenderables/renderables.py:1.79
*** gzz/gfx/librenderables/renderables.py:1.78 Sat Sep 28 06:03:16 2002
--- gzz/gfx/librenderables/renderables.py Sat Sep 28 06:22:22 2002
***************
*** 426,439 ****
for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
if (dbg) cout << "Pass\\n";
! (*it).setUpVP(&lightParam);
GLERR
glMultiDrawElementsEXT(GL_QUAD_STRIP,
counts, GL_UNSIGNED_INT, (const GLvoid **)indps,
dice-1);
GLERR
! (*it).tearDownVP();
GLERR
}
--- 426,439 ----
for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
if (dbg) cout << "Pass\\n";
! (*it).setUp_VP(&lightParam);
GLERR
glMultiDrawElementsEXT(GL_QUAD_STRIP,
counts, GL_UNSIGNED_INT, (const GLvoid **)indps,
dice-1);
GLERR
! (*it).tearDown_VP();
GLERR
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx libpaper/Paper.cxx libpaper/Paper.hxx l...,
Asko Soukka <=