gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx demo/paperbasis.py libcallgl/callgl.hxx...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/paperbasis.py libcallgl/callgl.hxx...
Date: Sun, 15 Sep 2002 06:22:13 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/09/15 06:22:13

Modified files:
        gfx/demo       : paperbasis.py 
        gfx/libcallgl  : callgl.hxx 
        gfx/librenderables: Renderables.hxx renderables.py 

Log message:
        Draw tex0, tex1, and the intersection (using depth buffer) separately 
in paperbasis; Use F1, F2, and F3 to toggle different register combiners for 
the textures and the intersection; clamped textures are no longer needed

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paperbasis.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.hxx.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/Renderables.hxx.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.27&tr2=1.28&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/paperbasis.py
diff -c gzz/gfx/demo/paperbasis.py:1.2 gzz/gfx/demo/paperbasis.py:1.3
*** gzz/gfx/demo/paperbasis.py:1.2      Sat Sep 14 06:22:28 2002
--- gzz/gfx/demo/paperbasis.py  Sun Sep 15 06:22:13 2002
***************
*** 1,5 ****
--- 1,7 ----
  from __future__ import nested_scopes
  
+ from gfx.libutil import nvcode
+ 
  execfile("gfx/libpaper/papermill.py")
  
  passmask = [ 1, 0, 0, 0 ]
***************
*** 17,29 ****
          currentScene.initpaper()
  
  
  def getpaper(seed):
-     global basisclamp
      pap = ThePaperMill().getPaper(seed, passmask=passmask)
  
!     return GZZGL.createBasisPaperQuad(pap)
! 
! 
  
  rng = java.util.Random()
  
--- 19,99 ----
          currentScene.initpaper()
  
  
+ tex0codes = {
+     "ALL" : "",
+     "RGB" : """
+     ActiveTexture TEXTURE1
+     Disable TEXTURE_2D
+     Disable REGISTER_COMBINERS_NV
+     """,
+     "DOT" : nvcode.combinercode("""
+     CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
+ 
+     CI0 RGB A TEXTURE0 EXPAND_NORMAL_NV RGB
+     CI0 RGB B CONSTANT_COLOR0_NV EXPAND_NORMAL_NV RGB
+     CI0 RGB C TEXTURE1 EXPAND_NORMAL_NV RGB
+     CI0 RGB D CONSTANT_COLOR1_NV EXPAND_NORMAL_NV RGB
+     CO0 RGB SPARE0_NV SPARE1_NV DISCARD_NV NONE NONE TRUE TRUE FALSE
+ 
+     FCI A ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI B ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI C ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI D SPARE0_NV UNSIGNED_IDENTITY_NV RGB
+     FCI G ZERO UNSIGNED_INVERT_NV ALPHA
+     """),
+     }
+ tex1codes = {
+     "ALL" : "",
+     "RGB" : """
+     ActiveTexture TEXTURE0
+     Disable TEXTURE_2D
+     Disable REGISTER_COMBINERS_NV
+     """,
+     "DOT" : nvcode.combinercode("""
+     CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
+     
+     CI0 RGB A TEXTURE0 EXPAND_NORMAL_NV RGB
+     CI0 RGB B CONSTANT_COLOR0_NV EXPAND_NORMAL_NV RGB
+     CI0 RGB C TEXTURE1 EXPAND_NORMAL_NV RGB
+     CI0 RGB D CONSTANT_COLOR1_NV EXPAND_NORMAL_NV RGB
+     CO0 RGB SPARE0_NV SPARE1_NV DISCARD_NV NONE NONE TRUE TRUE FALSE
+ 
+     FCI A ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI B ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI C ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI D SPARE1_NV UNSIGNED_IDENTITY_NV RGB
+     FCI G ZERO UNSIGNED_INVERT_NV ALPHA
+     """),
+     }
+ isectcodes = {
+     "ALL" : "",
+     "DOT" : nvcode.combinercode("""
+     CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
+     
+     # SPARE0 <- (TEX0 . TEX1)
+     CI0 RGB A TEXTURE0 EXPAND_NORMAL_NV RGB
+     CI0 RGB B TEXTURE1 EXPAND_NORMAL_NV RGB
+     CO0 RGB SPARE0_NV DISCARD_NV DISCARD_NV NONE NONE TRUE FALSE FALSE
+ 
+     FCI A ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI B ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI C ZERO UNSIGNED_IDENTITY_NV RGB
+     FCI D SPARE0_NV UNSIGNED_IDENTITY_NV RGB
+     FCI G ZERO UNSIGNED_INVERT_NV ALPHA
+     """)
+     }
+ 
+ tex0comb = "ALL"
+ tex1comb = "ALL"
+ isectcomb = "ALL"
+ 
  def getpaper(seed):
      pap = ThePaperMill().getPaper(seed, passmask=passmask)
  
!     return GZZGL.createBasisPaperQuad(pap,
!                                       tex0codes[tex0comb],
!                                       tex1codes[tex1comb],
!                                       isectcodes[isectcomb])
  
  rng = java.util.Random()
  
***************
*** 49,55 ****
          elif k == "Down": y0 += 20
          elif k == "Left": x0 -= 20
          elif k == "Right": x0 += 20
!         
  
          if oldseed != self.seed:
            self.pq = None
--- 119,142 ----
          elif k == "Down": y0 += 20
          elif k == "Left": x0 -= 20
          elif k == "Right": x0 += 20
!         elif k == "F1":
!             global tex0comb
!             list = tex0codes.keys()
!             tex0comb = list[(list.index(tex0comb) + 1) % len(list)]
!             print "Using", tex0comb, tex1comb, isectcomb, "combiners"
!             self.initpaper()
!         elif k == "F2":
!             global tex1comb
!             list = tex1codes.keys()
!             tex1comb = list[(list.index(tex1comb) + 1) % len(list)]
!             print "Using", tex0comb, tex1comb, isectcomb, "combiners"
!             self.initpaper()
!         elif k == "F3":
!             global isectcomb
!             list = isectcodes.keys()
!             isectcomb = list[(list.index(isectcomb) + 1) % len(list)]
!             print "Using", tex0comb, tex1comb, isectcomb, "combiners"
!             self.initpaper()
  
          if oldseed != self.seed:
            self.pq = None
Index: gzz/gfx/libcallgl/callgl.hxx
diff -c gzz/gfx/libcallgl/callgl.hxx:1.13 gzz/gfx/libcallgl/callgl.hxx:1.14
*** gzz/gfx/libcallgl/callgl.hxx:1.13   Fri Sep 13 12:15:30 2002
--- gzz/gfx/libcallgl/callgl.hxx        Sun Sep 15 06:22:13 2002
***************
*** 119,125 ****
        string getSource() const { return source; }
        void operator () (void) const {
        //cout << "Calling list " << displist->name << "\n";
!       glCallList(displist->name);  
        }
  
      protected:
--- 119,125 ----
        string getSource() const { return source; }
        void operator () (void) const {
        //cout << "Calling list " << displist->name << "\n";
!       if (displist.get()) glCallList(displist->name);  
        }
  
      protected:
Index: gzz/gfx/librenderables/Renderables.hxx
diff -c gzz/gfx/librenderables/Renderables.hxx:1.9 
gzz/gfx/librenderables/Renderables.hxx:1.10
*** gzz/gfx/librenderables/Renderables.hxx:1.9  Sat Sep 14 06:22:28 2002
--- gzz/gfx/librenderables/Renderables.hxx      Sun Sep 15 06:22:13 2002
***************
*** 14,20 ****
  #include "libcolor/spaces.hxx"
  #include "libtext/Text.hxx"
  
! #include <map> // XXX: used by ../demo/clamptexture.cxx hack
  
  #define GLERR { int er = glGetError(); if(er != GL_NO_ERROR) \
                    cout << "===== OPENGL ERROR "<<__FILE__<<" "<<__LINE__ \
--- 14,20 ----
  #include "libcolor/spaces.hxx"
  #include "libtext/Text.hxx"
  
! //#include <map> // XXX: used by ../demo/clamptexture.cxx hack
  
  #define GLERR { int er = glGetError(); if(er != GL_NO_ERROR) \
                    cout << "===== OPENGL ERROR "<<__FILE__<<" "<<__LINE__ \
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.27 
gzz/gfx/librenderables/renderables.py:1.28
*** gzz/gfx/librenderables/renderables.py:1.27  Sun Sep 15 06:11:14 2002
--- gzz/gfx/librenderables/renderables.py       Sun Sep 15 06:22:13 2002
***************
*** 514,528 ****
  {
      "Type" : "2",
      "Name": "BasisPaperQuad",
!     "Data": "Paper::Paper* paper; ",
      "Params" : """
!           Paper paper
        """,
      "ParamCode" : """
            this->paper = paper;
        """,
      "ExtraClass" : """
!             #include "../demo/clamptexture.cxx"
      """,
      "RenderCode" : """
            DBG(dbg) << "Paper\\n";
--- 514,531 ----
  {
      "Type" : "2",
      "Name": "BasisPaperQuad",
!     "Data": "Paper::Paper* paper; CallGLCode tex0code, tex1code, isectcode;",
      "Params" : """
!           Paper paper, String tex0, String tex1, String isect
        """,
      "ParamCode" : """
            this->paper = paper;
+             tex0code = CallGLCode(string(tex0.begin(), tex0.end()).c_str());
+             tex1code = CallGLCode(string(tex1.begin(), tex1.end()).c_str());
+             isectcode = CallGLCode(string(isect.begin(), 
isect.end()).c_str());
        """,
      "ExtraClass" : """
!             //#include "../demo/clamptexture.cxx"
      """,
      "RenderCode" : """
            DBG(dbg) << "Paper\\n";
***************
*** 548,566 ****
  
            for(Paper::Paper::iterator it = paper->begin(); it != paper->end(); 
++it) {
                if (dbg) cout << "Pass\\n";
-                 (*it).setupcode();
  
                GLERR
  
!                 glActiveTexture(GL_TEXTURE1);
!                 clampTexture2D(1.0);
!                 glActiveTexture(GL_TEXTURE0);
!                 clampTexture2D(1.0);
  
                  Pt p[] = { Pt(0,0), Pt(0,1), Pt(1,1), Pt(1,0) };
  
                glBegin(GL_QUADS);
- 
                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords1.transform(p[i]);
                      glMultiTexCoord2fARB(0, p[i].x, p[i].y);
--- 551,573 ----
  
            for(Paper::Paper::iterator it = paper->begin(); it != paper->end(); 
++it) {
                if (dbg) cout << "Pass\\n";
  
                GLERR
  
!                 //glActiveTexture(GL_TEXTURE1);
!                 //clampTexture2D(1.0);
!                 //glActiveTexture(GL_TEXTURE0);
!                 //clampTexture2D(1.0);
  
                  Pt p[] = { Pt(0,0), Pt(0,1), Pt(1,1), Pt(1,0) };
  
+                 // Draw the first texture
+                 (*it).setupcode();
+                 glEnable(GL_DEPTH_TEST);
+                 glDepthFunc(GL_LESS);
+                 tex0code();
+                 GLERR;
                glBegin(GL_QUADS);
                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords1.transform(p[i]);
                      glMultiTexCoord2fARB(0, p[i].x, p[i].y);
***************
*** 570,577 ****
                      //           c2y.dot(v - c2orig)) << "\\n";
                      coords1.vertex(p[i]);
                  }
  
!                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords2.transform(p[i]);
                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);
                      glMultiTexCoord2fARB(0, c1x.dot(v - c1orig),
--- 577,595 ----
                      //           c2y.dot(v - c2orig)) << "\\n";
                      coords1.vertex(p[i]);
                  }
+                 glEnd();
+               GLERR;
+               (*it).teardowncode();
+               GLERR
  
!                 // Draw the intersection
!                 (*it).setupcode();
!                 glEnable(GL_DEPTH_TEST);
!                 glDepthFunc(GL_EQUAL);
!                 isectcode();
!               GLERR;
!               glBegin(GL_QUADS);
!                 for (int i = 0; i < 4; i++) {
                      ZPt v = coords2.transform(p[i]);
                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);
                      glMultiTexCoord2fARB(0, c1x.dot(v - c1orig),
***************
*** 580,593 ****
                      //           c1y.dot(v - c1orig)) << "\\n";
                      coords2.vertex(p[i]);
                  }
- 
                  glEnd();
  
! 
! 
                GLERR
                (*it).teardowncode();
                GLERR
  
            }
  
--- 598,631 ----
                      //           c1y.dot(v - c1orig)) << "\\n";
                      coords2.vertex(p[i]);
                  }
                  glEnd();
+               GLERR
+               (*it).teardowncode();
+               GLERR
  
!                 // Draw the second texture
!                 (*it).setupcode();
!                 glEnable(GL_DEPTH_TEST);
!                 glDepthFunc(GL_LESS);
!                 tex1code();
!               GLERR
!               glBegin(GL_QUADS);
!                 for (int i = 0; i < 4; i++) {
!                     ZPt v = coords2.transform(p[i]);
!                     glMultiTexCoord2fARB(1, p[i].x, p[i].y);
!                     glMultiTexCoord2fARB(0, c1x.dot(v - c1orig),
!                                             c1y.dot(v - c1orig));
!                     //cout << Pt(c1x.dot(v - c1orig),
!                     //           c1y.dot(v - c1orig)) << "\\n";
!                     coords2.vertex(p[i]);
!                 }
!                 glEnd();
                GLERR
                (*it).teardowncode();
                GLERR
+ 
+ 
+ 
  
            }
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]