|
|
|
1 |
/* |
/* |
2 |
OvalBgVob.java |
OvalBgVob.java |
3 |
* |
* |
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 |
} |
} |
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 |
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]); |
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; |
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; |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|