propane 2.7.2-java → 2.8.0.pre-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/CHANGELOG.md +1 -1
- data/README.md +10 -8
- data/Rakefile +1 -1
- data/lib/propane/app.rb +3 -3
- data/lib/propane/version.rb +1 -1
- data/lib/{processing-core.jar → propane-2.8.0.jar} +0 -0
- data/library/control_panel/control_panel.rb +3 -2
- data/pom.rb +89 -88
- data/pom.xml +75 -46
- data/propane.gemspec +1 -2
- data/src/main/java/japplemenubar/JAppleMenuBar.java +88 -0
- data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
- data/src/{monkstone → main/java/monkstone}/ColorUtil.java +0 -0
- data/src/{monkstone → main/java/monkstone}/MathToolModule.java +0 -0
- data/src/{monkstone → main/java/monkstone}/PropaneLibrary.java +0 -0
- data/src/{monkstone → main/java/monkstone}/core/LibraryProxy.java +0 -0
- data/src/{monkstone → main/java/monkstone}/fastmath/Deglut.java +0 -0
- data/src/{monkstone → main/java/monkstone}/fastmath/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/filechooser/Chooser.java +0 -0
- data/src/{monkstone → main/java/monkstone}/noise/SimplexNoise.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/CustomHorizontalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/CustomVerticalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleHorizontalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleVerticalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/Slider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SliderBar.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SliderGroup.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/WheelHandler.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/AppRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/JRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/ShapeRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec2/Vec2.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec2/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec3/Vec3.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec3/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/videoevent/VideoInterface.java +0 -0
- data/src/{monkstone → main/java/monkstone}/videoevent/package-info.java +0 -0
- data/src/main/java/processing/awt/PGraphicsJava2D.java +3029 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +377 -0
- data/src/main/java/processing/awt/PSurfaceAWT.java +1567 -0
- data/src/main/java/processing/core/PApplet.java +15709 -0
- data/src/main/java/processing/core/PConstants.java +527 -0
- data/src/main/java/processing/core/PFont.java +1098 -0
- data/src/main/java/processing/core/PGraphics.java +8467 -0
- data/src/main/java/processing/core/PImage.java +3438 -0
- data/src/main/java/processing/core/PMatrix.java +208 -0
- data/src/main/java/processing/core/PMatrix2D.java +534 -0
- data/src/main/java/processing/core/PMatrix3D.java +877 -0
- data/src/main/java/processing/core/PShape.java +3445 -0
- data/src/main/java/processing/core/PShapeOBJ.java +469 -0
- data/src/main/java/processing/core/PShapeSVG.java +1787 -0
- data/src/main/java/processing/core/PStyle.java +63 -0
- data/src/main/java/processing/core/PSurface.java +161 -0
- data/src/main/java/processing/core/PSurfaceNone.java +374 -0
- data/src/main/java/processing/core/PVector.java +1063 -0
- data/src/main/java/processing/data/FloatDict.java +829 -0
- data/src/main/java/processing/data/FloatList.java +912 -0
- data/src/main/java/processing/data/IntDict.java +796 -0
- data/src/main/java/processing/data/IntList.java +913 -0
- data/src/main/java/processing/data/JSONArray.java +1260 -0
- data/src/main/java/processing/data/JSONObject.java +2282 -0
- data/src/main/java/processing/data/JSONTokener.java +435 -0
- data/src/main/java/processing/data/Sort.java +46 -0
- data/src/main/java/processing/data/StringDict.java +601 -0
- data/src/main/java/processing/data/StringList.java +775 -0
- data/src/main/java/processing/data/Table.java +4923 -0
- data/src/main/java/processing/data/TableRow.java +198 -0
- data/src/main/java/processing/data/XML.java +1149 -0
- data/src/main/java/processing/event/Event.java +125 -0
- data/src/main/java/processing/event/KeyEvent.java +70 -0
- data/src/main/java/processing/event/MouseEvent.java +149 -0
- data/src/main/java/processing/event/TouchEvent.java +57 -0
- data/src/main/java/processing/opengl/FontTexture.java +379 -0
- data/src/main/java/processing/opengl/FrameBuffer.java +503 -0
- data/src/main/java/processing/opengl/LinePath.java +623 -0
- data/src/main/java/processing/opengl/LineStroker.java +685 -0
- data/src/main/java/processing/opengl/PGL.java +3366 -0
- data/src/main/java/processing/opengl/PGraphics2D.java +615 -0
- data/src/main/java/processing/opengl/PGraphics3D.java +281 -0
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13634 -0
- data/src/main/java/processing/opengl/PJOGL.java +1966 -0
- data/src/main/java/processing/opengl/PShader.java +1478 -0
- data/src/main/java/processing/opengl/PShapeOpenGL.java +5234 -0
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1315 -0
- data/src/main/java/processing/opengl/Texture.java +1670 -0
- data/src/main/java/processing/opengl/VertexBuffer.java +88 -0
- data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
- data/src/main/java/processing/opengl/cursors/cross.png +0 -0
- data/src/main/java/processing/opengl/cursors/hand.png +0 -0
- data/src/main/java/processing/opengl/cursors/license.txt +27 -0
- data/src/main/java/processing/opengl/cursors/move.png +0 -0
- data/src/main/java/processing/opengl/cursors/text.png +0 -0
- data/src/main/java/processing/opengl/cursors/wait.png +0 -0
- data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
- data/src/main/java/processing/opengl/shaders/ColorVert.glsl +34 -0
- data/src/main/java/processing/opengl/shaders/LightFrag.glsl +33 -0
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +154 -0
- data/src/main/java/processing/opengl/shaders/LightVert.glsl +151 -0
- data/src/main/java/processing/opengl/shaders/LineFrag.glsl +32 -0
- data/src/main/java/processing/opengl/shaders/LineVert.glsl +100 -0
- data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
- data/src/main/java/processing/opengl/shaders/PointFrag.glsl +32 -0
- data/src/main/java/processing/opengl/shaders/PointVert.glsl +56 -0
- data/src/main/java/processing/opengl/shaders/TexFrag.glsl +37 -0
- data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +160 -0
- data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
- data/src/main/java/processing/opengl/shaders/TexVert.glsl +38 -0
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/src/main/resources/license.txt +508 -0
- data/vendors/Rakefile +5 -20
- metadata +115 -33
- data/lib/propane.jar +0 -0
@@ -0,0 +1,379 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
3
|
+
/*
|
4
|
+
Part of the Processing project - http://processing.org
|
5
|
+
|
6
|
+
Copyright (c) 2012-15 The Processing Foundation
|
7
|
+
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
8
|
+
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
9
|
+
|
10
|
+
This library is free software; you can redistribute it and/or
|
11
|
+
modify it under the terms of the GNU Lesser General Public
|
12
|
+
License as published by the Free Software Foundation, version 2.1.
|
13
|
+
|
14
|
+
This library is distributed in the hope that it will be useful,
|
15
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
Lesser General Public License for more details.
|
18
|
+
|
19
|
+
You should have received a copy of the GNU Lesser General
|
20
|
+
Public License along with this library; if not, write to the
|
21
|
+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
22
|
+
Boston, MA 02111-1307 USA
|
23
|
+
*/
|
24
|
+
|
25
|
+
package processing.opengl;
|
26
|
+
|
27
|
+
import processing.core.PApplet;
|
28
|
+
import processing.core.PConstants;
|
29
|
+
import processing.core.PFont;
|
30
|
+
import processing.core.PGraphics;
|
31
|
+
import processing.core.PImage;
|
32
|
+
|
33
|
+
import java.util.HashMap;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* All the infrastructure needed for optimized font rendering
|
37
|
+
* in OpenGL. Basically, this special class is needed because
|
38
|
+
* fonts in Processing are handled by a separate PImage for each
|
39
|
+
* glyph. For performance reasons, all these glyphs should be
|
40
|
+
* stored in a single OpenGL texture (otherwise, rendering a
|
41
|
+
* string of text would involve binding and un-binding several
|
42
|
+
* textures.
|
43
|
+
* PFontTexture manages the correspondence between individual
|
44
|
+
* glyphs and the large OpenGL texture containing them. Also,
|
45
|
+
* in the case that the font size is very large, one single
|
46
|
+
* OpenGL texture might not be enough to store all the glyphs,
|
47
|
+
* so PFontTexture also takes care of spreading a single font
|
48
|
+
* over several textures.
|
49
|
+
* @author Andres Colubri
|
50
|
+
*/
|
51
|
+
class FontTexture implements PConstants {
|
52
|
+
protected PGL pgl;
|
53
|
+
protected boolean is3D;
|
54
|
+
|
55
|
+
protected int minSize;
|
56
|
+
protected int maxSize;
|
57
|
+
protected int offsetX;
|
58
|
+
protected int offsetY;
|
59
|
+
protected int lineHeight;
|
60
|
+
protected Texture[] textures = null;
|
61
|
+
protected PImage[] images = null;
|
62
|
+
protected int lastTex;
|
63
|
+
protected TextureInfo[] glyphTexinfos;
|
64
|
+
protected HashMap<PFont.Glyph, TextureInfo> texinfoMap;
|
65
|
+
|
66
|
+
public FontTexture(PGraphicsOpenGL pg, PFont font, boolean is3D) {
|
67
|
+
pgl = pg.pgl;
|
68
|
+
this.is3D = is3D;
|
69
|
+
|
70
|
+
initTexture(pg, font);
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
protected void allocate() {
|
75
|
+
// Nothing to do here: the font textures will allocate
|
76
|
+
// themselves.
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
protected void dispose() {
|
81
|
+
for (int i = 0; i < textures.length; i++) {
|
82
|
+
textures[i].dispose();
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
|
87
|
+
protected void initTexture(PGraphicsOpenGL pg, PFont font) {
|
88
|
+
lastTex = -1;
|
89
|
+
|
90
|
+
int spow = PGL.nextPowerOfTwo(font.getSize());
|
91
|
+
minSize = PApplet.min(PGraphicsOpenGL.maxTextureSize,
|
92
|
+
PApplet.max(PGL.MIN_FONT_TEX_SIZE, spow));
|
93
|
+
maxSize = PApplet.min(PGraphicsOpenGL.maxTextureSize,
|
94
|
+
PApplet.max(PGL.MAX_FONT_TEX_SIZE, 2 * spow));
|
95
|
+
|
96
|
+
if (maxSize < spow) {
|
97
|
+
PGraphics.showWarning("The font size is too large to be properly " +
|
98
|
+
"displayed with OpenGL");
|
99
|
+
}
|
100
|
+
|
101
|
+
addTexture(pg);
|
102
|
+
|
103
|
+
offsetX = 0;
|
104
|
+
offsetY = 0;
|
105
|
+
lineHeight = 0;
|
106
|
+
|
107
|
+
texinfoMap = new HashMap<PFont.Glyph, TextureInfo>();
|
108
|
+
glyphTexinfos = new TextureInfo[font.getGlyphCount()];
|
109
|
+
addAllGlyphsToTexture(pg, font);
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
public boolean addTexture(PGraphicsOpenGL pg) {
|
114
|
+
int w, h;
|
115
|
+
boolean resize;
|
116
|
+
|
117
|
+
w = maxSize;
|
118
|
+
if (-1 < lastTex && textures[lastTex].glHeight < maxSize) {
|
119
|
+
// The height of the current texture is less than the maximum, this
|
120
|
+
// means we can replace it with a larger texture.
|
121
|
+
h = PApplet.min(2 * textures[lastTex].glHeight, maxSize);
|
122
|
+
resize = true;
|
123
|
+
} else {
|
124
|
+
h = minSize;
|
125
|
+
resize = false;
|
126
|
+
}
|
127
|
+
|
128
|
+
Texture tex;
|
129
|
+
if (is3D) {
|
130
|
+
// Bilinear sampling ensures that the texture doesn't look pixelated
|
131
|
+
// either when it is magnified or minified...
|
132
|
+
tex = new Texture(pg, w, h,
|
133
|
+
new Texture.Parameters(ARGB, Texture.BILINEAR, false));
|
134
|
+
} else {
|
135
|
+
// ...however, the effect of bilinear sampling is to add some blurriness
|
136
|
+
// to the text in its original size. In 2D, we assume that text will be
|
137
|
+
// shown at its original size, so linear sampling is chosen instead (which
|
138
|
+
// only affects minimized text).
|
139
|
+
tex = new Texture(pg, w, h,
|
140
|
+
new Texture.Parameters(ARGB, Texture.LINEAR, false));
|
141
|
+
}
|
142
|
+
|
143
|
+
if (textures == null) {
|
144
|
+
textures = new Texture[1];
|
145
|
+
textures[0] = tex;
|
146
|
+
images = new PImage[1];
|
147
|
+
images[0] = pg.wrapTexture(tex);
|
148
|
+
lastTex = 0;
|
149
|
+
} else if (resize) {
|
150
|
+
// Replacing old smaller texture with larger one.
|
151
|
+
// But first we must copy the contents of the older
|
152
|
+
// texture into the new one.
|
153
|
+
Texture tex0 = textures[lastTex];
|
154
|
+
tex.put(tex0);
|
155
|
+
textures[lastTex] = tex;
|
156
|
+
|
157
|
+
pg.setCache(images[lastTex], tex);
|
158
|
+
images[lastTex].width = tex.width;
|
159
|
+
images[lastTex].height = tex.height;
|
160
|
+
} else {
|
161
|
+
// Adding new texture to the list.
|
162
|
+
lastTex = textures.length;
|
163
|
+
Texture[] tempTex = new Texture[lastTex + 1];
|
164
|
+
PApplet.arrayCopy(textures, tempTex, textures.length);
|
165
|
+
tempTex[lastTex] = tex;
|
166
|
+
textures = tempTex;
|
167
|
+
|
168
|
+
PImage[] tempImg = new PImage[textures.length];
|
169
|
+
PApplet.arrayCopy(images, tempImg, images.length);
|
170
|
+
tempImg[lastTex] = pg.wrapTexture(tex);
|
171
|
+
images = tempImg;
|
172
|
+
}
|
173
|
+
|
174
|
+
// Make sure that the current texture is bound.
|
175
|
+
tex.bind();
|
176
|
+
|
177
|
+
return resize;
|
178
|
+
}
|
179
|
+
|
180
|
+
|
181
|
+
public void begin() {
|
182
|
+
}
|
183
|
+
|
184
|
+
|
185
|
+
public void end() {
|
186
|
+
for (int i = 0; i < textures.length; i++) {
|
187
|
+
pgl.disableTexturing(textures[i].glTarget);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
public PImage getTexture(TextureInfo info) {
|
193
|
+
return images[info.texIndex];
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
// Add all the current glyphs to opengl texture.
|
198
|
+
public void addAllGlyphsToTexture(PGraphicsOpenGL pg, PFont font) {
|
199
|
+
// loop over current glyphs.
|
200
|
+
for (int i = 0; i < font.getGlyphCount(); i++) {
|
201
|
+
addToTexture(pg, i, font.getGlyph(i));
|
202
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
public void updateGlyphsTexCoords() {
|
207
|
+
// loop over current glyphs.
|
208
|
+
for (int i = 0; i < glyphTexinfos.length; i++) {
|
209
|
+
TextureInfo tinfo = glyphTexinfos[i];
|
210
|
+
if (tinfo != null && tinfo.texIndex == lastTex) {
|
211
|
+
tinfo.updateUV();
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
|
217
|
+
public TextureInfo getTexInfo(PFont.Glyph glyph) {
|
218
|
+
TextureInfo info = texinfoMap.get(glyph);
|
219
|
+
return info;
|
220
|
+
}
|
221
|
+
|
222
|
+
|
223
|
+
public TextureInfo addToTexture(PGraphicsOpenGL pg, PFont.Glyph glyph) {
|
224
|
+
int n = glyphTexinfos.length;
|
225
|
+
if (n == 0) {
|
226
|
+
glyphTexinfos = new TextureInfo[1];
|
227
|
+
}
|
228
|
+
addToTexture(pg, n, glyph);
|
229
|
+
return glyphTexinfos[n];
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
public boolean contextIsOutdated() {
|
234
|
+
boolean outdated = false;
|
235
|
+
for (int i = 0; i < textures.length; i++) {
|
236
|
+
if (textures[i].contextIsOutdated()) {
|
237
|
+
outdated = true;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
if (outdated) {
|
241
|
+
for (int i = 0; i < textures.length; i++) {
|
242
|
+
textures[i].dispose();
|
243
|
+
}
|
244
|
+
}
|
245
|
+
return outdated;
|
246
|
+
}
|
247
|
+
|
248
|
+
// public void draw() {
|
249
|
+
// Texture tex = textures[lastTex];
|
250
|
+
// pgl.drawTexture(tex.glTarget, tex.glName,
|
251
|
+
// tex.glWidth, tex.glHeight,
|
252
|
+
// 0, 0, tex.glWidth, tex.glHeight);
|
253
|
+
// }
|
254
|
+
|
255
|
+
|
256
|
+
// Adds this glyph to the opengl texture in PFont.
|
257
|
+
protected void addToTexture(PGraphicsOpenGL pg, int idx, PFont.Glyph glyph) {
|
258
|
+
// We add one pixel to avoid issues when sampling the font texture at
|
259
|
+
// fractional screen positions. I.e.: the pixel on the screen only contains
|
260
|
+
// half of the font rectangle, so it would sample half of the color from the
|
261
|
+
// glyph area in the texture, and the other half from the contiguous pixel.
|
262
|
+
// If the later contains a portion of the neighbor glyph and the former
|
263
|
+
// doesn't, this would result in a shaded pixel when the correct output is
|
264
|
+
// blank. This is a consequence of putting all the glyphs in a common
|
265
|
+
// texture with bilinear sampling.
|
266
|
+
int w = 1 + glyph.width + 1;
|
267
|
+
int h = 1 + glyph.height + 1;
|
268
|
+
|
269
|
+
// Converting the pixels array from the PImage into a valid RGBA array for
|
270
|
+
// OpenGL.
|
271
|
+
int[] rgba = new int[w * h];
|
272
|
+
int t = 0;
|
273
|
+
int p = 0;
|
274
|
+
if (PGL.BIG_ENDIAN) {
|
275
|
+
java.util.Arrays.fill(rgba, 0, w, 0xFFFFFF00); // Set the first row to blank pixels.
|
276
|
+
t = w;
|
277
|
+
for (int y = 0; y < glyph.height; y++) {
|
278
|
+
rgba[t++] = 0xFFFFFF00; // Set the leftmost pixel in this row as blank
|
279
|
+
for (int x = 0; x < glyph.width; x++) {
|
280
|
+
rgba[t++] = 0xFFFFFF00 | glyph.image.pixels[p++];
|
281
|
+
}
|
282
|
+
rgba[t++] = 0xFFFFFF00; // Set the rightmost pixel in this row as blank
|
283
|
+
}
|
284
|
+
java.util.Arrays.fill(rgba, (h - 1) * w, h * w, 0xFFFFFF00); // Set the last row to blank pixels.
|
285
|
+
} else {
|
286
|
+
java.util.Arrays.fill(rgba, 0, w, 0x00FFFFFF); // Set the first row to blank pixels.
|
287
|
+
t = w;
|
288
|
+
for (int y = 0; y < glyph.height; y++) {
|
289
|
+
rgba[t++] = 0x00FFFFFF; // Set the leftmost pixel in this row as blank
|
290
|
+
for (int x = 0; x < glyph.width; x++) {
|
291
|
+
rgba[t++] = (glyph.image.pixels[p++] << 24) | 0x00FFFFFF;
|
292
|
+
}
|
293
|
+
rgba[t++] = 0x00FFFFFF; // Set the rightmost pixel in this row as blank
|
294
|
+
}
|
295
|
+
java.util.Arrays.fill(rgba, (h - 1) * w, h * w, 0x00FFFFFF); // Set the last row to blank pixels.
|
296
|
+
}
|
297
|
+
|
298
|
+
// Is there room for this glyph in the current line?
|
299
|
+
if (offsetX + w > textures[lastTex].glWidth) {
|
300
|
+
// No room, go to the next line:
|
301
|
+
offsetX = 0;
|
302
|
+
offsetY += lineHeight;
|
303
|
+
}
|
304
|
+
lineHeight = Math.max(lineHeight, h);
|
305
|
+
|
306
|
+
boolean resized = false;
|
307
|
+
if (offsetY + lineHeight > textures[lastTex].glHeight) {
|
308
|
+
// We run out of space in the current texture, so we add a new texture:
|
309
|
+
resized = addTexture(pg);
|
310
|
+
if (resized) {
|
311
|
+
// Because the current texture has been resized, we need to
|
312
|
+
// update the UV coordinates of all the glyphs associated to it:
|
313
|
+
updateGlyphsTexCoords();
|
314
|
+
} else {
|
315
|
+
// A new texture has been created. Reseting texture coordinates
|
316
|
+
// and line.
|
317
|
+
offsetX = 0;
|
318
|
+
offsetY = 0;
|
319
|
+
lineHeight = 0;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
TextureInfo tinfo = new TextureInfo(lastTex, offsetX, offsetY, w, h, rgba);
|
324
|
+
offsetX += w;
|
325
|
+
|
326
|
+
if (idx == glyphTexinfos.length) {
|
327
|
+
TextureInfo[] temp = new TextureInfo[glyphTexinfos.length + 1];
|
328
|
+
System.arraycopy(glyphTexinfos, 0, temp, 0, glyphTexinfos.length);
|
329
|
+
glyphTexinfos = temp;
|
330
|
+
}
|
331
|
+
|
332
|
+
glyphTexinfos[idx] = tinfo;
|
333
|
+
texinfoMap.put(glyph, tinfo);
|
334
|
+
}
|
335
|
+
|
336
|
+
|
337
|
+
class TextureInfo {
|
338
|
+
int texIndex;
|
339
|
+
int width;
|
340
|
+
int height;
|
341
|
+
int[] crop;
|
342
|
+
float u0, u1;
|
343
|
+
float v0, v1;
|
344
|
+
int[] pixels;
|
345
|
+
|
346
|
+
TextureInfo(int tidx, int cropX, int cropY, int cropW, int cropH,
|
347
|
+
int[] pix) {
|
348
|
+
texIndex = tidx;
|
349
|
+
crop = new int[4];
|
350
|
+
// The region of the texture corresponding to the glyph is surrounded by a
|
351
|
+
// 1-pixel wide border to avoid artifacts due to bilinear sampling. This
|
352
|
+
// is why the additions and subtractions to the crop values.
|
353
|
+
crop[0] = cropX + 1;
|
354
|
+
crop[1] = cropY + 1 + cropH - 2;
|
355
|
+
crop[2] = cropW - 2;
|
356
|
+
crop[3] = -cropH + 2;
|
357
|
+
pixels = pix;
|
358
|
+
updateUV();
|
359
|
+
updateTex();
|
360
|
+
}
|
361
|
+
|
362
|
+
|
363
|
+
void updateUV() {
|
364
|
+
width = textures[texIndex].glWidth;
|
365
|
+
height = textures[texIndex].glHeight;
|
366
|
+
|
367
|
+
u0 = (float)crop[0] / (float)width;
|
368
|
+
u1 = u0 + (float)crop[2] / (float)width;
|
369
|
+
v0 = (float)(crop[1] + crop[3]) / (float)height;
|
370
|
+
v1 = v0 - (float)crop[3] / (float)height;
|
371
|
+
}
|
372
|
+
|
373
|
+
|
374
|
+
void updateTex() {
|
375
|
+
textures[texIndex].setNative(pixels, crop[0] - 1, crop[1] + crop[3] - 1,
|
376
|
+
crop[2] + 2, -crop[3] + 2);
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|