gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/irregu4.py librenderables/renderab...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/irregu4.py librenderables/renderab...
Date: Mon, 11 Nov 2002 12:40:24 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/11/11 12:40:23

Modified files:
        gfx/demo       : irregu4.py 
        gfx/librenderables: renderables.py 
        gfx/libutil    : Irregu.hxx 

Log message:
        Add UTF8String conversion type to renderables.py and cleanup Irregu 
library

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu4.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.137&tr2=1.138&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/Irregu.hxx.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregu4.py
diff -u gzz/gfx/demo/irregu4.py:1.4 gzz/gfx/demo/irregu4.py:1.5
--- gzz/gfx/demo/irregu4.py:1.4 Mon Nov 11 10:37:13 2002
+++ gzz/gfx/demo/irregu4.py     Mon Nov 11 12:40:23 2002
@@ -192,15 +192,14 @@
         texscale = 1.0
         linewidth = 1./128
         scale_pow = 0
-        border0 = -.5
-        border1 = .5
-        ripple_scale = .25
+        border0 = -.5 * ripple_scale * texscale
+        border1 = .5 * ripple_scale * texscale
 
         SLICE = (SLICE_2D, SLICE_1D)[self.flags >> 4 & 1]
 
         self.outer = GLRen.createIrregularEdge(
-            texscale, linewidth, scale_pow, border0, border1, ripple_scale,
-            "1 1 1 1", "0 0 0 0", 3, 0,
+            texscale, linewidth, scale_pow, border0, border1, 
+            "1 1 1 1 0 0 0 0", "", 3, 0,
             Y_SECCOLOR + SLICE + DOTVEC_COLOR + INTERP_DOTVEC,
             outer_code, 1.0);
 
@@ -210,8 +209,8 @@
             outer_code = code2 % {"tex" : texINTENSITY.getTexId(),
                                   "color" : "0 0 0 0" }
             self.outer = GLRen.createIrregularEdge(
-                texscale, linewidth, scale_pow, border0, border1, ripple_scale,
-                "1 1 1 1", "0 0 0 0", 0, 1,
+                texscale, linewidth, scale_pow, border0, border1, 
+                "1 1 1 1 0 0 0 0", "", 0, 1,
                 Y_SECCOLOR + SLICE,
                 outer_code, 1.0);
 
@@ -232,8 +231,9 @@
             stdcode += "Disable ALPHA_TEST\n"
             
         self.inner = GLRen.createIrregularEdge(
-            texscale, linewidth, scale_pow, border0, border1, ripple_scale,
-            ("0 0 0 0", "1 1 1 1")[self.flags >> 1 & 1], "0 0 0 0", 0, 0,
+            texscale, linewidth, scale_pow, border0, border1, 
+            ("0 0 0 0 0 0 0 0", "1 1 1 1 0 0 0 0")[self.flags >> 1 & 1], "",
+            0, 0,
             SLICE + Y_COLOR, stdcode, 1.0);
  
 
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.137 
gzz/gfx/librenderables/renderables.py:1.138
--- gzz/gfx/librenderables/renderables.py:1.137 Mon Nov 11 09:13:10 2002
+++ gzz/gfx/librenderables/renderables.py       Mon Nov 11 12:40:23 2002
@@ -30,6 +30,12 @@
        "pre" : (lambda v, p : "unicodecharvector "\
                  +v+" = jstr2unistr(env, "+p+");\n"),
     },
+    "UTF8String" : {
+       "JNI" : "jstring",
+       "CXX" : "string",
+       "pre" : (lambda v, p : "string "\
+                 +v+" = jstr2stdstr(env, "+p+");\n"),
+    },
     "Font" : {
        "JNI" : "jint",
        "CXX" : "TextRenderer *",
@@ -157,7 +163,7 @@
        glRasterPos3f(p.x, p.y, p.z);
        float ras[4];
        glGetFloatv(GL_CURRENT_RASTER_POSITION, ras);
-       glReadPixels(ras[0], ras[1], w, h, format, type, bytes);
+       glReadPixels((int)ras[0], (int)ras[1], w, h, format, type, bytes);
        GLERR
        glPopClientAttrib();
        glPopAttrib();
@@ -844,7 +850,7 @@
     "Data": "Paper::Paper* paper; CallGLCode tex0code, tex1code, isectcode; 
float x0, y0, x1, y1;",
     "Params" : """
            Paper paper, float x0, float y0, float x1, float y1,
-            String tex0, String tex1, String isect
+            UTF8String tex0, UTF8String tex1, UTF8String isect
        """,
     "ParamCode" : """
            this->paper = paper;
@@ -852,9 +858,9 @@
             this->y0 = y0;
             this->x1 = x1;
             this->y1 = y1;
-            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());
+            tex0code = CallGLCode(tex0.c_str());
+            tex1code = CallGLCode(tex1.c_str());
+            isectcode = CallGLCode(isect.c_str());
        """,
     "RenderCode" : """
            DBG(dbg) << "Paper\\n";
@@ -952,7 +958,7 @@
                float dicefactor;""",
     "Params" : """
            float x0, float y0, float x1, float y1,
-           float border, float ripple_period, int flags, String setupcode,
+           float border, float ripple_period, int flags, UTF8String setupcode,
            float dicefactor
        """,
     "ParamCode" : """
@@ -963,7 +969,7 @@
             this->border = border;
             this->freq = 1.0 / ripple_period;
             this->flags = flags;
-            setup = CallGLCode(string(setupcode.begin(), 
setupcode.end()).c_str());
+            setup = CallGLCode(setupcode.c_str());
            this->dicefactor = dicefactor;
        """,
     "ExtraClass" : """
@@ -1214,14 +1220,14 @@
     "Data": """float texscale; float ripple_scale; int mode; CallGLCode setup;
                float dicefactor;""",
     "Params" : """
-           float texscale, float ripple_scale, int mode, String setupcode,
+           float texscale, float ripple_scale, int mode, UTF8String setupcode,
            float dicefactor
        """,
     "ParamCode" : """
             this->texscale = texscale;
             this->ripple_scale = ripple_scale;
             this->mode = mode;
-            setup = CallGLCode(string(setupcode.begin(), 
setupcode.end()).c_str());
+            setup = CallGLCode(setupcode.c_str());
            this->dicefactor = dicefactor;
        """,
     "RenderCode" : """
@@ -1245,11 +1251,10 @@
         }
 
         setup();
-        float col0[] = {1,1,1,1};
-        float col1[] = {0,0,0,0};
+        float col[] = {1,1,1,1,0,0,0,0};
         if (!mode) glColor4f(0,0,0,1);
         Irregu::draw(coords1, vert, norm, texscale, 1.0/128, 0,
-                     -.5, .5, col0, col1, 3, 0, 
+                     -.5, .5, col, NULL, 3, 0, 
                      Irregu::SLICE_1D + Irregu::Y_SECCOLOR +
                      mode * Irregu::DOTVEC_COLOR + Irregu::INTERP_DOTVEC);
 
@@ -1274,43 +1279,44 @@
 # coords2: frame => paper (assumed to be affine)
 #
 # texscale is paper-texture scaling
-# ripple_scale is the amplitude-period scale of the texture
 {
     "Type" : "2",
     "Name": "IrregularEdge",
-    "Data": """float texscale, linewidth, scale_pow, border0, border1, 
ripple_scale;
-            float col0[4], col1[4]; int angles, multi, flags;
+    "Data": """float texscale, linewidth, scale_pow, border0, border1;
+            vector<float> const0, const1; int angles, multi, flags;
             CallGLCode setup;
            float dicefactor;""",
     "Params" : """
            float texscale, float linewidth, float scale_pow,
-            float border0, float border1, float ripple_scale,
-            String col0, String col1, int angles, int multi, int flags,
-            String setupcode, float dicefactor
+            float border0, float border1, 
+            UTF8String const0, UTF8String const1, int angles, int multi, int 
flags,
+            UTF8String setupcode, float dicefactor
        """,
+    "ExtraClass" : """
+            vector<float> getconstvec(string s) {
+                vector<float> v;
+                const char *p = s.c_str();
+                char *e;
+                float f;
+                while (f = strtof(p, &e), e > p) {
+                    v.push_back(f);
+                    p = e;
+                }
+                return v;
+            }
+    """,
     "ParamCode" : """
             this->texscale = texscale;
             this->linewidth = linewidth;
             this->scale_pow = scale_pow;
             this->border0 = border0;
             this->border1 = border1;
-            this->ripple_scale = ripple_scale;
-            this->col0[0] = this->col0[1] = this->col0[2] = this->col0[3] = 1;
-            this->col1[0] = this->col1[1] = this->col1[2] = this->col1[3] = 1;
-            string foo;
-            foo = string(col0.begin(), col0.end());
-            sscanf(foo.c_str(), "%f %f %f %f",
-                  &this->col0[0], &this->col0[1],
-                  &this->col0[2], &this->col0[3]);
-            foo = string(col1.begin(), col1.end());
-            sscanf(foo.c_str(), "%f %f %f %f",
-                  &this->col1[0], &this->col1[1],
-                  &this->col1[2], &this->col1[3]);
+            this->const0 = getconstvec(const0);
+            this->const1 = getconstvec(const1);
             this->angles = angles;
             this->multi = multi;
             this->flags = flags;
-            foo = string(setupcode.begin(), setupcode.end());
-            setup = CallGLCode(foo.c_str());
+            setup = CallGLCode(setupcode.c_str());
            this->dicefactor = dicefactor;
        """,
     "RenderCode" : """
@@ -1329,14 +1335,15 @@
         for (int i = 0; i <= n; i++) {
             norm[i] = (vert[(i+1) % n] - vert[(i+n-1) % n]).cw90().normalize();
 
-            norm[i] *= (ripple_scale * texscale) /
-                   norm[i].dot((vert[(i+1) % n] - vert[i]).cw90().normalize());
+            norm[i] *= norm[i].dot((vert[(i+1) % n] - 
vert[i]).cw90().normalize());
         }
 
         setup();
         GLERR;
         Irregu::draw(coords1, vert, norm, texscale, linewidth, scale_pow,
-                     border0, border1, col0, col1, angles, multi, flags);
+                     border0, border1,
+                     &const0[0], &const1[0],
+                     angles, multi, flags);
 
         GLERR;
         glPopAttrib();
Index: gzz/gfx/libutil/Irregu.hxx
diff -u gzz/gfx/libutil/Irregu.hxx:1.5 gzz/gfx/libutil/Irregu.hxx:1.6
--- gzz/gfx/libutil/Irregu.hxx:1.5      Mon Nov 11 09:51:09 2002
+++ gzz/gfx/libutil/Irregu.hxx  Mon Nov 11 12:40:23 2002
@@ -72,7 +72,7 @@
              const vector<ZPt> &pt, const vector<ZVec> &norm, 
              float texscale, float linewidth, float scale_pow,
              float border0, float border1,
-             const float col0[], const float col1[],
+             const float c0[], const float c1[],
              int angles, int multi,
              unsigned flags) {
     
@@ -106,11 +106,11 @@
                    glColor4fv(dotvec);
                }
                
-               colorfv(col0);
+               colorfv(c0);
                texCoord(vert[i][0], texscale);
                vertex(vert2[i][0]);
 
-               colorfv(col1);
+               colorfv(c0 + 4);
                texCoord(vert[i][1], texscale);
                vertex(vert2[i][1]);
            }
@@ -165,7 +165,7 @@
                GLenum u;
 
                if (multi > 0) glColor4f(0,0,dy1,dy1);
-               colorfv(col1);
+               colorfv(c0 + 4);
                texCoord(a1q, texscale * q1);
                u = GL_TEXTURE1;
                for (int d = 1; d <= multi; d++) {
@@ -175,7 +175,7 @@
                vertex(vert2[i][1]);
 
                if (multi > 0) glColor4f(0,0,dy0,dy0);
-               colorfv(col0);
+               colorfv(c0);
                texCoord(pt[i], texscale);
                u = GL_TEXTURE1;
                for (int d = 1; d <= multi; d++) {
@@ -191,7 +191,7 @@
                    glColor4fv(dotvec);
                }
 
-               //colorfv(col0);
+               //colorfv(c0);
                texCoord(pt[j], texscale);
                u = GL_TEXTURE1;
                for (int d = 1; d <= multi; d++) {
@@ -201,7 +201,7 @@
                vertex(vert2[j][0]);
                
                if (multi > 0) glColor4f(0,0,dy1,dy1);
-               colorfv(col1);
+               colorfv(c0 + 4);
                texCoord(b1q, texscale * q1);
                u = GL_TEXTURE1;
                for (int d = 1; d <= multi; d++) {




reply via email to

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