gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/irregular2.py libcallgl/callgl.cxx


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/irregular2.py libcallgl/callgl.cxx
Date: Mon, 16 Sep 2002 14:57:21 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/09/16 14:57:21

Modified files:
        gfx/demo       : irregular2.py 
        gfx/libcallgl  : callgl.cxx 

Log message:
        Add cs2 bounding box into irregular2

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregular2.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.cxx.diff?tr1=1.12&tr2=1.13&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregular2.py
diff -c gzz/gfx/demo/irregular2.py:1.3 gzz/gfx/demo/irregular2.py:1.4
*** gzz/gfx/demo/irregular2.py:1.3      Mon Sep 16 12:35:15 2002
--- gzz/gfx/demo/irregular2.py  Mon Sep 16 14:57:21 2002
***************
*** 5,10 ****
--- 5,12 ----
  tex.shade(128, 128, 0, 4, "RGBA", "RGBA",
            "fnoise", ["scale", "0.05", "freq", "8", "df", "4", "bias", "0.5"])
  
+ boxtex = GZZGL.createTexture()
+ 
  class IrreguScene:
      def __init__(self):
          print "Texture id:", tex.getTexId()
***************
*** 15,39 ****
          self.combiners = "Enable"
  
      def initirregu(self):
        self.iq = GZZGL.createIrregularQuad(-1, -1, 1, 1, .5, """
!                 PushAttrib ENABLE_BIT
                  Enable ALPHA_TEST
                  AlphaFunc GREATER 0.0
                  BindTexture TEXTURE_2D %s
                  Enable TEXTURE_2D
                  %s REGISTER_COMBINERS_NV
                  CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
!                 CombinerInputNV COMBINER0_NV ALPHA VARIABLE_A_NV ZERO 
UNSIGNED_INVERT_NV ALPHA
                  CombinerInputNV COMBINER0_NV ALPHA VARIABLE_B_NV TEXTURE0 
SIGNED_NEGATE_NV ALPHA
!                 CombinerInputNV COMBINER0_NV ALPHA VARIABLE_C_NV ZERO 
UNSIGNED_INVERT_NV ALPHA
                  CombinerInputNV COMBINER0_NV ALPHA VARIABLE_D_NV 
SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV BLUE
                  CombinerOutputNV COMBINER0_NV ALPHA DISCARD_NV DISCARD_NV 
SPARE0_NV NONE NONE FALSE FALSE FALSE
                  FinalCombinerInputNV VARIABLE_A_NV ZERO UNSIGNED_IDENTITY_NV 
RGB
                  FinalCombinerInputNV VARIABLE_B_NV ZERO UNSIGNED_IDENTITY_NV 
RGB
                  FinalCombinerInputNV VARIABLE_C_NV ZERO UNSIGNED_IDENTITY_NV 
RGB
                  FinalCombinerInputNV VARIABLE_D_NV PRIMARY_COLOR_NV 
UNSIGNED_IDENTITY_NV RGB
                  FinalCombinerInputNV VARIABLE_G_NV SPARE0_NV 
UNSIGNED_IDENTITY_NV ALPHA
!                 """ % (tex.getTexId(), self.combiners))
  
      def key(self, k):
          if 0: pass
--- 17,78 ----
          self.combiners = "Enable"
  
      def initirregu(self):
+         w = 2
+ 
+         # Setup texgen for TEXTURE1 so that [-w,w]x[-1,1] in cs2 is mapped
+         # into [.25,75]^2 (center box of a 4x4 texture)
+         iw = .25 / w
+         self.mask = getDList("""
+             ActiveTexture TEXTURE1
+             TexGen S TEXTURE_GEN_MODE EYE_LINEAR
+             TexGen S EYE_PLANE %(iw)s 0 0 .5
+             Enable TEXTURE_GEN_S
+             TexGen T TEXTURE_GEN_MODE EYE_LINEAR
+             TexGen T EYE_PLANE 0 .25 0 .5
+             Enable TEXTURE_GEN_T
+             ActiveTexture TEXTURE0
+             Begin LINE_LOOP
+             Vertex -%(w)sr -1
+             Vertex -%(w)s +1
+             Vertex +%(w)s +1
+             Vertex +%(w)s -1
+             End
+         """ % locals())
+ 
        self.iq = GZZGL.createIrregularQuad(-1, -1, 1, 1, .5, """
!                 PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT
                  Enable ALPHA_TEST
                  AlphaFunc GREATER 0.0
+ 
+                 ActiveTexture TEXTURE1
+                 BindTexture TEXTURE_2D %s
+                 Enable TEXTURE_2D
+                 TexImage2D TEXTURE_2D 0 ALPHA 4 4 0 ALPHA 0 0 0 0 0 1 1 0 0 1 
1 0 0 0 0 0
+                 TexParameter TEXTURE_2D TEXTURE_BASE_LEVEL 0
+                 TexParameter TEXTURE_2D TEXTURE_MAX_LEVEL 0
+               TexParameter TEXTURE_2D TEXTURE_WRAP_S CLAMP
+               TexParameter TEXTURE_2D TEXTURE_WRAP_T CLAMP
+               TexParameter TEXTURE_2D TEXTURE_MIN_FILTER NEAREST
+               TexParameter TEXTURE_2D TEXTURE_MAG_FILTER NEAREST
+ 
+                 ActiveTexture TEXTURE0
+                 
                  BindTexture TEXTURE_2D %s
                  Enable TEXTURE_2D
                  %s REGISTER_COMBINERS_NV
                  CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
!                 CombinerInputNV COMBINER0_NV ALPHA VARIABLE_A_NV TEXTURE1 
UNSIGNED_IDENTITY_NV ALPHA
                  CombinerInputNV COMBINER0_NV ALPHA VARIABLE_B_NV TEXTURE0 
SIGNED_NEGATE_NV ALPHA
!                 CombinerInputNV COMBINER0_NV ALPHA VARIABLE_C_NV TEXTURE1 
UNSIGNED_IDENTITY_NV ALPHA
                  CombinerInputNV COMBINER0_NV ALPHA VARIABLE_D_NV 
SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV BLUE
                  CombinerOutputNV COMBINER0_NV ALPHA DISCARD_NV DISCARD_NV 
SPARE0_NV NONE NONE FALSE FALSE FALSE
+ 
                  FinalCombinerInputNV VARIABLE_A_NV ZERO UNSIGNED_IDENTITY_NV 
RGB
                  FinalCombinerInputNV VARIABLE_B_NV ZERO UNSIGNED_IDENTITY_NV 
RGB
                  FinalCombinerInputNV VARIABLE_C_NV ZERO UNSIGNED_IDENTITY_NV 
RGB
                  FinalCombinerInputNV VARIABLE_D_NV PRIMARY_COLOR_NV 
UNSIGNED_IDENTITY_NV RGB
                  FinalCombinerInputNV VARIABLE_G_NV SPARE0_NV 
UNSIGNED_IDENTITY_NV ALPHA
!                 """ % (boxtex.getTexId(), tex.getTexId(), self.combiners))
  
      def key(self, k):
          if 0: pass
***************
*** 52,59 ****
      def scene(self, vs):
        putnoc(vs, background((0.1,0.4,0.5)))
  
          cs1 = vs.coords.affineCoordsys(0, "1", 10, self.x1, self.y1, 100, 0, 
0, 100)
!         cs2 = vs.coords.affineCoordsys(0, "2", 10, 600, 450, 150, 0, 0, 150)
          vs.map.put(self.iq, cs1, cs2)
  
  currentScene = IrreguScene()
--- 91,100 ----
      def scene(self, vs):
        putnoc(vs, background((0.1,0.4,0.5)))
  
+ 
          cs1 = vs.coords.affineCoordsys(0, "1", 10, self.x1, self.y1, 100, 0, 
0, 100)
!         cs2 = vs.coords.affineCoordsys(0, "2", 10, 600, 450, 150, 32.3, 
-14.2, 150)
!         vs.map.put(self.mask, cs2)
          vs.map.put(self.iq, cs1, cs2)
  
  currentScene = IrreguScene()
Index: gzz/gfx/libcallgl/callgl.cxx
diff -c gzz/gfx/libcallgl/callgl.cxx:1.12 gzz/gfx/libcallgl/callgl.cxx:1.13
*** gzz/gfx/libcallgl/callgl.cxx:1.12   Fri Sep 13 11:29:56 2002
--- gzz/gfx/libcallgl/callgl.cxx        Mon Sep 16 14:57:21 2002
***************
*** 207,212 ****
--- 207,223 ----
          } else {
            glFogf(getToken(v[1]), getTokenf(v[2]));
          }
+       } else if (checkfunc(v, "TexImage2D", 8, true)) {
+         int w = atoi(v[4].c_str());
+         int h = atoi(v[5].c_str());
+         vector<GLfloat> pixels = getfv(v, 8, w * h);
+         if (pixels.size() != (unsigned)(w * h)) {
+           cerr << "TexImage2D dimensions " << w << "x" << h << " do not match 
the size " << pixels.size() << " of data\n";
+           return false; 
+         }
+         glTexImage2D(getToken(v[1]), atoi(v[2].c_str()), getToken(v[3]),
+                      w, h, atoi(v[6].c_str()), getToken(v[7]),
+                      GL_FLOAT, &pixels[0]);
        } else if (checkfunc(v, "TexEnv", 3, true)) {
          if (v.size() > 4) {
            vector<GLfloat> params = getfv(v, 3, 4);




reply via email to

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