gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz gzz/view/LollipopCellView.java gzz/vob/vobs...


From: Asko Soukka
Subject: [Gzz-commits] gzz gzz/view/LollipopCellView.java gzz/vob/vobs...
Date: Thu, 12 Dec 2002 04:42:20 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Asko Soukka <address@hidden>    02/12/12 04:42:20

Modified files:
        gzz/view       : LollipopCellView.java 
        gzz/vob/vobs   : ColoredSectorVob.java RectBgVob.java 
                         SolidBgVob.java 
        test/gzz/vob   : bgvobs.test 
        gfx/librenderables: renderables.py 

Log message:
        ColoredSectorVob, fixing 'default color' in GL

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/LollipopCellView.java.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/ColoredSectorVob.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/RectBgVob.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/SolidBgVob.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/vob/bgvobs.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.161&tr2=1.162&r1=text&r2=text

Patches:
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.161 
gzz/gfx/librenderables/renderables.py:1.162
--- gzz/gfx/librenderables/renderables.py:1.161 Wed Dec 11 07:20:06 2002
+++ gzz/gfx/librenderables/renderables.py       Thu Dec 12 04:42:20 2002
@@ -551,7 +551,7 @@
            ZPt p2 = coords2.transform(ZPt(box2.x*px2,box2.y*py2,0));
            p1.z += dz1;
            p2.z += dz2;
-            if (colored) glPushAttrib(GL_COLOR_BUFFER_BIT);
+            if (colored) glPushAttrib(GL_CURRENT_BIT);
             glPushAttrib(GL_ENABLE_BIT);
             glDisable(GL_TEXTURE_2D);
             if (colored) glColor4f(red, green, blue, alpha);
Index: gzz/gzz/view/LollipopCellView.java
diff -u gzz/gzz/view/LollipopCellView.java:1.7 
gzz/gzz/view/LollipopCellView.java:1.8
--- gzz/gzz/view/LollipopCellView.java:1.7      Wed Dec 11 17:25:40 2002
+++ gzz/gzz/view/LollipopCellView.java  Thu Dec 12 04:42:20 2002
@@ -38,7 +38,7 @@
 /** A factory for making ball-and-stick aka lollipop cell vobs. */
 
 public class LollipopCellView extends BoxCellView {
-public static final String rcsid = "$Id: LollipopCellView.java,v 1.7 
2002/12/11 22:25:40 humppake Exp $";
+public static final String rcsid = "$Id: LollipopCellView.java,v 1.8 
2002/12/12 09:42:20 humppake Exp $";
     float[] boxwh = new float[2];
 
     public LollipopCellView(CellView ccv) {
@@ -61,7 +61,7 @@
            throw new NullPointerException("clone dim not set in 
LollipopCellView");
             
        /** Uses ColoredSectorVob as the ball. */
-       final ColoredSectorVob bg = new ColoredSectorVob(300, 10);
+       final ColoredSectorVob bg = new ColoredSectorVob(45, 270, 10);
 
        List cursorColors = context.getCursorColors(c);
        if(cursorColors != null)
Index: gzz/gzz/vob/vobs/ColoredSectorVob.java
diff -u gzz/gzz/vob/vobs/ColoredSectorVob.java:1.2 
gzz/gzz/vob/vobs/ColoredSectorVob.java:1.3
--- gzz/gzz/vob/vobs/ColoredSectorVob.java:1.2  Wed Dec 11 17:25:40 2002
+++ gzz/gzz/vob/vobs/ColoredSectorVob.java      Thu Dec 12 04:42:20 2002
@@ -41,17 +41,17 @@
  */
 
 public class ColoredSectorVob extends Vob {
-public static final String rcsid = "$Id: ColoredSectorVob.java,v 1.2 
2002/12/11 22:25:40 humppake Exp $";
+public static final String rcsid = "$Id: ColoredSectorVob.java,v 1.3 
2002/12/12 09:42:20 humppake Exp $";
     public static boolean dbg = false;
     static final void p(String s) { if(dbg) System.out.println(s); }
     static final void pa(String s) { System.out.println(s); }
 
     static protected float [][] circleGL = new float[360][2];
     static protected boolean circleGLReady = false;
-    static protected void prepareCircleGL() {
+    static protected void prepareCircleGL(int start) {
        if (!circleGLReady) {
            for (int i=0;i<360;i++) {
-               float a = (float)((Math.PI / 180) * (360-(i+90)));
+               float a = (float)((Math.PI / 180) * (360-(i+start)));
                circleGL[i][0] = 0.5f + x(a, 0.5f);
                circleGL[i][1] = 0.5f + y(a, 0.5f);
            }
@@ -65,13 +65,29 @@
        return (float)(Math.sin((double)angle) * radius);
     }
 
-    protected int angle = 360;
-    protected int step = 10;
-    public ColoredSectorVob(int angle, int step) {
+    protected int start;
+    protected int sector;
+    protected int step;
+
+    /** Creates ColoredSectorVob
+     * @param start Start angle of the sector. 0 degree is at clock three.
+     *              90 degrees is at clock twelve.
+     * @param sector The angle of the sector to be drawn. Max 360 degrees. 
+     * @param step Every step:th vertex is drawn. This affects only the
+     *             GL implementation. Currently the maximum
+     *             resolution is 360 vertexes. XXX this will be removed
+     *             after DiceableMesh renderable works.
+     */
+    public ColoredSectorVob(int start, int sector, int step) {
        super();
-       this.angle = angle;
+       this.start = start;
+       this.sector = sector;
        this.step = step;
     }
+    /* Default valus for drawing a small circle. */
+    public ColoredSectorVob(){
+        this(90, 360, 10);
+    }
 
     static Rectangle rect = new Rectangle();
     int nsolids = 0;
@@ -94,27 +110,30 @@
        /** Heavier border with bigger cells */
        if(drawBorder && mh >= 20) {
             g.setColor(info1.getMixedFgColor());
-           g.fillArc(mx-1, my-1, mw+2, mh+2, 90, angle);
+           g.fillArc(mx-1, my-1, mw+2, mh+2, start, sector);
        }
 
        if(nsolids == 0) {
            g.setColor(bg);
-           g.fillArc(mx, my, mw, mh, 90, angle);
+           g.fillArc(mx, my, mw, mh, start, sector);
        } else {
            // Draws multiple background colours as sectors
-           int arc = angle / nsolids;
+           int arc = sector / nsolids;
            for(int i=0; i<nsolids; i++) {
                g.setColor(solids[i]);
-               g.fillArc(mx, my, mw, mh, 90 + arc * i, arc);
+               g.fillArc(mx, my, mw, mh, start + arc * i, arc);
            }
        }
 
        if(drawBorder) {
             g.setColor(info1.getMixedFgColor());
-           g.drawArc(mx, my, mw, mh, 90, angle);
-           if (angle < 360) {
-               g.drawLine(mx+mw/2, my+mh/2, mx+mw/2, my);
-               float a = (float)((Math.PI / 180f) * (360f-(angle+90f)));
+           g.drawArc(mx, my, mw, mh, start, sector);
+           if (sector < 360) {
+               float a = (float)((Math.PI / 180f) * (360f-(start)));
+               g.drawLine(mx+mw/2, my+mh/2,
+                          mx+mw/2 + (int)x(a, mw/2),
+                          my+mh/2 + (int)y(a, mh/2));
+               a = (float)((Math.PI / 180f) * (360f-(sector+start)));
                g.drawLine(mx+mw/2, my+mh/2,
                           mx+mw/2 + (int)x(a, mw/2),
                           my+mh/2 + (int)y(a, mh/2));
@@ -131,10 +150,10 @@
                                int coordsys2) {
         if(dbg) pa("Addtolistgl coloredsectorvob "+coordsys1);
        if(glList == null) {
-           if (!circleGLReady) prepareCircleGL();
+           if (!circleGLReady) prepareCircleGL(start);
            String bgcall = "";
            if(nsolids > 0) {
-               int arc = angle / nsolids;
+               int arc = sector / nsolids;
                for(int i=0; i<nsolids; i++) {
                    Color c = solids[i];
                     bgcall += (
@@ -146,7 +165,7 @@
                                   " " + circleGL[j][1] + "\n");
                    }
                    int last = (i+1)*arc-1;
-                   if (angle == 360) last++;
+                   if (sector == 360) last++;
                    if (last == 360) last = 0;
                    bgcall += ("Vertex " + circleGL[last][0] +
                               " " + circleGL[last][1] + "\n" +
@@ -156,26 +175,26 @@
                bgcall = (
                    "Color "+ColorUtil.colorGLString(bg)+" 1\n" +
                    "Begin POLYGON\n");
-               if (angle < 360) bgcall += ("Vertex 0.5 0.5\n");
-               for (int i=0;i<angle;i+=step) {
+               if (sector < 360) bgcall += ("Vertex 0.5 0.5\n");
+               for (int i=0;i<sector;i+=step) {
                    bgcall += ("Vertex " + circleGL[i][0] +
                               " " + circleGL[i][1] + "\n");
                }
-               bgcall += ("Vertex " + circleGL[angle-1][0] +
-                          " " + circleGL[angle-1][1] + "\n" +
+               bgcall += ("Vertex " + circleGL[sector-1][0] +
+                          " " + circleGL[sector-1][1] + "\n" +
                           "End\n");
            }
 
            bgcall += (
                      "Color 0 0 0 1\n" +
                      "Begin LINE_LOOP\n");
-           if (angle < 360) bgcall += ("Vertex 0.5 0.5\n");
-           for (int i=0;i<angle;i+=step) {
+           if (sector < 360) bgcall += ("Vertex 0.5 0.5\n");
+           for (int i=0;i<sector;i+=step) {
                bgcall += ("Vertex " + circleGL[i][0] +
                               " " + circleGL[i][1] + "\n");
            }
-           bgcall += ("Vertex " + circleGL[angle-1][0] +
-                      " " + circleGL[angle-1][1] + "\n" +
+           bgcall += ("Vertex " + circleGL[sector-1][0] +
+                      " " + circleGL[sector-1][1] + "\n" +
                       "End\n");
                    
            glList = GLRen.createCallListBoxCoorded(
Index: gzz/gzz/vob/vobs/RectBgVob.java
diff -u gzz/gzz/vob/vobs/RectBgVob.java:1.5 gzz/gzz/vob/vobs/RectBgVob.java:1.6
--- gzz/gzz/vob/vobs/RectBgVob.java:1.5 Thu Dec  5 05:57:34 2002
+++ gzz/gzz/vob/vobs/RectBgVob.java     Thu Dec 12 04:42:20 2002
@@ -40,7 +40,7 @@
  */
 
 public class RectBgVob extends Vob {
-public static final String rcsid = "$Id: RectBgVob.java,v 1.5 2002/12/05 
10:57:34 tjl Exp $";
+public static final String rcsid = "$Id: RectBgVob.java,v 1.6 2002/12/12 
09:42:20 humppake Exp $";
     public static boolean dbg = false;
     static final void pa(String s) { System.out.println(s); }
 
@@ -126,7 +126,7 @@
            }
 
            glList = GLRen.createCallListBoxCoorded(
-               "PushAttrib COLOR_BUFFER_BIT ENABLE_BIT\n"+
+               "PushAttrib CURRENT_BIT ENABLE_BIT\n"+
                 "Disable TEXTURE_2D\n"+
 
                bgcall +
Index: gzz/gzz/vob/vobs/SolidBgVob.java
diff -u gzz/gzz/vob/vobs/SolidBgVob.java:1.2 
gzz/gzz/vob/vobs/SolidBgVob.java:1.3
--- gzz/gzz/vob/vobs/SolidBgVob.java:1.2        Thu Dec  5 05:57:34 2002
+++ gzz/gzz/vob/vobs/SolidBgVob.java    Thu Dec 12 04:42:20 2002
@@ -75,7 +75,7 @@
            "Enable DEPTH_TEST\n"+
            "DepthFunc LEQUAL\n"+
            "BlendFunc SRC_ALPHA ONE_MINUS_SRC_ALPHA\n"+
-           "Color 1 1 1 1\n"+
+           "Color 0 0 0 1\n"+
            "";
         
     }
Index: gzz/test/gzz/vob/bgvobs.test
diff -u gzz/test/gzz/vob/bgvobs.test:1.2 gzz/test/gzz/vob/bgvobs.test:1.3
--- gzz/test/gzz/vob/bgvobs.test:1.2    Thu Nov 28 02:18:08 2002
+++ gzz/test/gzz/vob/bgvobs.test        Thu Dec 12 04:42:20 2002
@@ -50,6 +50,29 @@
 
     checkNotAvgColor(140, 140, 20, 20, (255, 0, 0), delta=1)
 
+def testSolidBgVob():
+    """Tests that SolidBgVob is drawn with wanted color, and after
+       that the default color is black. """
+
+    sty1 = win.getGraphicsAPI().getTextStyle("SansSerif", 0, 20)
+
+    vs = getvs()
+    size = vs.getSize()
+    vs.map.put(gzz.vob.vobs.SolidBgVob(Color.black))
+
+    textvob = gzz.vob.vobs.TextVob(sty1, "XXXXXX")
+
+    text_width = int(textvob.getWidth(1))
+    text_height = int(textvob.getHeight(1))
+    text_depth = int(textvob.getDepth(1))
+
+    cs = vs.orthoBoxCS(0, "window",  0, 100, 100, 1, 1, size.width, 
size.height)
+    cs_text = vs.orthoCS(cs, "text", 0, 0, 0, text_height + text_depth, 
text_height + text_depth)
+    vs.map.put(textvob, cs_text)
+    render(vs)
+
+    checkAvgColor(100, 100, text_width, text_height+text_depth, (0, 0, 0), 
delta=1)
+
 def testOvalbgVob():
     """Tests that OvalBgVob is drawn correctly using box CS.
     """



reply via email to

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