gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gzz/vob/vobs ColoredSquareSectorVob.java Ov...


From: Asko Soukka
Subject: [Gzz-commits] gzz/gzz/vob/vobs ColoredSquareSectorVob.java Ov...
Date: Wed, 05 Mar 2003 09:34:23 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Asko Soukka <address@hidden>    03/03/05 09:34:23

Modified files:
        gzz/vob/vobs   : ColoredSquareSectorVob.java OvalBgVob.java 

Log message:
        vobwork

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/ColoredSquareSectorVob.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/OvalBgVob.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text

Patches:
Index: gzz/gzz/vob/vobs/ColoredSquareSectorVob.java
diff -u gzz/gzz/vob/vobs/ColoredSquareSectorVob.java:1.6 
gzz/gzz/vob/vobs/ColoredSquareSectorVob.java:1.7
--- gzz/gzz/vob/vobs/ColoredSquareSectorVob.java:1.6    Wed Mar  5 07:57:40 2003
+++ gzz/gzz/vob/vobs/ColoredSquareSectorVob.java        Wed Mar  5 09:34:23 2003
@@ -1,7 +1,7 @@
 /*
 ColoredSquareSectorVob.java
  *    
- *    Copyright (c) 1999-2002, Ted Nelson and Tuomas Lukka
+ *    Copyright (c) 2003, Asko Soukka
  *
  *    This file is part of Gzz.
  *    
@@ -23,7 +23,7 @@
  *
  */
 /*
- * Written by Tuomas Lukka, Tero Mäyränen and Asko Soukka
+ * Written by Asko Soukka
  */
 
 package gzz.vob.vobs;
@@ -45,7 +45,7 @@
  */
 
 public class ColoredSquareSectorVob extends ColoredSectorVob {
-public static final String rcsid = "$Id: ColoredSquareSectorVob.java,v 1.6 
2003/03/05 12:57:40 humppake Exp $";
+public static final String rcsid = "$Id: ColoredSquareSectorVob.java,v 1.7 
2003/03/05 14:34:23 humppake Exp $";
 
     public ColoredSquareSectorVob() {
        super(90, 360, 10);
Index: gzz/gzz/vob/vobs/OvalBgVob.java
diff -u gzz/gzz/vob/vobs/OvalBgVob.java:1.9 gzz/gzz/vob/vobs/OvalBgVob.java:1.10
--- gzz/gzz/vob/vobs/OvalBgVob.java:1.9 Fri Feb 21 15:02:48 2003
+++ gzz/gzz/vob/vobs/OvalBgVob.java     Wed Mar  5 09:34:23 2003
@@ -1,7 +1,7 @@
 /*
 OvalBgVob.java
  *    
- *    Copyright (c) 1999-2002, Ted Nelson and Tuomas Lukka
+ *    Copyright (c) 2003, Asko Soukka
  *
  *    This file is part of Gzz.
  *    
@@ -23,7 +23,7 @@
  *
  */
 /*
- * Written by Tuomas Lukka, Tero Mäyränen and Asko Soukka
+ * Written by Asko Soukka
  */
 
 package gzz.vob.vobs;
@@ -45,38 +45,20 @@
  * surrounded by a circle of the current foreground color.
  */
 
-public class OvalBgVob extends Vob {
-public static final String rcsid = "$Id: OvalBgVob.java,v 1.9 2003/02/21 
20:02:48 tjl 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;
-       }
-    }
-
-    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; }
+public class OvalBgVob extends ColoredSectorVob {
+public static final String rcsid = "$Id: OvalBgVob.java,v 1.10 2003/03/05 
14:34:23 humppake Exp $";
 
-    boolean drawBorder = true;
+    public OvalBgVob() {
+       super(90, 360, 10);
+       start = 90;
+       sector = 360;
+       step = 10; 
+    }
 
     public void render(Graphics g,
-                               boolean fast,
-                               Vob.RenderInfo info1,
-                               Vob.RenderInfo info2) {
+                      boolean fast,
+                      Vob.RenderInfo info1,
+                      Vob.RenderInfo info2) {
        info1.getExtRect(rect);
        int mx = rect.x, my=rect.y,
            mw = rect.width, mh = rect.height;
@@ -139,92 +121,95 @@
            g.drawOval(mx, my, mw, mh);
        }
 
-
        g.setColor(oldfg);
     }
 
-    Vob glList;
+    Vob glStencil, glBorder;
+
+    public int putGL(final VobScene vs, final int coordsys1) {
+        if(dbg) pa("Addtolistgl ovalbg "+coordsys1);
 
-    public int putGL(VobScene vs, int coordsys1) {
-        if(dbg) pa("Addtolistgl rectbg "+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(0.5f);
            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;
-                   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");
-               }
-           } 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");
-           }
-                   
+               bgcall += glSolidsString();
+           } else bgcall += glBgString();
+           
            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"
                );
        }
-       vs.map.put(glList, coordsys1);
-       return 0;
-    }
 
-    /** Adds one more solid color to be drawn inside
-     * the cell.
-     */
-    public boolean addColor(Color c) {
-       if(solids == null || nsolids >= solids.length) {
-           Color[] n= new Color[nsolids + 10];
-           if(solids != null) System.arraycopy(solids, 0, n, 0, nsolids);
-           solids = n;
+       if(glStencil == null) {
+           glStencil = GLRen.createCallListBoxCoorded(
+               "PushAttrib CURRENT_BIT ENABLE_BIT\n"+
+               "Disable TEXTURE_2D\n"+
+               super.glBgString() +
+               "PopAttrib\n"
+               );
        }
-       solids[nsolids++] = c;
-       return false;
-    }
-    /** The currently put solid colors.
-     * null = none. There may be null references near the end
-     * of the array. Mostly useful for checking for nullness.
-     */
-    public Color[] getSolidColors() { return solids; }
-}
-
-
-
-
-
 
+       if(glBorder == null) {
+           glBorder = GLRen.createCallListBoxCoorded(
+               "PushAttrib CURRENT_BIT ENABLE_BIT\n"+
+               "Disable TEXTURE_2D\n"+
+               glBorderString() +
+               "PopAttrib\n"
+               );
+       }
 
+       gzz.gfx.gl.Stencil.drawStenciled(
+          vs,
+          new Runnable() { public void run() {
+              vs.map.put(glStencil, coordsys1);
+          }},
+          null,
+          null,
+          new Runnable() { public void run() {
+              vs.map.put(glList, coordsys1);
+          }},
+          false
+       );
 
+       if(drawBorder) vs.map.put(glBorder, coordsys1);
+       return 0;
+    }
 
+    protected String glBgString() {
+       String glString = "";
+       glString += (
+                    "Color "+ColorUtil.colorGLString(bg)+" 1\n" +
+                    "Begin QUAD_STRIP\n"+
+                    "Vertex 1 1\nVertex 1 0\n"+
+                    "Vertex 0 1\nVertex 0 0\n"+
+                    "End\n");
+       return glString;
+    }
 
+    protected String glSolidsString() {
+       double w = 1.0 / nsolids;
+       String glString = "";
+       for(int i=0; i<nsolids; i++) {
+           double x1 = i*w;
+           double x2 = x1 + w;
+           Color c = solids[i];
+           glString += (
+             "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");
+       }
+       return glString;
+    }
+}




reply via email to

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