/[gzz]/gzz/gzz/vob/OvalBgVob.java
ViewVC logotype

Diff of /gzz/gzz/vob/OvalBgVob.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by humppake, Fri Oct 18 12:46:39 2002 UTC revision 1.4 by humppake, Mon Oct 21 10:43:26 2002 UTC
# Line 1  Line 1 
   
1  /*  /*
2  OvalBgVob.java  OvalBgVob.java
3   *       *    
# Line 48  public static final String rcsid = "$Id$ Line 47  public static final String rcsid = "$Id$
47    
48      static Rectangle rect = new Rectangle();      static Rectangle rect = new Rectangle();
49    
50      static private GL.Texture tex;      static protected GL.Texture tex;
51      static private boolean texLoaded = false;      static protected boolean texLoaded = false;
52      static private void loadTex() {      static protected void loadTex() {
53          if (!texLoaded) {          if (!texLoaded) {
54              String[] texparam = {"type", "8"};              String[] texparam = {"line_width", "2.0"};
55              tex = GL.createTexture();              tex = GL.createTexture();
56              tex.shade(128, 128, 0, 1, "ALPHA", "ALPHA", "geometric", texparam);              tex.shade_all_levels(512, 512, 0, 4, "RGBA", "RGBA", "circle", texparam);
57              texLoaded = true;              texLoaded = true;
58          }          }
59      }      }
# Line 76  public static final String rcsid = "$Id$ Line 75  public static final String rcsid = "$Id$
75          int mx = rect.x, my=rect.y,          int mx = rect.x, my=rect.y,
76              mw = rect.width, mh = rect.height;              mw = rect.width, mh = rect.height;
77    
         /** Origo and radius for circle.  
          * Irrelevant, when using drawOval ad fillOval.  
           Point co = new Point(mx+mw/2, my+h/2);  
           int cr;  
           if (mw < mh) cr = mw;  
           else cr = mh;  
         */  
   
78          Color oldfg = g.getColor();          Color oldfg = g.getColor();
79    
80          // Draw a rectangle in the background color, wiping out          // Draw a rectangle in the background color, wiping out
# Line 96  public static final String rcsid = "$Id$ Line 87  public static final String rcsid = "$Id$
87              g.setColor(bg);              g.setColor(bg);
88              g.fillOval(mx, my, mw, mh);              g.fillOval(mx, my, mw, mh);
89          } else {          } else {
90                // Draws multiple background colours as sectors
91              int arc = 360 / nsolids;              int arc = 360 / nsolids;
92              for(int i=0; i<nsolids; i++) {              for(int i=0; i<nsolids; i++) {
93                  g.setColor(solids[i]);                  g.setColor(solids[i]);
# Line 119  public static final String rcsid = "$Id$ Line 111  public static final String rcsid = "$Id$
111                                  int coordsys2) {                                  int coordsys2) {
112          if(dbg) pa("Addtolistgl rectbg "+coordsys1);          if(dbg) pa("Addtolistgl rectbg "+coordsys1);
113          if(glList == null) {          if(glList == null) {
114                /** In OpenGL the oval shape is done by drawing
115                 * a quad stript with an oval texture inside it.
116                 */
117              if (!texLoaded) loadTex();              if (!texLoaded) loadTex();
118              String bgcall = "";              String bgcall = "";
119              if(nsolids > 0) {              if(nsolids > 0) {
                 double arc = (2*Math.PI) / nsolids;  
120                  double w = 1.0 / nsolids;                  double w = 1.0 / nsolids;
121                  for(int i=0; i<nsolids; i++) {                  for(int i=0; i<nsolids; i++) {
122                      double x1 = i*w;                      double x1 = i*w;
# Line 151  public static final String rcsid = "$Id$ Line 145  public static final String rcsid = "$Id$
145                      "TexCoord 0 0\nVertex 0 0\n"+                      "TexCoord 0 0\nVertex 0 0\n"+
146                      "End\n");                      "End\n");
147              }              }
148                        
149              glList = GLRen.createCallListCoorded(              glList = GLRen.createCallListCoorded(
150                  "PushAttrib ENABLE_BIT\n"+                  "PushAttrib ENABLE_BIT\n"+
151                  "BindTexture TEXTURE_2D "+tex.getTexId()+"\n"+                  "BindTexture TEXTURE_2D "+tex.getTexId()+"\n"+
152                  "Enable TEXTURE_2D\n"+                  "TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_NEAREST\n"+
153                                  "TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR\n"+
154                  /** Draws border. */                  "Enable BLEND\n"+
155                  "Color 0 0 0 1\n" +                  "BlendFunc SRC_ALPHA ONE_MINUS_SRC_ALPHA\n"+
156                  "Begin QUAD_STRIP\n"+                  "Enable TEXTURE_2D\n"+
157                  /** XXX Border width probably should NOT be                  bgcall +
158                   * relative to vob's size as below.                  "PopAttrib\n"
159                   */                  );
                 "TexCoord 1 1\nVertex 1.05 1.05\n"+  
                 "TexCoord 1 0\nVertex 1.05 -0.05\n"+  
                 "TexCoord 0 1\nVertex -0.05 1.05\n"+  
                 "TexCoord 0 0\nVertex -0.05 -0.05\n"+  
                 "End\n" +  
   
                 /** Draws filled oval using circular texture. */  
                 bgcall +  
   
                 "PopAttrib\n"  
                     );  
160          }          }
161          curs = glList.addToListGL(win, list, curs, coordsys1, coordsys2);          curs = glList.addToListGL(win, list, curs, coordsys1, coordsys2);
162          return curs;          return curs;
# Line 200  public static final String rcsid = "$Id$ Line 183  public static final String rcsid = "$Id$
183    
184    
185    
186    
187    
188    
189    
190    
191    
192    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26