picrate 0.7.0-java → 0.8.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.mvn/wrapper/MavenWrapperDownloader.java +117 -0
- data/.mvn/wrapper/maven-wrapper.properties +2 -1
- data/.travis.yml +2 -5
- data/CHANGELOG.md +4 -0
- data/README.md +3 -3
- data/Rakefile +15 -27
- data/docs/_config.yml +1 -1
- data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -1
- data/docs/_posts/2018-11-18-building-gem.md +1 -1
- data/lib/picrate/app.rb +1 -1
- data/lib/picrate/native_folder.rb +1 -1
- data/lib/picrate/version.rb +1 -1
- data/mvnw +127 -51
- data/mvnw.cmd +182 -0
- data/pom.rb +39 -30
- data/pom.xml +50 -37
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/core/LibraryProxy.java +0 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +1 -1
- data/src/main/java/monkstone/vecmath/GfxRender.java +87 -0
- data/src/main/java/monkstone/vecmath/ShapeRender.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +48 -50
- data/src/main/java/processing/awt/PShapeJava2D.java +10 -0
- data/src/main/java/processing/awt/PSurfaceAWT.java +315 -371
- data/src/main/java/processing/core/PApplet.java +15424 -15495
- data/src/main/java/processing/core/PConstants.java +4 -4
- data/src/main/java/processing/core/PFont.java +394 -369
- data/src/main/java/processing/core/PGraphics.java +11 -10
- data/src/main/java/processing/core/PImage.java +1389 -1435
- data/src/main/java/processing/core/PMatrix2D.java +297 -294
- data/src/main/java/processing/core/PMatrix3D.java +641 -594
- data/src/main/java/processing/core/PShape.java +1755 -1784
- data/src/main/java/processing/core/PShapeOBJ.java +145 -133
- data/src/main/java/processing/core/PShapeSVG.java +808 -801
- data/src/main/java/processing/core/PStyle.java +141 -149
- data/src/main/java/processing/core/PSurface.java +111 -117
- data/src/main/java/processing/core/PSurfaceNone.java +178 -187
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +349 -346
- data/src/main/java/processing/opengl/FontTexture.java +40 -59
- data/src/main/java/processing/opengl/FrameBuffer.java +28 -18
- data/src/main/java/processing/opengl/LinePath.java +7 -7
- data/src/main/java/processing/opengl/LineStroker.java +6 -10
- data/src/main/java/processing/opengl/PGL.java +56 -44
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +909 -2338
- data/src/main/java/processing/opengl/PJOGL.java +1722 -1763
- data/src/main/java/processing/opengl/PShader.java +1308 -1192
- data/src/main/java/processing/opengl/PShapeOpenGL.java +487 -1811
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +482 -497
- data/src/main/java/processing/opengl/Texture.java +99 -76
- data/src/main/java/processing/opengl/VertexBuffer.java +41 -43
- data/vendors/Rakefile +1 -1
- metadata +7 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
2
|
|
3
|
-
/*
|
3
|
+
/*
|
4
4
|
Part of the Processing project - http://processing.org
|
5
5
|
|
6
6
|
Copyright (c) 2012-15 The Processing Foundation
|
@@ -20,8 +20,7 @@
|
|
20
20
|
Public License along with this library; if not, write to the
|
21
21
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
22
22
|
Boston, MA 02111-1307 USA
|
23
|
-
*/
|
24
|
-
|
23
|
+
*/
|
25
24
|
package processing.opengl;
|
26
25
|
|
27
26
|
import processing.core.*;
|
@@ -33,132 +32,132 @@ import java.nio.IntBuffer;
|
|
33
32
|
import java.util.HashMap;
|
34
33
|
|
35
34
|
/**
|
36
|
-
* This class encapsulates a GLSL shader program, including a vertex
|
37
|
-
*
|
38
|
-
*
|
35
|
+
* This class encapsulates a GLSL shader program, including a vertex and a
|
36
|
+
* fragment shader. Based on the GLSLShader class from GLGraphics, which in turn
|
37
|
+
* was originally based in the code by JohnG:
|
39
38
|
* http://processing.org/discourse/beta/num_1159494801.html
|
40
39
|
*
|
41
40
|
* @webref rendering:shaders
|
42
41
|
*/
|
43
42
|
public class PShader implements PConstants {
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
"attribute *vec2 *offset";
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
"in *vec2 *offset;";
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
"attribute *vec4 *direction";
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
"in *vec4 *direction";
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
"#define *PROCESSING_POINT_SHADER";
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
"#define *PROCESSING_LINE_SHADER";
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
"#define *PROCESSING_COLOR_SHADER";
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
"#define *PROCESSING_LIGHT_SHADER";
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
"#define *PROCESSING_TEXTURE_SHADER";
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
"#define *PROCESSING_TEXLIGHT_SHADER";
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
"#define *PROCESSING_POLYGON_SHADER";
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
"#define *PROCESSING_TRIANGLES_SHADER";
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
"#define *PROCESSING_QUADS_SHADER";
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
44
|
+
/**
|
45
|
+
*
|
46
|
+
*/
|
47
|
+
static protected final int POINT = 0;
|
48
|
+
|
49
|
+
/**
|
50
|
+
*
|
51
|
+
*/
|
52
|
+
static protected final int LINE = 1;
|
53
|
+
|
54
|
+
/**
|
55
|
+
*
|
56
|
+
*/
|
57
|
+
static protected final int POLY = 2;
|
58
|
+
|
59
|
+
/**
|
60
|
+
*
|
61
|
+
*/
|
62
|
+
static protected final int COLOR = 3;
|
63
|
+
|
64
|
+
/**
|
65
|
+
*
|
66
|
+
*/
|
67
|
+
static protected final int LIGHT = 4;
|
68
|
+
|
69
|
+
/**
|
70
|
+
*
|
71
|
+
*/
|
72
|
+
static protected final int TEXTURE = 5;
|
73
|
+
|
74
|
+
/**
|
75
|
+
*
|
76
|
+
*/
|
77
|
+
static protected final int TEXLIGHT = 6;
|
78
|
+
|
79
|
+
/**
|
80
|
+
*
|
81
|
+
*/
|
82
|
+
static protected String pointShaderAttrRegexp
|
83
|
+
= "attribute *vec2 *offset";
|
84
|
+
|
85
|
+
/**
|
86
|
+
*
|
87
|
+
*/
|
88
|
+
static protected String pointShaderInRegexp
|
89
|
+
= "in *vec2 *offset;";
|
90
|
+
|
91
|
+
/**
|
92
|
+
*
|
93
|
+
*/
|
94
|
+
static protected String lineShaderAttrRegexp
|
95
|
+
= "attribute *vec4 *direction";
|
96
|
+
|
97
|
+
/**
|
98
|
+
*
|
99
|
+
*/
|
100
|
+
static protected String lineShaderInRegexp
|
101
|
+
= "in *vec4 *direction";
|
102
|
+
|
103
|
+
/**
|
104
|
+
*
|
105
|
+
*/
|
106
|
+
static protected String pointShaderDefRegexp
|
107
|
+
= "#define *PROCESSING_POINT_SHADER";
|
108
|
+
|
109
|
+
/**
|
110
|
+
*
|
111
|
+
*/
|
112
|
+
static protected String lineShaderDefRegexp
|
113
|
+
= "#define *PROCESSING_LINE_SHADER";
|
114
|
+
|
115
|
+
/**
|
116
|
+
*
|
117
|
+
*/
|
118
|
+
static protected String colorShaderDefRegexp
|
119
|
+
= "#define *PROCESSING_COLOR_SHADER";
|
120
|
+
|
121
|
+
/**
|
122
|
+
*
|
123
|
+
*/
|
124
|
+
static protected String lightShaderDefRegexp
|
125
|
+
= "#define *PROCESSING_LIGHT_SHADER";
|
126
|
+
|
127
|
+
/**
|
128
|
+
*
|
129
|
+
*/
|
130
|
+
static protected String texShaderDefRegexp
|
131
|
+
= "#define *PROCESSING_TEXTURE_SHADER";
|
132
|
+
|
133
|
+
/**
|
134
|
+
*
|
135
|
+
*/
|
136
|
+
static protected String texlightShaderDefRegexp
|
137
|
+
= "#define *PROCESSING_TEXLIGHT_SHADER";
|
138
|
+
|
139
|
+
/**
|
140
|
+
*
|
141
|
+
*/
|
142
|
+
static protected String polyShaderDefRegexp
|
143
|
+
= "#define *PROCESSING_POLYGON_SHADER";
|
144
|
+
|
145
|
+
/**
|
146
|
+
*
|
147
|
+
*/
|
148
|
+
static protected String triShaderAttrRegexp
|
149
|
+
= "#define *PROCESSING_TRIANGLES_SHADER";
|
150
|
+
|
151
|
+
/**
|
152
|
+
*
|
153
|
+
*/
|
154
|
+
static protected String quadShaderAttrRegexp
|
155
|
+
= "#define *PROCESSING_QUADS_SHADER";
|
156
|
+
|
157
|
+
/**
|
158
|
+
*
|
159
|
+
*/
|
160
|
+
protected PApplet parent;
|
162
161
|
// The main renderer associated to the parent PApplet.
|
163
162
|
//protected PGraphicsOpenGL pgMain;
|
164
163
|
// We need a reference to the renderer since a shader might
|
@@ -166,305 +165,298 @@ public class PShader implements PConstants {
|
|
166
165
|
// (the one corresponding to the main surface, or other offscreen
|
167
166
|
// renderers).
|
168
167
|
|
169
|
-
|
170
|
-
|
171
|
-
|
168
|
+
/**
|
169
|
+
*
|
170
|
+
*/
|
172
171
|
protected PGraphicsOpenGL primaryPG;
|
173
172
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
173
|
+
/**
|
174
|
+
*
|
175
|
+
*/
|
176
|
+
protected PGraphicsOpenGL currentPG;
|
178
177
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
178
|
+
/**
|
179
|
+
*
|
180
|
+
*/
|
181
|
+
protected PGL pgl;
|
183
182
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
183
|
+
/**
|
184
|
+
*
|
185
|
+
*/
|
186
|
+
protected int context; // The context that created this shader.
|
188
187
|
|
189
188
|
// The shader type: POINT, LINE, POLY, etc.
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
*/
|
189
|
+
/**
|
190
|
+
*
|
191
|
+
*/
|
194
192
|
protected int type;
|
195
193
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
194
|
+
/**
|
195
|
+
*
|
196
|
+
*/
|
197
|
+
public int glProgram;
|
200
198
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
199
|
+
/**
|
200
|
+
*
|
201
|
+
*/
|
202
|
+
public int glVertex;
|
205
203
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
204
|
+
/**
|
205
|
+
*
|
206
|
+
*/
|
207
|
+
public int glFragment;
|
210
208
|
private GLResourceShader glres;
|
211
209
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
/**
|
218
|
-
*
|
219
|
-
*/
|
220
|
-
protected URL fragmentURL;
|
221
|
-
|
222
|
-
/**
|
223
|
-
*
|
224
|
-
*/
|
225
|
-
protected String vertexFilename;
|
226
|
-
|
227
|
-
/**
|
228
|
-
*
|
229
|
-
*/
|
230
|
-
protected String fragmentFilename;
|
231
|
-
|
232
|
-
/**
|
233
|
-
*
|
234
|
-
*/
|
235
|
-
protected String[] vertexShaderSource;
|
236
|
-
|
237
|
-
/**
|
238
|
-
*
|
239
|
-
*/
|
240
|
-
protected String[] fragmentShaderSource;
|
241
|
-
|
242
|
-
/**
|
243
|
-
*
|
244
|
-
*/
|
245
|
-
protected boolean bound;
|
246
|
-
|
247
|
-
/**
|
248
|
-
*
|
249
|
-
*/
|
250
|
-
protected HashMap<String, UniformValue> uniformValues = null;
|
251
|
-
|
252
|
-
/**
|
253
|
-
*
|
254
|
-
*/
|
255
|
-
protected HashMap<Integer, Texture> textures;
|
256
|
-
|
257
|
-
/**
|
258
|
-
*
|
259
|
-
*/
|
260
|
-
protected HashMap<Integer, Integer> texUnits;
|
210
|
+
/**
|
211
|
+
*
|
212
|
+
*/
|
213
|
+
protected URL vertexURL;
|
261
214
|
|
262
|
-
|
215
|
+
/**
|
216
|
+
*
|
217
|
+
*/
|
218
|
+
protected URL fragmentURL;
|
219
|
+
|
220
|
+
/**
|
221
|
+
*
|
222
|
+
*/
|
223
|
+
protected String vertexFilename;
|
224
|
+
|
225
|
+
/**
|
226
|
+
*
|
227
|
+
*/
|
228
|
+
protected String fragmentFilename;
|
229
|
+
|
230
|
+
/**
|
231
|
+
*
|
232
|
+
*/
|
233
|
+
protected String[] vertexShaderSource;
|
234
|
+
|
235
|
+
/**
|
236
|
+
*
|
237
|
+
*/
|
238
|
+
protected String[] fragmentShaderSource;
|
239
|
+
|
240
|
+
/**
|
241
|
+
*
|
242
|
+
*/
|
243
|
+
protected boolean bound;
|
244
|
+
|
245
|
+
/**
|
246
|
+
*
|
247
|
+
*/
|
248
|
+
protected HashMap<String, UniformValue> uniformValues = null;
|
263
249
|
|
264
|
-
|
265
|
-
|
266
|
-
|
250
|
+
/**
|
251
|
+
*
|
252
|
+
*/
|
253
|
+
protected HashMap<Integer, Texture> textures;
|
254
|
+
|
255
|
+
/**
|
256
|
+
*
|
257
|
+
*/
|
258
|
+
protected HashMap<Integer, Integer> texUnits;
|
259
|
+
|
260
|
+
// Direct buffers to pass shader data to GL
|
261
|
+
/**
|
262
|
+
*
|
263
|
+
*/
|
267
264
|
protected IntBuffer intBuffer;
|
268
265
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
266
|
+
/**
|
267
|
+
*
|
268
|
+
*/
|
269
|
+
protected FloatBuffer floatBuffer;
|
273
270
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
271
|
+
/**
|
272
|
+
*
|
273
|
+
*/
|
274
|
+
protected boolean loadedAttributes = false;
|
278
275
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
276
|
+
/**
|
277
|
+
*
|
278
|
+
*/
|
279
|
+
protected boolean loadedUniforms = false;
|
283
280
|
|
284
281
|
// Uniforms common to all shader types
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
*/
|
282
|
+
/**
|
283
|
+
*
|
284
|
+
*/
|
289
285
|
protected int transformMatLoc;
|
290
286
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
287
|
+
/**
|
288
|
+
*
|
289
|
+
*/
|
290
|
+
protected int modelviewMatLoc;
|
295
291
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
292
|
+
/**
|
293
|
+
*
|
294
|
+
*/
|
295
|
+
protected int projectionMatLoc;
|
300
296
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
297
|
+
/**
|
298
|
+
*
|
299
|
+
*/
|
300
|
+
protected int ppixelsLoc;
|
305
301
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
302
|
+
/**
|
303
|
+
*
|
304
|
+
*/
|
305
|
+
protected int ppixelsUnit;
|
310
306
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
307
|
+
/**
|
308
|
+
*
|
309
|
+
*/
|
310
|
+
protected int viewportLoc;
|
315
311
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
312
|
+
/**
|
313
|
+
*
|
314
|
+
*/
|
315
|
+
protected int resolutionLoc;
|
320
316
|
|
321
317
|
// Uniforms only for lines and points
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
*/
|
318
|
+
/**
|
319
|
+
*
|
320
|
+
*/
|
326
321
|
protected int perspectiveLoc;
|
327
322
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
323
|
+
/**
|
324
|
+
*
|
325
|
+
*/
|
326
|
+
protected int scaleLoc;
|
332
327
|
|
333
328
|
// Lighting uniforms
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
*/
|
329
|
+
/**
|
330
|
+
*
|
331
|
+
*/
|
338
332
|
protected int lightCountLoc;
|
339
333
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
/**
|
346
|
-
*
|
347
|
-
*/
|
348
|
-
protected int lightNormalLoc;
|
349
|
-
|
350
|
-
/**
|
351
|
-
*
|
352
|
-
*/
|
353
|
-
protected int lightAmbientLoc;
|
354
|
-
|
355
|
-
/**
|
356
|
-
*
|
357
|
-
*/
|
358
|
-
protected int lightDiffuseLoc;
|
359
|
-
|
360
|
-
/**
|
361
|
-
*
|
362
|
-
*/
|
363
|
-
protected int lightSpecularLoc;
|
364
|
-
|
365
|
-
/**
|
366
|
-
*
|
367
|
-
*/
|
368
|
-
protected int lightFalloffLoc;
|
369
|
-
|
370
|
-
/**
|
371
|
-
*
|
372
|
-
*/
|
373
|
-
protected int lightSpotLoc;
|
334
|
+
/**
|
335
|
+
*
|
336
|
+
*/
|
337
|
+
protected int lightPositionLoc;
|
374
338
|
|
375
|
-
|
339
|
+
/**
|
340
|
+
*
|
341
|
+
*/
|
342
|
+
protected int lightNormalLoc;
|
376
343
|
|
377
|
-
|
378
|
-
|
379
|
-
|
344
|
+
/**
|
345
|
+
*
|
346
|
+
*/
|
347
|
+
protected int lightAmbientLoc;
|
348
|
+
|
349
|
+
/**
|
350
|
+
*
|
351
|
+
*/
|
352
|
+
protected int lightDiffuseLoc;
|
353
|
+
|
354
|
+
/**
|
355
|
+
*
|
356
|
+
*/
|
357
|
+
protected int lightSpecularLoc;
|
358
|
+
|
359
|
+
/**
|
360
|
+
*
|
361
|
+
*/
|
362
|
+
protected int lightFalloffLoc;
|
363
|
+
|
364
|
+
/**
|
365
|
+
*
|
366
|
+
*/
|
367
|
+
protected int lightSpotLoc;
|
368
|
+
|
369
|
+
// Texturing uniforms
|
370
|
+
/**
|
371
|
+
*
|
372
|
+
*/
|
380
373
|
protected Texture texture;
|
381
374
|
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
375
|
+
/**
|
376
|
+
*
|
377
|
+
*/
|
378
|
+
protected int texUnit;
|
386
379
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
380
|
+
/**
|
381
|
+
*
|
382
|
+
*/
|
383
|
+
protected int textureLoc;
|
391
384
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
385
|
+
/**
|
386
|
+
*
|
387
|
+
*/
|
388
|
+
protected int texMatrixLoc;
|
396
389
|
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
390
|
+
/**
|
391
|
+
*
|
392
|
+
*/
|
393
|
+
protected int texOffsetLoc;
|
401
394
|
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
395
|
+
/**
|
396
|
+
*
|
397
|
+
*/
|
398
|
+
protected float[] tcmat;
|
406
399
|
|
407
400
|
// Vertex attributes
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
*/
|
401
|
+
/**
|
402
|
+
*
|
403
|
+
*/
|
412
404
|
protected int vertexLoc;
|
413
405
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
406
|
+
/**
|
407
|
+
*
|
408
|
+
*/
|
409
|
+
protected int colorLoc;
|
410
|
+
|
411
|
+
/**
|
412
|
+
*
|
413
|
+
*/
|
414
|
+
protected int normalLoc;
|
415
|
+
|
416
|
+
/**
|
417
|
+
*
|
418
|
+
*/
|
419
|
+
protected int texCoordLoc;
|
420
|
+
|
421
|
+
/**
|
422
|
+
*
|
423
|
+
*/
|
424
|
+
protected int normalMatLoc;
|
425
|
+
|
426
|
+
/**
|
427
|
+
*
|
428
|
+
*/
|
429
|
+
protected int directionLoc;
|
430
|
+
|
431
|
+
/**
|
432
|
+
*
|
433
|
+
*/
|
434
|
+
protected int offsetLoc;
|
435
|
+
|
436
|
+
/**
|
437
|
+
*
|
438
|
+
*/
|
439
|
+
protected int ambientLoc;
|
440
|
+
|
441
|
+
/**
|
442
|
+
*
|
443
|
+
*/
|
444
|
+
protected int specularLoc;
|
445
|
+
|
446
|
+
/**
|
447
|
+
*
|
448
|
+
*/
|
449
|
+
protected int emissiveLoc;
|
450
|
+
|
451
|
+
/**
|
452
|
+
*
|
453
|
+
*/
|
454
|
+
protected int shininessLoc;
|
455
|
+
|
456
|
+
/**
|
457
|
+
*
|
458
|
+
*/
|
459
|
+
public PShader() {
|
468
460
|
parent = null;
|
469
461
|
pgl = null;
|
470
462
|
context = -1;
|
@@ -486,22 +478,20 @@ public class PShader implements PConstants {
|
|
486
478
|
type = -1;
|
487
479
|
}
|
488
480
|
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
481
|
+
/**
|
482
|
+
*
|
483
|
+
* @param parent
|
484
|
+
*/
|
485
|
+
public PShader(PApplet parent) {
|
494
486
|
this();
|
495
487
|
this.parent = parent;
|
496
|
-
primaryPG = (PGraphicsOpenGL)parent.g;
|
488
|
+
primaryPG = (PGraphicsOpenGL) parent.g;
|
497
489
|
pgl = primaryPG.pgl;
|
498
490
|
context = pgl.createEmptyContext();
|
499
491
|
}
|
500
492
|
|
501
|
-
|
502
493
|
/**
|
503
|
-
* Creates a shader program using the specified vertex and fragment
|
504
|
-
* shaders.
|
494
|
+
* Creates a shader program using the specified vertex and fragment shaders.
|
505
495
|
*
|
506
496
|
* @param parent the parent program
|
507
497
|
* @param vertFilename name of the vertex shader
|
@@ -509,7 +499,7 @@ public class PShader implements PConstants {
|
|
509
499
|
*/
|
510
500
|
public PShader(PApplet parent, String vertFilename, String fragFilename) {
|
511
501
|
this.parent = parent;
|
512
|
-
primaryPG = (PGraphicsOpenGL)parent.g;
|
502
|
+
primaryPG = (PGraphicsOpenGL) parent.g;
|
513
503
|
pgl = primaryPG.pgl;
|
514
504
|
|
515
505
|
this.vertexURL = null;
|
@@ -534,22 +524,21 @@ public class PShader implements PConstants {
|
|
534
524
|
type = fragType;
|
535
525
|
} else if (fragType == -1) {
|
536
526
|
type = vertType;
|
537
|
-
} else if (fragType == vertType)
|
527
|
+
} else if (fragType == vertType) {
|
538
528
|
type = vertType;
|
539
529
|
} else {
|
540
530
|
PGraphics.showWarning(PGraphicsOpenGL.INCONSISTENT_SHADER_TYPES);
|
541
531
|
}
|
542
532
|
}
|
543
533
|
|
544
|
-
|
545
534
|
/**
|
546
|
-
|
535
|
+
* @param parent
|
547
536
|
* @param vertURL network location of the vertex shader
|
548
537
|
* @param fragURL network location of the fragment shader
|
549
538
|
*/
|
550
539
|
public PShader(PApplet parent, URL vertURL, URL fragURL) {
|
551
540
|
this.parent = parent;
|
552
|
-
primaryPG = (PGraphicsOpenGL)parent.g;
|
541
|
+
primaryPG = (PGraphicsOpenGL) parent.g;
|
553
542
|
pgl = primaryPG.pgl;
|
554
543
|
|
555
544
|
this.vertexURL = vertURL;
|
@@ -574,22 +563,22 @@ public class PShader implements PConstants {
|
|
574
563
|
type = fragType;
|
575
564
|
} else if (fragType == -1) {
|
576
565
|
type = vertType;
|
577
|
-
} else if (fragType == vertType)
|
566
|
+
} else if (fragType == vertType) {
|
578
567
|
type = vertType;
|
579
568
|
} else {
|
580
569
|
PGraphics.showWarning(PGraphicsOpenGL.INCONSISTENT_SHADER_TYPES);
|
581
570
|
}
|
582
571
|
}
|
583
572
|
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
573
|
+
/**
|
574
|
+
*
|
575
|
+
* @param parent
|
576
|
+
* @param vertSource
|
577
|
+
* @param fragSource
|
578
|
+
*/
|
579
|
+
public PShader(PApplet parent, String[] vertSource, String[] fragSource) {
|
591
580
|
this.parent = parent;
|
592
|
-
primaryPG = (PGraphicsOpenGL)parent.g;
|
581
|
+
primaryPG = (PGraphicsOpenGL) parent.g;
|
593
582
|
pgl = primaryPG.pgl;
|
594
583
|
|
595
584
|
this.vertexURL = null;
|
@@ -614,66 +603,65 @@ public class PShader implements PConstants {
|
|
614
603
|
type = fragType;
|
615
604
|
} else if (fragType == -1) {
|
616
605
|
type = vertType;
|
617
|
-
} else if (fragType == vertType)
|
606
|
+
} else if (fragType == vertType) {
|
618
607
|
type = vertType;
|
619
608
|
} else {
|
620
609
|
PGraphics.showWarning(PGraphicsOpenGL.INCONSISTENT_SHADER_TYPES);
|
621
610
|
}
|
622
611
|
}
|
623
612
|
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
613
|
+
/**
|
614
|
+
*
|
615
|
+
* @param vertFilename
|
616
|
+
*/
|
617
|
+
public void setVertexShader(String vertFilename) {
|
629
618
|
this.vertexFilename = vertFilename;
|
630
619
|
vertexShaderSource = pgl.loadVertexShader(vertFilename);
|
631
620
|
}
|
632
621
|
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
622
|
+
/**
|
623
|
+
*
|
624
|
+
* @param vertURL
|
625
|
+
*/
|
626
|
+
public void setVertexShader(URL vertURL) {
|
638
627
|
this.vertexURL = vertURL;
|
639
628
|
vertexShaderSource = pgl.loadVertexShader(vertURL);
|
640
629
|
}
|
641
630
|
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
631
|
+
/**
|
632
|
+
*
|
633
|
+
* @param vertSource
|
634
|
+
*/
|
635
|
+
public void setVertexShader(String[] vertSource) {
|
647
636
|
vertexShaderSource = vertSource;
|
648
637
|
}
|
649
638
|
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
639
|
+
/**
|
640
|
+
*
|
641
|
+
* @param fragFilename
|
642
|
+
*/
|
643
|
+
public void setFragmentShader(String fragFilename) {
|
655
644
|
this.fragmentFilename = fragFilename;
|
656
645
|
fragmentShaderSource = pgl.loadFragmentShader(fragFilename);
|
657
646
|
}
|
658
647
|
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
648
|
+
/**
|
649
|
+
*
|
650
|
+
* @param fragURL
|
651
|
+
*/
|
652
|
+
public void setFragmentShader(URL fragURL) {
|
664
653
|
this.fragmentURL = fragURL;
|
665
654
|
fragmentShaderSource = pgl.loadFragmentShader(fragURL);
|
666
655
|
}
|
667
656
|
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
657
|
+
/**
|
658
|
+
*
|
659
|
+
* @param fragSource
|
660
|
+
*/
|
661
|
+
public void setFragmentShader(String[] fragSource) {
|
673
662
|
fragmentShaderSource = fragSource;
|
674
663
|
}
|
675
664
|
|
676
|
-
|
677
665
|
/**
|
678
666
|
* Initializes (if needed) and binds the shader program.
|
679
667
|
*/
|
@@ -686,15 +674,18 @@ public class PShader implements PConstants {
|
|
686
674
|
bindTextures();
|
687
675
|
}
|
688
676
|
|
689
|
-
if (hasType())
|
677
|
+
if (hasType()) {
|
678
|
+
bindTyped();
|
679
|
+
}
|
690
680
|
}
|
691
681
|
|
692
|
-
|
693
682
|
/**
|
694
683
|
* Unbinds the shader program.
|
695
684
|
*/
|
696
685
|
public void unbind() {
|
697
|
-
if (hasType())
|
686
|
+
if (hasType()) {
|
687
|
+
unbindTyped();
|
688
|
+
}
|
698
689
|
|
699
690
|
if (bound) {
|
700
691
|
unbindTextures();
|
@@ -703,10 +694,10 @@ public class PShader implements PConstants {
|
|
703
694
|
}
|
704
695
|
}
|
705
696
|
|
706
|
-
|
707
697
|
/**
|
708
698
|
* Returns true if the shader is bound, false otherwise.
|
709
|
-
|
699
|
+
*
|
700
|
+
* @return
|
710
701
|
*/
|
711
702
|
public boolean bound() {
|
712
703
|
return bound;
|
@@ -719,149 +710,152 @@ public class PShader implements PConstants {
|
|
719
710
|
* @param x first component of the variable to modify
|
720
711
|
*/
|
721
712
|
public void set(String name, int x) {
|
722
|
-
setUniformImpl(name, UniformValue.INT1, new int[]
|
713
|
+
setUniformImpl(name, UniformValue.INT1, new int[]{x});
|
723
714
|
}
|
724
715
|
|
725
716
|
/**
|
726
|
-
|
727
|
-
* @param y second component of the variable to modify. The variable has to be
|
728
|
-
|
717
|
+
* @param name
|
718
|
+
* @param y second component of the variable to modify. The variable has to be
|
719
|
+
* declared with an array/vector type in the shader (i.e.: int[2], vec2)
|
720
|
+
* @param x
|
729
721
|
*/
|
730
722
|
public void set(String name, int x, int y) {
|
731
|
-
setUniformImpl(name, UniformValue.INT2, new int[]
|
723
|
+
setUniformImpl(name, UniformValue.INT2, new int[]{x, y});
|
732
724
|
}
|
733
725
|
|
734
726
|
/**
|
735
|
-
|
736
|
-
* @param z third component of the variable to modify. The variable has to be
|
737
|
-
|
738
|
-
|
727
|
+
* @param name
|
728
|
+
* @param z third component of the variable to modify. The variable has to be
|
729
|
+
* declared with an array/vector type in the shader (i.e.: int[3], vec3)
|
730
|
+
* @param x
|
731
|
+
* @param y
|
739
732
|
*/
|
740
733
|
public void set(String name, int x, int y, int z) {
|
741
|
-
setUniformImpl(name, UniformValue.INT3, new int[]
|
734
|
+
setUniformImpl(name, UniformValue.INT3, new int[]{x, y, z});
|
742
735
|
}
|
743
736
|
|
744
737
|
/**
|
745
|
-
|
746
|
-
|
747
|
-
* @param w fourth component of the variable to modify. The variable has to be
|
748
|
-
|
749
|
-
|
738
|
+
* @param name
|
739
|
+
* @param x
|
740
|
+
* @param w fourth component of the variable to modify. The variable has to be
|
741
|
+
* declared with an array/vector type in the shader (i.e.: int[4], vec4)
|
742
|
+
* @param z
|
743
|
+
* @param y
|
750
744
|
*/
|
751
745
|
public void set(String name, int x, int y, int z, int w) {
|
752
|
-
setUniformImpl(name, UniformValue.INT4, new int[]
|
746
|
+
setUniformImpl(name, UniformValue.INT4, new int[]{x, y, z, w});
|
753
747
|
}
|
754
748
|
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
setUniformImpl(name, UniformValue.FLOAT1, new float[]
|
749
|
+
/**
|
750
|
+
*
|
751
|
+
* @param name
|
752
|
+
* @param x
|
753
|
+
*/
|
754
|
+
public void set(String name, float x) {
|
755
|
+
setUniformImpl(name, UniformValue.FLOAT1, new float[]{x});
|
762
756
|
}
|
763
757
|
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
setUniformImpl(name, UniformValue.FLOAT2, new float[]
|
758
|
+
/**
|
759
|
+
*
|
760
|
+
* @param name
|
761
|
+
* @param x
|
762
|
+
* @param y
|
763
|
+
*/
|
764
|
+
public void set(String name, float x, float y) {
|
765
|
+
setUniformImpl(name, UniformValue.FLOAT2, new float[]{x, y});
|
772
766
|
}
|
773
767
|
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
setUniformImpl(name, UniformValue.FLOAT3, new float[]
|
768
|
+
/**
|
769
|
+
*
|
770
|
+
* @param name
|
771
|
+
* @param x
|
772
|
+
* @param y
|
773
|
+
* @param z
|
774
|
+
*/
|
775
|
+
public void set(String name, float x, float y, float z) {
|
776
|
+
setUniformImpl(name, UniformValue.FLOAT3, new float[]{x, y, z});
|
783
777
|
}
|
784
778
|
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
setUniformImpl(name, UniformValue.FLOAT4, new float[]
|
779
|
+
/**
|
780
|
+
*
|
781
|
+
* @param name
|
782
|
+
* @param x
|
783
|
+
* @param y
|
784
|
+
* @param z
|
785
|
+
* @param w
|
786
|
+
*/
|
787
|
+
public void set(String name, float x, float y, float z, float w) {
|
788
|
+
setUniformImpl(name, UniformValue.FLOAT4, new float[]{x, y, z, w});
|
795
789
|
}
|
796
790
|
|
797
791
|
/**
|
798
|
-
|
799
|
-
* @param vec modifies all the components of an array/vector uniform variable.
|
792
|
+
* @param name
|
793
|
+
* @param vec modifies all the components of an array/vector uniform variable.
|
794
|
+
* PVector can only be used if the type of the variable is vec3.
|
800
795
|
*/
|
801
796
|
public void set(String name, PVector vec) {
|
802
797
|
setUniformImpl(name, UniformValue.FLOAT3,
|
803
|
-
|
798
|
+
new float[]{vec.x, vec.y, vec.z});
|
804
799
|
}
|
805
800
|
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
setUniformImpl(name, UniformValue.INT1, new int[]
|
801
|
+
/**
|
802
|
+
*
|
803
|
+
* @param name
|
804
|
+
* @param x
|
805
|
+
*/
|
806
|
+
public void set(String name, boolean x) {
|
807
|
+
setUniformImpl(name, UniformValue.INT1, new int[]{(x) ? 1 : 0});
|
813
808
|
}
|
814
809
|
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
810
|
+
/**
|
811
|
+
*
|
812
|
+
* @param name
|
813
|
+
* @param x
|
814
|
+
* @param y
|
815
|
+
*/
|
816
|
+
public void set(String name, boolean x, boolean y) {
|
822
817
|
setUniformImpl(name, UniformValue.INT2,
|
823
|
-
|
818
|
+
new int[]{(x) ? 1 : 0, (y) ? 1 : 0});
|
824
819
|
}
|
825
820
|
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
821
|
+
/**
|
822
|
+
*
|
823
|
+
* @param name
|
824
|
+
* @param x
|
825
|
+
* @param y
|
826
|
+
* @param z
|
827
|
+
*/
|
828
|
+
public void set(String name, boolean x, boolean y, boolean z) {
|
834
829
|
setUniformImpl(name, UniformValue.INT3,
|
835
|
-
|
836
|
-
}
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
830
|
+
new int[]{(x) ? 1 : 0, (y) ? 1 : 0, (z) ? 1 : 0});
|
831
|
+
}
|
832
|
+
|
833
|
+
/**
|
834
|
+
*
|
835
|
+
* @param name
|
836
|
+
* @param x
|
837
|
+
* @param y
|
838
|
+
* @param z
|
839
|
+
* @param w
|
840
|
+
*/
|
841
|
+
public void set(String name, boolean x, boolean y, boolean z, boolean w) {
|
847
842
|
setUniformImpl(name, UniformValue.INT4,
|
848
|
-
|
843
|
+
new int[]{(x) ? 1 : 0, (y) ? 1 : 0, (z) ? 1 : 0, (w) ? 1 : 0});
|
849
844
|
}
|
850
845
|
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
846
|
+
/**
|
847
|
+
*
|
848
|
+
* @param name
|
849
|
+
* @param vec
|
850
|
+
*/
|
851
|
+
public void set(String name, int[] vec) {
|
857
852
|
set(name, vec, 1);
|
858
853
|
}
|
859
854
|
|
860
|
-
|
861
855
|
/**
|
862
|
-
|
856
|
+
* @param name
|
863
857
|
* @param ncoords number of coordinates per element, max 4
|
864
|
-
|
858
|
+
* @param vec
|
865
859
|
*/
|
866
860
|
public void set(String name, int[] vec, int ncoords) {
|
867
861
|
if (ncoords == 1) {
|
@@ -873,29 +867,29 @@ public class PShader implements PConstants {
|
|
873
867
|
} else if (ncoords == 4) {
|
874
868
|
setUniformImpl(name, UniformValue.INT4VEC, vec);
|
875
869
|
} else if (4 < ncoords) {
|
876
|
-
PGraphics.showWarning("Only up to 4 coordinates per element are "
|
877
|
-
|
870
|
+
PGraphics.showWarning("Only up to 4 coordinates per element are "
|
871
|
+
+ "supported.");
|
878
872
|
} else {
|
879
873
|
PGraphics.showWarning("Wrong number of coordinates: it is negative!");
|
880
874
|
}
|
881
875
|
}
|
882
876
|
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
877
|
+
/**
|
878
|
+
*
|
879
|
+
* @param name
|
880
|
+
* @param vec
|
881
|
+
*/
|
882
|
+
public void set(String name, float[] vec) {
|
889
883
|
set(name, vec, 1);
|
890
884
|
}
|
891
885
|
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
886
|
+
/**
|
887
|
+
*
|
888
|
+
* @param name
|
889
|
+
* @param vec
|
890
|
+
* @param ncoords
|
891
|
+
*/
|
892
|
+
public void set(String name, float[] vec, int ncoords) {
|
899
893
|
if (ncoords == 1) {
|
900
894
|
setUniformImpl(name, UniformValue.FLOAT1VEC, vec);
|
901
895
|
} else if (ncoords == 2) {
|
@@ -905,108 +899,106 @@ public class PShader implements PConstants {
|
|
905
899
|
} else if (ncoords == 4) {
|
906
900
|
setUniformImpl(name, UniformValue.FLOAT4VEC, vec);
|
907
901
|
} else if (4 < ncoords) {
|
908
|
-
PGraphics.showWarning("Only up to 4 coordinates per element are "
|
909
|
-
|
902
|
+
PGraphics.showWarning("Only up to 4 coordinates per element are "
|
903
|
+
+ "supported.");
|
910
904
|
} else {
|
911
905
|
PGraphics.showWarning("Wrong number of coordinates: it is negative!");
|
912
906
|
}
|
913
907
|
}
|
914
908
|
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
909
|
+
/**
|
910
|
+
*
|
911
|
+
* @param name
|
912
|
+
* @param vec
|
913
|
+
*/
|
914
|
+
public void set(String name, boolean[] vec) {
|
921
915
|
set(name, vec, 1);
|
922
916
|
}
|
923
917
|
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
918
|
+
/**
|
919
|
+
*
|
920
|
+
* @param name
|
921
|
+
* @param boolvec
|
922
|
+
* @param ncoords
|
923
|
+
*/
|
924
|
+
public void set(String name, boolean[] boolvec, int ncoords) {
|
931
925
|
int[] vec = new int[boolvec.length];
|
932
926
|
for (int i = 0; i < boolvec.length; i++) {
|
933
|
-
vec[i] = (boolvec[i])?1:0;
|
927
|
+
vec[i] = (boolvec[i]) ? 1 : 0;
|
934
928
|
}
|
935
929
|
set(name, vec, ncoords);
|
936
930
|
}
|
937
931
|
|
938
|
-
|
939
932
|
/**
|
940
|
-
|
933
|
+
* @param name
|
941
934
|
* @param mat matrix of values
|
942
935
|
*/
|
943
936
|
public void set(String name, PMatrix2D mat) {
|
944
|
-
float[] matv = {
|
945
|
-
|
937
|
+
float[] matv = {mat.m00, mat.m01,
|
938
|
+
mat.m10, mat.m11};
|
946
939
|
setUniformImpl(name, UniformValue.MAT2, matv);
|
947
940
|
}
|
948
941
|
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
942
|
+
/**
|
943
|
+
*
|
944
|
+
* @param name
|
945
|
+
* @param mat
|
946
|
+
*/
|
947
|
+
public void set(String name, PMatrix3D mat) {
|
955
948
|
set(name, mat, false);
|
956
949
|
}
|
957
950
|
|
958
951
|
/**
|
959
|
-
|
952
|
+
* @param name
|
960
953
|
* @param use3x3 enforces the matrix is 3 x 3
|
961
|
-
|
954
|
+
* @param mat
|
962
955
|
*/
|
963
956
|
public void set(String name, PMatrix3D mat, boolean use3x3) {
|
964
957
|
if (use3x3) {
|
965
|
-
float[] matv = {
|
966
|
-
|
967
|
-
|
958
|
+
float[] matv = {mat.m00, mat.m01, mat.m02,
|
959
|
+
mat.m10, mat.m11, mat.m12,
|
960
|
+
mat.m20, mat.m21, mat.m22};
|
968
961
|
setUniformImpl(name, UniformValue.MAT3, matv);
|
969
962
|
} else {
|
970
|
-
float[] matv = {
|
971
|
-
|
972
|
-
|
973
|
-
|
963
|
+
float[] matv = {mat.m00, mat.m01, mat.m02, mat.m03,
|
964
|
+
mat.m10, mat.m11, mat.m12, mat.m13,
|
965
|
+
mat.m20, mat.m21, mat.m22, mat.m23,
|
966
|
+
mat.m30, mat.m31, mat.m32, mat.m33};
|
974
967
|
setUniformImpl(name, UniformValue.MAT4, matv);
|
975
968
|
}
|
976
969
|
}
|
977
970
|
|
978
971
|
/**
|
979
|
-
|
980
|
-
* @param tex sets the sampler uniform variable to read from this image
|
972
|
+
* @param name
|
973
|
+
* @param tex sets the sampler uniform variable to read from this image
|
974
|
+
* texture
|
981
975
|
*/
|
982
976
|
public void set(String name, PImage tex) {
|
983
977
|
setUniformImpl(name, UniformValue.SAMPLER2D, tex);
|
984
978
|
}
|
985
979
|
|
986
|
-
|
987
980
|
/**
|
988
981
|
* Extra initialization method that can be used by subclasses, called after
|
989
|
-
* compiling and attaching the vertex and fragment shaders, and before
|
990
|
-
*
|
982
|
+
* compiling and attaching the vertex and fragment shaders, and before linking
|
983
|
+
* the shader program.
|
991
984
|
*
|
992
985
|
*/
|
993
986
|
protected void setup() {
|
994
987
|
}
|
995
988
|
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
989
|
+
/**
|
990
|
+
*
|
991
|
+
* @param idxId
|
992
|
+
* @param count
|
993
|
+
* @param offset
|
994
|
+
*/
|
995
|
+
protected void draw(int idxId, int count, int offset) {
|
1003
996
|
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, idxId);
|
1004
997
|
pgl.drawElements(PGL.TRIANGLES, count, PGL.INDEX_TYPE,
|
1005
|
-
|
998
|
+
offset * PGL.SIZEOF_INDEX);
|
1006
999
|
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
|
1007
1000
|
}
|
1008
1001
|
|
1009
|
-
|
1010
1002
|
/**
|
1011
1003
|
* Returns the ID location of the attribute parameter given its name.
|
1012
1004
|
*
|
@@ -1018,7 +1010,6 @@ public class PShader implements PConstants {
|
|
1018
1010
|
return pgl.getAttribLocation(glProgram, name);
|
1019
1011
|
}
|
1020
1012
|
|
1021
|
-
|
1022
1013
|
/**
|
1023
1014
|
* Returns the ID location of the uniform parameter given its name.
|
1024
1015
|
*
|
@@ -1030,194 +1021,214 @@ public class PShader implements PConstants {
|
|
1030
1021
|
return pgl.getUniformLocation(glProgram, name);
|
1031
1022
|
}
|
1032
1023
|
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1024
|
+
/**
|
1025
|
+
*
|
1026
|
+
* @param loc
|
1027
|
+
* @param vboId
|
1028
|
+
* @param size
|
1029
|
+
* @param type
|
1030
|
+
* @param normalized
|
1031
|
+
* @param stride
|
1032
|
+
* @param offset
|
1033
|
+
*/
|
1034
|
+
protected void setAttributeVBO(int loc, int vboId, int size, int type,
|
1035
|
+
boolean normalized, int stride, int offset) {
|
1045
1036
|
if (-1 < loc) {
|
1046
1037
|
pgl.bindBuffer(PGL.ARRAY_BUFFER, vboId);
|
1047
1038
|
pgl.vertexAttribPointer(loc, size, type, normalized, stride, offset);
|
1048
1039
|
}
|
1049
1040
|
}
|
1050
1041
|
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1042
|
+
/**
|
1043
|
+
*
|
1044
|
+
* @param loc
|
1045
|
+
* @param x
|
1046
|
+
*/
|
1047
|
+
protected void setUniformValue(int loc, int x) {
|
1057
1048
|
if (-1 < loc) {
|
1058
1049
|
pgl.uniform1i(loc, x);
|
1059
1050
|
}
|
1060
1051
|
}
|
1061
1052
|
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1053
|
+
/**
|
1054
|
+
*
|
1055
|
+
* @param loc
|
1056
|
+
* @param x
|
1057
|
+
* @param y
|
1058
|
+
*/
|
1059
|
+
protected void setUniformValue(int loc, int x, int y) {
|
1069
1060
|
if (-1 < loc) {
|
1070
1061
|
pgl.uniform2i(loc, x, y);
|
1071
1062
|
}
|
1072
1063
|
}
|
1073
1064
|
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1065
|
+
/**
|
1066
|
+
*
|
1067
|
+
* @param loc
|
1068
|
+
* @param x
|
1069
|
+
* @param y
|
1070
|
+
* @param z
|
1071
|
+
*/
|
1072
|
+
protected void setUniformValue(int loc, int x, int y, int z) {
|
1082
1073
|
if (-1 < loc) {
|
1083
1074
|
pgl.uniform3i(loc, x, y, z);
|
1084
1075
|
}
|
1085
1076
|
}
|
1086
1077
|
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1078
|
+
/**
|
1079
|
+
*
|
1080
|
+
* @param loc
|
1081
|
+
* @param x
|
1082
|
+
* @param y
|
1083
|
+
* @param z
|
1084
|
+
* @param w
|
1085
|
+
*/
|
1086
|
+
protected void setUniformValue(int loc, int x, int y, int z, int w) {
|
1096
1087
|
if (-1 < loc) {
|
1097
1088
|
pgl.uniform4i(loc, x, y, z, w);
|
1098
1089
|
}
|
1099
1090
|
}
|
1100
1091
|
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1092
|
+
/**
|
1093
|
+
*
|
1094
|
+
* @param loc
|
1095
|
+
* @param x
|
1096
|
+
*/
|
1097
|
+
protected void setUniformValue(int loc, float x) {
|
1107
1098
|
if (-1 < loc) {
|
1108
1099
|
pgl.uniform1f(loc, x);
|
1109
1100
|
}
|
1110
1101
|
}
|
1111
1102
|
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1103
|
+
/**
|
1104
|
+
*
|
1105
|
+
* @param loc
|
1106
|
+
* @param x
|
1107
|
+
* @param y
|
1108
|
+
*/
|
1109
|
+
protected void setUniformValue(int loc, float x, float y) {
|
1119
1110
|
if (-1 < loc) {
|
1120
1111
|
pgl.uniform2f(loc, x, y);
|
1121
1112
|
}
|
1122
1113
|
}
|
1123
1114
|
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1115
|
+
/**
|
1116
|
+
*
|
1117
|
+
* @param loc
|
1118
|
+
* @param x
|
1119
|
+
* @param y
|
1120
|
+
* @param z
|
1121
|
+
*/
|
1122
|
+
protected void setUniformValue(int loc, float x, float y, float z) {
|
1132
1123
|
if (-1 < loc) {
|
1133
1124
|
pgl.uniform3f(loc, x, y, z);
|
1134
1125
|
}
|
1135
1126
|
}
|
1136
1127
|
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1128
|
+
/**
|
1129
|
+
*
|
1130
|
+
* @param loc
|
1131
|
+
* @param x
|
1132
|
+
* @param y
|
1133
|
+
* @param z
|
1134
|
+
* @param w
|
1135
|
+
*/
|
1136
|
+
protected void setUniformValue(int loc, float x, float y, float z, float w) {
|
1146
1137
|
if (-1 < loc) {
|
1147
1138
|
pgl.uniform4f(loc, x, y, z, w);
|
1148
1139
|
}
|
1149
1140
|
}
|
1150
1141
|
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1142
|
+
/**
|
1143
|
+
*
|
1144
|
+
* @param loc
|
1145
|
+
* @param vec
|
1146
|
+
* @param ncoords
|
1147
|
+
* @param length
|
1148
|
+
*/
|
1149
|
+
protected void setUniformVector(int loc, int[] vec, int ncoords,
|
1150
|
+
int length) {
|
1160
1151
|
if (-1 < loc) {
|
1161
1152
|
updateIntBuffer(vec);
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1153
|
+
switch (ncoords) {
|
1154
|
+
case 1:
|
1155
|
+
pgl.uniform1iv(loc, length, intBuffer);
|
1156
|
+
break;
|
1157
|
+
case 2:
|
1158
|
+
pgl.uniform2iv(loc, length, intBuffer);
|
1159
|
+
break;
|
1160
|
+
case 3:
|
1161
|
+
pgl.uniform3iv(loc, length, intBuffer);
|
1162
|
+
break;
|
1163
|
+
case 4:
|
1164
|
+
pgl.uniform3iv(loc, length, intBuffer);
|
1165
|
+
break;
|
1166
|
+
default:
|
1167
|
+
break;
|
1170
1168
|
}
|
1171
1169
|
}
|
1172
1170
|
}
|
1173
1171
|
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1172
|
+
/**
|
1173
|
+
*
|
1174
|
+
* @param loc
|
1175
|
+
* @param vec
|
1176
|
+
* @param ncoords
|
1177
|
+
* @param length
|
1178
|
+
*/
|
1179
|
+
protected void setUniformVector(int loc, float[] vec, int ncoords,
|
1180
|
+
int length) {
|
1183
1181
|
if (-1 < loc) {
|
1184
1182
|
updateFloatBuffer(vec);
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1183
|
+
switch (ncoords) {
|
1184
|
+
case 1:
|
1185
|
+
pgl.uniform1fv(loc, length, floatBuffer);
|
1186
|
+
break;
|
1187
|
+
case 2:
|
1188
|
+
pgl.uniform2fv(loc, length, floatBuffer);
|
1189
|
+
break;
|
1190
|
+
case 3:
|
1191
|
+
pgl.uniform3fv(loc, length, floatBuffer);
|
1192
|
+
break;
|
1193
|
+
case 4:
|
1194
|
+
pgl.uniform4fv(loc, length, floatBuffer);
|
1195
|
+
break;
|
1196
|
+
default:
|
1197
|
+
break;
|
1193
1198
|
}
|
1194
1199
|
}
|
1195
1200
|
}
|
1196
1201
|
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1202
|
+
/**
|
1203
|
+
*
|
1204
|
+
* @param loc
|
1205
|
+
* @param mat
|
1206
|
+
*/
|
1207
|
+
protected void setUniformMatrix(int loc, float[] mat) {
|
1203
1208
|
if (-1 < loc) {
|
1204
1209
|
updateFloatBuffer(mat);
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1210
|
+
switch (mat.length) {
|
1211
|
+
case 4:
|
1212
|
+
pgl.uniformMatrix2fv(loc, 1, false, floatBuffer);
|
1213
|
+
break;
|
1214
|
+
case 9:
|
1215
|
+
pgl.uniformMatrix3fv(loc, 1, false, floatBuffer);
|
1216
|
+
break;
|
1217
|
+
case 16:
|
1218
|
+
pgl.uniformMatrix4fv(loc, 1, false, floatBuffer);
|
1219
|
+
break;
|
1220
|
+
default:
|
1221
|
+
break;
|
1211
1222
|
}
|
1212
1223
|
}
|
1213
1224
|
}
|
1214
1225
|
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1226
|
+
/**
|
1227
|
+
*
|
1228
|
+
* @param loc
|
1229
|
+
* @param tex
|
1230
|
+
*/
|
1231
|
+
protected void setUniformTex(int loc, Texture tex) {
|
1221
1232
|
if (texUnits != null) {
|
1222
1233
|
Integer unit = texUnits.get(loc);
|
1223
1234
|
if (unit != null) {
|
@@ -1229,146 +1240,190 @@ public class PShader implements PConstants {
|
|
1229
1240
|
}
|
1230
1241
|
}
|
1231
1242
|
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1243
|
+
/**
|
1244
|
+
*
|
1245
|
+
* @param name
|
1246
|
+
* @param type
|
1247
|
+
* @param value
|
1248
|
+
*/
|
1249
|
+
protected void setUniformImpl(String name, int type, Object value) {
|
1239
1250
|
if (uniformValues == null) {
|
1240
|
-
uniformValues = new HashMap
|
1251
|
+
uniformValues = new HashMap<>();
|
1241
1252
|
}
|
1242
1253
|
uniformValues.put(name, new UniformValue(type, value));
|
1243
1254
|
}
|
1244
1255
|
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1256
|
+
/**
|
1257
|
+
*
|
1258
|
+
*/
|
1259
|
+
protected void consumeUniforms() {
|
1249
1260
|
if (uniformValues != null && 0 < uniformValues.size()) {
|
1250
1261
|
int unit = 0;
|
1251
|
-
for (String name: uniformValues.keySet()) {
|
1262
|
+
for (String name : uniformValues.keySet()) {
|
1252
1263
|
int loc = getUniformLoc(name);
|
1253
1264
|
if (loc == -1) {
|
1254
|
-
PGraphics.showWarning("The shader doesn't have a uniform called \""
|
1255
|
-
|
1256
|
-
|
1265
|
+
PGraphics.showWarning("The shader doesn't have a uniform called \""
|
1266
|
+
+ name + "\" OR the uniform was removed during "
|
1267
|
+
+ "compilation because it was unused.");
|
1257
1268
|
continue;
|
1258
1269
|
}
|
1259
1270
|
UniformValue val = uniformValues.get(name);
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
int[] v = ((int[])val.value);
|
1271
|
-
pgl.uniform4i(loc, v[0], v[1], v[2], v[3]);
|
1272
|
-
} else if (val.type == UniformValue.FLOAT1) {
|
1273
|
-
float[] v = ((float[])val.value);
|
1274
|
-
pgl.uniform1f(loc, v[0]);
|
1275
|
-
} else if (val.type == UniformValue.FLOAT2) {
|
1276
|
-
float[] v = ((float[])val.value);
|
1277
|
-
pgl.uniform2f(loc, v[0], v[1]);
|
1278
|
-
} else if (val.type == UniformValue.FLOAT3) {
|
1279
|
-
float[] v = ((float[])val.value);
|
1280
|
-
pgl.uniform3f(loc, v[0], v[1], v[2]);
|
1281
|
-
} else if (val.type == UniformValue.FLOAT4) {
|
1282
|
-
float[] v = ((float[])val.value);
|
1283
|
-
pgl.uniform4f(loc, v[0], v[1], v[2], v[3]);
|
1284
|
-
} else if (val.type == UniformValue.INT1VEC) {
|
1285
|
-
int[] v = ((int[])val.value);
|
1286
|
-
updateIntBuffer(v);
|
1287
|
-
pgl.uniform1iv(loc, v.length, intBuffer);
|
1288
|
-
} else if (val.type == UniformValue.INT2VEC) {
|
1289
|
-
int[] v = ((int[])val.value);
|
1290
|
-
updateIntBuffer(v);
|
1291
|
-
pgl.uniform2iv(loc, v.length / 2, intBuffer);
|
1292
|
-
} else if (val.type == UniformValue.INT3VEC) {
|
1293
|
-
int[] v = ((int[])val.value);
|
1294
|
-
updateIntBuffer(v);
|
1295
|
-
pgl.uniform3iv(loc, v.length / 3, intBuffer);
|
1296
|
-
} else if (val.type == UniformValue.INT4VEC) {
|
1297
|
-
int[] v = ((int[])val.value);
|
1298
|
-
updateIntBuffer(v);
|
1299
|
-
pgl.uniform4iv(loc, v.length / 4, intBuffer);
|
1300
|
-
} else if (val.type == UniformValue.FLOAT1VEC) {
|
1301
|
-
float[] v = ((float[])val.value);
|
1302
|
-
updateFloatBuffer(v);
|
1303
|
-
pgl.uniform1fv(loc, v.length, floatBuffer);
|
1304
|
-
} else if (val.type == UniformValue.FLOAT2VEC) {
|
1305
|
-
float[] v = ((float[])val.value);
|
1306
|
-
updateFloatBuffer(v);
|
1307
|
-
pgl.uniform2fv(loc, v.length / 2, floatBuffer);
|
1308
|
-
} else if (val.type == UniformValue.FLOAT3VEC) {
|
1309
|
-
float[] v = ((float[])val.value);
|
1310
|
-
updateFloatBuffer(v);
|
1311
|
-
pgl.uniform3fv(loc, v.length / 3, floatBuffer);
|
1312
|
-
} else if (val.type == UniformValue.FLOAT4VEC) {
|
1313
|
-
float[] v = ((float[])val.value);
|
1314
|
-
updateFloatBuffer(v);
|
1315
|
-
pgl.uniform4fv(loc, v.length / 4, floatBuffer);
|
1316
|
-
} else if (val.type == UniformValue.MAT2) {
|
1317
|
-
float[] v = ((float[])val.value);
|
1318
|
-
updateFloatBuffer(v);
|
1319
|
-
pgl.uniformMatrix2fv(loc, 1, false, floatBuffer);
|
1320
|
-
} else if (val.type == UniformValue.MAT3) {
|
1321
|
-
float[] v = ((float[])val.value);
|
1322
|
-
updateFloatBuffer(v);
|
1323
|
-
pgl.uniformMatrix3fv(loc, 1, false, floatBuffer);
|
1324
|
-
} else if (val.type == UniformValue.MAT4) {
|
1325
|
-
float[] v = ((float[])val.value);
|
1326
|
-
updateFloatBuffer(v);
|
1327
|
-
pgl.uniformMatrix4fv(loc, 1, false, floatBuffer);
|
1328
|
-
} else if (val.type == UniformValue.SAMPLER2D) {
|
1329
|
-
PImage img = (PImage)val.value;
|
1330
|
-
Texture tex = currentPG.getTexture(img);
|
1331
|
-
|
1332
|
-
if (textures == null) textures = new HashMap<Integer, Texture>();
|
1333
|
-
textures.put(loc, tex);
|
1334
|
-
|
1335
|
-
if (texUnits == null) texUnits = new HashMap<Integer, Integer>();
|
1336
|
-
if (texUnits.containsKey(loc)) {
|
1337
|
-
unit = texUnits.get(loc);
|
1338
|
-
pgl.uniform1i(loc, unit);
|
1339
|
-
} else {
|
1340
|
-
texUnits.put(loc, unit);
|
1341
|
-
pgl.uniform1i(loc, unit);
|
1271
|
+
switch (val.type) {
|
1272
|
+
case UniformValue.INT1: {
|
1273
|
+
int[] v = ((int[]) val.value);
|
1274
|
+
pgl.uniform1i(loc, v[0]);
|
1275
|
+
break;
|
1276
|
+
}
|
1277
|
+
case UniformValue.INT2: {
|
1278
|
+
int[] v = ((int[]) val.value);
|
1279
|
+
pgl.uniform2i(loc, v[0], v[1]);
|
1280
|
+
break;
|
1342
1281
|
}
|
1343
|
-
|
1282
|
+
case UniformValue.INT3: {
|
1283
|
+
int[] v = ((int[]) val.value);
|
1284
|
+
pgl.uniform3i(loc, v[0], v[1], v[2]);
|
1285
|
+
break;
|
1286
|
+
}
|
1287
|
+
case UniformValue.INT4: {
|
1288
|
+
int[] v = ((int[]) val.value);
|
1289
|
+
pgl.uniform4i(loc, v[0], v[1], v[2], v[3]);
|
1290
|
+
break;
|
1291
|
+
}
|
1292
|
+
case UniformValue.FLOAT1: {
|
1293
|
+
float[] v = ((float[]) val.value);
|
1294
|
+
pgl.uniform1f(loc, v[0]);
|
1295
|
+
break;
|
1296
|
+
}
|
1297
|
+
case UniformValue.FLOAT2: {
|
1298
|
+
float[] v = ((float[]) val.value);
|
1299
|
+
pgl.uniform2f(loc, v[0], v[1]);
|
1300
|
+
break;
|
1301
|
+
}
|
1302
|
+
case UniformValue.FLOAT3: {
|
1303
|
+
float[] v = ((float[]) val.value);
|
1304
|
+
pgl.uniform3f(loc, v[0], v[1], v[2]);
|
1305
|
+
break;
|
1306
|
+
}
|
1307
|
+
case UniformValue.FLOAT4: {
|
1308
|
+
float[] v = ((float[]) val.value);
|
1309
|
+
pgl.uniform4f(loc, v[0], v[1], v[2], v[3]);
|
1310
|
+
break;
|
1311
|
+
}
|
1312
|
+
case UniformValue.INT1VEC: {
|
1313
|
+
int[] v = ((int[]) val.value);
|
1314
|
+
updateIntBuffer(v);
|
1315
|
+
pgl.uniform1iv(loc, v.length, intBuffer);
|
1316
|
+
break;
|
1317
|
+
}
|
1318
|
+
case UniformValue.INT2VEC: {
|
1319
|
+
int[] v = ((int[]) val.value);
|
1320
|
+
updateIntBuffer(v);
|
1321
|
+
pgl.uniform2iv(loc, v.length / 2, intBuffer);
|
1322
|
+
break;
|
1323
|
+
}
|
1324
|
+
case UniformValue.INT3VEC: {
|
1325
|
+
int[] v = ((int[]) val.value);
|
1326
|
+
updateIntBuffer(v);
|
1327
|
+
pgl.uniform3iv(loc, v.length / 3, intBuffer);
|
1328
|
+
break;
|
1329
|
+
}
|
1330
|
+
case UniformValue.INT4VEC: {
|
1331
|
+
int[] v = ((int[]) val.value);
|
1332
|
+
updateIntBuffer(v);
|
1333
|
+
pgl.uniform4iv(loc, v.length / 4, intBuffer);
|
1334
|
+
break;
|
1335
|
+
}
|
1336
|
+
case UniformValue.FLOAT1VEC: {
|
1337
|
+
float[] v = ((float[]) val.value);
|
1338
|
+
updateFloatBuffer(v);
|
1339
|
+
pgl.uniform1fv(loc, v.length, floatBuffer);
|
1340
|
+
break;
|
1341
|
+
}
|
1342
|
+
case UniformValue.FLOAT2VEC: {
|
1343
|
+
float[] v = ((float[]) val.value);
|
1344
|
+
updateFloatBuffer(v);
|
1345
|
+
pgl.uniform2fv(loc, v.length / 2, floatBuffer);
|
1346
|
+
break;
|
1347
|
+
}
|
1348
|
+
case UniformValue.FLOAT3VEC: {
|
1349
|
+
float[] v = ((float[]) val.value);
|
1350
|
+
updateFloatBuffer(v);
|
1351
|
+
pgl.uniform3fv(loc, v.length / 3, floatBuffer);
|
1352
|
+
break;
|
1353
|
+
}
|
1354
|
+
case UniformValue.FLOAT4VEC: {
|
1355
|
+
float[] v = ((float[]) val.value);
|
1356
|
+
updateFloatBuffer(v);
|
1357
|
+
pgl.uniform4fv(loc, v.length / 4, floatBuffer);
|
1358
|
+
break;
|
1359
|
+
}
|
1360
|
+
case UniformValue.MAT2: {
|
1361
|
+
float[] v = ((float[]) val.value);
|
1362
|
+
updateFloatBuffer(v);
|
1363
|
+
pgl.uniformMatrix2fv(loc, 1, false, floatBuffer);
|
1364
|
+
break;
|
1365
|
+
}
|
1366
|
+
case UniformValue.MAT3: {
|
1367
|
+
float[] v = ((float[]) val.value);
|
1368
|
+
updateFloatBuffer(v);
|
1369
|
+
pgl.uniformMatrix3fv(loc, 1, false, floatBuffer);
|
1370
|
+
break;
|
1371
|
+
}
|
1372
|
+
case UniformValue.MAT4: {
|
1373
|
+
float[] v = ((float[]) val.value);
|
1374
|
+
updateFloatBuffer(v);
|
1375
|
+
pgl.uniformMatrix4fv(loc, 1, false, floatBuffer);
|
1376
|
+
break;
|
1377
|
+
}
|
1378
|
+
case UniformValue.SAMPLER2D:
|
1379
|
+
PImage img = (PImage) val.value;
|
1380
|
+
Texture tex = currentPG.getTexture(img);
|
1381
|
+
if (textures == null) {
|
1382
|
+
textures = new HashMap<>();
|
1383
|
+
}
|
1384
|
+
textures.put(loc, tex);
|
1385
|
+
if (texUnits == null) {
|
1386
|
+
texUnits = new HashMap<>();
|
1387
|
+
}
|
1388
|
+
if (texUnits.containsKey(loc)) {
|
1389
|
+
unit = texUnits.get(loc);
|
1390
|
+
pgl.uniform1i(loc, unit);
|
1391
|
+
} else {
|
1392
|
+
texUnits.put(loc, unit);
|
1393
|
+
pgl.uniform1i(loc, unit);
|
1394
|
+
}
|
1395
|
+
unit++;
|
1396
|
+
break;
|
1397
|
+
default:
|
1398
|
+
break;
|
1344
1399
|
}
|
1345
1400
|
}
|
1346
1401
|
uniformValues.clear();
|
1347
1402
|
}
|
1348
1403
|
}
|
1349
1404
|
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1405
|
+
/**
|
1406
|
+
*
|
1407
|
+
* @param vec
|
1408
|
+
*/
|
1409
|
+
protected void updateIntBuffer(int[] vec) {
|
1355
1410
|
intBuffer = PGL.updateIntBuffer(intBuffer, vec, false);
|
1356
1411
|
}
|
1357
1412
|
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1413
|
+
/**
|
1414
|
+
*
|
1415
|
+
* @param vec
|
1416
|
+
*/
|
1417
|
+
protected void updateFloatBuffer(float[] vec) {
|
1363
1418
|
floatBuffer = PGL.updateFloatBuffer(floatBuffer, vec, false);
|
1364
1419
|
}
|
1365
1420
|
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1421
|
+
/**
|
1422
|
+
*
|
1423
|
+
*/
|
1424
|
+
protected void bindTextures() {
|
1370
1425
|
if (textures != null && texUnits != null) {
|
1371
|
-
|
1426
|
+
textures.keySet().forEach((loc) -> {
|
1372
1427
|
Texture tex = textures.get(loc);
|
1373
1428
|
Integer unit = texUnits.get(loc);
|
1374
1429
|
if (unit != null) {
|
@@ -1377,16 +1432,16 @@ public class PShader implements PConstants {
|
|
1377
1432
|
} else {
|
1378
1433
|
throw new RuntimeException("Cannot find unit for texture " + tex);
|
1379
1434
|
}
|
1380
|
-
}
|
1435
|
+
});
|
1381
1436
|
}
|
1382
1437
|
}
|
1383
1438
|
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1439
|
+
/**
|
1440
|
+
*
|
1441
|
+
*/
|
1442
|
+
protected void unbindTextures() {
|
1388
1443
|
if (textures != null && texUnits != null) {
|
1389
|
-
|
1444
|
+
textures.keySet().forEach((loc) -> {
|
1390
1445
|
Texture tex = textures.get(loc);
|
1391
1446
|
Integer unit = texUnits.get(loc);
|
1392
1447
|
if (unit != null) {
|
@@ -1395,15 +1450,15 @@ public class PShader implements PConstants {
|
|
1395
1450
|
} else {
|
1396
1451
|
throw new RuntimeException("Cannot find unit for texture " + tex);
|
1397
1452
|
}
|
1398
|
-
}
|
1453
|
+
});
|
1399
1454
|
pgl.activeTexture(PGL.TEXTURE0);
|
1400
1455
|
}
|
1401
1456
|
}
|
1402
1457
|
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1458
|
+
/**
|
1459
|
+
*
|
1460
|
+
*/
|
1461
|
+
public void init() {
|
1407
1462
|
if (glProgram == 0 || contextIsOutdated()) {
|
1408
1463
|
create();
|
1409
1464
|
if (compile()) {
|
@@ -1419,19 +1474,19 @@ public class PShader implements PConstants {
|
|
1419
1474
|
}
|
1420
1475
|
}
|
1421
1476
|
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1477
|
+
/**
|
1478
|
+
*
|
1479
|
+
*/
|
1480
|
+
protected void create() {
|
1426
1481
|
context = pgl.getCurrentContext();
|
1427
1482
|
glres = new GLResourceShader(this);
|
1428
1483
|
}
|
1429
1484
|
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1485
|
+
/**
|
1486
|
+
*
|
1487
|
+
* @return
|
1488
|
+
*/
|
1489
|
+
protected boolean compile() {
|
1435
1490
|
boolean vertRes = true;
|
1436
1491
|
if (hasVertexShader()) {
|
1437
1492
|
vertRes = compileVertexShader();
|
@@ -1449,31 +1504,31 @@ public class PShader implements PConstants {
|
|
1449
1504
|
return vertRes && fragRes;
|
1450
1505
|
}
|
1451
1506
|
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1507
|
+
/**
|
1508
|
+
*
|
1509
|
+
*/
|
1510
|
+
protected void validate() {
|
1456
1511
|
pgl.getProgramiv(glProgram, PGL.LINK_STATUS, intBuffer);
|
1457
|
-
boolean linked = intBuffer.get(0)
|
1512
|
+
boolean linked = intBuffer.get(0) != 0;
|
1458
1513
|
if (!linked) {
|
1459
|
-
PGraphics.showException("Cannot link shader program:\n"
|
1460
|
-
|
1514
|
+
PGraphics.showException("Cannot link shader program:\n"
|
1515
|
+
+ pgl.getProgramInfoLog(glProgram));
|
1461
1516
|
}
|
1462
1517
|
|
1463
1518
|
pgl.validateProgram(glProgram);
|
1464
1519
|
pgl.getProgramiv(glProgram, PGL.VALIDATE_STATUS, intBuffer);
|
1465
|
-
boolean validated = intBuffer.get(0)
|
1520
|
+
boolean validated = intBuffer.get(0) != 0;
|
1466
1521
|
if (!validated) {
|
1467
|
-
PGraphics.showException("Cannot validate shader program:\n"
|
1468
|
-
|
1522
|
+
PGraphics.showException("Cannot validate shader program:\n"
|
1523
|
+
+ pgl.getProgramInfoLog(glProgram));
|
1469
1524
|
}
|
1470
1525
|
}
|
1471
1526
|
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1527
|
+
/**
|
1528
|
+
*
|
1529
|
+
* @return
|
1530
|
+
*/
|
1531
|
+
protected boolean contextIsOutdated() {
|
1477
1532
|
boolean outdated = !pgl.contextIsCurrent(context);
|
1478
1533
|
if (outdated) {
|
1479
1534
|
dispose();
|
@@ -1481,66 +1536,62 @@ public class PShader implements PConstants {
|
|
1481
1536
|
return outdated;
|
1482
1537
|
}
|
1483
1538
|
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1539
|
+
/**
|
1540
|
+
*
|
1541
|
+
* @return
|
1542
|
+
*/
|
1543
|
+
protected boolean hasVertexShader() {
|
1489
1544
|
return vertexShaderSource != null && 0 < vertexShaderSource.length;
|
1490
1545
|
}
|
1491
1546
|
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1547
|
+
/**
|
1548
|
+
*
|
1549
|
+
* @return
|
1550
|
+
*/
|
1551
|
+
protected boolean hasFragmentShader() {
|
1497
1552
|
return fragmentShaderSource != null && 0 < fragmentShaderSource.length;
|
1498
1553
|
}
|
1499
1554
|
|
1500
|
-
|
1501
1555
|
/**
|
1502
|
-
* @
|
1503
|
-
* @return
|
1556
|
+
* @return
|
1504
1557
|
*/
|
1505
1558
|
protected boolean compileVertexShader() {
|
1506
1559
|
pgl.shaderSource(glVertex, PApplet.join(vertexShaderSource, "\n"));
|
1507
1560
|
pgl.compileShader(glVertex);
|
1508
1561
|
|
1509
1562
|
pgl.getShaderiv(glVertex, PGL.COMPILE_STATUS, intBuffer);
|
1510
|
-
boolean compiled = intBuffer.get(0)
|
1563
|
+
boolean compiled = intBuffer.get(0) != 0;
|
1511
1564
|
if (!compiled) {
|
1512
|
-
PGraphics.showException("Cannot compile vertex shader:\n"
|
1513
|
-
|
1565
|
+
PGraphics.showException("Cannot compile vertex shader:\n"
|
1566
|
+
+ pgl.getShaderInfoLog(glVertex));
|
1514
1567
|
return false;
|
1515
1568
|
} else {
|
1516
1569
|
return true;
|
1517
1570
|
}
|
1518
1571
|
}
|
1519
1572
|
|
1520
|
-
|
1521
1573
|
/**
|
1522
|
-
* @
|
1523
|
-
* @return
|
1574
|
+
* @return
|
1524
1575
|
*/
|
1525
1576
|
protected boolean compileFragmentShader() {
|
1526
1577
|
pgl.shaderSource(glFragment, PApplet.join(fragmentShaderSource, "\n"));
|
1527
1578
|
pgl.compileShader(glFragment);
|
1528
1579
|
|
1529
1580
|
pgl.getShaderiv(glFragment, PGL.COMPILE_STATUS, intBuffer);
|
1530
|
-
boolean compiled = intBuffer.get(0)
|
1581
|
+
boolean compiled = intBuffer.get(0) != 0;
|
1531
1582
|
if (!compiled) {
|
1532
|
-
PGraphics.showException("Cannot compile fragment shader:\n"
|
1533
|
-
|
1583
|
+
PGraphics.showException("Cannot compile fragment shader:\n"
|
1584
|
+
+ pgl.getShaderInfoLog(glFragment));
|
1534
1585
|
return false;
|
1535
1586
|
} else {
|
1536
1587
|
return true;
|
1537
1588
|
}
|
1538
1589
|
}
|
1539
1590
|
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1591
|
+
/**
|
1592
|
+
*
|
1593
|
+
*/
|
1594
|
+
protected void dispose() {
|
1544
1595
|
if (glres != null) {
|
1545
1596
|
glres.dispose();
|
1546
1597
|
glVertex = 0;
|
@@ -1550,118 +1601,123 @@ public class PShader implements PConstants {
|
|
1550
1601
|
}
|
1551
1602
|
}
|
1552
1603
|
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
for (
|
1561
|
-
String line =
|
1562
|
-
|
1563
|
-
if (PApplet.match(line, colorShaderDefRegexp) != null)
|
1604
|
+
/**
|
1605
|
+
*
|
1606
|
+
* @param source
|
1607
|
+
* @param defaultType
|
1608
|
+
* @return
|
1609
|
+
*/
|
1610
|
+
static protected int getShaderType(String[] source, int defaultType) {
|
1611
|
+
for (String source1 : source) {
|
1612
|
+
String line = source1.trim();
|
1613
|
+
if (PApplet.match(line, colorShaderDefRegexp) != null) {
|
1564
1614
|
return PShader.COLOR;
|
1565
|
-
else if (PApplet.match(line, lightShaderDefRegexp) != null)
|
1615
|
+
} else if (PApplet.match(line, lightShaderDefRegexp) != null) {
|
1566
1616
|
return PShader.LIGHT;
|
1567
|
-
else if (PApplet.match(line, texShaderDefRegexp) != null)
|
1617
|
+
} else if (PApplet.match(line, texShaderDefRegexp) != null) {
|
1568
1618
|
return PShader.TEXTURE;
|
1569
|
-
else if (PApplet.match(line, texlightShaderDefRegexp) != null)
|
1619
|
+
} else if (PApplet.match(line, texlightShaderDefRegexp) != null) {
|
1570
1620
|
return PShader.TEXLIGHT;
|
1571
|
-
else if (PApplet.match(line, polyShaderDefRegexp) != null)
|
1621
|
+
} else if (PApplet.match(line, polyShaderDefRegexp) != null) {
|
1572
1622
|
return PShader.POLY;
|
1573
|
-
else if (PApplet.match(line, triShaderAttrRegexp) != null)
|
1623
|
+
} else if (PApplet.match(line, triShaderAttrRegexp) != null) {
|
1574
1624
|
return PShader.POLY;
|
1575
|
-
else if (PApplet.match(line, quadShaderAttrRegexp) != null)
|
1625
|
+
} else if (PApplet.match(line, quadShaderAttrRegexp) != null) {
|
1576
1626
|
return PShader.POLY;
|
1577
|
-
else if (PApplet.match(line, pointShaderDefRegexp) != null)
|
1627
|
+
} else if (PApplet.match(line, pointShaderDefRegexp) != null) {
|
1578
1628
|
return PShader.POINT;
|
1579
|
-
else if (PApplet.match(line, lineShaderDefRegexp) != null)
|
1629
|
+
} else if (PApplet.match(line, lineShaderDefRegexp) != null) {
|
1580
1630
|
return PShader.LINE;
|
1581
|
-
else if (PApplet.match(line, pointShaderAttrRegexp) != null)
|
1631
|
+
} else if (PApplet.match(line, pointShaderAttrRegexp) != null) {
|
1582
1632
|
return PShader.POINT;
|
1583
|
-
else if (PApplet.match(line, pointShaderInRegexp) != null)
|
1633
|
+
} else if (PApplet.match(line, pointShaderInRegexp) != null) {
|
1584
1634
|
return PShader.POINT;
|
1585
|
-
else if (PApplet.match(line, lineShaderAttrRegexp) != null)
|
1635
|
+
} else if (PApplet.match(line, lineShaderAttrRegexp) != null) {
|
1586
1636
|
return PShader.LINE;
|
1587
|
-
else if (PApplet.match(line, lineShaderInRegexp) != null)
|
1637
|
+
} else if (PApplet.match(line, lineShaderInRegexp) != null) {
|
1588
1638
|
return PShader.LINE;
|
1639
|
+
}
|
1589
1640
|
}
|
1590
1641
|
return defaultType;
|
1591
1642
|
}
|
1592
1643
|
|
1593
|
-
|
1594
1644
|
// ***************************************************************************
|
1595
1645
|
//
|
1596
1646
|
// Processing specific
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
*/
|
1602
|
-
|
1603
|
-
|
1647
|
+
/**
|
1648
|
+
*
|
1649
|
+
* @return
|
1650
|
+
*/
|
1604
1651
|
protected int getType() {
|
1605
1652
|
return type;
|
1606
1653
|
}
|
1607
1654
|
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1655
|
+
/**
|
1656
|
+
*
|
1657
|
+
* @param type
|
1658
|
+
*/
|
1659
|
+
protected void setType(int type) {
|
1613
1660
|
this.type = type;
|
1614
1661
|
}
|
1615
1662
|
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1663
|
+
/**
|
1664
|
+
*
|
1665
|
+
* @return
|
1666
|
+
*/
|
1667
|
+
protected boolean hasType() {
|
1621
1668
|
return POINT <= type && type <= TEXLIGHT;
|
1622
1669
|
}
|
1623
1670
|
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1671
|
+
/**
|
1672
|
+
*
|
1673
|
+
* @return
|
1674
|
+
*/
|
1675
|
+
protected boolean isPointShader() {
|
1629
1676
|
return type == POINT;
|
1630
1677
|
}
|
1631
1678
|
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1679
|
+
/**
|
1680
|
+
*
|
1681
|
+
* @return
|
1682
|
+
*/
|
1683
|
+
protected boolean isLineShader() {
|
1637
1684
|
return type == LINE;
|
1638
1685
|
}
|
1639
1686
|
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1687
|
+
/**
|
1688
|
+
*
|
1689
|
+
* @return
|
1690
|
+
*/
|
1691
|
+
protected boolean isPolyShader() {
|
1645
1692
|
return POLY <= type && type <= TEXLIGHT;
|
1646
1693
|
}
|
1647
1694
|
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
if (getType() == PShader.POLY)
|
1695
|
+
/**
|
1696
|
+
*
|
1697
|
+
* @param type
|
1698
|
+
* @return
|
1699
|
+
*/
|
1700
|
+
protected boolean checkPolyType(int type) {
|
1701
|
+
if (getType() == PShader.POLY) {
|
1702
|
+
return true;
|
1703
|
+
}
|
1655
1704
|
|
1656
1705
|
if (getType() != type) {
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1706
|
+
switch (type) {
|
1707
|
+
case TEXLIGHT:
|
1708
|
+
PGraphics.showWarning(PGraphicsOpenGL.NO_TEXLIGHT_SHADER_ERROR);
|
1709
|
+
break;
|
1710
|
+
case LIGHT:
|
1711
|
+
PGraphics.showWarning(PGraphicsOpenGL.NO_LIGHT_SHADER_ERROR);
|
1712
|
+
break;
|
1713
|
+
case TEXTURE:
|
1714
|
+
PGraphics.showWarning(PGraphicsOpenGL.NO_TEXTURE_SHADER_ERROR);
|
1715
|
+
break;
|
1716
|
+
case COLOR:
|
1717
|
+
PGraphics.showWarning(PGraphicsOpenGL.NO_COLOR_SHADER_ERROR);
|
1718
|
+
break;
|
1719
|
+
default:
|
1720
|
+
break;
|
1665
1721
|
}
|
1666
1722
|
return false;
|
1667
1723
|
}
|
@@ -1669,30 +1725,34 @@ public class PShader implements PConstants {
|
|
1669
1725
|
return true;
|
1670
1726
|
}
|
1671
1727
|
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1728
|
+
/**
|
1729
|
+
*
|
1730
|
+
* @return
|
1731
|
+
*/
|
1732
|
+
protected int getLastTexUnit() {
|
1677
1733
|
return texUnits == null ? -1 : texUnits.size() - 1;
|
1678
1734
|
}
|
1679
1735
|
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1736
|
+
/**
|
1737
|
+
*
|
1738
|
+
* @param pg
|
1739
|
+
*/
|
1740
|
+
protected void setRenderer(PGraphicsOpenGL pg) {
|
1685
1741
|
this.currentPG = pg;
|
1686
1742
|
}
|
1687
1743
|
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
if (loadedAttributes)
|
1744
|
+
/**
|
1745
|
+
*
|
1746
|
+
*/
|
1747
|
+
protected void loadAttributes() {
|
1748
|
+
if (loadedAttributes) {
|
1749
|
+
return;
|
1750
|
+
}
|
1693
1751
|
|
1694
1752
|
vertexLoc = getAttributeLoc("vertex");
|
1695
|
-
if (vertexLoc == -1)
|
1753
|
+
if (vertexLoc == -1) {
|
1754
|
+
vertexLoc = getAttributeLoc("position");
|
1755
|
+
}
|
1696
1756
|
|
1697
1757
|
colorLoc = getAttributeLoc("color");
|
1698
1758
|
texCoordLoc = getAttributeLoc("texCoord");
|
@@ -1713,22 +1773,27 @@ public class PShader implements PConstants {
|
|
1713
1773
|
loadedAttributes = true;
|
1714
1774
|
}
|
1715
1775
|
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
if (loadedUniforms)
|
1776
|
+
/**
|
1777
|
+
*
|
1778
|
+
*/
|
1779
|
+
protected void loadUniforms() {
|
1780
|
+
if (loadedUniforms) {
|
1781
|
+
return;
|
1782
|
+
}
|
1721
1783
|
transformMatLoc = getUniformLoc("transform");
|
1722
|
-
if (transformMatLoc == -1)
|
1784
|
+
if (transformMatLoc == -1) {
|
1723
1785
|
transformMatLoc = getUniformLoc("transformMatrix");
|
1786
|
+
}
|
1724
1787
|
|
1725
1788
|
modelviewMatLoc = getUniformLoc("modelview");
|
1726
|
-
if (modelviewMatLoc == -1)
|
1789
|
+
if (modelviewMatLoc == -1) {
|
1727
1790
|
modelviewMatLoc = getUniformLoc("modelviewMatrix");
|
1791
|
+
}
|
1728
1792
|
|
1729
1793
|
projectionMatLoc = getUniformLoc("projection");
|
1730
|
-
if (projectionMatLoc == -1)
|
1794
|
+
if (projectionMatLoc == -1) {
|
1731
1795
|
projectionMatLoc = getUniformLoc("projectionMatrix");
|
1796
|
+
}
|
1732
1797
|
|
1733
1798
|
viewportLoc = getUniformLoc("viewport");
|
1734
1799
|
resolutionLoc = getUniformLoc("resolution");
|
@@ -1758,10 +1823,10 @@ public class PShader implements PConstants {
|
|
1758
1823
|
loadedUniforms = true;
|
1759
1824
|
}
|
1760
1825
|
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1826
|
+
/**
|
1827
|
+
*
|
1828
|
+
*/
|
1829
|
+
protected void setCommonUniforms() {
|
1765
1830
|
if (-1 < transformMatLoc) {
|
1766
1831
|
currentPG.updateGLProjmodelview();
|
1767
1832
|
setUniformMatrix(transformMatLoc, currentPG.glProjmodelview);
|
@@ -1801,10 +1866,10 @@ public class PShader implements PConstants {
|
|
1801
1866
|
}
|
1802
1867
|
}
|
1803
1868
|
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1869
|
+
/**
|
1870
|
+
*
|
1871
|
+
*/
|
1872
|
+
protected void bindTyped() {
|
1808
1873
|
if (currentPG == null) {
|
1809
1874
|
setRenderer(primaryPG.getCurrentPG());
|
1810
1875
|
loadAttributes();
|
@@ -1812,20 +1877,36 @@ public class PShader implements PConstants {
|
|
1812
1877
|
}
|
1813
1878
|
setCommonUniforms();
|
1814
1879
|
|
1815
|
-
if (-1 < vertexLoc)
|
1816
|
-
|
1817
|
-
|
1818
|
-
if (-1 <
|
1880
|
+
if (-1 < vertexLoc) {
|
1881
|
+
pgl.enableVertexAttribArray(vertexLoc);
|
1882
|
+
}
|
1883
|
+
if (-1 < colorLoc) {
|
1884
|
+
pgl.enableVertexAttribArray(colorLoc);
|
1885
|
+
}
|
1886
|
+
if (-1 < texCoordLoc) {
|
1887
|
+
pgl.enableVertexAttribArray(texCoordLoc);
|
1888
|
+
}
|
1889
|
+
if (-1 < normalLoc) {
|
1890
|
+
pgl.enableVertexAttribArray(normalLoc);
|
1891
|
+
}
|
1819
1892
|
|
1820
1893
|
if (-1 < normalMatLoc) {
|
1821
1894
|
currentPG.updateGLNormal();
|
1822
1895
|
setUniformMatrix(normalMatLoc, currentPG.glNormal);
|
1823
1896
|
}
|
1824
1897
|
|
1825
|
-
if (-1 < ambientLoc)
|
1826
|
-
|
1827
|
-
|
1828
|
-
if (-1 <
|
1898
|
+
if (-1 < ambientLoc) {
|
1899
|
+
pgl.enableVertexAttribArray(ambientLoc);
|
1900
|
+
}
|
1901
|
+
if (-1 < specularLoc) {
|
1902
|
+
pgl.enableVertexAttribArray(specularLoc);
|
1903
|
+
}
|
1904
|
+
if (-1 < emissiveLoc) {
|
1905
|
+
pgl.enableVertexAttribArray(emissiveLoc);
|
1906
|
+
}
|
1907
|
+
if (-1 < shininessLoc) {
|
1908
|
+
pgl.enableVertexAttribArray(shininessLoc);
|
1909
|
+
}
|
1829
1910
|
|
1830
1911
|
int count = currentPG.lightCount;
|
1831
1912
|
setUniformValue(lightCountLoc, count);
|
@@ -1836,17 +1917,21 @@ public class PShader implements PConstants {
|
|
1836
1917
|
setUniformVector(lightDiffuseLoc, currentPG.lightDiffuse, 3, count);
|
1837
1918
|
setUniformVector(lightSpecularLoc, currentPG.lightSpecular, 3, count);
|
1838
1919
|
setUniformVector(lightFalloffLoc, currentPG.lightFalloffCoefficients,
|
1839
|
-
|
1920
|
+
3, count);
|
1840
1921
|
setUniformVector(lightSpotLoc, currentPG.lightSpotParameters, 2, count);
|
1841
1922
|
}
|
1842
1923
|
|
1843
|
-
if (-1 < directionLoc)
|
1924
|
+
if (-1 < directionLoc) {
|
1925
|
+
pgl.enableVertexAttribArray(directionLoc);
|
1926
|
+
}
|
1844
1927
|
|
1845
|
-
if (-1 < offsetLoc)
|
1928
|
+
if (-1 < offsetLoc) {
|
1929
|
+
pgl.enableVertexAttribArray(offsetLoc);
|
1930
|
+
}
|
1846
1931
|
|
1847
1932
|
if (-1 < perspectiveLoc) {
|
1848
|
-
if (currentPG.getHint(ENABLE_STROKE_PERSPECTIVE)
|
1849
|
-
|
1933
|
+
if (currentPG.getHint(ENABLE_STROKE_PERSPECTIVE)
|
1934
|
+
&& currentPG.nonOrthoProjection()) {
|
1850
1935
|
setUniformValue(perspectiveLoc, 1);
|
1851
1936
|
} else {
|
1852
1937
|
setUniformValue(perspectiveLoc, 0);
|
@@ -1867,13 +1952,17 @@ public class PShader implements PConstants {
|
|
1867
1952
|
}
|
1868
1953
|
}
|
1869
1954
|
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
if (-1 < offsetLoc)
|
1955
|
+
/**
|
1956
|
+
*
|
1957
|
+
*/
|
1958
|
+
protected void unbindTyped() {
|
1959
|
+
if (-1 < offsetLoc) {
|
1960
|
+
pgl.disableVertexAttribArray(offsetLoc);
|
1961
|
+
}
|
1875
1962
|
|
1876
|
-
if (-1 < directionLoc)
|
1963
|
+
if (-1 < directionLoc) {
|
1964
|
+
pgl.disableVertexAttribArray(directionLoc);
|
1965
|
+
}
|
1877
1966
|
|
1878
1967
|
if (-1 < textureLoc && texture != null) {
|
1879
1968
|
pgl.activeTexture(PGL.TEXTURE0 + texUnit);
|
@@ -1882,15 +1971,31 @@ public class PShader implements PConstants {
|
|
1882
1971
|
texture = null;
|
1883
1972
|
}
|
1884
1973
|
|
1885
|
-
if (-1 < ambientLoc)
|
1886
|
-
|
1887
|
-
|
1888
|
-
if (-1 <
|
1974
|
+
if (-1 < ambientLoc) {
|
1975
|
+
pgl.disableVertexAttribArray(ambientLoc);
|
1976
|
+
}
|
1977
|
+
if (-1 < specularLoc) {
|
1978
|
+
pgl.disableVertexAttribArray(specularLoc);
|
1979
|
+
}
|
1980
|
+
if (-1 < emissiveLoc) {
|
1981
|
+
pgl.disableVertexAttribArray(emissiveLoc);
|
1982
|
+
}
|
1983
|
+
if (-1 < shininessLoc) {
|
1984
|
+
pgl.disableVertexAttribArray(shininessLoc);
|
1985
|
+
}
|
1889
1986
|
|
1890
|
-
if (-1 < vertexLoc)
|
1891
|
-
|
1892
|
-
|
1893
|
-
if (-1 <
|
1987
|
+
if (-1 < vertexLoc) {
|
1988
|
+
pgl.disableVertexAttribArray(vertexLoc);
|
1989
|
+
}
|
1990
|
+
if (-1 < colorLoc) {
|
1991
|
+
pgl.disableVertexAttribArray(colorLoc);
|
1992
|
+
}
|
1993
|
+
if (-1 < texCoordLoc) {
|
1994
|
+
pgl.disableVertexAttribArray(texCoordLoc);
|
1995
|
+
}
|
1996
|
+
if (-1 < normalLoc) {
|
1997
|
+
pgl.disableVertexAttribArray(normalLoc);
|
1998
|
+
}
|
1894
1999
|
|
1895
2000
|
if (-1 < ppixelsLoc) {
|
1896
2001
|
pgl.enableFBOLayer();
|
@@ -1902,38 +2007,38 @@ public class PShader implements PConstants {
|
|
1902
2007
|
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
|
1903
2008
|
}
|
1904
2009
|
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
2010
|
+
/**
|
2011
|
+
*
|
2012
|
+
* @param tex
|
2013
|
+
*/
|
2014
|
+
protected void setTexture(Texture tex) {
|
1910
2015
|
texture = tex;
|
1911
2016
|
|
1912
2017
|
float scaleu = 1;
|
1913
2018
|
float scalev = 1;
|
1914
|
-
float dispu
|
1915
|
-
float dispv
|
2019
|
+
float dispu = 0;
|
2020
|
+
float dispv = 0;
|
1916
2021
|
|
1917
2022
|
if (tex != null) {
|
1918
2023
|
if (tex.invertedX()) {
|
1919
2024
|
scaleu = -1;
|
1920
|
-
dispu
|
2025
|
+
dispu = 1;
|
1921
2026
|
}
|
1922
2027
|
|
1923
2028
|
if (tex.invertedY()) {
|
1924
2029
|
scalev = -1;
|
1925
|
-
dispv
|
2030
|
+
dispv = 1;
|
1926
2031
|
}
|
1927
2032
|
|
1928
2033
|
scaleu *= tex.maxTexcoordU();
|
1929
|
-
dispu
|
2034
|
+
dispu *= tex.maxTexcoordU();
|
1930
2035
|
scalev *= tex.maxTexcoordV();
|
1931
|
-
dispv
|
2036
|
+
dispv *= tex.maxTexcoordV();
|
1932
2037
|
|
1933
2038
|
setUniformValue(texOffsetLoc, 1.0f / tex.width, 1.0f / tex.height);
|
1934
2039
|
|
1935
2040
|
if (-1 < textureLoc) {
|
1936
|
-
texUnit =
|
2041
|
+
texUnit = -1 < ppixelsUnit ? ppixelsUnit + 1 : getLastTexUnit() + 1;
|
1937
2042
|
setUniformValue(textureLoc, texUnit);
|
1938
2043
|
pgl.activeTexture(PGL.TEXTURE0 + texUnit);
|
1939
2044
|
tex.bind();
|
@@ -1944,214 +2049,225 @@ public class PShader implements PConstants {
|
|
1944
2049
|
if (tcmat == null) {
|
1945
2050
|
tcmat = new float[16];
|
1946
2051
|
}
|
1947
|
-
tcmat[0] = scaleu;
|
1948
|
-
tcmat[
|
1949
|
-
tcmat[
|
1950
|
-
tcmat[
|
2052
|
+
tcmat[0] = scaleu;
|
2053
|
+
tcmat[4] = 0;
|
2054
|
+
tcmat[8] = 0;
|
2055
|
+
tcmat[12] = dispu;
|
2056
|
+
tcmat[1] = 0;
|
2057
|
+
tcmat[5] = scalev;
|
2058
|
+
tcmat[9] = 0;
|
2059
|
+
tcmat[13] = dispv;
|
2060
|
+
tcmat[2] = 0;
|
2061
|
+
tcmat[6] = 0;
|
2062
|
+
tcmat[10] = 0;
|
2063
|
+
tcmat[14] = 0;
|
2064
|
+
tcmat[3] = 0;
|
2065
|
+
tcmat[7] = 0;
|
2066
|
+
tcmat[11] = 0;
|
2067
|
+
tcmat[15] = 0;
|
1951
2068
|
setUniformMatrix(texMatrixLoc, tcmat);
|
1952
2069
|
}
|
1953
2070
|
}
|
1954
2071
|
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
2072
|
+
/**
|
2073
|
+
*
|
2074
|
+
* @return
|
2075
|
+
*/
|
2076
|
+
protected boolean supportsTexturing() {
|
1960
2077
|
return -1 < textureLoc;
|
1961
2078
|
}
|
1962
2079
|
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
2080
|
+
/**
|
2081
|
+
*
|
2082
|
+
* @return
|
2083
|
+
*/
|
2084
|
+
protected boolean supportLighting() {
|
1968
2085
|
return -1 < lightCountLoc || -1 < lightPositionLoc || -1 < lightNormalLoc;
|
1969
2086
|
}
|
1970
2087
|
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
2088
|
+
/**
|
2089
|
+
*
|
2090
|
+
* @return
|
2091
|
+
*/
|
2092
|
+
protected boolean accessTexCoords() {
|
1976
2093
|
return -1 < texCoordLoc;
|
1977
2094
|
}
|
1978
2095
|
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
2096
|
+
/**
|
2097
|
+
*
|
2098
|
+
* @return
|
2099
|
+
*/
|
2100
|
+
protected boolean accessNormals() {
|
1984
2101
|
return -1 < normalLoc;
|
1985
2102
|
}
|
1986
2103
|
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
return -1 < ambientLoc || -1 < specularLoc || -1 < emissiveLoc
|
1993
|
-
|
1994
|
-
}
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2104
|
+
/**
|
2105
|
+
*
|
2106
|
+
* @return
|
2107
|
+
*/
|
2108
|
+
protected boolean accessLightAttribs() {
|
2109
|
+
return -1 < ambientLoc || -1 < specularLoc || -1 < emissiveLoc
|
2110
|
+
|| -1 < shininessLoc;
|
2111
|
+
}
|
2112
|
+
|
2113
|
+
/**
|
2114
|
+
*
|
2115
|
+
* @param vboId
|
2116
|
+
* @param size
|
2117
|
+
* @param type
|
2118
|
+
* @param stride
|
2119
|
+
* @param offset
|
2120
|
+
*/
|
2121
|
+
protected void setVertexAttribute(int vboId, int size, int type,
|
2122
|
+
int stride, int offset) {
|
2006
2123
|
setAttributeVBO(vertexLoc, vboId, size, type, false, stride, offset);
|
2007
2124
|
}
|
2008
2125
|
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2126
|
+
/**
|
2127
|
+
*
|
2128
|
+
* @param vboId
|
2129
|
+
* @param size
|
2130
|
+
* @param type
|
2131
|
+
* @param stride
|
2132
|
+
* @param offset
|
2133
|
+
*/
|
2134
|
+
protected void setColorAttribute(int vboId, int size, int type,
|
2135
|
+
int stride, int offset) {
|
2019
2136
|
setAttributeVBO(colorLoc, vboId, size, type, true, stride, offset);
|
2020
2137
|
}
|
2021
2138
|
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2139
|
+
/**
|
2140
|
+
*
|
2141
|
+
* @param vboId
|
2142
|
+
* @param size
|
2143
|
+
* @param type
|
2144
|
+
* @param stride
|
2145
|
+
* @param offset
|
2146
|
+
*/
|
2147
|
+
protected void setNormalAttribute(int vboId, int size, int type,
|
2148
|
+
int stride, int offset) {
|
2032
2149
|
setAttributeVBO(normalLoc, vboId, size, type, false, stride, offset);
|
2033
2150
|
}
|
2034
2151
|
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2152
|
+
/**
|
2153
|
+
*
|
2154
|
+
* @param vboId
|
2155
|
+
* @param size
|
2156
|
+
* @param type
|
2157
|
+
* @param stride
|
2158
|
+
* @param offset
|
2159
|
+
*/
|
2160
|
+
protected void setTexcoordAttribute(int vboId, int size, int type,
|
2161
|
+
int stride, int offset) {
|
2045
2162
|
setAttributeVBO(texCoordLoc, vboId, size, type, false, stride, offset);
|
2046
2163
|
}
|
2047
2164
|
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2165
|
+
/**
|
2166
|
+
*
|
2167
|
+
* @param vboId
|
2168
|
+
* @param size
|
2169
|
+
* @param type
|
2170
|
+
* @param stride
|
2171
|
+
* @param offset
|
2172
|
+
*/
|
2173
|
+
protected void setAmbientAttribute(int vboId, int size, int type,
|
2174
|
+
int stride, int offset) {
|
2058
2175
|
setAttributeVBO(ambientLoc, vboId, size, type, true, stride, offset);
|
2059
2176
|
}
|
2060
2177
|
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2178
|
+
/**
|
2179
|
+
*
|
2180
|
+
* @param vboId
|
2181
|
+
* @param size
|
2182
|
+
* @param type
|
2183
|
+
* @param stride
|
2184
|
+
* @param offset
|
2185
|
+
*/
|
2186
|
+
protected void setSpecularAttribute(int vboId, int size, int type,
|
2187
|
+
int stride, int offset) {
|
2071
2188
|
setAttributeVBO(specularLoc, vboId, size, type, true, stride, offset);
|
2072
2189
|
}
|
2073
2190
|
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2191
|
+
/**
|
2192
|
+
*
|
2193
|
+
* @param vboId
|
2194
|
+
* @param size
|
2195
|
+
* @param type
|
2196
|
+
* @param stride
|
2197
|
+
* @param offset
|
2198
|
+
*/
|
2199
|
+
protected void setEmissiveAttribute(int vboId, int size, int type,
|
2200
|
+
int stride, int offset) {
|
2084
2201
|
setAttributeVBO(emissiveLoc, vboId, size, type, true, stride, offset);
|
2085
2202
|
}
|
2086
2203
|
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2204
|
+
/**
|
2205
|
+
*
|
2206
|
+
* @param vboId
|
2207
|
+
* @param size
|
2208
|
+
* @param type
|
2209
|
+
* @param stride
|
2210
|
+
* @param offset
|
2211
|
+
*/
|
2212
|
+
protected void setShininessAttribute(int vboId, int size, int type,
|
2213
|
+
int stride, int offset) {
|
2097
2214
|
setAttributeVBO(shininessLoc, vboId, size, type, false, stride, offset);
|
2098
2215
|
}
|
2099
2216
|
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2217
|
+
/**
|
2218
|
+
*
|
2219
|
+
* @param vboId
|
2220
|
+
* @param size
|
2221
|
+
* @param type
|
2222
|
+
* @param stride
|
2223
|
+
* @param offset
|
2224
|
+
*/
|
2225
|
+
protected void setLineAttribute(int vboId, int size, int type,
|
2226
|
+
int stride, int offset) {
|
2110
2227
|
setAttributeVBO(directionLoc, vboId, size, type, false, stride, offset);
|
2111
2228
|
}
|
2112
2229
|
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2230
|
+
/**
|
2231
|
+
*
|
2232
|
+
* @param vboId
|
2233
|
+
* @param size
|
2234
|
+
* @param type
|
2235
|
+
* @param stride
|
2236
|
+
* @param offset
|
2237
|
+
*/
|
2238
|
+
protected void setPointAttribute(int vboId, int size, int type,
|
2239
|
+
int stride, int offset) {
|
2123
2240
|
setAttributeVBO(offsetLoc, vboId, size, type, false, stride, offset);
|
2124
2241
|
}
|
2125
2242
|
|
2126
|
-
|
2127
2243
|
// ***************************************************************************
|
2128
2244
|
//
|
2129
2245
|
// Class to store a user-specified value for a uniform parameter
|
2130
2246
|
// in the shader
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
*/
|
2247
|
+
/**
|
2248
|
+
*
|
2249
|
+
*/
|
2135
2250
|
protected static class UniformValue {
|
2136
|
-
|
2137
|
-
static final int
|
2138
|
-
static final int
|
2139
|
-
static final int
|
2140
|
-
static final int
|
2141
|
-
static final int
|
2142
|
-
static final int
|
2143
|
-
static final int
|
2144
|
-
static final int
|
2145
|
-
static final int
|
2146
|
-
static final int
|
2147
|
-
static final int
|
2251
|
+
|
2252
|
+
static final int INT1 = 0;
|
2253
|
+
static final int INT2 = 1;
|
2254
|
+
static final int INT3 = 2;
|
2255
|
+
static final int INT4 = 3;
|
2256
|
+
static final int FLOAT1 = 4;
|
2257
|
+
static final int FLOAT2 = 5;
|
2258
|
+
static final int FLOAT3 = 6;
|
2259
|
+
static final int FLOAT4 = 7;
|
2260
|
+
static final int INT1VEC = 8;
|
2261
|
+
static final int INT2VEC = 9;
|
2262
|
+
static final int INT3VEC = 10;
|
2263
|
+
static final int INT4VEC = 11;
|
2148
2264
|
static final int FLOAT1VEC = 12;
|
2149
2265
|
static final int FLOAT2VEC = 13;
|
2150
2266
|
static final int FLOAT3VEC = 14;
|
2151
2267
|
static final int FLOAT4VEC = 15;
|
2152
|
-
static final int MAT2
|
2153
|
-
static final int MAT3
|
2154
|
-
static final int MAT4
|
2268
|
+
static final int MAT2 = 16;
|
2269
|
+
static final int MAT3 = 17;
|
2270
|
+
static final int MAT4 = 18;
|
2155
2271
|
static final int SAMPLER2D = 19;
|
2156
2272
|
|
2157
2273
|
int type;
|