picrate 0.5.0-java → 0.6.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +3 -1
- data/README.md +1 -1
- data/Rakefile +8 -6
- data/docs/_editors/geany.md +5 -4
- data/docs/_editors/vim.md +6 -0
- data/docs/_includes/head.html +1 -0
- data/docs/_libraries/control_panel.md +2 -2
- data/docs/_libraries/gl_video.md +21 -0
- data/docs/_posts/2018-05-06-getting_started.md +10 -9
- data/docs/_posts/2018-05-06-install_jruby.md +19 -2
- data/docs/_posts/2018-06-26-auto_install_picrate.md +19 -4
- data/docs/_posts/2018-11-18-building-gem.md +18 -0
- data/docs/_posts/2018-11-27-getting_started_geany.md +38 -0
- data/docs/about.md +21 -10
- data/docs/assets/android-chrome-192x192.png +0 -0
- data/docs/assets/android-chrome-512x512.png +0 -0
- data/docs/assets/favicon.ico +0 -0
- data/docs/assets/geany.png +0 -0
- data/docs/assets/jwishy_picrate.png +0 -0
- data/docs/assets/picrate.svg +251 -0
- data/docs/index.html +8 -14
- data/lib/picrate/runner.rb +6 -2
- data/lib/picrate/version.rb +1 -1
- data/library/boids/boids.rb +10 -13
- data/mvnw +234 -0
- data/picrate.gemspec +2 -1
- data/pom.rb +1 -1
- data/pom.xml +1 -1
- data/src/main/java/japplemenubar/JAppleMenuBar.java +10 -2
- data/src/main/java/monkstone/ColorUtil.java +11 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -0
- data/src/main/java/monkstone/PicrateLibrary.java +1 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -0
- data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleSlider.java +8 -8
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/Slider.java +3 -3
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/vecmath/AppRender.java +1 -0
- data/src/main/java/monkstone/vecmath/JRender.java +1 -0
- data/src/main/java/monkstone/vecmath/ShapeRender.java +1 -0
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -0
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -0
- data/src/main/java/processing/awt/PGraphicsJava2D.java +85 -16
- data/src/main/java/processing/awt/PSurfaceAWT.java +1 -1
- data/src/main/java/processing/core/PApplet.java +18 -12
- data/src/main/java/processing/core/PShape.java +1182 -305
- data/src/main/java/processing/core/PStyle.java +1 -1
- data/src/main/java/processing/core/PSurface.java +1 -1
- data/src/main/java/processing/data/FloatDict.java +196 -54
- data/src/main/java/processing/data/FloatList.java +167 -54
- data/src/main/java/processing/data/IntDict.java +211 -56
- data/src/main/java/processing/data/IntList.java +185 -52
- data/src/main/java/processing/data/JSONArray.java +69 -20
- data/src/main/java/processing/data/JSONObject.java +53 -12
- data/src/main/java/processing/data/Sort.java +40 -10
- data/src/main/java/processing/data/StringDict.java +159 -49
- data/src/main/java/processing/data/StringList.java +147 -42
- data/src/main/java/processing/data/Table.java +778 -223
- data/src/main/java/processing/data/TableRow.java +26 -2
- data/src/main/java/processing/data/XML.java +190 -50
- data/src/main/java/processing/event/Event.java +93 -0
- data/src/main/java/processing/event/KeyEvent.java +55 -13
- data/src/main/java/processing/event/MouseEvent.java +77 -1
- data/src/main/java/processing/event/TouchEvent.java +14 -1
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +8 -0
- data/src/main/java/processing/opengl/FrameBuffer.java +228 -66
- data/src/main/java/processing/opengl/LinePath.java +131 -27
- data/src/main/java/processing/opengl/LineStroker.java +30 -5
- data/src/main/java/processing/opengl/PGL.java +4066 -865
- data/src/main/java/processing/opengl/PGraphics2D.java +38 -10
- data/src/main/java/processing/opengl/PGraphics3D.java +38 -6
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +1980 -474
- data/src/main/java/processing/opengl/PJOGL.java +1460 -248
- data/src/main/java/processing/opengl/PShader.java +904 -217
- data/src/main/java/processing/opengl/PShapeOpenGL.java +1811 -487
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +278 -71
- data/src/main/java/processing/opengl/Texture.java +610 -135
- data/src/main/java/processing/opengl/VertexBuffer.java +45 -9
- 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/vendors/Rakefile +1 -1
- metadata +13 -6
- data/docs/assets/circle_collisions.png +0 -0
- data/docs/favicon.ico +0 -0
|
@@ -29,10 +29,16 @@ import processing.core.PMatrix3D;
|
|
|
29
29
|
import processing.core.PShape;
|
|
30
30
|
import processing.core.PShapeSVG;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @author Martin Prout
|
|
35
|
+
*/
|
|
33
36
|
public class PGraphics2D extends PGraphicsOpenGL {
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
public PGraphics2D() {
|
|
36
42
|
super();
|
|
37
43
|
}
|
|
38
44
|
|
|
@@ -113,8 +119,10 @@ public class PGraphics2D extends PGraphicsOpenGL {
|
|
|
113
119
|
showMethodWarning("frustum");
|
|
114
120
|
}
|
|
115
121
|
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
@Override
|
|
118
126
|
protected void defaultPerspective() {
|
|
119
127
|
super.ortho(0, width, -height, 0, -1, +1);
|
|
120
128
|
}
|
|
@@ -150,8 +158,10 @@ public class PGraphics2D extends PGraphicsOpenGL {
|
|
|
150
158
|
showMethodWarning("camera");
|
|
151
159
|
}
|
|
152
160
|
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
*/
|
|
164
|
+
@Override
|
|
155
165
|
protected void defaultCamera() {
|
|
156
166
|
eyeDist = 1;
|
|
157
167
|
resetMatrix();
|
|
@@ -162,6 +172,10 @@ public class PGraphics2D extends PGraphicsOpenGL {
|
|
|
162
172
|
|
|
163
173
|
// MATRIX MORE!
|
|
164
174
|
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
|
|
165
179
|
|
|
166
180
|
@Override
|
|
167
181
|
protected void begin2D() {
|
|
@@ -171,8 +185,10 @@ public class PGraphics2D extends PGraphicsOpenGL {
|
|
|
171
185
|
defaultCamera();
|
|
172
186
|
}
|
|
173
187
|
|
|
174
|
-
|
|
175
|
-
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
*/
|
|
191
|
+
@Override
|
|
176
192
|
protected void end2D() {
|
|
177
193
|
popMatrix();
|
|
178
194
|
popProjection();
|
|
@@ -235,13 +251,25 @@ public class PGraphics2D extends PGraphicsOpenGL {
|
|
|
235
251
|
|
|
236
252
|
// SHAPE I/O
|
|
237
253
|
|
|
254
|
+
/**
|
|
255
|
+
*
|
|
256
|
+
* @param extension
|
|
257
|
+
* @return
|
|
258
|
+
*/
|
|
259
|
+
|
|
238
260
|
|
|
239
261
|
static protected boolean isSupportedExtension(String extension) {
|
|
240
262
|
return extension.equals("svg") || extension.equals("svgz");
|
|
241
263
|
}
|
|
242
264
|
|
|
243
|
-
|
|
244
|
-
|
|
265
|
+
/**
|
|
266
|
+
*
|
|
267
|
+
* @param pg
|
|
268
|
+
* @param filename
|
|
269
|
+
* @param extension
|
|
270
|
+
* @return
|
|
271
|
+
*/
|
|
272
|
+
static protected PShape loadShapeImpl(PGraphics pg,
|
|
245
273
|
String filename, String extension) {
|
|
246
274
|
if (extension.equals("svg") || extension.equals("svgz")) {
|
|
247
275
|
PShapeSVG svg = new PShapeSVG(pg.parent.loadXML(filename));
|
|
@@ -28,10 +28,16 @@ import processing.core.PGraphics;
|
|
|
28
28
|
import processing.core.PShape;
|
|
29
29
|
import processing.core.PShapeOBJ;
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @author Martin Prout
|
|
34
|
+
*/
|
|
32
35
|
public class PGraphics3D extends PGraphicsOpenGL {
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
public PGraphics3D() {
|
|
35
41
|
super();
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -57,6 +63,10 @@ public class PGraphics3D extends PGraphicsOpenGL {
|
|
|
57
63
|
|
|
58
64
|
// PROJECTION
|
|
59
65
|
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
|
|
60
70
|
|
|
61
71
|
@Override
|
|
62
72
|
protected void defaultPerspective() {
|
|
@@ -68,6 +78,10 @@ public class PGraphics3D extends PGraphicsOpenGL {
|
|
|
68
78
|
|
|
69
79
|
// CAMERA
|
|
70
80
|
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
|
|
71
85
|
|
|
72
86
|
@Override
|
|
73
87
|
protected void defaultCamera() {
|
|
@@ -79,6 +93,10 @@ public class PGraphics3D extends PGraphicsOpenGL {
|
|
|
79
93
|
|
|
80
94
|
// MATRIX MORE!
|
|
81
95
|
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
|
|
82
100
|
|
|
83
101
|
@Override
|
|
84
102
|
protected void begin2D() {
|
|
@@ -101,8 +119,10 @@ public class PGraphics3D extends PGraphicsOpenGL {
|
|
|
101
119
|
updateProjmodelview();
|
|
102
120
|
}
|
|
103
121
|
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
@Override
|
|
106
126
|
protected void end2D() {
|
|
107
127
|
popMatrix();
|
|
108
128
|
popProjection();
|
|
@@ -114,13 +134,25 @@ public class PGraphics3D extends PGraphicsOpenGL {
|
|
|
114
134
|
|
|
115
135
|
// SHAPE I/O
|
|
116
136
|
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
* @param extension
|
|
140
|
+
* @return
|
|
141
|
+
*/
|
|
142
|
+
|
|
117
143
|
|
|
118
144
|
static protected boolean isSupportedExtension(String extension) {
|
|
119
145
|
return extension.equals("obj");
|
|
120
146
|
}
|
|
121
147
|
|
|
122
|
-
|
|
123
|
-
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
* @param pg
|
|
151
|
+
* @param filename
|
|
152
|
+
* @param extension
|
|
153
|
+
* @return
|
|
154
|
+
*/
|
|
155
|
+
static protected PShape loadShapeImpl(PGraphics pg, String filename,
|
|
124
156
|
String extension) {
|
|
125
157
|
PShapeOBJ obj = null;
|
|
126
158
|
|
|
@@ -95,13 +95,21 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
95
95
|
* endShape) when-full (geometry is accumulated until a maximum size is
|
|
96
96
|
* reached. */
|
|
97
97
|
static protected final int FLUSH_CONTINUOUSLY = 0;
|
|
98
|
-
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
static protected final int FLUSH_WHEN_FULL = 1;
|
|
99
103
|
|
|
100
104
|
/** Type of geometry: immediate is that generated with beginShape/vertex/
|
|
101
105
|
* endShape, retained is the result of creating a PShapeOpenGL object with
|
|
102
106
|
* createShape. */
|
|
103
107
|
static protected final int IMMEDIATE = 0;
|
|
104
|
-
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
*/
|
|
112
|
+
static protected final int RETAINED = 1;
|
|
105
113
|
|
|
106
114
|
/** Current flush mode. */
|
|
107
115
|
protected int flushMode = FLUSH_WHEN_FULL;
|
|
@@ -110,142 +118,436 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
110
118
|
|
|
111
119
|
// VBOs for immediate rendering:
|
|
112
120
|
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
*/
|
|
124
|
+
|
|
113
125
|
protected VertexBuffer bufPolyVertex;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
protected VertexBuffer bufPolyColor;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
protected VertexBuffer bufPolyNormal;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
protected VertexBuffer bufPolyTexcoord;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
protected VertexBuffer bufPolyAmbient;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
protected VertexBuffer bufPolySpecular;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
*/
|
|
155
|
+
protected VertexBuffer bufPolyEmissive;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
*
|
|
159
|
+
*/
|
|
160
|
+
protected VertexBuffer bufPolyShininess;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
protected VertexBuffer bufPolyIndex;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
*/
|
|
170
|
+
protected boolean polyBuffersCreated = false;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
protected int polyBuffersContext;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
*
|
|
179
|
+
*/
|
|
180
|
+
protected VertexBuffer bufLineVertex;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
*
|
|
184
|
+
*/
|
|
185
|
+
protected VertexBuffer bufLineColor;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
*/
|
|
190
|
+
protected VertexBuffer bufLineAttrib;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
*
|
|
194
|
+
*/
|
|
195
|
+
protected VertexBuffer bufLineIndex;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
protected boolean lineBuffersCreated = false;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
*
|
|
204
|
+
*/
|
|
205
|
+
protected int lineBuffersContext;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
*
|
|
209
|
+
*/
|
|
210
|
+
protected VertexBuffer bufPointVertex;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
*
|
|
214
|
+
*/
|
|
215
|
+
protected VertexBuffer bufPointColor;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
*
|
|
219
|
+
*/
|
|
220
|
+
protected VertexBuffer bufPointAttrib;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
*
|
|
224
|
+
*/
|
|
225
|
+
protected VertexBuffer bufPointIndex;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
protected boolean pointBuffersCreated = false;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
*/
|
|
235
|
+
protected int pointBuffersContext;
|
|
138
236
|
|
|
139
237
|
// Generic vertex attributes (only for polys)
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
*
|
|
241
|
+
*/
|
|
140
242
|
protected AttributeMap polyAttribs;
|
|
141
243
|
|
|
142
|
-
|
|
143
|
-
|
|
244
|
+
/**
|
|
245
|
+
*
|
|
246
|
+
*/
|
|
247
|
+
static protected final int INIT_VERTEX_BUFFER_SIZE = 256;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
*
|
|
251
|
+
*/
|
|
252
|
+
static protected final int INIT_INDEX_BUFFER_SIZE = 512;
|
|
144
253
|
|
|
145
254
|
// ........................................................
|
|
146
255
|
|
|
147
256
|
// GL parameters
|
|
148
257
|
|
|
258
|
+
/**
|
|
259
|
+
*
|
|
260
|
+
*/
|
|
261
|
+
|
|
149
262
|
static protected boolean glParamsRead = false;
|
|
150
263
|
|
|
151
264
|
/** Extensions used by Processing */
|
|
152
265
|
static public boolean npotTexSupported;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
*
|
|
269
|
+
*/
|
|
270
|
+
static public boolean autoMipmapGenSupported;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
*
|
|
274
|
+
*/
|
|
275
|
+
static public boolean fboMultisampleSupported;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
280
|
+
static public boolean packedDepthStencilSupported;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
*
|
|
284
|
+
*/
|
|
285
|
+
static public boolean anisoSamplingSupported;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
*
|
|
289
|
+
*/
|
|
290
|
+
static public boolean blendEqSupported;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
*
|
|
294
|
+
*/
|
|
295
|
+
static public boolean readBufferSupported;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
*
|
|
299
|
+
*/
|
|
300
|
+
static public boolean drawBufferSupported;
|
|
160
301
|
|
|
161
302
|
/** Some hardware limits */
|
|
162
303
|
static public int maxTextureSize;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
*
|
|
307
|
+
*/
|
|
308
|
+
static public int maxSamples;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
*
|
|
312
|
+
*/
|
|
313
|
+
static public float maxAnisoAmount;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
*
|
|
317
|
+
*/
|
|
318
|
+
static public int depthBits;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
*
|
|
322
|
+
*/
|
|
323
|
+
static public int stencilBits;
|
|
167
324
|
|
|
168
325
|
/** OpenGL information strings */
|
|
169
326
|
static public String OPENGL_VENDOR;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
*
|
|
330
|
+
*/
|
|
331
|
+
static public String OPENGL_RENDERER;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
*
|
|
335
|
+
*/
|
|
336
|
+
static public String OPENGL_VERSION;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
*
|
|
340
|
+
*/
|
|
341
|
+
static public String OPENGL_EXTENSIONS;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
*
|
|
345
|
+
*/
|
|
346
|
+
static public String GLSL_VERSION;
|
|
174
347
|
|
|
175
348
|
// ........................................................
|
|
176
349
|
|
|
177
350
|
// Shaders
|
|
178
351
|
|
|
352
|
+
/**
|
|
353
|
+
*
|
|
354
|
+
*/
|
|
355
|
+
|
|
179
356
|
static protected URL defColorShaderVertURL =
|
|
180
357
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/ColorVert.glsl");
|
|
181
|
-
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
*
|
|
361
|
+
*/
|
|
362
|
+
static protected URL defTextureShaderVertURL =
|
|
182
363
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexVert.glsl");
|
|
183
|
-
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
*
|
|
367
|
+
*/
|
|
368
|
+
static protected URL defLightShaderVertURL =
|
|
184
369
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LightVert.glsl");
|
|
185
|
-
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
*
|
|
373
|
+
*/
|
|
374
|
+
static protected URL defTexlightShaderVertURL =
|
|
186
375
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexLightVert.glsl");
|
|
187
|
-
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
*
|
|
379
|
+
*/
|
|
380
|
+
static protected URL defColorShaderFragURL =
|
|
188
381
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/ColorFrag.glsl");
|
|
189
|
-
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
*
|
|
385
|
+
*/
|
|
386
|
+
static protected URL defTextureShaderFragURL =
|
|
190
387
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexFrag.glsl");
|
|
191
|
-
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
*
|
|
391
|
+
*/
|
|
392
|
+
static protected URL defLightShaderFragURL =
|
|
192
393
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LightFrag.glsl");
|
|
193
|
-
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
*
|
|
397
|
+
*/
|
|
398
|
+
static protected URL defTexlightShaderFragURL =
|
|
194
399
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexLightFrag.glsl");
|
|
195
400
|
|
|
196
|
-
|
|
401
|
+
/**
|
|
402
|
+
*
|
|
403
|
+
*/
|
|
404
|
+
static protected URL defLineShaderVertURL =
|
|
197
405
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LineVert.glsl");
|
|
198
|
-
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
*
|
|
409
|
+
*/
|
|
410
|
+
static protected URL defLineShaderFragURL =
|
|
199
411
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LineFrag.glsl");
|
|
200
|
-
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
*
|
|
415
|
+
*/
|
|
416
|
+
static protected URL defPointShaderVertURL =
|
|
201
417
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/PointVert.glsl");
|
|
202
|
-
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
*
|
|
421
|
+
*/
|
|
422
|
+
static protected URL defPointShaderFragURL =
|
|
203
423
|
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/PointFrag.glsl");
|
|
204
|
-
static protected URL maskShaderFragURL =
|
|
205
|
-
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/MaskFrag.glsl");
|
|
206
424
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
protected PShader defPointShader;
|
|
213
|
-
protected PShader maskShader;
|
|
425
|
+
/**
|
|
426
|
+
*
|
|
427
|
+
*/
|
|
428
|
+
static protected URL maskShaderFragURL =
|
|
429
|
+
PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/MaskFrag.glsl");
|
|
214
430
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
431
|
+
/**
|
|
432
|
+
*
|
|
433
|
+
*/
|
|
434
|
+
protected PShader defColorShader;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
*
|
|
438
|
+
*/
|
|
439
|
+
protected PShader defTextureShader;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
*
|
|
443
|
+
*/
|
|
444
|
+
protected PShader defLightShader;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
*
|
|
448
|
+
*/
|
|
449
|
+
protected PShader defTexlightShader;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
*
|
|
453
|
+
*/
|
|
454
|
+
protected PShader defLineShader;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
*
|
|
458
|
+
*/
|
|
459
|
+
protected PShader defPointShader;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
*
|
|
463
|
+
*/
|
|
464
|
+
protected PShader maskShader;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
*
|
|
468
|
+
*/
|
|
469
|
+
protected PShader polyShader;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
*
|
|
473
|
+
*/
|
|
474
|
+
protected PShader lineShader;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
*
|
|
478
|
+
*/
|
|
479
|
+
protected PShader pointShader;
|
|
218
480
|
|
|
219
481
|
// ........................................................
|
|
220
482
|
|
|
221
483
|
// Tessellator, geometry
|
|
222
484
|
|
|
485
|
+
/**
|
|
486
|
+
*
|
|
487
|
+
*/
|
|
488
|
+
|
|
223
489
|
protected InGeometry inGeo;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
*
|
|
493
|
+
*/
|
|
494
|
+
protected TessGeometry tessGeo;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
*
|
|
498
|
+
*/
|
|
499
|
+
protected TexCache texCache;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
*
|
|
503
|
+
*/
|
|
504
|
+
protected Tessellator tessellator;
|
|
227
505
|
|
|
228
506
|
// ........................................................
|
|
229
507
|
|
|
230
508
|
// Depth sorter
|
|
231
509
|
|
|
510
|
+
/**
|
|
511
|
+
*
|
|
512
|
+
*/
|
|
513
|
+
|
|
232
514
|
protected DepthSorter sorter;
|
|
233
|
-
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
*
|
|
518
|
+
*/
|
|
519
|
+
protected boolean isDepthSortingEnabled;
|
|
234
520
|
|
|
235
521
|
// ........................................................
|
|
236
522
|
|
|
237
523
|
// Async pixel reader
|
|
238
524
|
|
|
525
|
+
/**
|
|
526
|
+
*
|
|
527
|
+
*/
|
|
528
|
+
|
|
239
529
|
protected AsyncPixelReader asyncPixelReader;
|
|
240
|
-
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
*
|
|
533
|
+
*/
|
|
534
|
+
protected boolean asyncPixelReaderInitialized;
|
|
241
535
|
|
|
242
536
|
// Keeps track of ongoing transfers so they can be finished.
|
|
243
537
|
// Set is copied to the List when we need to iterate it
|
|
244
538
|
// so that readers can remove themselves from the Set during
|
|
245
539
|
// iteration if they don't have any ongoing transfers.
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
*
|
|
543
|
+
*/
|
|
246
544
|
protected static final Set<PGraphicsOpenGL.AsyncPixelReader>
|
|
247
545
|
ongoingPixelTransfers = new HashSet<>();
|
|
248
|
-
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
*
|
|
549
|
+
*/
|
|
550
|
+
protected static final List<PGraphicsOpenGL.AsyncPixelReader>
|
|
249
551
|
ongoingPixelTransfersIterable = new ArrayList<>();
|
|
250
552
|
|
|
251
553
|
// ........................................................
|
|
@@ -264,9 +566,36 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
264
566
|
|
|
265
567
|
/** Default camera properties. */
|
|
266
568
|
public float defCameraFOV;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
*
|
|
572
|
+
*/
|
|
573
|
+
public float defCameraX,
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
*
|
|
577
|
+
*/
|
|
578
|
+
defCameraY,
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
*
|
|
582
|
+
*/
|
|
583
|
+
defCameraZ;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
*
|
|
587
|
+
*/
|
|
588
|
+
public float defCameraNear,
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
*
|
|
592
|
+
*/
|
|
593
|
+
defCameraFar;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
*
|
|
597
|
+
*/
|
|
598
|
+
public float defCameraAspect;
|
|
270
599
|
|
|
271
600
|
/** Distance between camera eye and center. */
|
|
272
601
|
protected float eyeDist;
|
|
@@ -277,20 +606,64 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
277
606
|
// ........................................................
|
|
278
607
|
|
|
279
608
|
// All the matrices required for camera and geometry transformations.
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
*
|
|
612
|
+
*/
|
|
280
613
|
public PMatrix3D projection;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
*
|
|
617
|
+
*/
|
|
618
|
+
public PMatrix3D camera;
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
*
|
|
622
|
+
*/
|
|
623
|
+
public PMatrix3D cameraInv;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
*
|
|
627
|
+
*/
|
|
628
|
+
public PMatrix3D modelview;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
*
|
|
632
|
+
*/
|
|
633
|
+
public PMatrix3D modelviewInv;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
*
|
|
637
|
+
*/
|
|
638
|
+
public PMatrix3D projmodelview;
|
|
286
639
|
|
|
287
640
|
// To pass to shaders
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
*
|
|
644
|
+
*/
|
|
288
645
|
protected float[] glProjection;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
*
|
|
649
|
+
*/
|
|
650
|
+
protected float[] glModelview;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
*
|
|
654
|
+
*/
|
|
655
|
+
protected float[] glProjmodelview;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
*
|
|
659
|
+
*/
|
|
660
|
+
protected float[] glNormal;
|
|
292
661
|
|
|
293
662
|
// Useful to have around.
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
*
|
|
666
|
+
*/
|
|
294
667
|
static protected PMatrix3D identity = new PMatrix3D();
|
|
295
668
|
|
|
296
669
|
/**
|
|
@@ -299,10 +672,20 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
299
672
|
*/
|
|
300
673
|
protected boolean sized;
|
|
301
674
|
|
|
302
|
-
|
|
675
|
+
/**
|
|
676
|
+
*
|
|
677
|
+
*/
|
|
678
|
+
static protected final int MATRIX_STACK_DEPTH = 32;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
*
|
|
682
|
+
*/
|
|
683
|
+
protected int modelviewStackDepth;
|
|
303
684
|
|
|
304
|
-
|
|
305
|
-
|
|
685
|
+
/**
|
|
686
|
+
*
|
|
687
|
+
*/
|
|
688
|
+
protected int projectionStackDepth;
|
|
306
689
|
|
|
307
690
|
/** Modelview matrix stack **/
|
|
308
691
|
protected float[][] modelviewStack = new float[MATRIX_STACK_DEPTH][16];
|
|
@@ -323,8 +706,16 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
323
706
|
|
|
324
707
|
// Lights:
|
|
325
708
|
|
|
709
|
+
/**
|
|
710
|
+
*
|
|
711
|
+
*/
|
|
712
|
+
|
|
326
713
|
public boolean lights;
|
|
327
|
-
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
*
|
|
717
|
+
*/
|
|
718
|
+
public int lightCount = 0;
|
|
328
719
|
|
|
329
720
|
/** Light types */
|
|
330
721
|
public int[] lightType;
|
|
@@ -363,20 +754,40 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
363
754
|
|
|
364
755
|
/** Current light falloff */
|
|
365
756
|
public float currentLightFalloffConstant;
|
|
366
|
-
|
|
367
|
-
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
*
|
|
760
|
+
*/
|
|
761
|
+
public float currentLightFalloffLinear;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
*
|
|
765
|
+
*/
|
|
766
|
+
public float currentLightFalloffQuadratic;
|
|
368
767
|
|
|
369
768
|
// ........................................................
|
|
370
769
|
|
|
371
770
|
// Texturing:
|
|
372
771
|
|
|
772
|
+
/**
|
|
773
|
+
*
|
|
774
|
+
*/
|
|
775
|
+
|
|
373
776
|
protected int textureWrap = CLAMP;
|
|
374
|
-
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
*
|
|
780
|
+
*/
|
|
781
|
+
protected int textureSampling = Texture.TRILINEAR;
|
|
375
782
|
|
|
376
783
|
// ........................................................
|
|
377
784
|
|
|
378
785
|
// Clipping
|
|
379
786
|
|
|
787
|
+
/**
|
|
788
|
+
*
|
|
789
|
+
*/
|
|
790
|
+
|
|
380
791
|
protected boolean clip = false;
|
|
381
792
|
|
|
382
793
|
/** Clipping rectangle. */
|
|
@@ -394,23 +805,61 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
394
805
|
|
|
395
806
|
// Framebuffer stack:
|
|
396
807
|
|
|
808
|
+
/**
|
|
809
|
+
*
|
|
810
|
+
*/
|
|
811
|
+
|
|
397
812
|
static protected final int FB_STACK_DEPTH = 16;
|
|
398
813
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
814
|
+
/**
|
|
815
|
+
*
|
|
816
|
+
*/
|
|
817
|
+
protected int fbStackDepth;
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
*
|
|
821
|
+
*/
|
|
822
|
+
protected FrameBuffer[] fbStack;
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
*
|
|
826
|
+
*/
|
|
827
|
+
protected FrameBuffer drawFramebuffer;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
*
|
|
831
|
+
*/
|
|
832
|
+
protected FrameBuffer readFramebuffer;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
*
|
|
836
|
+
*/
|
|
837
|
+
protected FrameBuffer currentFramebuffer;
|
|
404
838
|
|
|
405
839
|
// .......................................................
|
|
406
840
|
|
|
407
841
|
// Offscreen rendering:
|
|
408
842
|
|
|
843
|
+
/**
|
|
844
|
+
*
|
|
845
|
+
*/
|
|
846
|
+
|
|
409
847
|
protected FrameBuffer offscreenFramebuffer;
|
|
410
|
-
protected FrameBuffer multisampleFramebuffer;
|
|
411
|
-
protected boolean offscreenMultisample;
|
|
412
848
|
|
|
413
|
-
|
|
849
|
+
/**
|
|
850
|
+
*
|
|
851
|
+
*/
|
|
852
|
+
protected FrameBuffer multisampleFramebuffer;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
*
|
|
856
|
+
*/
|
|
857
|
+
protected boolean offscreenMultisample;
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
*
|
|
861
|
+
*/
|
|
862
|
+
protected boolean pixOpChangedFB;
|
|
414
863
|
|
|
415
864
|
// ........................................................
|
|
416
865
|
|
|
@@ -446,8 +895,16 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
446
895
|
|
|
447
896
|
/** Used to detect continuous use of the smooth/noSmooth functions */
|
|
448
897
|
protected boolean smoothDisabled = false;
|
|
449
|
-
|
|
450
|
-
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
*
|
|
901
|
+
*/
|
|
902
|
+
protected int smoothCallCount = 0;
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
*
|
|
906
|
+
*/
|
|
907
|
+
protected int lastSmoothCall = -10;
|
|
451
908
|
|
|
452
909
|
/** Used to avoid flushing the geometry when blendMode() is called with the
|
|
453
910
|
* same blend mode as the last */
|
|
@@ -455,22 +912,64 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
455
912
|
|
|
456
913
|
/** Type of pixels operation. */
|
|
457
914
|
static protected final int OP_NONE = 0;
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
*
|
|
918
|
+
*/
|
|
919
|
+
static protected final int OP_READ = 1;
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
*
|
|
923
|
+
*/
|
|
924
|
+
static protected final int OP_WRITE = 2;
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
*
|
|
928
|
+
*/
|
|
929
|
+
protected int pixelsOp = OP_NONE;
|
|
461
930
|
|
|
462
931
|
/** Viewport dimensions. */
|
|
463
932
|
protected IntBuffer viewport;
|
|
464
933
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
934
|
+
/**
|
|
935
|
+
*
|
|
936
|
+
*/
|
|
937
|
+
protected boolean openContour = false;
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
*
|
|
941
|
+
*/
|
|
942
|
+
protected boolean breakShape = false;
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
*
|
|
946
|
+
*/
|
|
947
|
+
protected boolean defaultEdges = false;
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
*
|
|
951
|
+
*/
|
|
952
|
+
static protected final int EDGE_MIDDLE = 0;
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
*
|
|
956
|
+
*/
|
|
957
|
+
static protected final int EDGE_START = 1;
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
*
|
|
961
|
+
*/
|
|
962
|
+
static protected final int EDGE_STOP = 2;
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
*
|
|
966
|
+
*/
|
|
967
|
+
static protected final int EDGE_SINGLE = 3;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
*
|
|
971
|
+
*/
|
|
972
|
+
static protected final int EDGE_CLOSE = -1;
|
|
474
973
|
|
|
475
974
|
/** Used in round point and ellipse tessellation. The
|
|
476
975
|
* number of subdivisions per round point or ellipse is
|
|
@@ -485,8 +984,16 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
485
984
|
* F = POINT_ACCURACY_FACTOR
|
|
486
985
|
*/
|
|
487
986
|
final static protected int MIN_POINT_ACCURACY = 20;
|
|
488
|
-
|
|
489
|
-
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
*
|
|
990
|
+
*/
|
|
991
|
+
final static protected int MAX_POINT_ACCURACY = 200;
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
*
|
|
995
|
+
*/
|
|
996
|
+
final static protected float POINT_ACCURACY_FACTOR = 10.0f;
|
|
490
997
|
|
|
491
998
|
/** Used in quad point tessellation. */
|
|
492
999
|
final static protected float[][] QUAD_POINT_SIGNS =
|
|
@@ -494,7 +1001,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
494
1001
|
|
|
495
1002
|
/** To get data from OpenGL. */
|
|
496
1003
|
static protected IntBuffer intBuffer;
|
|
497
|
-
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
*
|
|
1007
|
+
*/
|
|
1008
|
+
static protected FloatBuffer floatBuffer;
|
|
498
1009
|
|
|
499
1010
|
// ........................................................
|
|
500
1011
|
|
|
@@ -564,8 +1075,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
564
1075
|
|
|
565
1076
|
// INIT/ALLOCATE/FINISH
|
|
566
1077
|
|
|
567
|
-
|
|
568
|
-
|
|
1078
|
+
/**
|
|
1079
|
+
*
|
|
1080
|
+
*/
|
|
1081
|
+
public PGraphicsOpenGL() {
|
|
569
1082
|
pgl = createPGL(this);
|
|
570
1083
|
|
|
571
1084
|
if (intBuffer == null) {
|
|
@@ -685,13 +1198,18 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
685
1198
|
super.dispose();
|
|
686
1199
|
}
|
|
687
1200
|
|
|
688
|
-
|
|
689
|
-
|
|
1201
|
+
/**
|
|
1202
|
+
*
|
|
1203
|
+
* @param mode
|
|
1204
|
+
*/
|
|
1205
|
+
protected void setFlushMode(int mode) {
|
|
690
1206
|
flushMode = mode;
|
|
691
1207
|
}
|
|
692
1208
|
|
|
693
|
-
|
|
694
|
-
|
|
1209
|
+
/**
|
|
1210
|
+
*
|
|
1211
|
+
*/
|
|
1212
|
+
protected void updatePixelSize() {
|
|
695
1213
|
float f = pgl.getPixelScale();
|
|
696
1214
|
pixelWidth = (int)(width * f);
|
|
697
1215
|
pixelHeight = (int)(height * f);
|
|
@@ -708,6 +1226,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
708
1226
|
|
|
709
1227
|
|
|
710
1228
|
// Factory method
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
*
|
|
1232
|
+
* @param pg
|
|
1233
|
+
* @return
|
|
1234
|
+
*/
|
|
711
1235
|
protected PGL createPGL(PGraphicsOpenGL pg) {
|
|
712
1236
|
return new PJOGL(pg);
|
|
713
1237
|
// return new PGLES(pg);
|
|
@@ -750,8 +1274,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
750
1274
|
return surface = new PSurfaceJOGL(this);
|
|
751
1275
|
}
|
|
752
1276
|
|
|
753
|
-
|
|
754
|
-
|
|
1277
|
+
/**
|
|
1278
|
+
*
|
|
1279
|
+
* @param filename
|
|
1280
|
+
* @return
|
|
1281
|
+
*/
|
|
1282
|
+
public boolean saveImpl(String filename) {
|
|
755
1283
|
// return super.save(filename); // ASYNC save frame using PBOs not yet available on Android
|
|
756
1284
|
|
|
757
1285
|
if (getHint(DISABLE_ASYNC_SAVEFRAME)) {
|
|
@@ -846,24 +1374,41 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
846
1374
|
|
|
847
1375
|
//////////////////////////////////////////////////////////////
|
|
848
1376
|
|
|
1377
|
+
/**
|
|
1378
|
+
*
|
|
1379
|
+
* @param font
|
|
1380
|
+
* @param fontTexture
|
|
1381
|
+
*/
|
|
1382
|
+
|
|
849
1383
|
|
|
850
1384
|
protected void setFontTexture(PFont font, FontTexture fontTexture) {
|
|
851
1385
|
getPrimaryPG().fontMap.put(font, fontTexture);
|
|
852
1386
|
}
|
|
853
1387
|
|
|
854
|
-
|
|
855
|
-
|
|
1388
|
+
/**
|
|
1389
|
+
*
|
|
1390
|
+
* @param font
|
|
1391
|
+
* @return
|
|
1392
|
+
*/
|
|
1393
|
+
protected FontTexture getFontTexture(PFont font) {
|
|
856
1394
|
return getPrimaryPG().fontMap.get(font);
|
|
857
1395
|
}
|
|
858
1396
|
|
|
859
|
-
|
|
860
|
-
|
|
1397
|
+
/**
|
|
1398
|
+
*
|
|
1399
|
+
* @param font
|
|
1400
|
+
*/
|
|
1401
|
+
protected void removeFontTexture(PFont font) {
|
|
861
1402
|
getPrimaryPG().fontMap.remove(font);
|
|
862
1403
|
}
|
|
863
1404
|
|
|
864
1405
|
|
|
865
1406
|
//////////////////////////////////////////////////////////////
|
|
866
1407
|
|
|
1408
|
+
/**
|
|
1409
|
+
*
|
|
1410
|
+
*/
|
|
1411
|
+
|
|
867
1412
|
|
|
868
1413
|
protected static class GLResourceTexture extends Disposable<Texture> {
|
|
869
1414
|
int glName;
|
|
@@ -871,7 +1416,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
871
1416
|
private PGL pgl;
|
|
872
1417
|
private int context;
|
|
873
1418
|
|
|
874
|
-
|
|
1419
|
+
/**
|
|
1420
|
+
*
|
|
1421
|
+
* @param tex
|
|
1422
|
+
*/
|
|
1423
|
+
public GLResourceTexture(Texture tex) {
|
|
875
1424
|
super(tex);
|
|
876
1425
|
|
|
877
1426
|
|
|
@@ -883,7 +1432,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
883
1432
|
this.context = tex.context;
|
|
884
1433
|
}
|
|
885
1434
|
|
|
886
|
-
|
|
1435
|
+
/**
|
|
1436
|
+
*
|
|
1437
|
+
*/
|
|
1438
|
+
@Override
|
|
887
1439
|
public void disposeNative() {
|
|
888
1440
|
if (pgl != null) {
|
|
889
1441
|
if (glName != 0) {
|
|
@@ -895,7 +1447,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
895
1447
|
}
|
|
896
1448
|
}
|
|
897
1449
|
|
|
898
|
-
|
|
1450
|
+
/**
|
|
1451
|
+
*
|
|
1452
|
+
* @param obj
|
|
1453
|
+
* @return
|
|
1454
|
+
*/
|
|
1455
|
+
@Override
|
|
899
1456
|
public boolean equals(Object obj) {
|
|
900
1457
|
if (!(obj instanceof GLResourceTexture)) {
|
|
901
1458
|
return false;
|
|
@@ -905,7 +1462,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
905
1462
|
other.context == context;
|
|
906
1463
|
}
|
|
907
1464
|
|
|
908
|
-
|
|
1465
|
+
/**
|
|
1466
|
+
*
|
|
1467
|
+
* @return
|
|
1468
|
+
*/
|
|
1469
|
+
@Override
|
|
909
1470
|
public int hashCode() {
|
|
910
1471
|
int result = 17;
|
|
911
1472
|
result = 31 * result + glName;
|
|
@@ -914,14 +1475,20 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
914
1475
|
}
|
|
915
1476
|
}
|
|
916
1477
|
|
|
917
|
-
|
|
918
|
-
|
|
1478
|
+
/**
|
|
1479
|
+
*
|
|
1480
|
+
*/
|
|
1481
|
+
protected static class GLResourceVertexBuffer extends Disposable<VertexBuffer> {
|
|
919
1482
|
int glId;
|
|
920
1483
|
|
|
921
1484
|
private PGL pgl;
|
|
922
1485
|
private int context;
|
|
923
1486
|
|
|
924
|
-
|
|
1487
|
+
/**
|
|
1488
|
+
*
|
|
1489
|
+
* @param vbo
|
|
1490
|
+
*/
|
|
1491
|
+
public GLResourceVertexBuffer(VertexBuffer vbo) {
|
|
925
1492
|
super(vbo);
|
|
926
1493
|
|
|
927
1494
|
pgl = vbo.pgl.graphics.getPrimaryPGL();
|
|
@@ -932,7 +1499,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
932
1499
|
this.context = vbo.context;
|
|
933
1500
|
}
|
|
934
1501
|
|
|
935
|
-
|
|
1502
|
+
/**
|
|
1503
|
+
*
|
|
1504
|
+
*/
|
|
1505
|
+
@Override
|
|
936
1506
|
public void disposeNative() {
|
|
937
1507
|
if (pgl != null) {
|
|
938
1508
|
if (glId != 0) {
|
|
@@ -944,7 +1514,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
944
1514
|
}
|
|
945
1515
|
}
|
|
946
1516
|
|
|
947
|
-
|
|
1517
|
+
/**
|
|
1518
|
+
*
|
|
1519
|
+
* @param obj
|
|
1520
|
+
* @return
|
|
1521
|
+
*/
|
|
1522
|
+
@Override
|
|
948
1523
|
public boolean equals(Object obj) {
|
|
949
1524
|
if (!(obj instanceof GLResourceVertexBuffer)) {
|
|
950
1525
|
return false;
|
|
@@ -954,7 +1529,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
954
1529
|
other.context == context;
|
|
955
1530
|
}
|
|
956
1531
|
|
|
957
|
-
|
|
1532
|
+
/**
|
|
1533
|
+
*
|
|
1534
|
+
* @return
|
|
1535
|
+
*/
|
|
1536
|
+
@Override
|
|
958
1537
|
public int hashCode() {
|
|
959
1538
|
int result = 17;
|
|
960
1539
|
result = 31 * result + glId;
|
|
@@ -963,8 +1542,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
963
1542
|
}
|
|
964
1543
|
}
|
|
965
1544
|
|
|
966
|
-
|
|
967
|
-
|
|
1545
|
+
/**
|
|
1546
|
+
*
|
|
1547
|
+
*/
|
|
1548
|
+
protected static class GLResourceShader extends Disposable<PShader> {
|
|
968
1549
|
int glProgram;
|
|
969
1550
|
int glVertex;
|
|
970
1551
|
int glFragment;
|
|
@@ -972,7 +1553,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
972
1553
|
private PGL pgl;
|
|
973
1554
|
private int context;
|
|
974
1555
|
|
|
975
|
-
|
|
1556
|
+
/**
|
|
1557
|
+
*
|
|
1558
|
+
* @param sh
|
|
1559
|
+
*/
|
|
1560
|
+
public GLResourceShader(PShader sh) {
|
|
976
1561
|
super(sh);
|
|
977
1562
|
|
|
978
1563
|
this.pgl = sh.pgl.graphics.getPrimaryPGL();
|
|
@@ -987,7 +1572,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
987
1572
|
this.context = sh.context;
|
|
988
1573
|
}
|
|
989
1574
|
|
|
990
|
-
|
|
1575
|
+
/**
|
|
1576
|
+
*
|
|
1577
|
+
*/
|
|
1578
|
+
@Override
|
|
991
1579
|
public void disposeNative() {
|
|
992
1580
|
if (pgl != null) {
|
|
993
1581
|
if (glFragment != 0) {
|
|
@@ -1006,7 +1594,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1006
1594
|
}
|
|
1007
1595
|
}
|
|
1008
1596
|
|
|
1009
|
-
|
|
1597
|
+
/**
|
|
1598
|
+
*
|
|
1599
|
+
* @param obj
|
|
1600
|
+
* @return
|
|
1601
|
+
*/
|
|
1602
|
+
@Override
|
|
1010
1603
|
public boolean equals(Object obj) {
|
|
1011
1604
|
if (!(obj instanceof GLResourceShader)) {
|
|
1012
1605
|
return false;
|
|
@@ -1018,7 +1611,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1018
1611
|
other.context == context;
|
|
1019
1612
|
}
|
|
1020
1613
|
|
|
1021
|
-
|
|
1614
|
+
/**
|
|
1615
|
+
*
|
|
1616
|
+
* @return
|
|
1617
|
+
*/
|
|
1618
|
+
@Override
|
|
1022
1619
|
public int hashCode() {
|
|
1023
1620
|
int result = 17;
|
|
1024
1621
|
result = 31 * result + glProgram;
|
|
@@ -1029,8 +1626,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1029
1626
|
}
|
|
1030
1627
|
}
|
|
1031
1628
|
|
|
1032
|
-
|
|
1033
|
-
|
|
1629
|
+
/**
|
|
1630
|
+
*
|
|
1631
|
+
*/
|
|
1632
|
+
protected static class GLResourceFrameBuffer extends Disposable<FrameBuffer> {
|
|
1034
1633
|
int glFbo;
|
|
1035
1634
|
int glDepth;
|
|
1036
1635
|
int glStencil;
|
|
@@ -1040,7 +1639,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1040
1639
|
private PGL pgl;
|
|
1041
1640
|
private int context;
|
|
1042
1641
|
|
|
1043
|
-
|
|
1642
|
+
/**
|
|
1643
|
+
*
|
|
1644
|
+
* @param fb
|
|
1645
|
+
*/
|
|
1646
|
+
public GLResourceFrameBuffer(FrameBuffer fb) {
|
|
1044
1647
|
super(fb);
|
|
1045
1648
|
|
|
1046
1649
|
pgl = fb.pg.getPrimaryPGL();
|
|
@@ -1077,7 +1680,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1077
1680
|
this.context = fb.context;
|
|
1078
1681
|
}
|
|
1079
1682
|
|
|
1080
|
-
|
|
1683
|
+
/**
|
|
1684
|
+
*
|
|
1685
|
+
*/
|
|
1686
|
+
@Override
|
|
1081
1687
|
public void disposeNative() {
|
|
1082
1688
|
if (pgl != null) {
|
|
1083
1689
|
if (glFbo != 0) {
|
|
@@ -1109,7 +1715,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1109
1715
|
}
|
|
1110
1716
|
}
|
|
1111
1717
|
|
|
1112
|
-
|
|
1718
|
+
/**
|
|
1719
|
+
*
|
|
1720
|
+
* @param obj
|
|
1721
|
+
* @return
|
|
1722
|
+
*/
|
|
1723
|
+
@Override
|
|
1113
1724
|
public boolean equals(Object obj) {
|
|
1114
1725
|
if (!(obj instanceof GLResourceFrameBuffer)) {
|
|
1115
1726
|
return false;
|
|
@@ -1123,7 +1734,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1123
1734
|
other.context == context;
|
|
1124
1735
|
}
|
|
1125
1736
|
|
|
1126
|
-
|
|
1737
|
+
/**
|
|
1738
|
+
*
|
|
1739
|
+
* @return
|
|
1740
|
+
*/
|
|
1741
|
+
@Override
|
|
1127
1742
|
public int hashCode() {
|
|
1128
1743
|
int result = 17;
|
|
1129
1744
|
result = 31 * result + glFbo;
|
|
@@ -1141,6 +1756,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1141
1756
|
|
|
1142
1757
|
// FRAMEBUFFERS
|
|
1143
1758
|
|
|
1759
|
+
/**
|
|
1760
|
+
*
|
|
1761
|
+
*/
|
|
1762
|
+
|
|
1144
1763
|
|
|
1145
1764
|
protected void pushFramebuffer() {
|
|
1146
1765
|
PGraphicsOpenGL ppg = getPrimaryPG();
|
|
@@ -1151,8 +1770,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1151
1770
|
ppg.fbStackDepth++;
|
|
1152
1771
|
}
|
|
1153
1772
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1773
|
+
/**
|
|
1774
|
+
*
|
|
1775
|
+
* @param fbo
|
|
1776
|
+
*/
|
|
1777
|
+
protected void setFramebuffer(FrameBuffer fbo) {
|
|
1156
1778
|
PGraphicsOpenGL ppg = getPrimaryPG();
|
|
1157
1779
|
if (ppg.currentFramebuffer != fbo) {
|
|
1158
1780
|
ppg.currentFramebuffer = fbo;
|
|
@@ -1160,8 +1782,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1160
1782
|
}
|
|
1161
1783
|
}
|
|
1162
1784
|
|
|
1163
|
-
|
|
1164
|
-
|
|
1785
|
+
/**
|
|
1786
|
+
*
|
|
1787
|
+
*/
|
|
1788
|
+
protected void popFramebuffer() {
|
|
1165
1789
|
PGraphicsOpenGL ppg = getPrimaryPG();
|
|
1166
1790
|
if (ppg.fbStackDepth == 0) {
|
|
1167
1791
|
throw new RuntimeException("popFramebuffer call is unbalanced.");
|
|
@@ -1175,8 +1799,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1175
1799
|
}
|
|
1176
1800
|
}
|
|
1177
1801
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1802
|
+
/**
|
|
1803
|
+
*
|
|
1804
|
+
* @return
|
|
1805
|
+
*/
|
|
1806
|
+
protected FrameBuffer getCurrentFB() {
|
|
1180
1807
|
return getPrimaryPG().currentFramebuffer;
|
|
1181
1808
|
}
|
|
1182
1809
|
|
|
@@ -1185,6 +1812,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1185
1812
|
|
|
1186
1813
|
// FRAME RENDERING
|
|
1187
1814
|
|
|
1815
|
+
/**
|
|
1816
|
+
*
|
|
1817
|
+
*/
|
|
1818
|
+
|
|
1188
1819
|
|
|
1189
1820
|
protected void createPolyBuffers() {
|
|
1190
1821
|
if (!polyBuffersCreated || polyBuffersContextIsOutdated()) {
|
|
@@ -1216,8 +1847,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1216
1847
|
if (created) pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
|
|
1217
1848
|
}
|
|
1218
1849
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1850
|
+
/**
|
|
1851
|
+
*
|
|
1852
|
+
* @param lit
|
|
1853
|
+
* @param tex
|
|
1854
|
+
* @param needNormals
|
|
1855
|
+
* @param needTexCoords
|
|
1856
|
+
*/
|
|
1857
|
+
protected void updatePolyBuffers(boolean lit, boolean tex,
|
|
1221
1858
|
boolean needNormals, boolean needTexCoords) {
|
|
1222
1859
|
createPolyBuffers();
|
|
1223
1860
|
|
|
@@ -1286,19 +1923,26 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1286
1923
|
PGL.STATIC_DRAW);
|
|
1287
1924
|
}
|
|
1288
1925
|
|
|
1289
|
-
|
|
1290
|
-
|
|
1926
|
+
/**
|
|
1927
|
+
*
|
|
1928
|
+
*/
|
|
1929
|
+
protected void unbindPolyBuffers() {
|
|
1291
1930
|
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
|
|
1292
1931
|
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
|
|
1293
1932
|
}
|
|
1294
1933
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1934
|
+
/**
|
|
1935
|
+
*
|
|
1936
|
+
* @return
|
|
1937
|
+
*/
|
|
1938
|
+
protected boolean polyBuffersContextIsOutdated() {
|
|
1297
1939
|
return !pgl.contextIsCurrent(polyBuffersContext);
|
|
1298
1940
|
}
|
|
1299
1941
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1942
|
+
/**
|
|
1943
|
+
*
|
|
1944
|
+
*/
|
|
1945
|
+
protected void createLineBuffers() {
|
|
1302
1946
|
if (!lineBuffersCreated || lineBufferContextIsOutdated()) {
|
|
1303
1947
|
lineBuffersContext = pgl.getCurrentContext();
|
|
1304
1948
|
|
|
@@ -1313,8 +1957,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1313
1957
|
}
|
|
1314
1958
|
}
|
|
1315
1959
|
|
|
1316
|
-
|
|
1317
|
-
|
|
1960
|
+
/**
|
|
1961
|
+
*
|
|
1962
|
+
*/
|
|
1963
|
+
protected void updateLineBuffers() {
|
|
1318
1964
|
createLineBuffers();
|
|
1319
1965
|
|
|
1320
1966
|
int size = tessGeo.lineVertexCount;
|
|
@@ -1345,19 +1991,26 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1345
1991
|
tessGeo.lineIndicesBuffer, PGL.STATIC_DRAW);
|
|
1346
1992
|
}
|
|
1347
1993
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1994
|
+
/**
|
|
1995
|
+
*
|
|
1996
|
+
*/
|
|
1997
|
+
protected void unbindLineBuffers() {
|
|
1350
1998
|
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
|
|
1351
1999
|
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
|
|
1352
2000
|
}
|
|
1353
2001
|
|
|
1354
|
-
|
|
1355
|
-
|
|
2002
|
+
/**
|
|
2003
|
+
*
|
|
2004
|
+
* @return
|
|
2005
|
+
*/
|
|
2006
|
+
protected boolean lineBufferContextIsOutdated() {
|
|
1356
2007
|
return !pgl.contextIsCurrent(lineBuffersContext);
|
|
1357
2008
|
}
|
|
1358
2009
|
|
|
1359
|
-
|
|
1360
|
-
|
|
2010
|
+
/**
|
|
2011
|
+
*
|
|
2012
|
+
*/
|
|
2013
|
+
protected void createPointBuffers() {
|
|
1361
2014
|
if (!pointBuffersCreated || pointBuffersContextIsOutdated()) {
|
|
1362
2015
|
pointBuffersContext = pgl.getCurrentContext();
|
|
1363
2016
|
|
|
@@ -1372,8 +2025,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1372
2025
|
}
|
|
1373
2026
|
}
|
|
1374
2027
|
|
|
1375
|
-
|
|
1376
|
-
|
|
2028
|
+
/**
|
|
2029
|
+
*
|
|
2030
|
+
*/
|
|
2031
|
+
protected void updatePointBuffers() {
|
|
1377
2032
|
createPointBuffers();
|
|
1378
2033
|
|
|
1379
2034
|
int size = tessGeo.pointVertexCount;
|
|
@@ -1402,14 +2057,19 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1402
2057
|
tessGeo.pointIndicesBuffer, PGL.STATIC_DRAW);
|
|
1403
2058
|
}
|
|
1404
2059
|
|
|
1405
|
-
|
|
1406
|
-
|
|
2060
|
+
/**
|
|
2061
|
+
*
|
|
2062
|
+
*/
|
|
2063
|
+
protected void unbindPointBuffers() {
|
|
1407
2064
|
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
|
|
1408
2065
|
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
|
|
1409
2066
|
}
|
|
1410
2067
|
|
|
1411
|
-
|
|
1412
|
-
|
|
2068
|
+
/**
|
|
2069
|
+
*
|
|
2070
|
+
* @return
|
|
2071
|
+
*/
|
|
2072
|
+
protected boolean pointBuffersContextIsOutdated() {
|
|
1413
2073
|
return !pgl.contextIsCurrent(pointBuffersContext);
|
|
1414
2074
|
}
|
|
1415
2075
|
|
|
@@ -1495,8 +2155,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1495
2155
|
report("bot endDraw()");
|
|
1496
2156
|
}
|
|
1497
2157
|
|
|
1498
|
-
|
|
1499
|
-
|
|
2158
|
+
/**
|
|
2159
|
+
*
|
|
2160
|
+
* @return
|
|
2161
|
+
*/
|
|
2162
|
+
protected PGraphicsOpenGL getPrimaryPG() {
|
|
1500
2163
|
if (primaryGraphics) {
|
|
1501
2164
|
return this;
|
|
1502
2165
|
} else {
|
|
@@ -1504,19 +2167,34 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1504
2167
|
}
|
|
1505
2168
|
}
|
|
1506
2169
|
|
|
1507
|
-
|
|
2170
|
+
/**
|
|
2171
|
+
*
|
|
2172
|
+
* @param pg
|
|
2173
|
+
*/
|
|
2174
|
+
protected void setCurrentPG(PGraphicsOpenGL pg) {
|
|
1508
2175
|
currentPG = pg;
|
|
1509
2176
|
}
|
|
1510
2177
|
|
|
1511
|
-
|
|
2178
|
+
/**
|
|
2179
|
+
*
|
|
2180
|
+
*/
|
|
2181
|
+
protected void setCurrentPG() {
|
|
1512
2182
|
currentPG = this;
|
|
1513
2183
|
}
|
|
1514
2184
|
|
|
1515
|
-
|
|
2185
|
+
/**
|
|
2186
|
+
*
|
|
2187
|
+
* @return
|
|
2188
|
+
*/
|
|
2189
|
+
protected PGraphicsOpenGL getCurrentPG() {
|
|
1516
2190
|
return currentPG;
|
|
1517
2191
|
}
|
|
1518
2192
|
|
|
1519
|
-
|
|
2193
|
+
/**
|
|
2194
|
+
*
|
|
2195
|
+
* @return
|
|
2196
|
+
*/
|
|
2197
|
+
protected PGL getPrimaryPGL() {
|
|
1520
2198
|
if (primaryGraphics) {
|
|
1521
2199
|
return pgl;
|
|
1522
2200
|
} else {
|
|
@@ -1539,19 +2217,25 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1539
2217
|
restoreGL();
|
|
1540
2218
|
}
|
|
1541
2219
|
|
|
1542
|
-
|
|
1543
|
-
|
|
2220
|
+
/**
|
|
2221
|
+
*
|
|
2222
|
+
*/
|
|
2223
|
+
public void updateProjmodelview() {
|
|
1544
2224
|
projmodelview.set(projection);
|
|
1545
2225
|
projmodelview.apply(modelview);
|
|
1546
2226
|
}
|
|
1547
2227
|
|
|
1548
|
-
|
|
1549
|
-
|
|
2228
|
+
/**
|
|
2229
|
+
*
|
|
2230
|
+
*/
|
|
2231
|
+
protected void restartPGL() {
|
|
1550
2232
|
initialized = false;
|
|
1551
2233
|
}
|
|
1552
2234
|
|
|
1553
|
-
|
|
1554
|
-
|
|
2235
|
+
/**
|
|
2236
|
+
*
|
|
2237
|
+
*/
|
|
2238
|
+
protected void restoreGL() {
|
|
1555
2239
|
blendMode(blendMode); // this should be set by reapplySettings...
|
|
1556
2240
|
|
|
1557
2241
|
if (hints[DISABLE_DEPTH_TEST]) {
|
|
@@ -1599,11 +2283,21 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1599
2283
|
}
|
|
1600
2284
|
}
|
|
1601
2285
|
|
|
1602
|
-
|
|
2286
|
+
/**
|
|
2287
|
+
*
|
|
2288
|
+
* @param target
|
|
2289
|
+
* @param framebuffer
|
|
2290
|
+
*/
|
|
2291
|
+
protected void beginBindFramebuffer(int target, int framebuffer) {
|
|
1603
2292
|
// Actually, nothing to do here.
|
|
1604
2293
|
}
|
|
1605
2294
|
|
|
1606
|
-
|
|
2295
|
+
/**
|
|
2296
|
+
*
|
|
2297
|
+
* @param target
|
|
2298
|
+
* @param framebuffer
|
|
2299
|
+
*/
|
|
2300
|
+
protected void endBindFramebuffer(int target, int framebuffer) {
|
|
1607
2301
|
FrameBuffer fb = getCurrentFB();
|
|
1608
2302
|
if (framebuffer == 0 && fb != null && fb.glFbo != 0) {
|
|
1609
2303
|
// The user is setting the framebuffer to 0 (screen buffer), but the
|
|
@@ -1612,15 +2306,25 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1612
2306
|
}
|
|
1613
2307
|
}
|
|
1614
2308
|
|
|
1615
|
-
|
|
2309
|
+
/**
|
|
2310
|
+
*
|
|
2311
|
+
*/
|
|
2312
|
+
protected void beginReadPixels() {
|
|
1616
2313
|
beginPixelsOp(OP_READ);
|
|
1617
2314
|
}
|
|
1618
2315
|
|
|
1619
|
-
|
|
2316
|
+
/**
|
|
2317
|
+
*
|
|
2318
|
+
*/
|
|
2319
|
+
protected void endReadPixels() {
|
|
1620
2320
|
endPixelsOp();
|
|
1621
2321
|
}
|
|
1622
2322
|
|
|
1623
|
-
|
|
2323
|
+
/**
|
|
2324
|
+
*
|
|
2325
|
+
* @param op
|
|
2326
|
+
*/
|
|
2327
|
+
protected void beginPixelsOp(int op) {
|
|
1624
2328
|
FrameBuffer pixfb = null;
|
|
1625
2329
|
FrameBuffer currfb = getCurrentFB();
|
|
1626
2330
|
if (primaryGraphics) {
|
|
@@ -1687,8 +2391,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1687
2391
|
pixelsOp = op;
|
|
1688
2392
|
}
|
|
1689
2393
|
|
|
1690
|
-
|
|
1691
|
-
|
|
2394
|
+
/**
|
|
2395
|
+
*
|
|
2396
|
+
*/
|
|
2397
|
+
protected void endPixelsOp() {
|
|
1692
2398
|
// Restoring current framebuffer prior to the pixel operation
|
|
1693
2399
|
if (pixOpChangedFB) {
|
|
1694
2400
|
popFramebuffer();
|
|
@@ -1702,8 +2408,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1702
2408
|
pixelsOp = OP_NONE;
|
|
1703
2409
|
}
|
|
1704
2410
|
|
|
1705
|
-
|
|
1706
|
-
|
|
2411
|
+
/**
|
|
2412
|
+
*
|
|
2413
|
+
*/
|
|
2414
|
+
protected void updateGLProjection() {
|
|
1707
2415
|
if (glProjection == null) {
|
|
1708
2416
|
glProjection = new float[16];
|
|
1709
2417
|
}
|
|
@@ -1729,8 +2437,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1729
2437
|
glProjection[15] = projection.m33;
|
|
1730
2438
|
}
|
|
1731
2439
|
|
|
1732
|
-
|
|
1733
|
-
|
|
2440
|
+
/**
|
|
2441
|
+
*
|
|
2442
|
+
*/
|
|
2443
|
+
protected void updateGLModelview() {
|
|
1734
2444
|
if (glModelview == null) {
|
|
1735
2445
|
glModelview = new float[16];
|
|
1736
2446
|
}
|
|
@@ -1756,8 +2466,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1756
2466
|
glModelview[15] = modelview.m33;
|
|
1757
2467
|
}
|
|
1758
2468
|
|
|
1759
|
-
|
|
1760
|
-
|
|
2469
|
+
/**
|
|
2470
|
+
*
|
|
2471
|
+
*/
|
|
2472
|
+
protected void updateGLProjmodelview() {
|
|
1761
2473
|
if (glProjmodelview == null) {
|
|
1762
2474
|
glProjmodelview = new float[16];
|
|
1763
2475
|
}
|
|
@@ -1783,8 +2495,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1783
2495
|
glProjmodelview[15] = projmodelview.m33;
|
|
1784
2496
|
}
|
|
1785
2497
|
|
|
1786
|
-
|
|
1787
|
-
|
|
2498
|
+
/**
|
|
2499
|
+
*
|
|
2500
|
+
*/
|
|
2501
|
+
protected void updateGLNormal() {
|
|
1788
2502
|
if (glNormal == null) {
|
|
1789
2503
|
glNormal = new float[9];
|
|
1790
2504
|
}
|
|
@@ -1903,8 +2617,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1903
2617
|
}
|
|
1904
2618
|
}
|
|
1905
2619
|
|
|
1906
|
-
|
|
1907
|
-
|
|
2620
|
+
/**
|
|
2621
|
+
*
|
|
2622
|
+
* @param which
|
|
2623
|
+
* @return
|
|
2624
|
+
*/
|
|
2625
|
+
protected boolean getHint(int which) {
|
|
1908
2626
|
if (which > 0) {
|
|
1909
2627
|
return hints[which];
|
|
1910
2628
|
} else {
|
|
@@ -1973,8 +2691,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
1973
2691
|
}
|
|
1974
2692
|
}
|
|
1975
2693
|
|
|
1976
|
-
|
|
1977
|
-
|
|
2694
|
+
/**
|
|
2695
|
+
*
|
|
2696
|
+
* @param indices
|
|
2697
|
+
*/
|
|
2698
|
+
protected void endShape(int[] indices) {
|
|
1978
2699
|
if (shape != TRIANGLE && shape != TRIANGLES) {
|
|
1979
2700
|
throw new RuntimeException("Indices and edges can only be set for " +
|
|
1980
2701
|
"TRIANGLE shapes");
|
|
@@ -2000,8 +2721,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2000
2721
|
this.textureWrap = wrap;
|
|
2001
2722
|
}
|
|
2002
2723
|
|
|
2003
|
-
|
|
2004
|
-
|
|
2724
|
+
/**
|
|
2725
|
+
*
|
|
2726
|
+
* @param sampling
|
|
2727
|
+
*/
|
|
2728
|
+
public void textureSampling(int sampling) {
|
|
2005
2729
|
this.textureSampling = sampling;
|
|
2006
2730
|
}
|
|
2007
2731
|
|
|
@@ -2099,8 +2823,15 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2099
2823
|
if (attrib != null) attrib.set(values);
|
|
2100
2824
|
}
|
|
2101
2825
|
|
|
2102
|
-
|
|
2103
|
-
|
|
2826
|
+
/**
|
|
2827
|
+
*
|
|
2828
|
+
* @param name
|
|
2829
|
+
* @param kind
|
|
2830
|
+
* @param type
|
|
2831
|
+
* @param size
|
|
2832
|
+
* @return
|
|
2833
|
+
*/
|
|
2834
|
+
protected VertexAttribute attribImpl(String name, int kind, int type, int size) {
|
|
2104
2835
|
if (4 < size) {
|
|
2105
2836
|
PGraphics.showWarning("Vertex attributes cannot have more than 4 values");
|
|
2106
2837
|
return null;
|
|
@@ -2127,8 +2858,15 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2127
2858
|
return attrib;
|
|
2128
2859
|
}
|
|
2129
2860
|
|
|
2130
|
-
|
|
2131
|
-
|
|
2861
|
+
/**
|
|
2862
|
+
*
|
|
2863
|
+
* @param x
|
|
2864
|
+
* @param y
|
|
2865
|
+
* @param z
|
|
2866
|
+
* @param u
|
|
2867
|
+
* @param v
|
|
2868
|
+
*/
|
|
2869
|
+
protected void vertexImpl(float x, float y, float z, float u, float v) {
|
|
2132
2870
|
boolean textured = textureImage != null;
|
|
2133
2871
|
int fcolor = 0x00;
|
|
2134
2872
|
if (fill || textured) {
|
|
@@ -2164,8 +2902,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2164
2902
|
VERTEX, vertexBreak());
|
|
2165
2903
|
}
|
|
2166
2904
|
|
|
2167
|
-
|
|
2168
|
-
|
|
2905
|
+
/**
|
|
2906
|
+
*
|
|
2907
|
+
* @return
|
|
2908
|
+
*/
|
|
2909
|
+
protected boolean vertexBreak() {
|
|
2169
2910
|
if (breakShape) {
|
|
2170
2911
|
breakShape = false;
|
|
2171
2912
|
return true;
|
|
@@ -2208,6 +2949,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2208
2949
|
|
|
2209
2950
|
// protected void sort()
|
|
2210
2951
|
|
|
2952
|
+
/**
|
|
2953
|
+
*
|
|
2954
|
+
* @param mode
|
|
2955
|
+
*/
|
|
2956
|
+
|
|
2211
2957
|
|
|
2212
2958
|
protected void tessellate(int mode) {
|
|
2213
2959
|
tessellator.setInGeometry(inGeo);
|
|
@@ -2257,8 +3003,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2257
3003
|
}
|
|
2258
3004
|
}
|
|
2259
3005
|
|
|
2260
|
-
|
|
2261
|
-
|
|
3006
|
+
/**
|
|
3007
|
+
*
|
|
3008
|
+
* @param indices
|
|
3009
|
+
*/
|
|
3010
|
+
protected void tessellate(int[] indices) {
|
|
2262
3011
|
tessellator.setInGeometry(inGeo);
|
|
2263
3012
|
tessellator.setTessGeometry(tessGeo);
|
|
2264
3013
|
tessellator.setFill(fill || textureImage != null);
|
|
@@ -2356,14 +3105,18 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2356
3105
|
texCache.clear();
|
|
2357
3106
|
}
|
|
2358
3107
|
|
|
2359
|
-
|
|
2360
|
-
|
|
3108
|
+
/**
|
|
3109
|
+
*
|
|
3110
|
+
*/
|
|
3111
|
+
protected void flushPixels() {
|
|
2361
3112
|
drawPixels(mx1, my1, mx2 - mx1, my2 - my1);
|
|
2362
3113
|
modified = false;
|
|
2363
3114
|
}
|
|
2364
3115
|
|
|
2365
|
-
|
|
2366
|
-
|
|
3116
|
+
/**
|
|
3117
|
+
*
|
|
3118
|
+
*/
|
|
3119
|
+
protected void flushPolys() {
|
|
2367
3120
|
boolean customShader = polyShader != null;
|
|
2368
3121
|
boolean needNormals = customShader ? polyShader.accessNormals() : false;
|
|
2369
3122
|
boolean needTexCoords = customShader ? polyShader.accessTexCoords() : false;
|
|
@@ -2436,7 +3189,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2436
3189
|
unbindPolyBuffers();
|
|
2437
3190
|
}
|
|
2438
3191
|
|
|
2439
|
-
|
|
3192
|
+
/**
|
|
3193
|
+
*
|
|
3194
|
+
*/
|
|
3195
|
+
protected void flushSortedPolys() {
|
|
2440
3196
|
boolean customShader = polyShader != null;
|
|
2441
3197
|
boolean needNormals = customShader ? polyShader.accessNormals() : false;
|
|
2442
3198
|
boolean needTexCoords = customShader ? polyShader.accessTexCoords() : false;
|
|
@@ -2734,8 +3490,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2734
3490
|
raw.endShape();
|
|
2735
3491
|
}
|
|
2736
3492
|
|
|
2737
|
-
|
|
2738
|
-
|
|
3493
|
+
/**
|
|
3494
|
+
*
|
|
3495
|
+
*/
|
|
3496
|
+
protected void flushLines() {
|
|
2739
3497
|
updateLineBuffers();
|
|
2740
3498
|
|
|
2741
3499
|
PShader shader = getLineShader();
|
|
@@ -2835,8 +3593,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2835
3593
|
raw.endShape();
|
|
2836
3594
|
}
|
|
2837
3595
|
|
|
2838
|
-
|
|
2839
|
-
|
|
3596
|
+
/**
|
|
3597
|
+
*
|
|
3598
|
+
*/
|
|
3599
|
+
protected void flushPoints() {
|
|
2840
3600
|
updatePointBuffers();
|
|
2841
3601
|
|
|
2842
3602
|
PShader shader = getPointShader();
|
|
@@ -2950,8 +3710,19 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2950
3710
|
x4, y4, z4);
|
|
2951
3711
|
}
|
|
2952
3712
|
|
|
2953
|
-
|
|
2954
|
-
|
|
3713
|
+
/**
|
|
3714
|
+
*
|
|
3715
|
+
* @param x2
|
|
3716
|
+
* @param y2
|
|
3717
|
+
* @param z2
|
|
3718
|
+
* @param x3
|
|
3719
|
+
* @param y3
|
|
3720
|
+
* @param z3
|
|
3721
|
+
* @param x4
|
|
3722
|
+
* @param y4
|
|
3723
|
+
* @param z4
|
|
3724
|
+
*/
|
|
3725
|
+
protected void bezierVertexImpl(float x2, float y2, float z2,
|
|
2955
3726
|
float x3, float y3, float z3,
|
|
2956
3727
|
float x4, float y4, float z4) {
|
|
2957
3728
|
bezierVertexCheck(shape, inGeo.vertexCount);
|
|
@@ -2979,8 +3750,16 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
2979
3750
|
x3, y3, z3);
|
|
2980
3751
|
}
|
|
2981
3752
|
|
|
2982
|
-
|
|
2983
|
-
|
|
3753
|
+
/**
|
|
3754
|
+
*
|
|
3755
|
+
* @param cx
|
|
3756
|
+
* @param cy
|
|
3757
|
+
* @param cz
|
|
3758
|
+
* @param x3
|
|
3759
|
+
* @param y3
|
|
3760
|
+
* @param z3
|
|
3761
|
+
*/
|
|
3762
|
+
protected void quadraticVertexImpl(float cx, float cy, float cz,
|
|
2984
3763
|
float x3, float y3, float z3) {
|
|
2985
3764
|
bezierVertexCheck(shape, inGeo.vertexCount);
|
|
2986
3765
|
inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
|
|
@@ -3007,8 +3786,13 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3007
3786
|
curveVertexImpl(x, y, z);
|
|
3008
3787
|
}
|
|
3009
3788
|
|
|
3010
|
-
|
|
3011
|
-
|
|
3789
|
+
/**
|
|
3790
|
+
*
|
|
3791
|
+
* @param x
|
|
3792
|
+
* @param y
|
|
3793
|
+
* @param z
|
|
3794
|
+
*/
|
|
3795
|
+
protected void curveVertexImpl(float x, float y, float z) {
|
|
3012
3796
|
curveVertexCheck(shape);
|
|
3013
3797
|
inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
|
|
3014
3798
|
ambientColor, specularColor, emissiveColor, shininess);
|
|
@@ -3033,8 +3817,13 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3033
3817
|
pointImpl(x, y, z);
|
|
3034
3818
|
}
|
|
3035
3819
|
|
|
3036
|
-
|
|
3037
|
-
|
|
3820
|
+
/**
|
|
3821
|
+
*
|
|
3822
|
+
* @param x
|
|
3823
|
+
* @param y
|
|
3824
|
+
* @param z
|
|
3825
|
+
*/
|
|
3826
|
+
protected void pointImpl(float x, float y, float z) {
|
|
3038
3827
|
beginShape(POINTS);
|
|
3039
3828
|
defaultEdges = false;
|
|
3040
3829
|
normalMode = NORMAL_MODE_SHAPE;
|
|
@@ -3058,8 +3847,16 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3058
3847
|
lineImpl(x1, y1, z1, x2, y2, z2);
|
|
3059
3848
|
}
|
|
3060
3849
|
|
|
3061
|
-
|
|
3062
|
-
|
|
3850
|
+
/**
|
|
3851
|
+
*
|
|
3852
|
+
* @param x1
|
|
3853
|
+
* @param y1
|
|
3854
|
+
* @param z1
|
|
3855
|
+
* @param x2
|
|
3856
|
+
* @param y2
|
|
3857
|
+
* @param z2
|
|
3858
|
+
*/
|
|
3859
|
+
protected void lineImpl(float x1, float y1, float z1,
|
|
3063
3860
|
float x2, float y2, float z2) {
|
|
3064
3861
|
beginShape(LINES);
|
|
3065
3862
|
defaultEdges = false;
|
|
@@ -3602,8 +4399,15 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3602
4399
|
}
|
|
3603
4400
|
}
|
|
3604
4401
|
|
|
3605
|
-
|
|
3606
|
-
|
|
4402
|
+
/**
|
|
4403
|
+
*
|
|
4404
|
+
* @param info
|
|
4405
|
+
* @param x0
|
|
4406
|
+
* @param y0
|
|
4407
|
+
* @param x1
|
|
4408
|
+
* @param y1
|
|
4409
|
+
*/
|
|
4410
|
+
protected void textCharModelImpl(FontTexture.TextureInfo info,
|
|
3607
4411
|
float x0, float y0,
|
|
3608
4412
|
float x1, float y1) {
|
|
3609
4413
|
beginShape(QUADS);
|
|
@@ -3644,6 +4448,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3644
4448
|
* triangle) back to the origin on some letters (i.e. a capital L when
|
|
3645
4449
|
* tested with Akzidenz Grotesk Light). But this won't be visible
|
|
3646
4450
|
* with the stroke shut off, so tabling that bug for now.
|
|
4451
|
+
* @param ch
|
|
4452
|
+
* @param x
|
|
4453
|
+
* @param y
|
|
3647
4454
|
*/
|
|
3648
4455
|
protected void textCharShapeImpl(char ch, float x, float y) {
|
|
3649
4456
|
// save the current stroke because it needs to be disabled
|
|
@@ -3755,15 +4562,26 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3755
4562
|
translateImpl(tx, ty, tz);
|
|
3756
4563
|
}
|
|
3757
4564
|
|
|
3758
|
-
|
|
3759
|
-
|
|
4565
|
+
/**
|
|
4566
|
+
*
|
|
4567
|
+
* @param tx
|
|
4568
|
+
* @param ty
|
|
4569
|
+
* @param tz
|
|
4570
|
+
*/
|
|
4571
|
+
protected void translateImpl(float tx, float ty, float tz) {
|
|
3760
4572
|
modelview.translate(tx, ty, tz);
|
|
3761
4573
|
invTranslate(modelviewInv, tx, ty, tz);
|
|
3762
4574
|
projmodelview.translate(tx, ty, tz);
|
|
3763
4575
|
}
|
|
3764
4576
|
|
|
3765
|
-
|
|
3766
|
-
|
|
4577
|
+
/**
|
|
4578
|
+
*
|
|
4579
|
+
* @param matrix
|
|
4580
|
+
* @param tx
|
|
4581
|
+
* @param ty
|
|
4582
|
+
* @param tz
|
|
4583
|
+
*/
|
|
4584
|
+
static protected void invTranslate(PMatrix3D matrix,
|
|
3767
4585
|
float tx, float ty, float tz) {
|
|
3768
4586
|
matrix.preApply(1, 0, 0, -tx,
|
|
3769
4587
|
0, 1, 0, -ty,
|
|
@@ -3771,8 +4589,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3771
4589
|
0, 0, 0, 1);
|
|
3772
4590
|
}
|
|
3773
4591
|
|
|
3774
|
-
|
|
3775
|
-
|
|
4592
|
+
/**
|
|
4593
|
+
*
|
|
4594
|
+
* @param matrix
|
|
4595
|
+
* @return
|
|
4596
|
+
*/
|
|
4597
|
+
static protected float matrixScale(PMatrix matrix) {
|
|
3776
4598
|
// Volumetric scaling factor that is associated to the given
|
|
3777
4599
|
// transformation matrix, which is given by the absolute value of its
|
|
3778
4600
|
// determinant:
|
|
@@ -3829,14 +4651,23 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3829
4651
|
/**
|
|
3830
4652
|
* Rotate around an arbitrary vector, similar to glRotate(), except that it
|
|
3831
4653
|
* takes radians (instead of degrees).
|
|
4654
|
+
* @param v2
|
|
4655
|
+
* @param v0
|
|
4656
|
+
* @param v1
|
|
3832
4657
|
*/
|
|
3833
4658
|
@Override
|
|
3834
4659
|
public void rotate(float angle, float v0, float v1, float v2) {
|
|
3835
4660
|
rotateImpl(angle, v0, v1, v2);
|
|
3836
4661
|
}
|
|
3837
4662
|
|
|
3838
|
-
|
|
3839
|
-
|
|
4663
|
+
/**
|
|
4664
|
+
*
|
|
4665
|
+
* @param angle
|
|
4666
|
+
* @param v0
|
|
4667
|
+
* @param v1
|
|
4668
|
+
* @param v2
|
|
4669
|
+
*/
|
|
4670
|
+
protected void rotateImpl(float angle, float v0, float v1, float v2) {
|
|
3840
4671
|
float norm2 = v0 * v0 + v1 * v1 + v2 * v2;
|
|
3841
4672
|
if (zero(norm2)) {
|
|
3842
4673
|
// The vector is zero, cannot apply rotation.
|
|
@@ -3881,6 +4712,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3881
4712
|
|
|
3882
4713
|
/**
|
|
3883
4714
|
* Same as scale(sx, sy, 1).
|
|
4715
|
+
* @param sx
|
|
4716
|
+
* @param sy
|
|
3884
4717
|
*/
|
|
3885
4718
|
@Override
|
|
3886
4719
|
public void scale(float sx, float sy) {
|
|
@@ -3890,6 +4723,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3890
4723
|
|
|
3891
4724
|
/**
|
|
3892
4725
|
* Scale in three dimensions.
|
|
4726
|
+
* @param sx
|
|
4727
|
+
* @param sy
|
|
4728
|
+
* @param sz
|
|
3893
4729
|
*/
|
|
3894
4730
|
@Override
|
|
3895
4731
|
public void scale(float sx, float sy, float sz) {
|
|
@@ -3898,6 +4734,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3898
4734
|
|
|
3899
4735
|
/**
|
|
3900
4736
|
* Scale in three dimensions.
|
|
4737
|
+
* @param sx
|
|
4738
|
+
* @param sy
|
|
4739
|
+
* @param sz
|
|
3901
4740
|
*/
|
|
3902
4741
|
protected void scaleImpl(float sx, float sy, float sz) {
|
|
3903
4742
|
modelview.scale(sx, sy, sz);
|
|
@@ -3905,8 +4744,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3905
4744
|
projmodelview.scale(sx, sy, sz);
|
|
3906
4745
|
}
|
|
3907
4746
|
|
|
3908
|
-
|
|
3909
|
-
|
|
4747
|
+
/**
|
|
4748
|
+
*
|
|
4749
|
+
* @param matrix
|
|
4750
|
+
* @param x
|
|
4751
|
+
* @param y
|
|
4752
|
+
* @param z
|
|
4753
|
+
*/
|
|
4754
|
+
static protected void invScale(PMatrix3D matrix, float x, float y, float z) {
|
|
3910
4755
|
matrix.preApply(1/x, 0, 0, 0, 0, 1/y, 0, 0, 0, 0, 1/z, 0, 0, 0, 0, 1);
|
|
3911
4756
|
}
|
|
3912
4757
|
|
|
@@ -3991,8 +4836,26 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
3991
4836
|
n30, n31, n32, n33);
|
|
3992
4837
|
}
|
|
3993
4838
|
|
|
3994
|
-
|
|
3995
|
-
|
|
4839
|
+
/**
|
|
4840
|
+
*
|
|
4841
|
+
* @param n00
|
|
4842
|
+
* @param n01
|
|
4843
|
+
* @param n02
|
|
4844
|
+
* @param n03
|
|
4845
|
+
* @param n10
|
|
4846
|
+
* @param n11
|
|
4847
|
+
* @param n12
|
|
4848
|
+
* @param n13
|
|
4849
|
+
* @param n20
|
|
4850
|
+
* @param n21
|
|
4851
|
+
* @param n22
|
|
4852
|
+
* @param n23
|
|
4853
|
+
* @param n30
|
|
4854
|
+
* @param n31
|
|
4855
|
+
* @param n32
|
|
4856
|
+
* @param n33
|
|
4857
|
+
*/
|
|
4858
|
+
protected void applyMatrixImpl(float n00, float n01, float n02, float n03,
|
|
3996
4859
|
float n10, float n11, float n12, float n13,
|
|
3997
4860
|
float n20, float n21, float n22, float n23,
|
|
3998
4861
|
float n30, float n31, float n32, float n33) {
|
|
@@ -4009,12 +4872,16 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4009
4872
|
n30, n31, n32, n33);
|
|
4010
4873
|
}
|
|
4011
4874
|
|
|
4012
|
-
|
|
4013
|
-
|
|
4875
|
+
/**
|
|
4876
|
+
*
|
|
4877
|
+
*/
|
|
4878
|
+
protected void begin2D() {
|
|
4014
4879
|
}
|
|
4015
4880
|
|
|
4016
|
-
|
|
4017
|
-
|
|
4881
|
+
/**
|
|
4882
|
+
*
|
|
4883
|
+
*/
|
|
4884
|
+
protected void end2D() {
|
|
4018
4885
|
}
|
|
4019
4886
|
|
|
4020
4887
|
|
|
@@ -4075,6 +4942,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4075
4942
|
|
|
4076
4943
|
// PROJECTION
|
|
4077
4944
|
|
|
4945
|
+
/**
|
|
4946
|
+
*
|
|
4947
|
+
*/
|
|
4948
|
+
|
|
4078
4949
|
|
|
4079
4950
|
public void pushProjection() {
|
|
4080
4951
|
if (projectionStackDepth == MATRIX_STACK_DEPTH) {
|
|
@@ -4084,8 +4955,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4084
4955
|
projectionStackDepth++;
|
|
4085
4956
|
}
|
|
4086
4957
|
|
|
4087
|
-
|
|
4088
|
-
|
|
4958
|
+
/**
|
|
4959
|
+
*
|
|
4960
|
+
*/
|
|
4961
|
+
public void popProjection() {
|
|
4089
4962
|
flush(); // The geometry with the old projection matrix needs to be drawn now
|
|
4090
4963
|
|
|
4091
4964
|
if (projectionStackDepth == 0) {
|
|
@@ -4096,22 +4969,45 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4096
4969
|
updateProjmodelview();
|
|
4097
4970
|
}
|
|
4098
4971
|
|
|
4099
|
-
|
|
4100
|
-
|
|
4972
|
+
/**
|
|
4973
|
+
*
|
|
4974
|
+
*/
|
|
4975
|
+
public void resetProjection() {
|
|
4101
4976
|
flush();
|
|
4102
4977
|
projection.reset();
|
|
4103
4978
|
updateProjmodelview();
|
|
4104
4979
|
}
|
|
4105
4980
|
|
|
4106
|
-
|
|
4107
|
-
|
|
4981
|
+
/**
|
|
4982
|
+
*
|
|
4983
|
+
* @param mat
|
|
4984
|
+
*/
|
|
4985
|
+
public void applyProjection(PMatrix3D mat) {
|
|
4108
4986
|
flush();
|
|
4109
4987
|
projection.apply(mat);
|
|
4110
4988
|
updateProjmodelview();
|
|
4111
4989
|
}
|
|
4112
4990
|
|
|
4113
|
-
|
|
4114
|
-
|
|
4991
|
+
/**
|
|
4992
|
+
*
|
|
4993
|
+
* @param n00
|
|
4994
|
+
* @param n01
|
|
4995
|
+
* @param n02
|
|
4996
|
+
* @param n03
|
|
4997
|
+
* @param n10
|
|
4998
|
+
* @param n11
|
|
4999
|
+
* @param n12
|
|
5000
|
+
* @param n13
|
|
5001
|
+
* @param n20
|
|
5002
|
+
* @param n21
|
|
5003
|
+
* @param n22
|
|
5004
|
+
* @param n23
|
|
5005
|
+
* @param n30
|
|
5006
|
+
* @param n31
|
|
5007
|
+
* @param n32
|
|
5008
|
+
* @param n33
|
|
5009
|
+
*/
|
|
5010
|
+
public void applyProjection(float n00, float n01, float n02, float n03,
|
|
4115
5011
|
float n10, float n11, float n12, float n13,
|
|
4116
5012
|
float n20, float n21, float n22, float n23,
|
|
4117
5013
|
float n30, float n31, float n32, float n33) {
|
|
@@ -4123,8 +5019,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4123
5019
|
updateProjmodelview();
|
|
4124
5020
|
}
|
|
4125
5021
|
|
|
4126
|
-
|
|
4127
|
-
|
|
5022
|
+
/**
|
|
5023
|
+
*
|
|
5024
|
+
* @param mat
|
|
5025
|
+
*/
|
|
5026
|
+
public void setProjection(PMatrix3D mat) {
|
|
4128
5027
|
flush();
|
|
4129
5028
|
projection.set(mat);
|
|
4130
5029
|
updateProjmodelview();
|
|
@@ -4136,6 +5035,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4136
5035
|
// 0, y, 0, b,
|
|
4137
5036
|
// 0, 0, z, c,
|
|
4138
5037
|
// 0, 0, 0, 1
|
|
5038
|
+
|
|
5039
|
+
/**
|
|
5040
|
+
*
|
|
5041
|
+
* @return
|
|
5042
|
+
*/
|
|
4139
5043
|
protected boolean orthoProjection() {
|
|
4140
5044
|
return zero(projection.m01) && zero(projection.m02) &&
|
|
4141
5045
|
zero(projection.m10) && zero(projection.m12) &&
|
|
@@ -4144,8 +5048,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4144
5048
|
zero(projection.m32) && same(projection.m33, 1);
|
|
4145
5049
|
}
|
|
4146
5050
|
|
|
4147
|
-
|
|
4148
|
-
|
|
5051
|
+
/**
|
|
5052
|
+
*
|
|
5053
|
+
* @return
|
|
5054
|
+
*/
|
|
5055
|
+
protected boolean nonOrthoProjection() {
|
|
4149
5056
|
return nonZero(projection.m01) || nonZero(projection.m02) ||
|
|
4150
5057
|
nonZero(projection.m10) || nonZero(projection.m12) ||
|
|
4151
5058
|
nonZero(projection.m20) || nonZero(projection.m21) ||
|
|
@@ -4158,23 +5065,43 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4158
5065
|
|
|
4159
5066
|
// Some float math utilities
|
|
4160
5067
|
|
|
5068
|
+
/**
|
|
5069
|
+
*
|
|
5070
|
+
* @param a
|
|
5071
|
+
* @param b
|
|
5072
|
+
* @return
|
|
5073
|
+
*/
|
|
5074
|
+
|
|
4161
5075
|
|
|
4162
5076
|
protected static boolean same(float a, float b) {
|
|
4163
5077
|
return Math.abs(a - b) < PGL.FLOAT_EPS;
|
|
4164
5078
|
}
|
|
4165
5079
|
|
|
4166
|
-
|
|
4167
|
-
|
|
5080
|
+
/**
|
|
5081
|
+
*
|
|
5082
|
+
* @param a
|
|
5083
|
+
* @param b
|
|
5084
|
+
* @return
|
|
5085
|
+
*/
|
|
5086
|
+
protected static boolean diff(float a, float b) {
|
|
4168
5087
|
return PGL.FLOAT_EPS <= Math.abs(a - b);
|
|
4169
5088
|
}
|
|
4170
5089
|
|
|
4171
|
-
|
|
4172
|
-
|
|
5090
|
+
/**
|
|
5091
|
+
*
|
|
5092
|
+
* @param a
|
|
5093
|
+
* @return
|
|
5094
|
+
*/
|
|
5095
|
+
protected static boolean zero(float a) {
|
|
4173
5096
|
return Math.abs(a) < PGL.FLOAT_EPS;
|
|
4174
5097
|
}
|
|
4175
5098
|
|
|
4176
|
-
|
|
4177
|
-
|
|
5099
|
+
/**
|
|
5100
|
+
*
|
|
5101
|
+
* @param a
|
|
5102
|
+
* @return
|
|
5103
|
+
*/
|
|
5104
|
+
protected static boolean nonZero(float a) {
|
|
4178
5105
|
return PGL.FLOAT_EPS <= Math.abs(a);
|
|
4179
5106
|
}
|
|
4180
5107
|
|
|
@@ -4440,8 +5367,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4440
5367
|
camera.print();
|
|
4441
5368
|
}
|
|
4442
5369
|
|
|
4443
|
-
|
|
4444
|
-
|
|
5370
|
+
/**
|
|
5371
|
+
*
|
|
5372
|
+
*/
|
|
5373
|
+
protected void defaultCamera() {
|
|
4445
5374
|
camera();
|
|
4446
5375
|
}
|
|
4447
5376
|
|
|
@@ -4532,7 +5461,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4532
5461
|
|
|
4533
5462
|
|
|
4534
5463
|
/**
|
|
4535
|
-
* Similar to gluPerspective().
|
|
5464
|
+
* Similar to gluPerspective().Implementation based on Mesa's glu.c
|
|
5465
|
+
* @param fov
|
|
4536
5466
|
*/
|
|
4537
5467
|
@Override
|
|
4538
5468
|
public void perspective(float fov, float aspect, float zNear, float zFar) {
|
|
@@ -4549,6 +5479,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4549
5479
|
* against) the current perspective matrix.
|
|
4550
5480
|
* <P>
|
|
4551
5481
|
* Implementation based on the explanation in the OpenGL blue book.
|
|
5482
|
+
* @param zfar
|
|
5483
|
+
* @param znear
|
|
4552
5484
|
*/
|
|
4553
5485
|
@Override
|
|
4554
5486
|
public void frustum(float left, float right, float bottom, float top,
|
|
@@ -4583,8 +5515,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4583
5515
|
projection.print();
|
|
4584
5516
|
}
|
|
4585
5517
|
|
|
4586
|
-
|
|
4587
|
-
|
|
5518
|
+
/**
|
|
5519
|
+
*
|
|
5520
|
+
*/
|
|
5521
|
+
protected void defaultPerspective() {
|
|
4588
5522
|
perspective();
|
|
4589
5523
|
}
|
|
4590
5524
|
|
|
@@ -4623,8 +5557,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4623
5557
|
return screenZImpl(x, y, z);
|
|
4624
5558
|
}
|
|
4625
5559
|
|
|
4626
|
-
|
|
4627
|
-
|
|
5560
|
+
/**
|
|
5561
|
+
*
|
|
5562
|
+
* @param x
|
|
5563
|
+
* @param y
|
|
5564
|
+
* @param z
|
|
5565
|
+
* @return
|
|
5566
|
+
*/
|
|
5567
|
+
protected float screenXImpl(float x, float y, float z) {
|
|
4628
5568
|
float ax =
|
|
4629
5569
|
modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;
|
|
4630
5570
|
float ay =
|
|
@@ -4636,8 +5576,15 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4636
5576
|
return screenXImpl(ax, ay, az, aw);
|
|
4637
5577
|
}
|
|
4638
5578
|
|
|
4639
|
-
|
|
4640
|
-
|
|
5579
|
+
/**
|
|
5580
|
+
*
|
|
5581
|
+
* @param x
|
|
5582
|
+
* @param y
|
|
5583
|
+
* @param z
|
|
5584
|
+
* @param w
|
|
5585
|
+
* @return
|
|
5586
|
+
*/
|
|
5587
|
+
protected float screenXImpl(float x, float y, float z, float w) {
|
|
4641
5588
|
float ox =
|
|
4642
5589
|
projection.m00*x + projection.m01*y + projection.m02*z + projection.m03*w;
|
|
4643
5590
|
float ow =
|
|
@@ -4650,8 +5597,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4650
5597
|
return sx;
|
|
4651
5598
|
}
|
|
4652
5599
|
|
|
4653
|
-
|
|
4654
|
-
|
|
5600
|
+
/**
|
|
5601
|
+
*
|
|
5602
|
+
* @param x
|
|
5603
|
+
* @param y
|
|
5604
|
+
* @param z
|
|
5605
|
+
* @return
|
|
5606
|
+
*/
|
|
5607
|
+
protected float screenYImpl(float x, float y, float z) {
|
|
4655
5608
|
float ax =
|
|
4656
5609
|
modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;
|
|
4657
5610
|
float ay =
|
|
@@ -4663,8 +5616,15 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4663
5616
|
return screenYImpl(ax, ay, az, aw);
|
|
4664
5617
|
}
|
|
4665
5618
|
|
|
4666
|
-
|
|
4667
|
-
|
|
5619
|
+
/**
|
|
5620
|
+
*
|
|
5621
|
+
* @param x
|
|
5622
|
+
* @param y
|
|
5623
|
+
* @param z
|
|
5624
|
+
* @param w
|
|
5625
|
+
* @return
|
|
5626
|
+
*/
|
|
5627
|
+
protected float screenYImpl(float x, float y, float z, float w) {
|
|
4668
5628
|
float oy =
|
|
4669
5629
|
projection.m10*x + projection.m11*y + projection.m12*z + projection.m13*w;
|
|
4670
5630
|
float ow =
|
|
@@ -4679,8 +5639,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4679
5639
|
return sy;
|
|
4680
5640
|
}
|
|
4681
5641
|
|
|
4682
|
-
|
|
4683
|
-
|
|
5642
|
+
/**
|
|
5643
|
+
*
|
|
5644
|
+
* @param x
|
|
5645
|
+
* @param y
|
|
5646
|
+
* @param z
|
|
5647
|
+
* @return
|
|
5648
|
+
*/
|
|
5649
|
+
protected float screenZImpl(float x, float y, float z) {
|
|
4684
5650
|
float ax =
|
|
4685
5651
|
modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;
|
|
4686
5652
|
float ay =
|
|
@@ -4692,8 +5658,15 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4692
5658
|
return screenZImpl(ax, ay, az, aw);
|
|
4693
5659
|
}
|
|
4694
5660
|
|
|
4695
|
-
|
|
4696
|
-
|
|
5661
|
+
/**
|
|
5662
|
+
*
|
|
5663
|
+
* @param x
|
|
5664
|
+
* @param y
|
|
5665
|
+
* @param z
|
|
5666
|
+
* @param w
|
|
5667
|
+
* @return
|
|
5668
|
+
*/
|
|
5669
|
+
protected float screenZImpl(float x, float y, float z, float w) {
|
|
4697
5670
|
float oz =
|
|
4698
5671
|
projection.m20*x + projection.m21*y + projection.m22*z + projection.m23*w;
|
|
4699
5672
|
float ow =
|
|
@@ -4989,6 +5962,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4989
5962
|
|
|
4990
5963
|
/**
|
|
4991
5964
|
* Add an ambient light based on the current color mode.
|
|
5965
|
+
* @param r
|
|
5966
|
+
* @param g
|
|
5967
|
+
* @param b
|
|
4992
5968
|
*/
|
|
4993
5969
|
@Override
|
|
4994
5970
|
public void ambientLight(float r, float g, float b) {
|
|
@@ -4997,8 +5973,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
4997
5973
|
|
|
4998
5974
|
|
|
4999
5975
|
/**
|
|
5000
|
-
* Add an ambient light based on the current color mode.
|
|
5001
|
-
|
|
5976
|
+
* Add an ambient light based on the current color mode.This version includes
|
|
5977
|
+
an (x, y, z) position for situations where the falloff distance is used.
|
|
5978
|
+
* @param r
|
|
5979
|
+
* @param g
|
|
5980
|
+
* @param b
|
|
5002
5981
|
*/
|
|
5003
5982
|
@Override
|
|
5004
5983
|
public void ambientLight(float r, float g, float b,
|
|
@@ -5124,6 +6103,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5124
6103
|
|
|
5125
6104
|
/**
|
|
5126
6105
|
* Set the specular color of the last light created.
|
|
6106
|
+
* @param x
|
|
6107
|
+
* @param y
|
|
6108
|
+
* @param z
|
|
5127
6109
|
*/
|
|
5128
6110
|
@Override
|
|
5129
6111
|
public void lightSpecular(float x, float y, float z) {
|
|
@@ -5133,20 +6115,31 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5133
6115
|
currentLightSpecular[2] = calcB;
|
|
5134
6116
|
}
|
|
5135
6117
|
|
|
5136
|
-
|
|
5137
|
-
|
|
6118
|
+
/**
|
|
6119
|
+
*
|
|
6120
|
+
*/
|
|
6121
|
+
protected void enableLighting() {
|
|
5138
6122
|
flush();
|
|
5139
6123
|
lights = true;
|
|
5140
6124
|
}
|
|
5141
6125
|
|
|
5142
|
-
|
|
5143
|
-
|
|
6126
|
+
/**
|
|
6127
|
+
*
|
|
6128
|
+
*/
|
|
6129
|
+
protected void disableLighting() {
|
|
5144
6130
|
flush();
|
|
5145
6131
|
lights = false;
|
|
5146
6132
|
}
|
|
5147
6133
|
|
|
5148
|
-
|
|
5149
|
-
|
|
6134
|
+
/**
|
|
6135
|
+
*
|
|
6136
|
+
* @param num
|
|
6137
|
+
* @param x
|
|
6138
|
+
* @param y
|
|
6139
|
+
* @param z
|
|
6140
|
+
* @param dir
|
|
6141
|
+
*/
|
|
6142
|
+
protected void lightPosition(int num, float x, float y, float z,
|
|
5150
6143
|
boolean dir) {
|
|
5151
6144
|
lightPosition[4 * num + 0] =
|
|
5152
6145
|
x*modelview.m00 + y*modelview.m01 + z*modelview.m02 + modelview.m03;
|
|
@@ -5159,8 +6152,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5159
6152
|
lightPosition[4 * num + 3] = dir ? 0 : 1;
|
|
5160
6153
|
}
|
|
5161
6154
|
|
|
5162
|
-
|
|
5163
|
-
|
|
6155
|
+
/**
|
|
6156
|
+
*
|
|
6157
|
+
* @param num
|
|
6158
|
+
* @param dx
|
|
6159
|
+
* @param dy
|
|
6160
|
+
* @param dz
|
|
6161
|
+
*/
|
|
6162
|
+
protected void lightNormal(int num, float dx, float dy, float dz) {
|
|
5164
6163
|
// Applying normal matrix to the light direction vector, which is the
|
|
5165
6164
|
// transpose of the inverse of the modelview.
|
|
5166
6165
|
float nx =
|
|
@@ -5183,72 +6182,116 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5183
6182
|
}
|
|
5184
6183
|
}
|
|
5185
6184
|
|
|
5186
|
-
|
|
5187
|
-
|
|
6185
|
+
/**
|
|
6186
|
+
*
|
|
6187
|
+
* @param num
|
|
6188
|
+
* @param r
|
|
6189
|
+
* @param g
|
|
6190
|
+
* @param b
|
|
6191
|
+
*/
|
|
6192
|
+
protected void lightAmbient(int num, float r, float g, float b) {
|
|
5188
6193
|
colorCalc(r, g, b);
|
|
5189
6194
|
lightAmbient[3 * num + 0] = calcR;
|
|
5190
6195
|
lightAmbient[3 * num + 1] = calcG;
|
|
5191
6196
|
lightAmbient[3 * num + 2] = calcB;
|
|
5192
6197
|
}
|
|
5193
6198
|
|
|
5194
|
-
|
|
5195
|
-
|
|
6199
|
+
/**
|
|
6200
|
+
*
|
|
6201
|
+
* @param num
|
|
6202
|
+
*/
|
|
6203
|
+
protected void noLightAmbient(int num) {
|
|
5196
6204
|
lightAmbient[3 * num + 0] = 0;
|
|
5197
6205
|
lightAmbient[3 * num + 1] = 0;
|
|
5198
6206
|
lightAmbient[3 * num + 2] = 0;
|
|
5199
6207
|
}
|
|
5200
6208
|
|
|
5201
|
-
|
|
5202
|
-
|
|
6209
|
+
/**
|
|
6210
|
+
*
|
|
6211
|
+
* @param num
|
|
6212
|
+
* @param r
|
|
6213
|
+
* @param g
|
|
6214
|
+
* @param b
|
|
6215
|
+
*/
|
|
6216
|
+
protected void lightDiffuse(int num, float r, float g, float b) {
|
|
5203
6217
|
colorCalc(r, g, b);
|
|
5204
6218
|
lightDiffuse[3 * num + 0] = calcR;
|
|
5205
6219
|
lightDiffuse[3 * num + 1] = calcG;
|
|
5206
6220
|
lightDiffuse[3 * num + 2] = calcB;
|
|
5207
6221
|
}
|
|
5208
6222
|
|
|
5209
|
-
|
|
5210
|
-
|
|
6223
|
+
/**
|
|
6224
|
+
*
|
|
6225
|
+
* @param num
|
|
6226
|
+
*/
|
|
6227
|
+
protected void noLightDiffuse(int num) {
|
|
5211
6228
|
lightDiffuse[3 * num + 0] = 0;
|
|
5212
6229
|
lightDiffuse[3 * num + 1] = 0;
|
|
5213
6230
|
lightDiffuse[3 * num + 2] = 0;
|
|
5214
6231
|
}
|
|
5215
6232
|
|
|
5216
|
-
|
|
5217
|
-
|
|
6233
|
+
/**
|
|
6234
|
+
*
|
|
6235
|
+
* @param num
|
|
6236
|
+
* @param r
|
|
6237
|
+
* @param g
|
|
6238
|
+
* @param b
|
|
6239
|
+
*/
|
|
6240
|
+
protected void lightSpecular(int num, float r, float g, float b) {
|
|
5218
6241
|
lightSpecular[3 * num + 0] = r;
|
|
5219
6242
|
lightSpecular[3 * num + 1] = g;
|
|
5220
6243
|
lightSpecular[3 * num + 2] = b;
|
|
5221
6244
|
}
|
|
5222
6245
|
|
|
5223
|
-
|
|
5224
|
-
|
|
6246
|
+
/**
|
|
6247
|
+
*
|
|
6248
|
+
* @param num
|
|
6249
|
+
*/
|
|
6250
|
+
protected void noLightSpecular(int num) {
|
|
5225
6251
|
lightSpecular[3 * num + 0] = 0;
|
|
5226
6252
|
lightSpecular[3 * num + 1] = 0;
|
|
5227
6253
|
lightSpecular[3 * num + 2] = 0;
|
|
5228
6254
|
}
|
|
5229
6255
|
|
|
5230
|
-
|
|
5231
|
-
|
|
6256
|
+
/**
|
|
6257
|
+
*
|
|
6258
|
+
* @param num
|
|
6259
|
+
* @param c0
|
|
6260
|
+
* @param c1
|
|
6261
|
+
* @param c2
|
|
6262
|
+
*/
|
|
6263
|
+
protected void lightFalloff(int num, float c0, float c1, float c2) {
|
|
5232
6264
|
lightFalloffCoefficients[3 * num + 0] = c0;
|
|
5233
6265
|
lightFalloffCoefficients[3 * num + 1] = c1;
|
|
5234
6266
|
lightFalloffCoefficients[3 * num + 2] = c2;
|
|
5235
6267
|
}
|
|
5236
6268
|
|
|
5237
|
-
|
|
5238
|
-
|
|
6269
|
+
/**
|
|
6270
|
+
*
|
|
6271
|
+
* @param num
|
|
6272
|
+
*/
|
|
6273
|
+
protected void noLightFalloff(int num) {
|
|
5239
6274
|
lightFalloffCoefficients[3 * num + 0] = 1;
|
|
5240
6275
|
lightFalloffCoefficients[3 * num + 1] = 0;
|
|
5241
6276
|
lightFalloffCoefficients[3 * num + 2] = 0;
|
|
5242
6277
|
}
|
|
5243
6278
|
|
|
5244
|
-
|
|
5245
|
-
|
|
6279
|
+
/**
|
|
6280
|
+
*
|
|
6281
|
+
* @param num
|
|
6282
|
+
* @param angle
|
|
6283
|
+
* @param exponent
|
|
6284
|
+
*/
|
|
6285
|
+
protected void lightSpot(int num, float angle, float exponent) {
|
|
5246
6286
|
lightSpotParameters[2 * num + 0] = Math.max(0, PApplet.cos(angle));
|
|
5247
6287
|
lightSpotParameters[2 * num + 1] = exponent;
|
|
5248
6288
|
}
|
|
5249
6289
|
|
|
5250
|
-
|
|
5251
|
-
|
|
6290
|
+
/**
|
|
6291
|
+
*
|
|
6292
|
+
* @param num
|
|
6293
|
+
*/
|
|
6294
|
+
protected void noLightSpot(int num) {
|
|
5252
6295
|
lightSpotParameters[2 * num + 0] = 0;
|
|
5253
6296
|
lightSpotParameters[2 * num + 1] = 0;
|
|
5254
6297
|
}
|
|
@@ -5321,9 +6364,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5321
6364
|
// showWarning() and showException() available from PGraphics.
|
|
5322
6365
|
|
|
5323
6366
|
/**
|
|
5324
|
-
* Report on anything from glError().
|
|
5325
|
-
|
|
5326
|
-
|
|
6367
|
+
* Report on anything from glError().Don't use this inside glBegin/glEnd otherwise it'll
|
|
6368
|
+
throw an GL_INVALID_OPERATION error.
|
|
6369
|
+
* @param where
|
|
5327
6370
|
*/
|
|
5328
6371
|
protected void report(String where) {
|
|
5329
6372
|
if (!hints[DISABLE_OPENGL_ERRORS]) {
|
|
@@ -5393,8 +6436,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5393
6436
|
}
|
|
5394
6437
|
}
|
|
5395
6438
|
|
|
5396
|
-
|
|
5397
|
-
|
|
6439
|
+
/**
|
|
6440
|
+
*
|
|
6441
|
+
*/
|
|
6442
|
+
protected void allocatePixels() {
|
|
5398
6443
|
updatePixelSize();
|
|
5399
6444
|
if ((pixels == null) || (pixels.length != pixelWidth * pixelHeight)) {
|
|
5400
6445
|
pixels = new int[pixelWidth * pixelHeight];
|
|
@@ -5403,8 +6448,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5403
6448
|
}
|
|
5404
6449
|
}
|
|
5405
6450
|
|
|
5406
|
-
|
|
5407
|
-
|
|
6451
|
+
/**
|
|
6452
|
+
*
|
|
6453
|
+
*/
|
|
6454
|
+
protected void readPixels() {
|
|
5408
6455
|
updatePixelSize();
|
|
5409
6456
|
beginPixelsOp(OP_READ);
|
|
5410
6457
|
try {
|
|
@@ -5427,8 +6474,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5427
6474
|
}
|
|
5428
6475
|
}
|
|
5429
6476
|
|
|
5430
|
-
|
|
5431
|
-
|
|
6477
|
+
/**
|
|
6478
|
+
*
|
|
6479
|
+
* @param x
|
|
6480
|
+
* @param y
|
|
6481
|
+
* @param w
|
|
6482
|
+
* @param h
|
|
6483
|
+
*/
|
|
6484
|
+
protected void drawPixels(int x, int y, int w, int h) {
|
|
5432
6485
|
int len = w * h;
|
|
5433
6486
|
if (nativePixels == null || nativePixels.length < len) {
|
|
5434
6487
|
nativePixels = new int[len];
|
|
@@ -5568,8 +6621,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5568
6621
|
}
|
|
5569
6622
|
}
|
|
5570
6623
|
|
|
5571
|
-
|
|
5572
|
-
|
|
6624
|
+
/**
|
|
6625
|
+
*
|
|
6626
|
+
*/
|
|
6627
|
+
protected static void completeFinishedPixelTransfers() {
|
|
5573
6628
|
ongoingPixelTransfersIterable.addAll(ongoingPixelTransfers);
|
|
5574
6629
|
for (AsyncPixelReader pixelReader : ongoingPixelTransfersIterable) {
|
|
5575
6630
|
// if the getter was not called this frame,
|
|
@@ -5582,7 +6637,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5582
6637
|
ongoingPixelTransfersIterable.clear();
|
|
5583
6638
|
}
|
|
5584
6639
|
|
|
5585
|
-
|
|
6640
|
+
/**
|
|
6641
|
+
*
|
|
6642
|
+
*/
|
|
6643
|
+
protected static void completeAllPixelTransfers() {
|
|
5586
6644
|
ongoingPixelTransfersIterable.addAll(ongoingPixelTransfers);
|
|
5587
6645
|
for (AsyncPixelReader pixelReader : ongoingPixelTransfersIterable) {
|
|
5588
6646
|
pixelReader.completeAllTransfers();
|
|
@@ -5604,8 +6662,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5604
6662
|
super.awaitAsyncSaveCompletion(filename);
|
|
5605
6663
|
}
|
|
5606
6664
|
|
|
5607
|
-
|
|
5608
|
-
|
|
6665
|
+
/**
|
|
6666
|
+
*
|
|
6667
|
+
*/
|
|
6668
|
+
protected class AsyncPixelReader {
|
|
5609
6669
|
|
|
5610
6670
|
// PImage formats used internally to offload
|
|
5611
6671
|
// color format conversion to save threads
|
|
@@ -5631,6 +6691,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5631
6691
|
|
|
5632
6692
|
/// PGRAPHICS API //////////////////////////////////////////////////////////
|
|
5633
6693
|
|
|
6694
|
+
/**
|
|
6695
|
+
*
|
|
6696
|
+
*/
|
|
6697
|
+
|
|
5634
6698
|
public AsyncPixelReader() {
|
|
5635
6699
|
supportsAsyncTransfers = pgl.hasPBOs() && pgl.hasSynchronization();
|
|
5636
6700
|
if (supportsAsyncTransfers) {
|
|
@@ -5649,8 +6713,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5649
6713
|
}
|
|
5650
6714
|
}
|
|
5651
6715
|
|
|
5652
|
-
|
|
5653
|
-
|
|
6716
|
+
/**
|
|
6717
|
+
*
|
|
6718
|
+
*/
|
|
6719
|
+
public void dispose() {
|
|
5654
6720
|
if (fences != null) {
|
|
5655
6721
|
while (size > 0) {
|
|
5656
6722
|
pgl.deleteSync(fences[tail]);
|
|
@@ -5676,8 +6742,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5676
6742
|
ongoingPixelTransfers.remove(this);
|
|
5677
6743
|
}
|
|
5678
6744
|
|
|
5679
|
-
|
|
5680
|
-
|
|
6745
|
+
/**
|
|
6746
|
+
*
|
|
6747
|
+
* @param file
|
|
6748
|
+
*/
|
|
6749
|
+
public void readAndSaveAsync(final File file) {
|
|
5681
6750
|
if (size > 0) {
|
|
5682
6751
|
boolean shouldRead = (size == BUFFER_COUNT);
|
|
5683
6752
|
if (!shouldRead) shouldRead = isLastTransferComplete();
|
|
@@ -5689,8 +6758,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5689
6758
|
calledThisFrame = true;
|
|
5690
6759
|
}
|
|
5691
6760
|
|
|
5692
|
-
|
|
5693
|
-
|
|
6761
|
+
/**
|
|
6762
|
+
*
|
|
6763
|
+
*/
|
|
6764
|
+
public void completeFinishedTransfers() {
|
|
5694
6765
|
if (size <= 0 || !asyncImageSaver.hasAvailableTarget()) return;
|
|
5695
6766
|
|
|
5696
6767
|
boolean needEndDraw = false;
|
|
@@ -5711,14 +6782,19 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5711
6782
|
if (needEndDraw) endDraw();
|
|
5712
6783
|
}
|
|
5713
6784
|
|
|
5714
|
-
|
|
5715
|
-
|
|
6785
|
+
/**
|
|
6786
|
+
*
|
|
6787
|
+
*/
|
|
6788
|
+
protected void completeAllTransfers() {
|
|
5716
6789
|
if (size <= 0) return;
|
|
5717
6790
|
completeTransfers(size);
|
|
5718
6791
|
}
|
|
5719
6792
|
|
|
5720
|
-
|
|
5721
|
-
|
|
6793
|
+
/**
|
|
6794
|
+
*
|
|
6795
|
+
* @param count
|
|
6796
|
+
*/
|
|
6797
|
+
protected void completeTransfers(int count) {
|
|
5722
6798
|
if (size <= 0) return;
|
|
5723
6799
|
if (count <= 0) return;
|
|
5724
6800
|
|
|
@@ -5742,8 +6818,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5742
6818
|
if (needEndDraw) endDraw();
|
|
5743
6819
|
}
|
|
5744
6820
|
|
|
5745
|
-
|
|
5746
|
-
|
|
6821
|
+
/**
|
|
6822
|
+
*
|
|
6823
|
+
* @param file
|
|
6824
|
+
*/
|
|
6825
|
+
protected void awaitTransferCompletion(File file) {
|
|
5747
6826
|
if (size <= 0) return;
|
|
5748
6827
|
|
|
5749
6828
|
int i = tail; // tail -> head, wraps around (we have circular queue)
|
|
@@ -5766,6 +6845,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5766
6845
|
|
|
5767
6846
|
/// TRANSFERS //////////////////////////////////////////////////////////////
|
|
5768
6847
|
|
|
6848
|
+
/**
|
|
6849
|
+
*
|
|
6850
|
+
* @return
|
|
6851
|
+
*/
|
|
6852
|
+
|
|
5769
6853
|
public boolean isLastTransferComplete() {
|
|
5770
6854
|
if (size <= 0) return false;
|
|
5771
6855
|
int status = pgl.clientWaitSync(fences[tail], 0, 0);
|
|
@@ -5773,8 +6857,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5773
6857
|
(status == PGL.CONDITION_SATISFIED);
|
|
5774
6858
|
}
|
|
5775
6859
|
|
|
5776
|
-
|
|
5777
|
-
|
|
6860
|
+
/**
|
|
6861
|
+
*
|
|
6862
|
+
* @param file
|
|
6863
|
+
*/
|
|
6864
|
+
public void beginTransfer(File file) {
|
|
5778
6865
|
// check the size of the buffer
|
|
5779
6866
|
if (widths[head] != pixelWidth || heights[head] != pixelHeight) {
|
|
5780
6867
|
if (widths[head] * heights[head] != pixelWidth * pixelHeight) {
|
|
@@ -5799,8 +6886,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5799
6886
|
size++;
|
|
5800
6887
|
}
|
|
5801
6888
|
|
|
5802
|
-
|
|
5803
|
-
|
|
6889
|
+
/**
|
|
6890
|
+
*
|
|
6891
|
+
*/
|
|
6892
|
+
public void endTransfer() {
|
|
5804
6893
|
pgl.deleteSync(fences[tail]);
|
|
5805
6894
|
pgl.bindBuffer(PGL.PIXEL_PACK_BUFFER, pbos[tail]);
|
|
5806
6895
|
ByteBuffer readBuffer = pgl.mapBuffer(PGL.PIXEL_PACK_BUFFER,
|
|
@@ -5834,6 +6923,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5834
6923
|
|
|
5835
6924
|
// Loads the current contents of the renderer's drawing surface into the
|
|
5836
6925
|
// its texture.
|
|
6926
|
+
|
|
6927
|
+
/**
|
|
6928
|
+
*
|
|
6929
|
+
*/
|
|
5837
6930
|
public void loadTexture() {
|
|
5838
6931
|
boolean needEndDraw = false;
|
|
5839
6932
|
if (!drawing) {
|
|
@@ -5891,6 +6984,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5891
6984
|
|
|
5892
6985
|
|
|
5893
6986
|
// Just marks the whole texture as updated
|
|
6987
|
+
|
|
6988
|
+
/**
|
|
6989
|
+
*
|
|
6990
|
+
*/
|
|
5894
6991
|
public void updateTexture() {
|
|
5895
6992
|
if (texture != null) {
|
|
5896
6993
|
texture.updateTexels();
|
|
@@ -5900,6 +6997,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5900
6997
|
|
|
5901
6998
|
// Marks the specified rectanglular subregion in the texture as
|
|
5902
6999
|
// updated.
|
|
7000
|
+
|
|
7001
|
+
/**
|
|
7002
|
+
*
|
|
7003
|
+
* @param x
|
|
7004
|
+
* @param y
|
|
7005
|
+
* @param w
|
|
7006
|
+
* @param h
|
|
7007
|
+
*/
|
|
5903
7008
|
public void updateTexture(int x, int y, int w, int h) {
|
|
5904
7009
|
if (texture != null) {
|
|
5905
7010
|
texture.updateTexels(x, y, w, h);
|
|
@@ -5908,6 +7013,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5908
7013
|
|
|
5909
7014
|
|
|
5910
7015
|
// Draws wherever it is in the screen texture right now to the display.
|
|
7016
|
+
|
|
7017
|
+
/**
|
|
7018
|
+
*
|
|
7019
|
+
*/
|
|
5911
7020
|
public void updateDisplay() {
|
|
5912
7021
|
flush();
|
|
5913
7022
|
beginPixelsOp(OP_WRITE);
|
|
@@ -5915,8 +7024,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5915
7024
|
endPixelsOp();
|
|
5916
7025
|
}
|
|
5917
7026
|
|
|
5918
|
-
|
|
5919
|
-
|
|
7027
|
+
/**
|
|
7028
|
+
*
|
|
7029
|
+
* @param sampling
|
|
7030
|
+
* @param mipmap
|
|
7031
|
+
*/
|
|
7032
|
+
protected void loadTextureImpl(int sampling, boolean mipmap) {
|
|
5920
7033
|
updatePixelSize();
|
|
5921
7034
|
if (pixelWidth == 0 || pixelHeight == 0) return;
|
|
5922
7035
|
if (texture == null || texture.contextIsOutdated()) {
|
|
@@ -5929,8 +7042,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5929
7042
|
}
|
|
5930
7043
|
}
|
|
5931
7044
|
|
|
5932
|
-
|
|
5933
|
-
|
|
7045
|
+
/**
|
|
7046
|
+
*
|
|
7047
|
+
*/
|
|
7048
|
+
protected void createPTexture() {
|
|
5934
7049
|
updatePixelSize();
|
|
5935
7050
|
if (texture != null) {
|
|
5936
7051
|
ptexture = new Texture(this, pixelWidth, pixelHeight, texture.getParameters());
|
|
@@ -5939,8 +7054,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5939
7054
|
}
|
|
5940
7055
|
}
|
|
5941
7056
|
|
|
5942
|
-
|
|
5943
|
-
|
|
7057
|
+
/**
|
|
7058
|
+
*
|
|
7059
|
+
*/
|
|
7060
|
+
protected void swapOffscreenTextures() {
|
|
5944
7061
|
FrameBuffer ofb = offscreenFramebuffer;
|
|
5945
7062
|
if (texture != null && ptexture != null && ofb != null) {
|
|
5946
7063
|
int temp = texture.glName;
|
|
@@ -5950,8 +7067,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5950
7067
|
}
|
|
5951
7068
|
}
|
|
5952
7069
|
|
|
5953
|
-
|
|
5954
|
-
|
|
7070
|
+
/**
|
|
7071
|
+
*
|
|
7072
|
+
*/
|
|
7073
|
+
protected void drawTexture() {
|
|
5955
7074
|
if (texture != null) {
|
|
5956
7075
|
// No blend so the texure replaces wherever is on the screen,
|
|
5957
7076
|
// irrespective of the alpha
|
|
@@ -5963,8 +7082,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5963
7082
|
}
|
|
5964
7083
|
}
|
|
5965
7084
|
|
|
5966
|
-
|
|
5967
|
-
|
|
7085
|
+
/**
|
|
7086
|
+
*
|
|
7087
|
+
* @param x
|
|
7088
|
+
* @param y
|
|
7089
|
+
* @param w
|
|
7090
|
+
* @param h
|
|
7091
|
+
*/
|
|
7092
|
+
protected void drawTexture(int x, int y, int w, int h) {
|
|
5968
7093
|
if (texture != null) {
|
|
5969
7094
|
// Processing Y axis is inverted with respect to OpenGL, so we need to
|
|
5970
7095
|
// invert the y coordinates of the screen rectangle.
|
|
@@ -5978,8 +7103,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
5978
7103
|
}
|
|
5979
7104
|
}
|
|
5980
7105
|
|
|
5981
|
-
|
|
5982
|
-
|
|
7106
|
+
/**
|
|
7107
|
+
*
|
|
7108
|
+
*/
|
|
7109
|
+
protected void drawPTexture() {
|
|
5983
7110
|
if (ptexture != null) {
|
|
5984
7111
|
// No blend so the texure replaces wherever is on the screen,
|
|
5985
7112
|
// irrespective of the alpha
|
|
@@ -6338,10 +7465,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6338
7465
|
|
|
6339
7466
|
|
|
6340
7467
|
/**
|
|
6341
|
-
* Not an approved function, this will change or be removed in the future.
|
|
6342
|
-
* This utility method returns the texture associated to the renderer's.
|
|
7468
|
+
* Not an approved function, this will change or be removed in the future.This utility method returns the texture associated to the renderer's.
|
|
6343
7469
|
* drawing surface, making sure is updated to reflect the current contents
|
|
6344
|
-
|
|
7470
|
+
off the screen (or offscreen drawing surface).
|
|
7471
|
+
* @return
|
|
6345
7472
|
*/
|
|
6346
7473
|
public Texture getTexture() {
|
|
6347
7474
|
return getTexture(true);
|
|
@@ -6350,6 +7477,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6350
7477
|
|
|
6351
7478
|
/**
|
|
6352
7479
|
* Not an approved function either, don't use it.
|
|
7480
|
+
* @param load
|
|
7481
|
+
* @return
|
|
6353
7482
|
*/
|
|
6354
7483
|
public Texture getTexture(boolean load) {
|
|
6355
7484
|
if (load) loadTexture();
|
|
@@ -6358,11 +7487,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6358
7487
|
|
|
6359
7488
|
|
|
6360
7489
|
/**
|
|
6361
|
-
* Not an approved function, this will change or be removed in the future.
|
|
6362
|
-
* This utility method returns the texture associated to the image.
|
|
7490
|
+
* Not an approved function, this will change or be removed in the future.This utility method returns the texture associated to the image.
|
|
6363
7491
|
* creating and/or updating it if needed.
|
|
6364
7492
|
*
|
|
6365
7493
|
* @param img the image to have a texture metadata associated to it
|
|
7494
|
+
* @return
|
|
6366
7495
|
*/
|
|
6367
7496
|
public Texture getTexture(PImage img) {
|
|
6368
7497
|
Texture tex = (Texture)initCache(img);
|
|
@@ -6388,13 +7517,18 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6388
7517
|
/**
|
|
6389
7518
|
* Not an approved function, test its use in libraries to grab the FB objects
|
|
6390
7519
|
* for offscreen PGraphics.
|
|
7520
|
+
* @return
|
|
6391
7521
|
*/
|
|
6392
7522
|
public FrameBuffer getFrameBuffer() {
|
|
6393
7523
|
return getFrameBuffer(false);
|
|
6394
7524
|
}
|
|
6395
7525
|
|
|
6396
|
-
|
|
6397
|
-
|
|
7526
|
+
/**
|
|
7527
|
+
*
|
|
7528
|
+
* @param multi
|
|
7529
|
+
* @return
|
|
7530
|
+
*/
|
|
7531
|
+
public FrameBuffer getFrameBuffer(boolean multi) {
|
|
6398
7532
|
if (multi) {
|
|
6399
7533
|
return multisampleFramebuffer;
|
|
6400
7534
|
} else {
|
|
@@ -6402,8 +7536,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6402
7536
|
}
|
|
6403
7537
|
}
|
|
6404
7538
|
|
|
6405
|
-
|
|
6406
|
-
|
|
7539
|
+
/**
|
|
7540
|
+
*
|
|
7541
|
+
* @param img
|
|
7542
|
+
* @return
|
|
7543
|
+
*/
|
|
7544
|
+
protected Object initCache(PImage img) {
|
|
6407
7545
|
if (!checkGLThread()) {
|
|
6408
7546
|
return null;
|
|
6409
7547
|
}
|
|
@@ -6420,8 +7558,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6420
7558
|
return tex;
|
|
6421
7559
|
}
|
|
6422
7560
|
|
|
6423
|
-
|
|
6424
|
-
|
|
7561
|
+
/**
|
|
7562
|
+
*
|
|
7563
|
+
*/
|
|
7564
|
+
protected void bindFrontTexture() {
|
|
6425
7565
|
if (primaryGraphics) {
|
|
6426
7566
|
pgl.bindFrontTexture();
|
|
6427
7567
|
} else {
|
|
@@ -6432,8 +7572,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6432
7572
|
}
|
|
6433
7573
|
}
|
|
6434
7574
|
|
|
6435
|
-
|
|
6436
|
-
|
|
7575
|
+
/**
|
|
7576
|
+
*
|
|
7577
|
+
*/
|
|
7578
|
+
protected void unbindFrontTexture() {
|
|
6437
7579
|
if (primaryGraphics) {
|
|
6438
7580
|
pgl.unbindFrontTexture();
|
|
6439
7581
|
} else {
|
|
@@ -6446,6 +7588,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6446
7588
|
* This utility method creates a texture for the provided image, and adds it
|
|
6447
7589
|
* to the metadata cache of the image.
|
|
6448
7590
|
* @param img the image to have a texture metadata associated to it
|
|
7591
|
+
* @return
|
|
6449
7592
|
*/
|
|
6450
7593
|
protected Texture addTexture(PImage img) {
|
|
6451
7594
|
Texture.Parameters params =
|
|
@@ -6454,8 +7597,13 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6454
7597
|
return addTexture(img, params);
|
|
6455
7598
|
}
|
|
6456
7599
|
|
|
6457
|
-
|
|
6458
|
-
|
|
7600
|
+
/**
|
|
7601
|
+
*
|
|
7602
|
+
* @param img
|
|
7603
|
+
* @param params
|
|
7604
|
+
* @return
|
|
7605
|
+
*/
|
|
7606
|
+
protected Texture addTexture(PImage img, Texture.Parameters params) {
|
|
6459
7607
|
if (img.width == 0 || img.height == 0) {
|
|
6460
7608
|
// Cannot add textures of size 0
|
|
6461
7609
|
return null;
|
|
@@ -6468,8 +7616,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6468
7616
|
return tex;
|
|
6469
7617
|
}
|
|
6470
7618
|
|
|
6471
|
-
|
|
6472
|
-
|
|
7619
|
+
/**
|
|
7620
|
+
*
|
|
7621
|
+
* @param tex
|
|
7622
|
+
*/
|
|
7623
|
+
protected void checkTexture(Texture tex) {
|
|
6473
7624
|
if (!tex.colorBuffer() &&
|
|
6474
7625
|
(tex.usingMipmaps == hints[DISABLE_TEXTURE_MIPMAPS] ||
|
|
6475
7626
|
tex.currentSampling() != textureSampling)) {
|
|
@@ -6490,8 +7641,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6490
7641
|
}
|
|
6491
7642
|
}
|
|
6492
7643
|
|
|
6493
|
-
|
|
6494
|
-
|
|
7644
|
+
/**
|
|
7645
|
+
*
|
|
7646
|
+
* @param tex
|
|
7647
|
+
* @return
|
|
7648
|
+
*/
|
|
7649
|
+
protected PImage wrapTexture(Texture tex) {
|
|
6495
7650
|
// We don't use the PImage(int width, int height, int mode) constructor to
|
|
6496
7651
|
// avoid initializing the pixels array.
|
|
6497
7652
|
PImage img = new PImage();
|
|
@@ -6503,8 +7658,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6503
7658
|
return img;
|
|
6504
7659
|
}
|
|
6505
7660
|
|
|
6506
|
-
|
|
6507
|
-
|
|
7661
|
+
/**
|
|
7662
|
+
*
|
|
7663
|
+
* @param img
|
|
7664
|
+
* @param tex
|
|
7665
|
+
*/
|
|
7666
|
+
protected void updateTexture(PImage img, Texture tex) {
|
|
6508
7667
|
if (tex != null) {
|
|
6509
7668
|
if (img.isModified()) {
|
|
6510
7669
|
int x = img.getModifiedX1();
|
|
@@ -6517,8 +7676,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6517
7676
|
img.setModified(false);
|
|
6518
7677
|
}
|
|
6519
7678
|
|
|
6520
|
-
|
|
6521
|
-
|
|
7679
|
+
/**
|
|
7680
|
+
*
|
|
7681
|
+
*/
|
|
7682
|
+
protected void deleteSurfaceTextures() {
|
|
6522
7683
|
if (texture != null) {
|
|
6523
7684
|
texture.dispose();
|
|
6524
7685
|
}
|
|
@@ -6534,8 +7695,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6534
7695
|
|
|
6535
7696
|
}
|
|
6536
7697
|
|
|
6537
|
-
|
|
6538
|
-
|
|
7698
|
+
/**
|
|
7699
|
+
*
|
|
7700
|
+
* @return
|
|
7701
|
+
*/
|
|
7702
|
+
protected boolean checkGLThread() {
|
|
6539
7703
|
if (pgl.threadIsCurrent()) {
|
|
6540
7704
|
return true;
|
|
6541
7705
|
} else {
|
|
@@ -6560,6 +7724,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6560
7724
|
|
|
6561
7725
|
// INITIALIZATION ROUTINES
|
|
6562
7726
|
|
|
7727
|
+
/**
|
|
7728
|
+
*
|
|
7729
|
+
*/
|
|
7730
|
+
|
|
6563
7731
|
|
|
6564
7732
|
protected void initPrimary() {
|
|
6565
7733
|
pgl.initSurface(smooth);
|
|
@@ -6571,8 +7739,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6571
7739
|
initialized = true;
|
|
6572
7740
|
}
|
|
6573
7741
|
|
|
6574
|
-
|
|
6575
|
-
|
|
7742
|
+
/**
|
|
7743
|
+
*
|
|
7744
|
+
*/
|
|
7745
|
+
protected void beginOnscreenDraw() {
|
|
6576
7746
|
updatePixelSize();
|
|
6577
7747
|
|
|
6578
7748
|
pgl.beginRender();
|
|
@@ -6595,13 +7765,17 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6595
7765
|
}
|
|
6596
7766
|
}
|
|
6597
7767
|
|
|
6598
|
-
|
|
6599
|
-
|
|
7768
|
+
/**
|
|
7769
|
+
*
|
|
7770
|
+
*/
|
|
7771
|
+
protected void endOnscreenDraw() {
|
|
6600
7772
|
pgl.endRender(parent.sketchWindowColor());
|
|
6601
7773
|
}
|
|
6602
7774
|
|
|
6603
|
-
|
|
6604
|
-
|
|
7775
|
+
/**
|
|
7776
|
+
*
|
|
7777
|
+
*/
|
|
7778
|
+
protected void initOffscreen() {
|
|
6605
7779
|
// Getting the context and capabilities from the main renderer.
|
|
6606
7780
|
loadTextureImpl(textureSampling, false);
|
|
6607
7781
|
|
|
@@ -6652,8 +7826,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6652
7826
|
initialized = true;
|
|
6653
7827
|
}
|
|
6654
7828
|
|
|
6655
|
-
|
|
6656
|
-
|
|
7829
|
+
/**
|
|
7830
|
+
*
|
|
7831
|
+
*/
|
|
7832
|
+
protected void beginOffscreenDraw() {
|
|
6657
7833
|
if (!initialized) {
|
|
6658
7834
|
initOffscreen();
|
|
6659
7835
|
} else {
|
|
@@ -6697,8 +7873,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6697
7873
|
}
|
|
6698
7874
|
}
|
|
6699
7875
|
|
|
6700
|
-
|
|
6701
|
-
|
|
7876
|
+
/**
|
|
7877
|
+
*
|
|
7878
|
+
*/
|
|
7879
|
+
protected void endOffscreenDraw() {
|
|
6702
7880
|
if (offscreenMultisample) {
|
|
6703
7881
|
FrameBuffer ofb = offscreenFramebuffer;
|
|
6704
7882
|
FrameBuffer mfb = multisampleFramebuffer;
|
|
@@ -6726,8 +7904,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6726
7904
|
getPrimaryPG().restoreGL();
|
|
6727
7905
|
}
|
|
6728
7906
|
|
|
6729
|
-
|
|
6730
|
-
|
|
7907
|
+
/**
|
|
7908
|
+
*
|
|
7909
|
+
*/
|
|
7910
|
+
protected void setViewport() {
|
|
6731
7911
|
viewport.put(0, 0); viewport.put(1, 0);
|
|
6732
7912
|
viewport.put(2, width); viewport.put(3, height);
|
|
6733
7913
|
pgl.viewport(viewport.get(0), viewport.get(1),
|
|
@@ -6741,8 +7921,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6741
7921
|
setGLSettings();
|
|
6742
7922
|
}
|
|
6743
7923
|
|
|
6744
|
-
|
|
6745
|
-
|
|
7924
|
+
/**
|
|
7925
|
+
*
|
|
7926
|
+
*/
|
|
7927
|
+
protected void setGLSettings() {
|
|
6746
7928
|
inGeo.clear();
|
|
6747
7929
|
tessGeo.clear();
|
|
6748
7930
|
texCache.clear();
|
|
@@ -6852,8 +8034,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
6852
8034
|
loaded = false;
|
|
6853
8035
|
}
|
|
6854
8036
|
|
|
6855
|
-
|
|
6856
|
-
|
|
8037
|
+
/**
|
|
8038
|
+
*
|
|
8039
|
+
*/
|
|
8040
|
+
protected void getGLParameters() {
|
|
6857
8041
|
OPENGL_VENDOR = pgl.getString(PGL.VENDOR);
|
|
6858
8042
|
OPENGL_RENDERER = pgl.getString(PGL.RENDERER);
|
|
6859
8043
|
OPENGL_VERSION = pgl.getString(PGL.VERSION);
|
|
@@ -7012,8 +8196,13 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7012
8196
|
}
|
|
7013
8197
|
}
|
|
7014
8198
|
|
|
7015
|
-
|
|
7016
|
-
|
|
8199
|
+
/**
|
|
8200
|
+
*
|
|
8201
|
+
* @param lit
|
|
8202
|
+
* @param tex
|
|
8203
|
+
* @return
|
|
8204
|
+
*/
|
|
8205
|
+
protected PShader getPolyShader(boolean lit, boolean tex) {
|
|
7017
8206
|
PShader shader;
|
|
7018
8207
|
PGraphicsOpenGL ppg = getPrimaryPG();
|
|
7019
8208
|
boolean useDefault = polyShader == null;
|
|
@@ -7084,8 +8273,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7084
8273
|
return shader;
|
|
7085
8274
|
}
|
|
7086
8275
|
|
|
7087
|
-
|
|
7088
|
-
|
|
8276
|
+
/**
|
|
8277
|
+
*
|
|
8278
|
+
* @return
|
|
8279
|
+
*/
|
|
8280
|
+
protected PShader getLineShader() {
|
|
7089
8281
|
PShader shader;
|
|
7090
8282
|
PGraphicsOpenGL ppg = getPrimaryPG();
|
|
7091
8283
|
if (lineShader == null) {
|
|
@@ -7104,8 +8296,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7104
8296
|
return shader;
|
|
7105
8297
|
}
|
|
7106
8298
|
|
|
7107
|
-
|
|
7108
|
-
|
|
8299
|
+
/**
|
|
8300
|
+
*
|
|
8301
|
+
* @return
|
|
8302
|
+
*/
|
|
8303
|
+
protected PShader getPointShader() {
|
|
7109
8304
|
PShader shader;
|
|
7110
8305
|
PGraphicsOpenGL ppg = getPrimaryPG();
|
|
7111
8306
|
if (pointShader == null) {
|
|
@@ -7129,6 +8324,13 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7129
8324
|
|
|
7130
8325
|
// Utils
|
|
7131
8326
|
|
|
8327
|
+
/**
|
|
8328
|
+
*
|
|
8329
|
+
* @param currSize
|
|
8330
|
+
* @param newMinSize
|
|
8331
|
+
* @return
|
|
8332
|
+
*/
|
|
8333
|
+
|
|
7132
8334
|
static protected int expandArraySize(int currSize, int newMinSize) {
|
|
7133
8335
|
int newSize = currSize;
|
|
7134
8336
|
while (newSize < newMinSize) {
|
|
@@ -7141,17 +8343,36 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7141
8343
|
|
|
7142
8344
|
// Generic vertex attributes.
|
|
7143
8345
|
|
|
7144
|
-
|
|
7145
|
-
|
|
8346
|
+
/**
|
|
8347
|
+
*
|
|
8348
|
+
* @return
|
|
8349
|
+
*/
|
|
8350
|
+
static protected AttributeMap newAttributeMap() {
|
|
7146
8351
|
return new AttributeMap();
|
|
7147
8352
|
}
|
|
7148
8353
|
|
|
8354
|
+
/**
|
|
8355
|
+
*
|
|
8356
|
+
*/
|
|
8357
|
+
static protected class AttributeMap extends HashMap<String, VertexAttribute> {
|
|
8358
|
+
|
|
8359
|
+
/**
|
|
8360
|
+
*
|
|
8361
|
+
*/
|
|
8362
|
+
public ArrayList<String> names = new ArrayList<>();
|
|
7149
8363
|
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
8364
|
+
/**
|
|
8365
|
+
*
|
|
8366
|
+
*/
|
|
8367
|
+
public int numComp = 0; // number of components for a single vertex
|
|
7153
8368
|
|
|
7154
|
-
|
|
8369
|
+
/**
|
|
8370
|
+
*
|
|
8371
|
+
* @param key
|
|
8372
|
+
* @param value
|
|
8373
|
+
* @return
|
|
8374
|
+
*/
|
|
8375
|
+
@Override
|
|
7155
8376
|
public VertexAttribute put(String key, VertexAttribute value) {
|
|
7156
8377
|
VertexAttribute prev = super.put(key, value);
|
|
7157
8378
|
names.add(key);
|
|
@@ -7160,13 +8381,20 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7160
8381
|
return prev;
|
|
7161
8382
|
}
|
|
7162
8383
|
|
|
7163
|
-
|
|
8384
|
+
/**
|
|
8385
|
+
*
|
|
8386
|
+
* @param i
|
|
8387
|
+
* @return
|
|
8388
|
+
*/
|
|
8389
|
+
public VertexAttribute get(int i) {
|
|
7164
8390
|
return super.get(names.get(i));
|
|
7165
8391
|
}
|
|
7166
8392
|
}
|
|
7167
8393
|
|
|
7168
|
-
|
|
7169
|
-
|
|
8394
|
+
/**
|
|
8395
|
+
*
|
|
8396
|
+
*/
|
|
8397
|
+
static protected class VertexAttribute {
|
|
7170
8398
|
static final int POSITION = 0;
|
|
7171
8399
|
static final int NORMAL = 1;
|
|
7172
8400
|
static final int COLOR = 2;
|
|
@@ -7226,7 +8454,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7226
8454
|
active = true;
|
|
7227
8455
|
}
|
|
7228
8456
|
|
|
7229
|
-
|
|
8457
|
+
/**
|
|
8458
|
+
*
|
|
8459
|
+
* @param attr
|
|
8460
|
+
* @return
|
|
8461
|
+
*/
|
|
8462
|
+
public boolean diff(VertexAttribute attr) {
|
|
7230
8463
|
return !name.equals(attr.name) ||
|
|
7231
8464
|
kind != attr.kind ||
|
|
7232
8465
|
type != attr.type ||
|
|
@@ -7342,26 +8575,48 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7342
8575
|
|
|
7343
8576
|
// Input (raw) and Tessellated geometry, tessellator.
|
|
7344
8577
|
|
|
8578
|
+
/**
|
|
8579
|
+
*
|
|
8580
|
+
* @param pg
|
|
8581
|
+
* @param attr
|
|
8582
|
+
* @param mode
|
|
8583
|
+
* @return
|
|
8584
|
+
*/
|
|
8585
|
+
|
|
7345
8586
|
|
|
7346
8587
|
static protected InGeometry newInGeometry(PGraphicsOpenGL pg, AttributeMap attr,
|
|
7347
8588
|
int mode) {
|
|
7348
8589
|
return new InGeometry(pg, attr, mode);
|
|
7349
8590
|
}
|
|
7350
8591
|
|
|
7351
|
-
|
|
7352
|
-
|
|
8592
|
+
/**
|
|
8593
|
+
*
|
|
8594
|
+
* @param pg
|
|
8595
|
+
* @param attr
|
|
8596
|
+
* @param mode
|
|
8597
|
+
* @return
|
|
8598
|
+
*/
|
|
8599
|
+
static protected TessGeometry newTessGeometry(PGraphicsOpenGL pg,
|
|
7353
8600
|
AttributeMap attr, int mode) {
|
|
7354
8601
|
return new TessGeometry(pg, attr, mode);
|
|
7355
8602
|
}
|
|
7356
8603
|
|
|
7357
|
-
|
|
7358
|
-
|
|
8604
|
+
/**
|
|
8605
|
+
*
|
|
8606
|
+
* @param pg
|
|
8607
|
+
* @return
|
|
8608
|
+
*/
|
|
8609
|
+
static protected TexCache newTexCache(PGraphicsOpenGL pg) {
|
|
7359
8610
|
return new TexCache(pg);
|
|
7360
8611
|
}
|
|
7361
8612
|
|
|
7362
8613
|
|
|
7363
8614
|
// Holds an array of textures and the range of vertex
|
|
7364
8615
|
// indices each texture applies to.
|
|
8616
|
+
|
|
8617
|
+
/**
|
|
8618
|
+
*
|
|
8619
|
+
*/
|
|
7365
8620
|
static protected class TexCache {
|
|
7366
8621
|
PGraphicsOpenGL pg;
|
|
7367
8622
|
int size;
|
|
@@ -7482,6 +8737,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7482
8737
|
// Stores the offsets and counts of indices and vertices
|
|
7483
8738
|
// to render a piece of geometry that doesn't fit in a single
|
|
7484
8739
|
// glDrawElements() call.
|
|
8740
|
+
|
|
8741
|
+
/**
|
|
8742
|
+
*
|
|
8743
|
+
*/
|
|
7485
8744
|
static protected class IndexCache {
|
|
7486
8745
|
int size;
|
|
7487
8746
|
int[] indexCount;
|
|
@@ -7597,6 +8856,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
7597
8856
|
|
|
7598
8857
|
// Holds the input vertices: xyz coordinates, fill/tint color,
|
|
7599
8858
|
// normal, texture coordinates and stroke color and weight.
|
|
8859
|
+
|
|
8860
|
+
/**
|
|
8861
|
+
*
|
|
8862
|
+
*/
|
|
7600
8863
|
static protected class InGeometry {
|
|
7601
8864
|
PGraphicsOpenGL pg;
|
|
7602
8865
|
int renderMode;
|
|
@@ -8281,7 +9544,20 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
8281
9544
|
return vertexCount - 1;
|
|
8282
9545
|
}
|
|
8283
9546
|
|
|
8284
|
-
|
|
9547
|
+
/**
|
|
9548
|
+
*
|
|
9549
|
+
* @param x2
|
|
9550
|
+
* @param y2
|
|
9551
|
+
* @param z2
|
|
9552
|
+
* @param x3
|
|
9553
|
+
* @param y3
|
|
9554
|
+
* @param z3
|
|
9555
|
+
* @param x4
|
|
9556
|
+
* @param y4
|
|
9557
|
+
* @param z4
|
|
9558
|
+
* @param brk
|
|
9559
|
+
*/
|
|
9560
|
+
public void addBezierVertex(float x2, float y2, float z2,
|
|
8285
9561
|
float x3, float y3, float z3,
|
|
8286
9562
|
float x4, float y4, float z4,
|
|
8287
9563
|
boolean brk) {
|
|
@@ -8290,14 +9566,31 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
8290
9566
|
addVertex(x4, y4, z4, -1, false);
|
|
8291
9567
|
}
|
|
8292
9568
|
|
|
8293
|
-
|
|
9569
|
+
/**
|
|
9570
|
+
*
|
|
9571
|
+
* @param cx
|
|
9572
|
+
* @param cy
|
|
9573
|
+
* @param cz
|
|
9574
|
+
* @param x3
|
|
9575
|
+
* @param y3
|
|
9576
|
+
* @param z3
|
|
9577
|
+
* @param brk
|
|
9578
|
+
*/
|
|
9579
|
+
public void addQuadraticVertex(float cx, float cy, float cz,
|
|
8294
9580
|
float x3, float y3, float z3,
|
|
8295
9581
|
boolean brk) {
|
|
8296
9582
|
addVertex(cx, cy, cz, QUADRATIC_VERTEX, brk);
|
|
8297
9583
|
addVertex(x3, y3, z3, -1, false);
|
|
8298
9584
|
}
|
|
8299
9585
|
|
|
8300
|
-
|
|
9586
|
+
/**
|
|
9587
|
+
*
|
|
9588
|
+
* @param x
|
|
9589
|
+
* @param y
|
|
9590
|
+
* @param z
|
|
9591
|
+
* @param brk
|
|
9592
|
+
*/
|
|
9593
|
+
public void addCurveVertex(float x, float y, float z, boolean brk) {
|
|
8301
9594
|
addVertex(x, y, z, CURVE_VERTEX, brk);
|
|
8302
9595
|
}
|
|
8303
9596
|
|
|
@@ -9089,6 +10382,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
9089
10382
|
|
|
9090
10383
|
|
|
9091
10384
|
// Holds tessellated data for polygon, line and point geometry.
|
|
10385
|
+
|
|
10386
|
+
/**
|
|
10387
|
+
*
|
|
10388
|
+
*/
|
|
9092
10389
|
static protected class TessGeometry {
|
|
9093
10390
|
int renderMode;
|
|
9094
10391
|
PGraphicsOpenGL pg;
|
|
@@ -9476,78 +10773,153 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
9476
10773
|
//
|
|
9477
10774
|
// Methods to prepare buffers for relative read/write operations
|
|
9478
10775
|
|
|
10776
|
+
/**
|
|
10777
|
+
*
|
|
10778
|
+
*/
|
|
10779
|
+
|
|
9479
10780
|
protected void updatePolyVerticesBuffer() {
|
|
9480
10781
|
updatePolyVerticesBuffer(0, polyVertexCount);
|
|
9481
10782
|
}
|
|
9482
10783
|
|
|
9483
|
-
|
|
10784
|
+
/**
|
|
10785
|
+
*
|
|
10786
|
+
* @param offset
|
|
10787
|
+
* @param size
|
|
10788
|
+
*/
|
|
10789
|
+
protected void updatePolyVerticesBuffer(int offset, int size) {
|
|
9484
10790
|
PGL.updateFloatBuffer(polyVerticesBuffer, polyVertices,
|
|
9485
10791
|
4 * offset, 4 * size);
|
|
9486
10792
|
}
|
|
9487
10793
|
|
|
9488
|
-
|
|
10794
|
+
/**
|
|
10795
|
+
*
|
|
10796
|
+
*/
|
|
10797
|
+
protected void updatePolyColorsBuffer() {
|
|
9489
10798
|
updatePolyColorsBuffer(0, polyVertexCount);
|
|
9490
10799
|
}
|
|
9491
10800
|
|
|
9492
|
-
|
|
10801
|
+
/**
|
|
10802
|
+
*
|
|
10803
|
+
* @param offset
|
|
10804
|
+
* @param size
|
|
10805
|
+
*/
|
|
10806
|
+
protected void updatePolyColorsBuffer(int offset, int size) {
|
|
9493
10807
|
PGL.updateIntBuffer(polyColorsBuffer, polyColors, offset, size);
|
|
9494
10808
|
}
|
|
9495
10809
|
|
|
9496
|
-
|
|
10810
|
+
/**
|
|
10811
|
+
*
|
|
10812
|
+
*/
|
|
10813
|
+
protected void updatePolyNormalsBuffer() {
|
|
9497
10814
|
updatePolyNormalsBuffer(0, polyVertexCount);
|
|
9498
10815
|
}
|
|
9499
10816
|
|
|
9500
|
-
|
|
10817
|
+
/**
|
|
10818
|
+
*
|
|
10819
|
+
* @param offset
|
|
10820
|
+
* @param size
|
|
10821
|
+
*/
|
|
10822
|
+
protected void updatePolyNormalsBuffer(int offset, int size) {
|
|
9501
10823
|
PGL.updateFloatBuffer(polyNormalsBuffer, polyNormals,
|
|
9502
10824
|
3 * offset, 3 * size);
|
|
9503
10825
|
}
|
|
9504
10826
|
|
|
9505
|
-
|
|
10827
|
+
/**
|
|
10828
|
+
*
|
|
10829
|
+
*/
|
|
10830
|
+
protected void updatePolyTexCoordsBuffer() {
|
|
9506
10831
|
updatePolyTexCoordsBuffer(0, polyVertexCount);
|
|
9507
10832
|
}
|
|
9508
10833
|
|
|
9509
|
-
|
|
10834
|
+
/**
|
|
10835
|
+
*
|
|
10836
|
+
* @param offset
|
|
10837
|
+
* @param size
|
|
10838
|
+
*/
|
|
10839
|
+
protected void updatePolyTexCoordsBuffer(int offset, int size) {
|
|
9510
10840
|
PGL.updateFloatBuffer(polyTexCoordsBuffer, polyTexCoords,
|
|
9511
10841
|
2 * offset, 2 * size);
|
|
9512
10842
|
}
|
|
9513
10843
|
|
|
9514
|
-
|
|
10844
|
+
/**
|
|
10845
|
+
*
|
|
10846
|
+
*/
|
|
10847
|
+
protected void updatePolyAmbientBuffer() {
|
|
9515
10848
|
updatePolyAmbientBuffer(0, polyVertexCount);
|
|
9516
10849
|
}
|
|
9517
10850
|
|
|
9518
|
-
|
|
10851
|
+
/**
|
|
10852
|
+
*
|
|
10853
|
+
* @param offset
|
|
10854
|
+
* @param size
|
|
10855
|
+
*/
|
|
10856
|
+
protected void updatePolyAmbientBuffer(int offset, int size) {
|
|
9519
10857
|
PGL.updateIntBuffer(polyAmbientBuffer, polyAmbient, offset, size);
|
|
9520
10858
|
}
|
|
9521
10859
|
|
|
9522
|
-
|
|
10860
|
+
/**
|
|
10861
|
+
*
|
|
10862
|
+
*/
|
|
10863
|
+
protected void updatePolySpecularBuffer() {
|
|
9523
10864
|
updatePolySpecularBuffer(0, polyVertexCount);
|
|
9524
10865
|
}
|
|
9525
10866
|
|
|
9526
|
-
|
|
10867
|
+
/**
|
|
10868
|
+
*
|
|
10869
|
+
* @param offset
|
|
10870
|
+
* @param size
|
|
10871
|
+
*/
|
|
10872
|
+
protected void updatePolySpecularBuffer(int offset, int size) {
|
|
9527
10873
|
PGL.updateIntBuffer(polySpecularBuffer, polySpecular, offset, size);
|
|
9528
10874
|
}
|
|
9529
10875
|
|
|
9530
|
-
|
|
10876
|
+
/**
|
|
10877
|
+
*
|
|
10878
|
+
*/
|
|
10879
|
+
protected void updatePolyEmissiveBuffer() {
|
|
9531
10880
|
updatePolyEmissiveBuffer(0, polyVertexCount);
|
|
9532
10881
|
}
|
|
9533
10882
|
|
|
9534
|
-
|
|
10883
|
+
/**
|
|
10884
|
+
*
|
|
10885
|
+
* @param offset
|
|
10886
|
+
* @param size
|
|
10887
|
+
*/
|
|
10888
|
+
protected void updatePolyEmissiveBuffer(int offset, int size) {
|
|
9535
10889
|
PGL.updateIntBuffer(polyEmissiveBuffer, polyEmissive, offset, size);
|
|
9536
10890
|
}
|
|
9537
10891
|
|
|
9538
|
-
|
|
10892
|
+
/**
|
|
10893
|
+
*
|
|
10894
|
+
*/
|
|
10895
|
+
protected void updatePolyShininessBuffer() {
|
|
9539
10896
|
updatePolyShininessBuffer(0, polyVertexCount);
|
|
9540
10897
|
}
|
|
9541
10898
|
|
|
9542
|
-
|
|
10899
|
+
/**
|
|
10900
|
+
*
|
|
10901
|
+
* @param offset
|
|
10902
|
+
* @param size
|
|
10903
|
+
*/
|
|
10904
|
+
protected void updatePolyShininessBuffer(int offset, int size) {
|
|
9543
10905
|
PGL.updateFloatBuffer(polyShininessBuffer, polyShininess, offset, size);
|
|
9544
10906
|
}
|
|
9545
10907
|
|
|
9546
|
-
|
|
10908
|
+
/**
|
|
10909
|
+
*
|
|
10910
|
+
* @param name
|
|
10911
|
+
*/
|
|
10912
|
+
protected void updateAttribBuffer(String name) {
|
|
9547
10913
|
updateAttribBuffer(name, 0, polyVertexCount);
|
|
9548
10914
|
}
|
|
9549
10915
|
|
|
9550
|
-
|
|
10916
|
+
/**
|
|
10917
|
+
*
|
|
10918
|
+
* @param name
|
|
10919
|
+
* @param offset
|
|
10920
|
+
* @param size
|
|
10921
|
+
*/
|
|
10922
|
+
protected void updateAttribBuffer(String name, int offset, int size) {
|
|
9551
10923
|
VertexAttribute attrib = polyAttribs.get(name);
|
|
9552
10924
|
if (attrib.type == PGL.FLOAT) {
|
|
9553
10925
|
FloatBuffer buffer = (FloatBuffer)polyAttribBuffers.get(name);
|
|
@@ -9567,79 +10939,151 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
9567
10939
|
}
|
|
9568
10940
|
}
|
|
9569
10941
|
|
|
9570
|
-
|
|
10942
|
+
/**
|
|
10943
|
+
*
|
|
10944
|
+
*/
|
|
10945
|
+
protected void updatePolyIndicesBuffer() {
|
|
9571
10946
|
updatePolyIndicesBuffer(0, polyIndexCount);
|
|
9572
10947
|
}
|
|
9573
10948
|
|
|
9574
|
-
|
|
10949
|
+
/**
|
|
10950
|
+
*
|
|
10951
|
+
* @param offset
|
|
10952
|
+
* @param size
|
|
10953
|
+
*/
|
|
10954
|
+
protected void updatePolyIndicesBuffer(int offset, int size) {
|
|
9575
10955
|
PGL.updateShortBuffer(polyIndicesBuffer, polyIndices, offset, size);
|
|
9576
10956
|
}
|
|
9577
10957
|
|
|
9578
|
-
|
|
10958
|
+
/**
|
|
10959
|
+
*
|
|
10960
|
+
*/
|
|
10961
|
+
protected void updateLineVerticesBuffer() {
|
|
9579
10962
|
updateLineVerticesBuffer(0, lineVertexCount);
|
|
9580
10963
|
}
|
|
9581
10964
|
|
|
9582
|
-
|
|
10965
|
+
/**
|
|
10966
|
+
*
|
|
10967
|
+
* @param offset
|
|
10968
|
+
* @param size
|
|
10969
|
+
*/
|
|
10970
|
+
protected void updateLineVerticesBuffer(int offset, int size) {
|
|
9583
10971
|
PGL.updateFloatBuffer(lineVerticesBuffer, lineVertices,
|
|
9584
10972
|
4 * offset, 4 * size);
|
|
9585
10973
|
}
|
|
9586
10974
|
|
|
9587
|
-
|
|
10975
|
+
/**
|
|
10976
|
+
*
|
|
10977
|
+
*/
|
|
10978
|
+
protected void updateLineColorsBuffer() {
|
|
9588
10979
|
updateLineColorsBuffer(0, lineVertexCount);
|
|
9589
10980
|
}
|
|
9590
10981
|
|
|
9591
|
-
|
|
10982
|
+
/**
|
|
10983
|
+
*
|
|
10984
|
+
* @param offset
|
|
10985
|
+
* @param size
|
|
10986
|
+
*/
|
|
10987
|
+
protected void updateLineColorsBuffer(int offset, int size) {
|
|
9592
10988
|
PGL.updateIntBuffer(lineColorsBuffer, lineColors, offset, size);
|
|
9593
10989
|
}
|
|
9594
10990
|
|
|
9595
|
-
|
|
10991
|
+
/**
|
|
10992
|
+
*
|
|
10993
|
+
*/
|
|
10994
|
+
protected void updateLineDirectionsBuffer() {
|
|
9596
10995
|
updateLineDirectionsBuffer(0, lineVertexCount);
|
|
9597
10996
|
}
|
|
9598
10997
|
|
|
9599
|
-
|
|
10998
|
+
/**
|
|
10999
|
+
*
|
|
11000
|
+
* @param offset
|
|
11001
|
+
* @param size
|
|
11002
|
+
*/
|
|
11003
|
+
protected void updateLineDirectionsBuffer(int offset, int size) {
|
|
9600
11004
|
PGL.updateFloatBuffer(lineDirectionsBuffer, lineDirections,
|
|
9601
11005
|
4 * offset, 4 * size);
|
|
9602
11006
|
}
|
|
9603
11007
|
|
|
9604
|
-
|
|
11008
|
+
/**
|
|
11009
|
+
*
|
|
11010
|
+
*/
|
|
11011
|
+
protected void updateLineIndicesBuffer() {
|
|
9605
11012
|
updateLineIndicesBuffer(0, lineIndexCount);
|
|
9606
11013
|
}
|
|
9607
11014
|
|
|
9608
|
-
|
|
11015
|
+
/**
|
|
11016
|
+
*
|
|
11017
|
+
* @param offset
|
|
11018
|
+
* @param size
|
|
11019
|
+
*/
|
|
11020
|
+
protected void updateLineIndicesBuffer(int offset, int size) {
|
|
9609
11021
|
PGL.updateShortBuffer(lineIndicesBuffer, lineIndices, offset, size);
|
|
9610
11022
|
}
|
|
9611
11023
|
|
|
9612
|
-
|
|
11024
|
+
/**
|
|
11025
|
+
*
|
|
11026
|
+
*/
|
|
11027
|
+
protected void updatePointVerticesBuffer() {
|
|
9613
11028
|
updatePointVerticesBuffer(0, pointVertexCount);
|
|
9614
11029
|
}
|
|
9615
11030
|
|
|
9616
|
-
|
|
11031
|
+
/**
|
|
11032
|
+
*
|
|
11033
|
+
* @param offset
|
|
11034
|
+
* @param size
|
|
11035
|
+
*/
|
|
11036
|
+
protected void updatePointVerticesBuffer(int offset, int size) {
|
|
9617
11037
|
PGL.updateFloatBuffer(pointVerticesBuffer, pointVertices,
|
|
9618
11038
|
4 * offset, 4 * size);
|
|
9619
11039
|
}
|
|
9620
11040
|
|
|
9621
|
-
|
|
11041
|
+
/**
|
|
11042
|
+
*
|
|
11043
|
+
*/
|
|
11044
|
+
protected void updatePointColorsBuffer() {
|
|
9622
11045
|
updatePointColorsBuffer(0, pointVertexCount);
|
|
9623
11046
|
}
|
|
9624
11047
|
|
|
9625
|
-
|
|
11048
|
+
/**
|
|
11049
|
+
*
|
|
11050
|
+
* @param offset
|
|
11051
|
+
* @param size
|
|
11052
|
+
*/
|
|
11053
|
+
protected void updatePointColorsBuffer(int offset, int size) {
|
|
9626
11054
|
PGL.updateIntBuffer(pointColorsBuffer, pointColors, offset, size);
|
|
9627
11055
|
}
|
|
9628
11056
|
|
|
9629
|
-
|
|
11057
|
+
/**
|
|
11058
|
+
*
|
|
11059
|
+
*/
|
|
11060
|
+
protected void updatePointOffsetsBuffer() {
|
|
9630
11061
|
updatePointOffsetsBuffer(0, pointVertexCount);
|
|
9631
11062
|
}
|
|
9632
11063
|
|
|
9633
|
-
|
|
11064
|
+
/**
|
|
11065
|
+
*
|
|
11066
|
+
* @param offset
|
|
11067
|
+
* @param size
|
|
11068
|
+
*/
|
|
11069
|
+
protected void updatePointOffsetsBuffer(int offset, int size) {
|
|
9634
11070
|
PGL.updateFloatBuffer(pointOffsetsBuffer, pointOffsets,
|
|
9635
11071
|
2 * offset, 2 * size);
|
|
9636
11072
|
}
|
|
9637
11073
|
|
|
9638
|
-
|
|
11074
|
+
/**
|
|
11075
|
+
*
|
|
11076
|
+
*/
|
|
11077
|
+
protected void updatePointIndicesBuffer() {
|
|
9639
11078
|
updatePointIndicesBuffer(0, pointIndexCount);
|
|
9640
11079
|
}
|
|
9641
11080
|
|
|
9642
|
-
|
|
11081
|
+
/**
|
|
11082
|
+
*
|
|
11083
|
+
* @param offset
|
|
11084
|
+
* @param size
|
|
11085
|
+
*/
|
|
11086
|
+
protected void updatePointIndicesBuffer(int offset, int size) {
|
|
9643
11087
|
PGL.updateShortBuffer(pointIndicesBuffer, pointIndices, offset, size);
|
|
9644
11088
|
}
|
|
9645
11089
|
|
|
@@ -10892,6 +12336,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
10892
12336
|
}
|
|
10893
12337
|
|
|
10894
12338
|
// Generates tessellated geometry given a batch of input vertices.
|
|
12339
|
+
|
|
12340
|
+
/**
|
|
12341
|
+
*
|
|
12342
|
+
*/
|
|
10895
12343
|
static protected class Tessellator {
|
|
10896
12344
|
InGeometry in;
|
|
10897
12345
|
TessGeometry tess;
|
|
@@ -10915,7 +12363,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
10915
12363
|
PMatrix transform;
|
|
10916
12364
|
float transformScale;
|
|
10917
12365
|
boolean is2D, is3D;
|
|
10918
|
-
|
|
12366
|
+
|
|
12367
|
+
/**
|
|
12368
|
+
*
|
|
12369
|
+
*/
|
|
12370
|
+
protected PGraphicsOpenGL pg;
|
|
10919
12371
|
|
|
10920
12372
|
int[] rawIndices;
|
|
10921
12373
|
int rawSize;
|
|
@@ -10944,7 +12396,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
10944
12396
|
float[] pathWeights;
|
|
10945
12397
|
int beginPath;
|
|
10946
12398
|
|
|
10947
|
-
|
|
12399
|
+
/**
|
|
12400
|
+
*
|
|
12401
|
+
*/
|
|
12402
|
+
public Tessellator() {
|
|
10948
12403
|
rawIndices = new int[512];
|
|
10949
12404
|
accurate2DStrokes = true;
|
|
10950
12405
|
transform = null;
|
|
@@ -11007,7 +12462,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
11007
12462
|
this.accurate2DStrokes = accurate;
|
|
11008
12463
|
}
|
|
11009
12464
|
|
|
11010
|
-
|
|
12465
|
+
/**
|
|
12466
|
+
*
|
|
12467
|
+
* @param pg
|
|
12468
|
+
*/
|
|
12469
|
+
protected void setRenderer(PGraphicsOpenGL pg) {
|
|
11011
12470
|
this.pg = pg;
|
|
11012
12471
|
}
|
|
11013
12472
|
|
|
@@ -12956,6 +14415,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
12956
14415
|
// Tessellates the path given as parameter. This will work only in 2D.
|
|
12957
14416
|
// Based on the opengl stroke hack described here:
|
|
12958
14417
|
// http://wiki.processing.org/w/Stroke_attributes_in_OpenGL
|
|
14418
|
+
|
|
14419
|
+
/**
|
|
14420
|
+
*
|
|
14421
|
+
* @param path
|
|
14422
|
+
*/
|
|
12959
14423
|
public void tessellateLinePath(LinePath path) {
|
|
12960
14424
|
initGluTess();
|
|
12961
14425
|
boolean clamp = clampLinePath();
|
|
@@ -13037,6 +14501,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
13037
14501
|
// This C implementation of GLU could be useful:
|
|
13038
14502
|
// http://code.google.com/p/glues/
|
|
13039
14503
|
// to eventually come up with an optimized GLU tessellator in native code.
|
|
14504
|
+
|
|
14505
|
+
/**
|
|
14506
|
+
*
|
|
14507
|
+
*/
|
|
13040
14508
|
protected class TessellatorCallback implements PGL.TessellatorCallback {
|
|
13041
14509
|
AttributeMap attribs;
|
|
13042
14510
|
boolean calcNormals;
|
|
@@ -13049,11 +14517,22 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
13049
14517
|
int vertOffset;
|
|
13050
14518
|
int primitive;
|
|
13051
14519
|
|
|
13052
|
-
|
|
14520
|
+
/**
|
|
14521
|
+
*
|
|
14522
|
+
* @param attribs
|
|
14523
|
+
*/
|
|
14524
|
+
public TessellatorCallback(AttributeMap attribs) {
|
|
13053
14525
|
this.attribs = attribs;
|
|
13054
14526
|
}
|
|
13055
14527
|
|
|
13056
|
-
|
|
14528
|
+
/**
|
|
14529
|
+
*
|
|
14530
|
+
* @param addCache
|
|
14531
|
+
* @param strokeTess
|
|
14532
|
+
* @param calcNorm
|
|
14533
|
+
* @param clampXY
|
|
14534
|
+
*/
|
|
14535
|
+
public void init(boolean addCache, boolean strokeTess, boolean calcNorm,
|
|
13057
14536
|
boolean clampXY) {
|
|
13058
14537
|
this.strokeTess = strokeTess;
|
|
13059
14538
|
this.calcNormals = calcNorm;
|
|
@@ -13065,7 +14544,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
13065
14544
|
}
|
|
13066
14545
|
}
|
|
13067
14546
|
|
|
13068
|
-
|
|
14547
|
+
/**
|
|
14548
|
+
*
|
|
14549
|
+
* @param type
|
|
14550
|
+
*/
|
|
14551
|
+
public void begin(int type) {
|
|
13069
14552
|
cacheIndex = cache.getLast();
|
|
13070
14553
|
if (firstPolyIndexCache == -1) {
|
|
13071
14554
|
firstPolyIndexCache = cacheIndex;
|
|
@@ -13083,7 +14566,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
13083
14566
|
else if (type == PGL.TRIANGLES) primitive = TRIANGLES;
|
|
13084
14567
|
}
|
|
13085
14568
|
|
|
13086
|
-
|
|
14569
|
+
/**
|
|
14570
|
+
*
|
|
14571
|
+
*/
|
|
14572
|
+
public void end() {
|
|
13087
14573
|
if (PGL.MAX_VERTEX_INDEX1 <= vertFirst + vertCount) {
|
|
13088
14574
|
// We need a new index block for the new batch of
|
|
13089
14575
|
// vertices resulting from this primitive. tessVert can
|
|
@@ -13146,19 +14632,33 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
13146
14632
|
}
|
|
13147
14633
|
}
|
|
13148
14634
|
|
|
13149
|
-
|
|
14635
|
+
/**
|
|
14636
|
+
*
|
|
14637
|
+
* @param tessIdx
|
|
14638
|
+
*/
|
|
14639
|
+
protected void addIndex(int tessIdx) {
|
|
13150
14640
|
tess.polyIndexCheck();
|
|
13151
14641
|
tess.polyIndices[tess.polyIndexCount - 1] =
|
|
13152
14642
|
(short) (vertFirst + tessIdx);
|
|
13153
14643
|
}
|
|
13154
14644
|
|
|
13155
|
-
|
|
14645
|
+
/**
|
|
14646
|
+
*
|
|
14647
|
+
* @param tessIdx0
|
|
14648
|
+
* @param tessIdx1
|
|
14649
|
+
* @param tessIdx2
|
|
14650
|
+
*/
|
|
14651
|
+
protected void calcTriNormal(int tessIdx0, int tessIdx1, int tessIdx2) {
|
|
13156
14652
|
tess.calcPolyNormal(vertFirst + vertOffset + tessIdx0,
|
|
13157
14653
|
vertFirst + vertOffset + tessIdx1,
|
|
13158
14654
|
vertFirst + vertOffset + tessIdx2);
|
|
13159
14655
|
}
|
|
13160
14656
|
|
|
13161
|
-
|
|
14657
|
+
/**
|
|
14658
|
+
*
|
|
14659
|
+
* @param data
|
|
14660
|
+
*/
|
|
14661
|
+
public void vertex(Object data) {
|
|
13162
14662
|
if (data instanceof double[]) {
|
|
13163
14663
|
double[] d = (double[]) data;
|
|
13164
14664
|
int l = d.length;
|
|
@@ -13182,7 +14682,11 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
13182
14682
|
}
|
|
13183
14683
|
}
|
|
13184
14684
|
|
|
13185
|
-
|
|
14685
|
+
/**
|
|
14686
|
+
*
|
|
14687
|
+
* @param errnum
|
|
14688
|
+
*/
|
|
14689
|
+
public void error(int errnum) {
|
|
13186
14690
|
String estring = pg.pgl.tessError(errnum);
|
|
13187
14691
|
PGraphics.showWarning(TESSELLATION_ERROR, estring);
|
|
13188
14692
|
}
|
|
@@ -13256,8 +14760,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
|
13256
14760
|
}
|
|
13257
14761
|
}
|
|
13258
14762
|
|
|
13259
|
-
|
|
13260
|
-
|
|
14763
|
+
/**
|
|
14764
|
+
*
|
|
14765
|
+
*/
|
|
14766
|
+
static protected class DepthSorter {
|
|
13261
14767
|
|
|
13262
14768
|
static final int X = 0;
|
|
13263
14769
|
static final int Y = 1;
|