gzz-commits
[Top][All Lists]
Advanced

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

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


From: Asko Soukka
Subject: [Gzz-commits] gzz/gzz vob/vobs/ColoredSectorVob.java view/Lol...
Date: Wed, 11 Dec 2002 17:25:40 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Asko Soukka <address@hidden>    02/12/11 17:25:40

Modified files:
        gzz/vob/vobs   : ColoredSectorVob.java 
        gzz/view       : LollipopCellView.java xubuoy.py 

Log message:
        ColoredSectorVob GL, when using this in GL default color turns into BG 
color... pushattrib CURRENT_BIT won't help... strange.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/ColoredSectorVob.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/LollipopCellView.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/xubuoy.py.diff?tr1=1.37&tr2=1.38&r1=text&r2=text

Patches:
Index: gzz/gzz/view/LollipopCellView.java
diff -u gzz/gzz/view/LollipopCellView.java:1.6 
gzz/gzz/view/LollipopCellView.java:1.7
--- gzz/gzz/view/LollipopCellView.java:1.6      Thu Dec  5 20:03:51 2002
+++ gzz/gzz/view/LollipopCellView.java  Wed Dec 11 17:25:40 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.6 
2002/12/06 01:03:51 benja Exp $";
+public static final String rcsid = "$Id: LollipopCellView.java,v 1.7 
2002/12/11 22:25:40 humppake Exp $";
     float[] boxwh = new float[2];
 
     public LollipopCellView(CellView ccv) {
@@ -60,8 +60,8 @@
        if(d_clone == null)
            throw new NullPointerException("clone dim not set in 
LollipopCellView");
             
-       /** Uses OvalBgVob as the ball. */
-       final OvalBgVob bg = new OvalBgVob();
+       /** Uses ColoredSectorVob as the ball. */
+       final ColoredSectorVob bg = new ColoredSectorVob(300, 10);
 
        List cursorColors = context.getCursorColors(c);
        if(cursorColors != null)
@@ -88,11 +88,11 @@
                                             boxwh[0] - (diameter + pad),
                                             boxwh[1] - 2*pad);
 
-       /** Coordsys to make OvalBgVob look circle and at 
+       /** Coordsys to make ColoredSectorVob look circle and at 
         * right place of cell's Box. Currently "right place"
         * is in the middle.
         */
-        final int ballBox = vs.scaleCS(box, "ball", diameter, diameter);
+       final int ballBox = vs.scaleCS(box, "ball", diameter, diameter);
 
        ccv.place(c, vs, contentBox, context);
        vs.map.put(bg, ballBox);
Index: gzz/gzz/view/xubuoy.py
diff -u gzz/gzz/view/xubuoy.py:1.37 gzz/gzz/view/xubuoy.py:1.38
--- gzz/gzz/view/xubuoy.py:1.37 Sun Dec  1 17:39:35 2002
+++ gzz/gzz/view/xubuoy.py      Wed Dec 11 17:25:40 2002
@@ -97,7 +97,7 @@
     
 style = gzz.client.GraphicsAPI.getInstance().getTextStyle("SansSerif", 
java.awt.Font.PLAIN, 10)
 contview = gzz.view.LinebrokenCellContentView(style)
-cellview = gzz.view.BoxCellView()
+cellview = gzz.view.BoxCellView(contview)
 
 class MyContext(gzz.view.ViewContext):
     emptylist = java.util.ArrayList()
Index: gzz/gzz/vob/vobs/ColoredSectorVob.java
diff -u gzz/gzz/vob/vobs/ColoredSectorVob.java:1.1 
gzz/gzz/vob/vobs/ColoredSectorVob.java:1.2
--- gzz/gzz/vob/vobs/ColoredSectorVob.java:1.1  Wed Dec 11 03:49:20 2002
+++ gzz/gzz/vob/vobs/ColoredSectorVob.java      Wed Dec 11 17:25:40 2002
@@ -41,36 +41,44 @@
  */
 
 public class ColoredSectorVob extends Vob {
-public static final String rcsid = "$Id: ColoredSectorVob.java,v 1.1 
2002/12/11 08:49:20 humppake Exp $";
+public static final String rcsid = "$Id: ColoredSectorVob.java,v 1.2 
2002/12/11 22:25:40 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 Rectangle rect = new Rectangle();
-
-    static protected GL.Texture tex;
-    static protected boolean texLoaded = false;
-    static protected void loadTex() {
-       if (!texLoaded) {
-           String[] texparam = {"line_width", "1"};
-           tex = GL.createTexture(); 
-           tex.shade_all_levels(512, 512, 0, 4, "RGBA", "RGBA", "circle", 
texparam);
-           texLoaded = true;
+    static protected float [][] circleGL = new float[360][2];
+    static protected boolean circleGLReady = false;
+    static protected void prepareCircleGL() {
+       if (!circleGLReady) {
+           for (int i=0;i<360;i++) {
+               float a = (float)((Math.PI / 180) * (360-(i+90)));
+               circleGL[i][0] = 0.5f + x(a, 0.5f);
+               circleGL[i][1] = 0.5f + y(a, 0.5f);
+           }
+           circleGLReady = true;
        }
     }
+    protected static float x(float angle, float radius) {
+       return (float)(Math.cos((double)angle) * radius);
+    }
+    protected static float y(float angle, float radius) {
+       return (float)(Math.sin((double)angle) * radius);
+    }
 
-    int nsolids = 0;
-    Color[] solids;
-    protected Color bg = Color.white;
     protected int angle = 360;
-
-    public ColoredSectorVob(int angle) {
+    protected int step = 10;
+    public ColoredSectorVob(int angle, int step) {
+       super();
        this.angle = angle;
+       this.step = step;
     }
 
+    static Rectangle rect = new Rectangle();
+    int nsolids = 0;
+    Color[] solids;
+    protected Color bg = Color.white;
     public void setBg(Color c){ if( c != null ) bg = c; }
     public Color getBg() { return bg; }
-
     boolean drawBorder = true;
 
     public void render(Graphics g,
@@ -106,7 +114,7 @@
            g.drawArc(mx, my, mw, mh, 90, angle);
            if (angle < 360) {
                g.drawLine(mx+mw/2, my+mh/2, mx+mw/2, my);
-               double a = (Math.PI / 180) * (360-(angle+90));
+               float a = (float)((Math.PI / 180f) * (360f-(angle+90f)));
                g.drawLine(mx+mw/2, my+mh/2,
                           mx+mw/2 + (int)x(a, mw/2),
                           my+mh/2 + (int)y(a, mh/2));
@@ -116,65 +124,63 @@
        g.setColor(oldfg);
     }
 
-    protected double x(double angle, double radius) {
-       return (Math.cos(angle) * radius);
-    }
-    
-    protected double y(double angle, double radius) {
-       return (Math.sin(angle) * radius);
-    }
-
     Vob glList;
 
     public int addToListGL(GraphicsAPI.RenderingSurface win,
                    int[] list, int curs, int coordsys1,
                                int coordsys2) {
-        if(dbg) pa("Addtolistgl rectbg "+coordsys1);
+        if(dbg) pa("Addtolistgl coloredsectorvob "+coordsys1);
        if(glList == null) {
-           /** In OpenGL the oval shape is done by drawing
-            * a quad stript with an oval texture inside it.
-            */
-           if (!texLoaded) loadTex();
+           if (!circleGLReady) prepareCircleGL();
            String bgcall = "";
            if(nsolids > 0) {
-               double w = 1.0 / nsolids;
-               for(int i=0; i<nsolids; i++) {
-                   double x1 = i*w;
-                   double x2 = x1 + w;
+               int arc = angle / nsolids;
+               for(int i=0; i<nsolids; i++) {
                    Color c = solids[i];
                     bgcall += (
-                       "Color "+ColorUtil.colorGLString(solids[i])+" 1\n"+
-                       "Begin QUAD_STRIP\n"+
-                       "TexCoord "+x1+" 1\n"+
-                       "Vertex "+x1+" 1\n"+
-                       "TexCoord "+x1+" 0\n"+
-                       "Vertex "+x1+" 0\n"+
-                       "TexCoord "+x2+" 1\n"+
-                       "Vertex "+x2+" 1\n"+
-                       "TexCoord "+x2+" 0\n"+
-                       "Vertex "+x2+" 0\n"+
-                       "End\n");
-               }
+                              "Color "+ColorUtil.colorGLString(solids[i])+" 
1\n"+
+                              "Begin POLYGON\n"+
+                              "Vertex 0.5 0.5\n");
+                   for (int j=i*arc;j<(i+1)*arc;j+=step) {
+                       bgcall += ("Vertex " + circleGL[j][0] +
+                                  " " + circleGL[j][1] + "\n");
+                   }
+                   int last = (i+1)*arc-1;
+                   if (angle == 360) last++;
+                   if (last == 360) last = 0;
+                   bgcall += ("Vertex " + circleGL[last][0] +
+                              " " + circleGL[last][1] + "\n" +
+                              "End\n");
+               }
            } else {
                bgcall = (
                    "Color "+ColorUtil.colorGLString(bg)+" 1\n" +
-                   "Begin QUAD_STRIP\n"+
-                   "TexCoord 1 1\nVertex 1 1\n"+
-                   "TexCoord 1 0\nVertex 1 0\n"+
-                   "TexCoord 0 1\nVertex 0 1\n"+
-                   "TexCoord 0 0\nVertex 0 0\n"+
-                   "End\n");
+                   "Begin POLYGON\n");
+               if (angle < 360) bgcall += ("Vertex 0.5 0.5\n");
+               for (int i=0;i<angle;i+=step) {
+                   bgcall += ("Vertex " + circleGL[i][0] +
+                              " " + circleGL[i][1] + "\n");
+               }
+               bgcall += ("Vertex " + circleGL[angle-1][0] +
+                          " " + circleGL[angle-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) {
+               bgcall += ("Vertex " + circleGL[i][0] +
+                              " " + circleGL[i][1] + "\n");
            }
+           bgcall += ("Vertex " + circleGL[angle-1][0] +
+                      " " + circleGL[angle-1][1] + "\n" +
+                      "End\n");
                    
            glList = GLRen.createCallListBoxCoorded(
                "PushAttrib CURRENT_BIT ENABLE_BIT\n"+
-               "BindTexture TEXTURE_2D "+tex.getTexId()+"\n"+
-               "TexParameter TEXTURE_2D TEXTURE_MIN_FILTER 
LINEAR_MIPMAP_LINEAR\n"+
-               "TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR\n"+
-                "TexParameter TEXTURE_2D TEXTURE_MAX_ANISOTROPY_EXT 1\n"+
-                       "Enable BLEND\n"+
-                       "BlendFunc SRC_ALPHA ONE_MINUS_SRC_ALPHA\n"+
-               "Enable TEXTURE_2D\n"+
+               "Disable TEXTURE_2D\n"+
                bgcall +
                "PopAttrib\n"
                );



reply via email to

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