[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx libcallgl/callgl.cxx libcallgl/callgl.h...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx libcallgl/callgl.cxx libcallgl/callgl.h... |
Date: |
Wed, 11 Sep 2002 06:41:46 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/09/11 06:41:46
Modified files:
gfx/libcallgl : callgl.cxx callgl.hxx
gfx/libpaper : Paper.cxx
gfx/librenderables: renderables.py
Log message:
Fix bugs in libpaper vertex entry point; start fisheye paper renderable
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.cxx.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.hxx.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/Paper.cxx.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.18&tr2=1.19&r1=text&r2=text
Patches:
Index: gzz/gfx/libcallgl/callgl.cxx
diff -c gzz/gfx/libcallgl/callgl.cxx:1.10 gzz/gfx/libcallgl/callgl.cxx:1.11
*** gzz/gfx/libcallgl/callgl.cxx:1.10 Tue Sep 10 05:53:15 2002
--- gzz/gfx/libcallgl/callgl.cxx Wed Sep 11 06:41:45 2002
***************
*** 565,568 ****
--- 565,601 ----
return r;
}
+
+
+ void VPCode::compile() {
+ vpid = shared_ptr<VPid>(new VPid);
+
+ int er = glGetError();
+ if (er != GL_NO_ERROR)
+ cerr << "Warning: OPENGL ERROR "
+ << gluErrorString(er)
+ << " before loading vertex program\n";
+
+ #ifdef GL_VERTEX_PROGRAM_NV
+ if (source.compare(0, 5, "!!VSP") == 0) {
+ glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, vpid->name,
+ source.length(), (GLubyte*)source.data());
+ } else {
+ glLoadProgramNV(GL_VERTEX_PROGRAM_NV, vpid->name, source.length(),
+ (GLubyte*)source.data());
+ }
+
+ er = glGetError();
+ if (er != GL_NO_ERROR) {
+ GLint errpos;
+
+ cerr << "OPENGL ERROR "
+ << gluErrorString(er)
+ << " when loading vertex program\n";
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_NV, &errpos);
+ std::cerr << "Program error position: " << errpos << "\n";
+ }
+ #endif
+ }
}
Index: gzz/gfx/libcallgl/callgl.hxx
diff -c gzz/gfx/libcallgl/callgl.hxx:1.8 gzz/gfx/libcallgl/callgl.hxx:1.9
*** gzz/gfx/libcallgl/callgl.hxx:1.8 Tue Sep 10 15:19:29 2002
--- gzz/gfx/libcallgl/callgl.hxx Wed Sep 11 06:41:45 2002
***************
*** 143,149 ****
#ifdef GL_VERTEX_PROGRAM_NV
VPid(GLuint name) : name(name) {}
VPid() { glGenProgramsNV(1, &name); }
! ~VPid() { if (name) glDeleteProgramsNV(1, &name); }
#endif
};
--- 143,149 ----
#ifdef GL_VERTEX_PROGRAM_NV
VPid(GLuint name) : name(name) {}
VPid() { glGenProgramsNV(1, &name); }
! ~VPid() { glDeleteProgramsNV(1, &name); }
#endif
};
***************
*** 169,185 ****
}
protected:
! void compile() {
! vpid = shared_ptr<VPid>(new VPid);
! #ifdef GL_VERTEX_PROGRAM_NV
! if (source.compare(0, 5, "!!VSP"))
! glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, vpid->name,
! source.length(), (GLubyte*)source.data());
! else
! glLoadProgramNV(GL_VERTEX_PROGRAM_NV, vpid->name, source.length(),
! (GLubyte*)source.data());
! #endif
! }
string source;
shared_ptr<VPid> vpid;
};
--- 169,175 ----
}
protected:
! void compile();
string source;
shared_ptr<VPid> vpid;
};
Index: gzz/gfx/libpaper/Paper.cxx
diff -c gzz/gfx/libpaper/Paper.cxx:1.8 gzz/gfx/libpaper/Paper.cxx:1.9
*** gzz/gfx/libpaper/Paper.cxx:1.8 Tue Sep 10 15:19:29 2002
--- gzz/gfx/libpaper/Paper.cxx Wed Sep 11 06:41:45 2002
***************
*** 2,13 ****
#include <sstream>
! /* define positions of tracked matrices inside the NV vertex program
registers */
! #define m_p_addr 0 // product of projection and modelview matrices
! #define paper_addr 4 // object-to-paper-coordinate mapping matrix
!
! /* the matrix that maps v[TEX0] into o[TEXi] is stored starting at
c[tex_addr_base + 4*i] */
! #define tex_addr_base 60 // texture matrix
namespace Paper {
TexGen::TexGen(const float *tex_mat) {
--- 2,10 ----
#include <sstream>
! /* the matrix that maps v[TEX0] into o[TEXi] is stored
! * starting at c[tex_addr_base + 4*i] */
! #define tex_addr_base 60
namespace Paper {
TexGen::TexGen(const float *tex_mat) {
***************
*** 47,56 ****
std::ostringstream code;
GLuint base = unit * 4 + tex_addr_base;
! code << "DP4 o[TEX" << unit << "].x, c[" << base + 0 << "], v[TEX0]\n"
! << "DP4 o[TEX" << unit << "].y, c[" << base + 1 << "], v[TEX0]\n"
! << "DP4 o[TEX" << unit << "].z, c[" << base + 2 << "], v[TEX0]\n"
! << "DP4 o[TEX" << unit << "].w, c[" << base + 3 << "], v[TEX0]\n";
return code.str();
}
--- 44,53 ----
std::ostringstream code;
GLuint base = unit * 4 + tex_addr_base;
! code << "DP4 o[TEX" << unit << "].x, c[" << base + 0 << "], v[TEX0];\n"
! << "DP4 o[TEX" << unit << "].y, c[" << base + 1 << "], v[TEX0];\n"
! << "DP4 o[TEX" << unit << "].z, c[" << base + 2 << "], v[TEX0];\n"
! << "DP4 o[TEX" << unit << "].w, c[" << base + 3 << "], v[TEX0];\n";
return code.str();
}
***************
*** 249,261 ****
void PaperPass::loadVP() {
std::ostringstream code;
! code << "!!VP1.0\n"
! << "DP4 o[HPOS].x, v[OPOS], c[" << m_p_addr + 0 << "]\n"
! << "DP4 o[HPOS].y, v[OPOS], c[" << m_p_addr + 1 << "]\n"
! << "DP4 o[HPOS].z, v[OPOS], c[" << m_p_addr + 2 << "]\n"
! << "DP4 o[HPOS].w, v[OPOS], c[" << m_p_addr + 3 << "]\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) {
--- 246,254 ----
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) {
***************
*** 264,270 ****
unit++;
}
! std::cerr << "Creating VPCode with the source " << code.str() << "\n";
texgenvp = VPCode(code.str().c_str());
}
--- 257,265 ----
unit++;
}
! code << "END\n";
!
! //std::cerr << "Creating VPCode with the source " << code.str() << "\n";
texgenvp = VPCode(code.str().c_str());
}
***************
*** 273,282 ****
if (texgenvp.getSource().length() == 0)
loadVP();
! #ifdef GL_VERTEX_PROGRAM_NV
! /* Track the product of modelview and projection matrices */
! glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, m_p_addr,
GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV);
! #endif
/* Set up VP TexGen parameters for each texture unit */
int unit = 0;
--- 268,274 ----
if (texgenvp.getSource().length() == 0)
loadVP();
! setupcode();
/* Set up VP TexGen parameters for each texture unit */
int unit = 0;
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.18
gzz/gfx/librenderables/renderables.py:1.19
*** gzz/gfx/librenderables/renderables.py:1.18 Thu Sep 5 08:34:25 2002
--- gzz/gfx/librenderables/renderables.py Wed Sep 11 06:41:45 2002
***************
*** 397,403 ****
for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
! if (dbg) cout << "Pass\n";
(*it).setUp(&lightParam);
GLERR
--- 397,403 ----
for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
! if (dbg) cout << "Pass\\n";
(*it).setUp(&lightParam);
GLERR
***************
*** 410,415 ****
--- 410,499 ----
GLERR
(*it).tearDown();
+ GLERR
+
+ }
+
+ GLERR
+ """,
+ } ,
+
+ {
+ "Type" : "2",
+ "Name": "FisheyePaperQuad",
+ "Data": "Pt corners[4]; Paper::Paper* paper; float scale;",
+ "Params" : """
+ Paper paper, float x0, float y0, float x1, float y1,
+ float scale
+ """,
+ "ParamCode" : """
+ this->paper = paper;
+ corners[0].x = corners[1].x = x0;
+ corners[0].y = corners[3].y = y0;
+ corners[2].x = corners[3].x = x1;
+ corners[1].y = corners[2].y = y1;
+ this->scale = scale;
+ """,
+ "RenderCode" : """
+ DBG(dbg) << "Paper\\n";
+ GLERR
+
+ ZPt paperorigin = coords2.transform(Pt(0, 0));
+ ZVec paperx = coords2.transform(Pt(1, 0)) - paperorigin;
+ ZVec papery = coords2.transform(Pt(0, 1)) - paperorigin;
+
+ Paper::LightParam lightParam;
+ lightParam.orig = paperorigin-ZPt(0,0,0);
+ lightParam.e0 = paperx * scale;
+ lightParam.e1 = papery * scale;
+ lightParam.e2 = ZVec(0,0,paperx.length()) * scale;
+
+ lightParam.Light = ZVec(-1,-1,1);
+ lightParam.Light_w = 0.0;
+
+ if(dbg) {
+ cout << "Paperquad: " <<
+ lightParam.orig << " " <<
+ lightParam.e0 << " " <<
+ lightParam.e1 << " " <<
+ lightParam.e2 << " " <<
+ "\\nCorners" <<
+ corners[0] <<
+ corners[1] <<
+ corners[2] <<
+ corners[3] <<
+ "\\nCorners trans:" <<
+ coords1.transform(corners[0]) <<
+ coords1.transform(corners[1]) <<
+ coords1.transform(corners[2]) <<
+ coords1.transform(corners[3]) <<
+ "\\n"
+ ;
+ }
+ GLERR
+
+ for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
+ if (dbg) cout << "Pass\\n";
+ (*it).setUpVP(&lightParam);
+
+ GLERR
+ glBegin(GL_QUADS);
+
+ glTexCoord2f(0,0);
+ coords1.vertex(corners[0]);
+
+ glTexCoord2f(0,1);
+ coords1.vertex(corners[1]);
+
+ glTexCoord2f(1,1);
+ coords1.vertex(corners[2]);
+
+ glTexCoord2f(1,0);
+ coords1.vertex(corners[3]);
+ glEnd();
+
+ GLERR
+ (*it).tearDownVP();
GLERR
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx libcallgl/callgl.cxx libcallgl/callgl.h...,
Janne V. Kujala <=