propane 3.4.0-java → 3.7.0.pre-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -2
- data/.mvn/wrapper/MavenWrapperDownloader.java +2 -2
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/.travis.yml +2 -2
- data/CHANGELOG.md +12 -0
- data/Gemfile +2 -0
- data/README.md +17 -8
- data/Rakefile +10 -11
- data/bin/propane +3 -1
- data/lib/propane.rb +6 -4
- data/lib/propane/app.rb +20 -10
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +23 -24
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +14 -6
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +28 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +6 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +7 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +4 -1
- data/pom.rb +37 -36
- data/pom.xml +7 -7
- data/propane.gemspec +16 -12
- data/src/main/java/monkstone/ColorUtil.java +13 -1
- data/src/main/java/monkstone/MathToolModule.java +253 -203
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +2 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- 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/SimpleVerticalSlider.java +1 -1
- 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/slider/WheelHandler.java +7 -6
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +3 -3
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
- data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +11 -27
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +781 -285
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -52
- data/src/main/java/processing/awt/PSurfaceAWT.java +309 -209
- data/src/main/java/processing/awt/ShimAWT.java +581 -0
- data/src/main/java/processing/core/PApplet.java +4510 -4503
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +914 -880
- data/src/main/java/processing/core/PGraphics.java +193 -177
- data/src/main/java/processing/core/PImage.java +611 -309
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +478 -415
- data/src/main/java/processing/core/PMatrix3D.java +762 -735
- data/src/main/java/processing/core/PShape.java +2888 -2652
- data/src/main/java/processing/core/PShapeOBJ.java +97 -92
- data/src/main/java/processing/core/PShapeSVG.java +1705 -1490
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +139 -97
- data/src/main/java/processing/core/PSurfaceNone.java +296 -218
- data/src/main/java/processing/core/PVector.java +997 -965
- data/src/main/java/processing/core/ThinkDifferent.java +15 -13
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3690 -3510
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +957 -883
- data/src/main/java/processing/dxf/RawDXF.java +404 -0
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +88 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
- data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
- data/src/main/java/processing/net/Client.java +744 -0
- data/src/main/java/processing/net/Server.java +388 -0
- data/src/main/java/processing/opengl/FontTexture.java +289 -270
- data/src/main/java/processing/opengl/FrameBuffer.java +386 -364
- data/src/main/java/processing/opengl/LinePath.java +547 -500
- data/src/main/java/processing/opengl/LineStroker.java +588 -581
- data/src/main/java/processing/opengl/PGL.java +3047 -2914
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
- data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
- data/src/main/java/processing/opengl/PShader.java +1266 -1257
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
- data/src/main/java/processing/opengl/Texture.java +1492 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +33 -62
- metadata +56 -48
- data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
- data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
- data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
- data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
- data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
- data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
- data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
- data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
- data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
- data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
- data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
- data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
- data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
- data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
- data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
- data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
- data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
- data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
- data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
- data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -1,3 +1,5 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
1
3
|
/*
|
2
4
|
Part of the Processing project - http://processing.org
|
3
5
|
|
@@ -18,7 +20,8 @@
|
|
18
20
|
Public License along with this library; if not, write to the
|
19
21
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
20
22
|
Boston, MA 02111-1307 USA
|
21
|
-
|
23
|
+
*/
|
24
|
+
|
22
25
|
package processing.opengl;
|
23
26
|
|
24
27
|
import java.awt.Font;
|
@@ -51,1875 +54,1955 @@ import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
|
|
51
54
|
import com.jogamp.opengl.glu.GLU;
|
52
55
|
import com.jogamp.opengl.glu.GLUtessellator;
|
53
56
|
import com.jogamp.opengl.glu.GLUtessellatorCallbackAdapter;
|
57
|
+
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
|
54
58
|
|
59
|
+
import processing.awt.PImageAWT;
|
55
60
|
import processing.core.PApplet;
|
56
61
|
import processing.core.PGraphics;
|
62
|
+
import processing.core.PImage;
|
57
63
|
import processing.core.PMatrix3D;
|
58
64
|
import processing.core.PSurface;
|
59
65
|
|
66
|
+
|
60
67
|
public class PJOGL extends PGL {
|
61
|
-
|
62
|
-
|
63
|
-
public static int profile = 2;
|
64
|
-
|
65
|
-
// User-provided icons to override defaults
|
66
|
-
protected static String[] icons = null;
|
67
|
-
|
68
|
-
// The two windowing toolkits available to use in JOGL:
|
69
|
-
public static final int AWT = 0; // http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing
|
70
|
-
public static final int NEWT = 1; // http://jogamp.org/jogl/doc/NEWT-Overview.html
|
71
|
-
|
72
|
-
// ........................................................
|
73
|
-
// Public members to access the underlying GL objects and context
|
74
|
-
/**
|
75
|
-
* Basic GL functionality, common to all profiles
|
76
|
-
*/
|
77
|
-
public GL gl;
|
78
|
-
|
79
|
-
/**
|
80
|
-
* GLU interface *
|
81
|
-
*/
|
82
|
-
public GLU glu;
|
83
|
-
|
84
|
-
/**
|
85
|
-
* The rendering context (holds rendering state info)
|
86
|
-
*/
|
87
|
-
public GLContext context;
|
88
|
-
|
89
|
-
// ........................................................
|
90
|
-
// Additional parameters
|
91
|
-
/**
|
92
|
-
* Time that the Processing's animation thread will wait for JOGL's
|
93
|
-
* rendering thread to be done with a single frame.
|
94
|
-
*/
|
95
|
-
protected static int DRAW_TIMEOUT_MILLIS = 500;
|
96
|
-
|
97
|
-
// ........................................................
|
98
|
-
// Protected JOGL-specific objects needed to access the GL profiles
|
99
|
-
/**
|
100
|
-
* The capabilities of the OpenGL rendering surface
|
101
|
-
*/
|
102
|
-
protected GLCapabilitiesImmutable capabilities;
|
103
|
-
|
104
|
-
/**
|
105
|
-
* The rendering surface
|
106
|
-
*/
|
107
|
-
protected GLDrawable drawable;
|
108
|
-
|
109
|
-
/**
|
110
|
-
* GLES2 functionality (shaders, etc)
|
111
|
-
*/
|
112
|
-
protected GL2ES2 gl2;
|
113
|
-
|
114
|
-
/**
|
115
|
-
* GL3 interface
|
116
|
-
*/
|
117
|
-
protected GL2GL3 gl3;
|
118
|
-
|
119
|
-
/**
|
120
|
-
* GL2 desktop functionality (blit framebuffer, map buffer range,
|
121
|
-
* multisampled renderbuffers)
|
122
|
-
*/
|
123
|
-
protected GL2 gl2x;
|
124
|
-
|
125
|
-
/**
|
126
|
-
* GL3ES3 interface
|
127
|
-
*/
|
128
|
-
protected GL3ES3 gl3es3;
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Stores exceptions that ocurred during drawing
|
132
|
-
*/
|
133
|
-
protected Exception drawException;
|
134
|
-
|
135
|
-
// ........................................................
|
136
|
-
// Utility arrays to copy projection/modelview matrices to GL
|
137
|
-
protected float[] projMatrix;
|
138
|
-
protected float[] mvMatrix;
|
139
|
-
|
140
|
-
// ........................................................
|
141
|
-
// Static initialization for some parameters that need to be different for
|
142
|
-
// JOGL
|
143
|
-
static {
|
144
|
-
MIN_DIRECT_BUFFER_SIZE = 2;
|
145
|
-
INDEX_TYPE = GL.GL_UNSIGNED_SHORT;
|
146
|
-
}
|
68
|
+
// OpenGL profile to use (2, 3 or 4)
|
69
|
+
public static int profile = 2;
|
147
70
|
|
148
|
-
|
149
|
-
|
150
|
-
public PJOGL(PGraphicsOpenGL pg) {
|
151
|
-
super(pg);
|
152
|
-
glu = new GLU();
|
153
|
-
}
|
71
|
+
// User-provided icons to override defaults
|
72
|
+
protected static String[] icons = null;
|
154
73
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
}
|
74
|
+
// The two windowing toolkits available to use in JOGL:
|
75
|
+
public static final int AWT = 0; // http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing
|
76
|
+
public static final int NEWT = 1; // http://jogamp.org/jogl/doc/NEWT-Overview.html
|
159
77
|
|
160
|
-
|
161
|
-
protected void setFrameRate(float fps) {
|
162
|
-
}
|
78
|
+
// ........................................................
|
163
79
|
|
164
|
-
|
165
|
-
protected void initSurface(int antialias) {
|
166
|
-
}
|
80
|
+
// Public members to access the underlying GL objects and context
|
167
81
|
|
168
|
-
|
169
|
-
|
170
|
-
}
|
82
|
+
/** Basic GL functionality, common to all profiles */
|
83
|
+
public GL gl;
|
171
84
|
|
172
|
-
|
173
|
-
|
174
|
-
}
|
85
|
+
/** GLU interface **/
|
86
|
+
public GLU glu;
|
175
87
|
|
176
|
-
|
177
|
-
|
178
|
-
PApplet.arrayCopy(icons, PJOGL.icons);
|
179
|
-
}
|
88
|
+
/** The rendering context (holds rendering state info) */
|
89
|
+
public GLContext context;
|
180
90
|
|
181
|
-
|
182
|
-
// Public methods to get/set renderer's properties
|
183
|
-
public void setCaps(GLCapabilities caps) {
|
184
|
-
reqNumSamples = caps.getNumSamples();
|
185
|
-
capabilities = caps;
|
186
|
-
}
|
91
|
+
// ........................................................
|
187
92
|
|
188
|
-
|
189
|
-
return capabilities;
|
190
|
-
}
|
93
|
+
// Additional parameters
|
191
94
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
gl.setSwapInterval(0);
|
197
|
-
} else if (30 < fps) {
|
198
|
-
gl.setSwapInterval(1);
|
199
|
-
} else {
|
200
|
-
gl.setSwapInterval(2);
|
201
|
-
}
|
202
|
-
targetFps = currentFps = fps;
|
203
|
-
setFps = true;
|
204
|
-
}
|
205
|
-
}
|
95
|
+
/** Time that the Processing's animation thread will wait for JOGL's rendering
|
96
|
+
* thread to be done with a single frame.
|
97
|
+
*/
|
98
|
+
protected static int DRAW_TIMEOUT_MILLIS = 500;
|
206
99
|
|
207
|
-
|
208
|
-
protected int getDepthBits() {
|
209
|
-
return capabilities.getDepthBits();
|
210
|
-
}
|
100
|
+
// ........................................................
|
211
101
|
|
212
|
-
|
213
|
-
protected int getStencilBits() {
|
214
|
-
return capabilities.getStencilBits();
|
215
|
-
}
|
102
|
+
// Protected JOGL-specific objects needed to access the GL profiles
|
216
103
|
|
217
|
-
|
218
|
-
|
219
|
-
PSurface surf = sketch.getSurface();
|
220
|
-
if (surf == null) {
|
221
|
-
return graphics.pixelDensity;
|
222
|
-
} else if (surf instanceof PSurfaceJOGL) {
|
223
|
-
return ((PSurfaceJOGL) surf).getPixelScale();
|
224
|
-
} else {
|
225
|
-
throw new RuntimeException("Renderer cannot find a JOGL surface");
|
226
|
-
}
|
227
|
-
}
|
104
|
+
/** The capabilities of the OpenGL rendering surface */
|
105
|
+
protected GLCapabilitiesImmutable capabilities;
|
228
106
|
|
229
|
-
|
230
|
-
|
231
|
-
PJOGL pjogl = (PJOGL) pgl;
|
232
|
-
|
233
|
-
this.drawable = pjogl.drawable;
|
234
|
-
this.context = pjogl.context;
|
235
|
-
this.glContext = pjogl.glContext;
|
236
|
-
setThread(pjogl.glThread);
|
237
|
-
|
238
|
-
this.gl = pjogl.gl;
|
239
|
-
this.gl2 = pjogl.gl2;
|
240
|
-
this.gl2x = pjogl.gl2x;
|
241
|
-
this.gl3 = pjogl.gl3;
|
242
|
-
this.gl3es3 = pjogl.gl3es3;
|
243
|
-
}
|
107
|
+
/** The rendering surface */
|
108
|
+
protected GLDrawable drawable;
|
244
109
|
|
245
|
-
|
246
|
-
|
247
|
-
glContext = context.hashCode();
|
248
|
-
setThread(Thread.currentThread());
|
249
|
-
|
250
|
-
gl = context.getGL();
|
251
|
-
gl2 = gl.getGL2ES2();
|
252
|
-
try {
|
253
|
-
gl2x = gl.getGL2();
|
254
|
-
} catch (com.jogamp.opengl.GLException e) {
|
255
|
-
gl2x = null;
|
256
|
-
}
|
257
|
-
try {
|
258
|
-
gl3 = gl.getGL2GL3();
|
259
|
-
} catch (com.jogamp.opengl.GLException e) {
|
260
|
-
gl3 = null;
|
261
|
-
}
|
262
|
-
try {
|
263
|
-
gl3es3 = gl.getGL3ES3();
|
264
|
-
} catch (com.jogamp.opengl.GLException e) {
|
265
|
-
gl3es3 = null;
|
266
|
-
}
|
267
|
-
}
|
268
|
-
|
269
|
-
@Override
|
270
|
-
protected boolean canDraw() {
|
271
|
-
return true;
|
272
|
-
}
|
273
|
-
|
274
|
-
@Override
|
275
|
-
protected void requestFocus() {
|
276
|
-
}
|
277
|
-
|
278
|
-
@Override
|
279
|
-
protected void requestDraw() {
|
280
|
-
}
|
281
|
-
|
282
|
-
@Override
|
283
|
-
protected void swapBuffers() {
|
284
|
-
PSurfaceJOGL surf = (PSurfaceJOGL) sketch.getSurface();
|
285
|
-
surf.window.swapBuffers();
|
286
|
-
}
|
110
|
+
/** GLES2 functionality (shaders, etc) */
|
111
|
+
protected GL2ES2 gl2;
|
287
112
|
|
288
|
-
|
289
|
-
|
290
|
-
if (0 < sketch.frameCount) {
|
291
|
-
if (isES()) {
|
292
|
-
initFBOLayerES();
|
293
|
-
} else {
|
294
|
-
initFBOLayerGL();
|
295
|
-
}
|
296
|
-
}
|
297
|
-
}
|
113
|
+
/** GL3 interface */
|
114
|
+
protected GL2GL3 gl3;
|
298
115
|
|
299
|
-
|
300
|
-
|
116
|
+
/** GL2 desktop functionality (blit framebuffer, map buffer range,
|
117
|
+
* multisampled renderbuffers) */
|
118
|
+
protected GL2 gl2x;
|
301
119
|
|
302
|
-
|
303
|
-
|
304
|
-
}
|
305
|
-
readPixelsImpl(0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
|
306
|
-
bindTexture(TEXTURE_2D, glColorTex.get(frontTex));
|
307
|
-
texSubImage2D(TEXTURE_2D, 0, 0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
|
120
|
+
/** GL3ES3 interface */
|
121
|
+
protected GL3ES3 gl3es3;
|
308
122
|
|
309
|
-
|
310
|
-
|
123
|
+
/** Stores exceptions that ocurred during drawing */
|
124
|
+
protected Exception drawException;
|
311
125
|
|
312
|
-
|
313
|
-
bindFramebufferImpl(FRAMEBUFFER, 0);
|
314
|
-
}
|
126
|
+
// ........................................................
|
315
127
|
|
316
|
-
|
317
|
-
// Copy the contents of the front and back screen buffers to the textures
|
318
|
-
// of the FBO, so they are properly initialized. Note that the front buffer
|
319
|
-
// of the default framebuffer (the screen) contains the previous frame:
|
320
|
-
// https://www.opengl.org/wiki/Default_Framebuffer
|
321
|
-
// so it is copied to the front texture of the FBO layer:
|
322
|
-
if (pclearColor || 0 < pgeomCount || !sketch.isLooping()) {
|
323
|
-
if (hasReadBuffer()) {
|
324
|
-
readBuffer(FRONT);
|
325
|
-
}
|
326
|
-
} else {
|
327
|
-
// ...except when the previous frame has not been cleared and nothing was
|
328
|
-
// rendered while looping. In this case the back buffer, which holds the
|
329
|
-
// initial state of the previous frame, still contains the most up-to-date
|
330
|
-
// screen state.
|
331
|
-
readBuffer(BACK);
|
332
|
-
}
|
333
|
-
bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0));
|
334
|
-
framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0,
|
335
|
-
TEXTURE_2D, glColorTex.get(frontTex), 0);
|
336
|
-
if (hasDrawBuffer()) {
|
337
|
-
drawBuffer(COLOR_ATTACHMENT0);
|
338
|
-
}
|
339
|
-
blitFramebuffer(0, 0, fboWidth, fboHeight,
|
340
|
-
0, 0, fboWidth, fboHeight,
|
341
|
-
COLOR_BUFFER_BIT, NEAREST);
|
342
|
-
|
343
|
-
readBuffer(BACK);
|
344
|
-
bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0));
|
345
|
-
framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0,
|
346
|
-
TEXTURE_2D, glColorTex.get(backTex), 0);
|
347
|
-
drawBuffer(COLOR_ATTACHMENT0);
|
348
|
-
blitFramebuffer(0, 0, fboWidth, fboHeight,
|
349
|
-
0, 0, fboWidth, fboHeight,
|
350
|
-
COLOR_BUFFER_BIT, NEAREST);
|
351
|
-
|
352
|
-
bindFramebufferImpl(FRAMEBUFFER, 0);
|
353
|
-
}
|
128
|
+
// Utility arrays to copy projection/modelview matrices to GL
|
354
129
|
|
355
|
-
|
356
|
-
|
357
|
-
PMatrix3D proj = graphics.projection;
|
358
|
-
PMatrix3D mdl = graphics.modelview;
|
359
|
-
if (gl2x != null) {
|
360
|
-
if (projMatrix == null) {
|
361
|
-
projMatrix = new float[16];
|
362
|
-
}
|
363
|
-
gl2x.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
|
364
|
-
projMatrix[0] = proj.m00;
|
365
|
-
projMatrix[1] = proj.m10;
|
366
|
-
projMatrix[2] = proj.m20;
|
367
|
-
projMatrix[3] = proj.m30;
|
368
|
-
projMatrix[4] = proj.m01;
|
369
|
-
projMatrix[5] = proj.m11;
|
370
|
-
projMatrix[6] = proj.m21;
|
371
|
-
projMatrix[7] = proj.m31;
|
372
|
-
projMatrix[8] = proj.m02;
|
373
|
-
projMatrix[9] = proj.m12;
|
374
|
-
projMatrix[10] = proj.m22;
|
375
|
-
projMatrix[11] = proj.m32;
|
376
|
-
projMatrix[12] = proj.m03;
|
377
|
-
projMatrix[13] = proj.m13;
|
378
|
-
projMatrix[14] = proj.m23;
|
379
|
-
projMatrix[15] = proj.m33;
|
380
|
-
gl2x.glLoadMatrixf(projMatrix, 0);
|
381
|
-
|
382
|
-
if (mvMatrix == null) {
|
383
|
-
mvMatrix = new float[16];
|
384
|
-
}
|
385
|
-
gl2x.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
386
|
-
mvMatrix[0] = mdl.m00;
|
387
|
-
mvMatrix[1] = mdl.m10;
|
388
|
-
mvMatrix[2] = mdl.m20;
|
389
|
-
mvMatrix[3] = mdl.m30;
|
390
|
-
mvMatrix[4] = mdl.m01;
|
391
|
-
mvMatrix[5] = mdl.m11;
|
392
|
-
mvMatrix[6] = mdl.m21;
|
393
|
-
mvMatrix[7] = mdl.m31;
|
394
|
-
mvMatrix[8] = mdl.m02;
|
395
|
-
mvMatrix[9] = mdl.m12;
|
396
|
-
mvMatrix[10] = mdl.m22;
|
397
|
-
mvMatrix[11] = mdl.m32;
|
398
|
-
mvMatrix[12] = mdl.m03;
|
399
|
-
mvMatrix[13] = mdl.m13;
|
400
|
-
mvMatrix[14] = mdl.m23;
|
401
|
-
mvMatrix[15] = mdl.m33;
|
402
|
-
gl2x.glLoadMatrixf(mvMatrix, 0);
|
403
|
-
}
|
404
|
-
}
|
130
|
+
protected float[] projMatrix;
|
131
|
+
protected float[] mvMatrix;
|
405
132
|
|
406
|
-
|
407
|
-
protected boolean hasFBOs() {
|
408
|
-
if (context.hasBasicFBOSupport()) {
|
409
|
-
return true;
|
410
|
-
} else {
|
411
|
-
return super.hasFBOs();
|
412
|
-
}
|
413
|
-
}
|
133
|
+
// ........................................................
|
414
134
|
|
415
|
-
|
416
|
-
|
417
|
-
if (context.hasGLSL()) {
|
418
|
-
return true;
|
419
|
-
} else {
|
420
|
-
return super.hasShaders();
|
421
|
-
}
|
422
|
-
}
|
135
|
+
// Static initialization for some parameters that need to be different for
|
136
|
+
// JOGL
|
423
137
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
}
|
429
|
-
if (!hasShaders()) {
|
430
|
-
throw new RuntimeException(MISSING_GLSL_ERROR);
|
431
|
-
}
|
432
|
-
}
|
138
|
+
static {
|
139
|
+
MIN_DIRECT_BUFFER_SIZE = 2;
|
140
|
+
INDEX_TYPE = GL.GL_UNSIGNED_SHORT;
|
141
|
+
}
|
433
142
|
|
434
|
-
///////////////////////////////////////////////////////////
|
435
|
-
// Utility functions
|
436
|
-
@Override
|
437
|
-
protected void enableTexturing(int target) {
|
438
|
-
if (target == TEXTURE_2D) {
|
439
|
-
texturingTargets[0] = true;
|
440
|
-
} else if (target == TEXTURE_RECTANGLE) {
|
441
|
-
texturingTargets[1] = true;
|
442
|
-
}
|
443
|
-
}
|
444
143
|
|
445
|
-
|
446
|
-
protected void disableTexturing(int target) {
|
447
|
-
if (target == TEXTURE_2D) {
|
448
|
-
texturingTargets[0] = false;
|
449
|
-
} else if (target == TEXTURE_RECTANGLE) {
|
450
|
-
texturingTargets[1] = false;
|
451
|
-
}
|
452
|
-
}
|
144
|
+
///////////////////////////////////////////////////////////////
|
453
145
|
|
454
|
-
|
455
|
-
* Convenience method to get a legit FontMetrics object. Where possible,
|
456
|
-
* override this any renderer subclass so that you're not using what's
|
457
|
-
* returned by getDefaultToolkit() to get your metrics.
|
458
|
-
*/
|
459
|
-
@SuppressWarnings("deprecation")
|
460
|
-
private FontMetrics getFontMetrics(Font font) { // ignore
|
461
|
-
return Toolkit.getDefaultToolkit().getFontMetrics(font);
|
462
|
-
}
|
146
|
+
// Initialization, finalization
|
463
147
|
|
464
|
-
/**
|
465
|
-
* Convenience method to jump through some Java2D hoops and get an FRC.
|
466
|
-
*/
|
467
|
-
private FontRenderContext getFontRenderContext(Font font) { // ignore
|
468
|
-
return getFontMetrics(font).getFontRenderContext();
|
469
|
-
}
|
470
148
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
149
|
+
public PJOGL(PGraphicsOpenGL pg) {
|
150
|
+
super(pg);
|
151
|
+
glu = new GLU();
|
152
|
+
}
|
475
153
|
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
154
|
+
public PJOGL(PGraphicsOpenGL pg, PGL.RenderCallback callback) {
|
155
|
+
super(pg, callback);
|
156
|
+
glu = new GLU();
|
157
|
+
}
|
480
158
|
|
481
|
-
@Override
|
482
|
-
protected int getTextWidth(Object font, char[] buffer, int start, int stop) {
|
483
|
-
// maybe should use one of the newer/fancier functions for this?
|
484
|
-
int length = stop - start;
|
485
|
-
FontMetrics metrics = getFontMetrics((Font) font);
|
486
|
-
return metrics.charsWidth(buffer, start, length);
|
487
|
-
}
|
488
159
|
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
160
|
+
@Override
|
161
|
+
public Object getNative() {
|
162
|
+
return sketch.getSurface().getNative();
|
163
|
+
}
|
493
164
|
|
494
|
-
@Override
|
495
|
-
protected int getGLSLVersion() {
|
496
|
-
VersionNumber vn = context.getGLSLVersionNumber();
|
497
|
-
return vn.getMajor() * 100 + vn.getMinor();
|
498
|
-
}
|
499
165
|
|
500
|
-
|
501
|
-
|
502
|
-
VersionNumber vn = context.getGLSLVersionNumber();
|
503
|
-
if (context.isGLESProfile() && 1 < vn.getMajor()) {
|
504
|
-
return " es";
|
505
|
-
} else {
|
506
|
-
return "";
|
507
|
-
}
|
508
|
-
}
|
166
|
+
@Override
|
167
|
+
protected void setFrameRate(float fps) {}
|
509
168
|
|
510
|
-
@Override
|
511
|
-
protected String[] loadVertexShader(String filename) {
|
512
|
-
return loadVertexShader(filename, getGLSLVersion(), getGLSLVersionSuffix());
|
513
|
-
}
|
514
169
|
|
515
|
-
|
516
|
-
|
517
|
-
return loadFragmentShader(filename, getGLSLVersion(), getGLSLVersionSuffix());
|
518
|
-
}
|
170
|
+
@Override
|
171
|
+
protected void initSurface(int antialias) {}
|
519
172
|
|
520
|
-
@Override
|
521
|
-
protected String[] loadVertexShader(URL url) {
|
522
|
-
return loadVertexShader(url, getGLSLVersion(), getGLSLVersionSuffix());
|
523
|
-
}
|
524
173
|
|
525
|
-
|
526
|
-
|
527
|
-
return loadFragmentShader(url, getGLSLVersion(), getGLSLVersionSuffix());
|
528
|
-
}
|
174
|
+
@Override
|
175
|
+
protected void reinitSurface() {}
|
529
176
|
|
530
|
-
@Override
|
531
|
-
protected String[] loadFragmentShader(String filename, int version, String versionSuffix) {
|
532
|
-
String[] fragSrc0 = sketch.loadStrings(filename);
|
533
|
-
return preprocessFragmentSource(fragSrc0, version, versionSuffix);
|
534
|
-
}
|
535
177
|
|
536
|
-
|
537
|
-
|
538
|
-
String[] vertSrc0 = sketch.loadStrings(filename);
|
539
|
-
return preprocessVertexSource(vertSrc0, version, versionSuffix);
|
540
|
-
}
|
178
|
+
@Override
|
179
|
+
protected void registerListeners() {}
|
541
180
|
|
542
|
-
@Override
|
543
|
-
protected String[] loadFragmentShader(URL url, int version, String versionSuffix) {
|
544
|
-
try {
|
545
|
-
String[] fragSrc0 = PApplet.loadStrings(url.openStream());
|
546
|
-
return preprocessFragmentSource(fragSrc0, version, versionSuffix);
|
547
|
-
} catch (IOException e) {
|
548
|
-
PGraphics.showException("Cannot load fragment shader " + url.getFile());
|
549
|
-
}
|
550
|
-
return null;
|
551
|
-
}
|
552
181
|
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
} catch (IOException e) {
|
559
|
-
PGraphics.showException("Cannot load vertex shader " + url.getFile());
|
560
|
-
}
|
561
|
-
return null;
|
562
|
-
}
|
182
|
+
@Override
|
183
|
+
protected PImage screenshot() {
|
184
|
+
AWTGLReadBufferUtil util = new AWTGLReadBufferUtil(capabilities.getGLProfile(), false);
|
185
|
+
return new PImageAWT(util.readPixelsToBufferedImage(gl, true));
|
186
|
+
}
|
563
187
|
|
564
|
-
///////////////////////////////////////////////////////////
|
565
|
-
// Tessellator
|
566
|
-
@Override
|
567
|
-
protected Tessellator createTessellator(TessellatorCallback callback) {
|
568
|
-
return new Tessellator(callback);
|
569
|
-
}
|
570
188
|
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
protected GLUCallback gluCallback;
|
576
|
-
|
577
|
-
public Tessellator(TessellatorCallback callback) {
|
578
|
-
this.callback = callback;
|
579
|
-
tess = GLU.gluNewTess();
|
580
|
-
gluCallback = new GLUCallback();
|
581
|
-
|
582
|
-
GLU.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, gluCallback);
|
583
|
-
GLU.gluTessCallback(tess, GLU.GLU_TESS_END, gluCallback);
|
584
|
-
GLU.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, gluCallback);
|
585
|
-
GLU.gluTessCallback(tess, GLU.GLU_TESS_COMBINE, gluCallback);
|
586
|
-
GLU.gluTessCallback(tess, GLU.GLU_TESS_ERROR, gluCallback);
|
587
|
-
}
|
588
|
-
|
589
|
-
@Override
|
590
|
-
public void setCallback(int flag) {
|
591
|
-
GLU.gluTessCallback(tess, flag, gluCallback);
|
592
|
-
}
|
593
|
-
|
594
|
-
@Override
|
595
|
-
public void setWindingRule(int rule) {
|
596
|
-
setProperty(GLU.GLU_TESS_WINDING_RULE, rule);
|
597
|
-
}
|
598
|
-
|
599
|
-
public void setProperty(int property, int value) {
|
600
|
-
GLU.gluTessProperty(tess, property, value);
|
601
|
-
}
|
602
|
-
|
603
|
-
@Override
|
604
|
-
public void beginPolygon() {
|
605
|
-
beginPolygon(null);
|
606
|
-
}
|
607
|
-
|
608
|
-
@Override
|
609
|
-
public void beginPolygon(Object data) {
|
610
|
-
GLU.gluTessBeginPolygon(tess, data);
|
611
|
-
}
|
612
|
-
|
613
|
-
@Override
|
614
|
-
public void endPolygon() {
|
615
|
-
GLU.gluTessEndPolygon(tess);
|
616
|
-
}
|
617
|
-
|
618
|
-
@Override
|
619
|
-
public void beginContour() {
|
620
|
-
GLU.gluTessBeginContour(tess);
|
621
|
-
}
|
622
|
-
|
623
|
-
@Override
|
624
|
-
public void endContour() {
|
625
|
-
GLU.gluTessEndContour(tess);
|
626
|
-
}
|
627
|
-
|
628
|
-
@Override
|
629
|
-
public void addVertex(double[] v) {
|
630
|
-
addVertex(v, 0, v);
|
631
|
-
}
|
632
|
-
|
633
|
-
@Override
|
634
|
-
public void addVertex(double[] v, int n, Object data) {
|
635
|
-
GLU.gluTessVertex(tess, v, n, data);
|
636
|
-
}
|
637
|
-
|
638
|
-
protected class GLUCallback extends GLUtessellatorCallbackAdapter {
|
639
|
-
|
640
|
-
@Override
|
641
|
-
public void begin(int type) {
|
642
|
-
callback.begin(type);
|
643
|
-
}
|
644
|
-
|
645
|
-
@Override
|
646
|
-
public void end() {
|
647
|
-
callback.end();
|
648
|
-
}
|
649
|
-
|
650
|
-
@Override
|
651
|
-
public void vertex(Object data) {
|
652
|
-
callback.vertex(data);
|
653
|
-
}
|
654
|
-
|
655
|
-
@Override
|
656
|
-
public void combine(double[] coords, Object[] data,
|
657
|
-
float[] weight, Object[] outData) {
|
658
|
-
callback.combine(coords, data, weight, outData);
|
659
|
-
}
|
660
|
-
|
661
|
-
@Override
|
662
|
-
public void error(int errnum) {
|
663
|
-
callback.error(errnum);
|
664
|
-
}
|
665
|
-
}
|
666
|
-
}
|
189
|
+
static public void setIcon(String... icons) {
|
190
|
+
PJOGL.icons = new String[icons.length];
|
191
|
+
PApplet.arrayCopy(icons, PJOGL.icons);
|
192
|
+
}
|
667
193
|
|
668
|
-
@Override
|
669
|
-
protected String tessError(int err) {
|
670
|
-
return glu.gluErrorString(err);
|
671
|
-
}
|
672
194
|
|
673
|
-
|
674
|
-
// Font outline
|
675
|
-
static {
|
676
|
-
SHAPE_TEXT_SUPPORTED = true;
|
677
|
-
SEG_MOVETO = PathIterator.SEG_MOVETO;
|
678
|
-
SEG_LINETO = PathIterator.SEG_LINETO;
|
679
|
-
SEG_QUADTO = PathIterator.SEG_QUADTO;
|
680
|
-
SEG_CUBICTO = PathIterator.SEG_CUBICTO;
|
681
|
-
SEG_CLOSE = PathIterator.SEG_CLOSE;
|
682
|
-
}
|
195
|
+
///////////////////////////////////////////////////////////////
|
683
196
|
|
684
|
-
|
685
|
-
protected FontOutline createFontOutline(char ch, Object font) {
|
686
|
-
return new FontOutline(ch, (Font) font);
|
687
|
-
}
|
197
|
+
// Public methods to get/set renderer's properties
|
688
198
|
|
689
|
-
protected class FontOutline implements PGL.FontOutline {
|
690
199
|
|
691
|
-
|
200
|
+
public void setCaps(GLCapabilities caps) {
|
201
|
+
reqNumSamples = caps.getNumSamples();
|
202
|
+
capabilities = caps;
|
203
|
+
}
|
692
204
|
|
693
|
-
public FontOutline(char ch, Font font) {
|
694
|
-
char textArray[] = new char[]{ch};
|
695
|
-
FontRenderContext frc = getFontRenderContext(font);
|
696
|
-
GlyphVector gv = font.createGlyphVector(frc, textArray);
|
697
|
-
Shape shp = gv.getOutline();
|
698
|
-
iter = shp.getPathIterator(null);
|
699
|
-
}
|
700
205
|
|
701
|
-
|
702
|
-
|
703
|
-
|
206
|
+
public GLCapabilitiesImmutable getCaps() {
|
207
|
+
return capabilities;
|
208
|
+
}
|
704
209
|
|
705
|
-
public int currentSegment(float coords[]) {
|
706
|
-
return iter.currentSegment(coords);
|
707
|
-
}
|
708
210
|
|
709
|
-
|
710
|
-
|
711
|
-
|
211
|
+
public void setFps(float fps) {
|
212
|
+
if (!setFps || targetFps != fps) {
|
213
|
+
if (60 < fps) {
|
214
|
+
// Disables v-sync
|
215
|
+
gl.setSwapInterval(0);
|
216
|
+
} else if (30 < fps) {
|
217
|
+
gl.setSwapInterval(1);
|
218
|
+
} else {
|
219
|
+
gl.setSwapInterval(2);
|
220
|
+
}
|
221
|
+
targetFps = currentFps = fps;
|
222
|
+
setFps = true;
|
712
223
|
}
|
224
|
+
}
|
713
225
|
|
714
|
-
///////////////////////////////////////////////////////////
|
715
|
-
// Constants
|
716
|
-
static {
|
717
|
-
FALSE = GL.GL_FALSE;
|
718
|
-
TRUE = GL.GL_TRUE;
|
719
|
-
|
720
|
-
INT = GL2ES2.GL_INT;
|
721
|
-
BYTE = GL.GL_BYTE;
|
722
|
-
SHORT = GL.GL_SHORT;
|
723
|
-
FLOAT = GL.GL_FLOAT;
|
724
|
-
BOOL = GL2ES2.GL_BOOL;
|
725
|
-
UNSIGNED_INT = GL.GL_UNSIGNED_INT;
|
726
|
-
UNSIGNED_BYTE = GL.GL_UNSIGNED_BYTE;
|
727
|
-
UNSIGNED_SHORT = GL.GL_UNSIGNED_SHORT;
|
728
|
-
|
729
|
-
RGB = GL.GL_RGB;
|
730
|
-
RGBA = GL.GL_RGBA;
|
731
|
-
ALPHA = GL.GL_ALPHA;
|
732
|
-
LUMINANCE = GL.GL_LUMINANCE;
|
733
|
-
LUMINANCE_ALPHA = GL.GL_LUMINANCE_ALPHA;
|
734
|
-
|
735
|
-
UNSIGNED_SHORT_5_6_5 = GL.GL_UNSIGNED_SHORT_5_6_5;
|
736
|
-
UNSIGNED_SHORT_4_4_4_4 = GL.GL_UNSIGNED_SHORT_4_4_4_4;
|
737
|
-
UNSIGNED_SHORT_5_5_5_1 = GL.GL_UNSIGNED_SHORT_5_5_5_1;
|
738
|
-
|
739
|
-
RGBA4 = GL.GL_RGBA4;
|
740
|
-
RGB5_A1 = GL.GL_RGB5_A1;
|
741
|
-
RGB565 = GL.GL_RGB565;
|
742
|
-
RGB8 = GL.GL_RGB8;
|
743
|
-
RGBA8 = GL.GL_RGBA8;
|
744
|
-
ALPHA8 = GL.GL_ALPHA8;
|
745
|
-
|
746
|
-
READ_ONLY = GL2ES3.GL_READ_ONLY;
|
747
|
-
WRITE_ONLY = GL.GL_WRITE_ONLY;
|
748
|
-
READ_WRITE = GL2ES3.GL_READ_WRITE;
|
749
|
-
|
750
|
-
TESS_WINDING_NONZERO = GLU.GLU_TESS_WINDING_NONZERO;
|
751
|
-
TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD;
|
752
|
-
TESS_EDGE_FLAG = GLU.GLU_TESS_EDGE_FLAG;
|
753
|
-
|
754
|
-
GENERATE_MIPMAP_HINT = GL.GL_GENERATE_MIPMAP_HINT;
|
755
|
-
FASTEST = GL.GL_FASTEST;
|
756
|
-
NICEST = GL.GL_NICEST;
|
757
|
-
DONT_CARE = GL.GL_DONT_CARE;
|
758
|
-
|
759
|
-
VENDOR = GL.GL_VENDOR;
|
760
|
-
RENDERER = GL.GL_RENDERER;
|
761
|
-
VERSION = GL.GL_VERSION;
|
762
|
-
EXTENSIONS = GL.GL_EXTENSIONS;
|
763
|
-
SHADING_LANGUAGE_VERSION = GL2ES2.GL_SHADING_LANGUAGE_VERSION;
|
764
|
-
|
765
|
-
MAX_SAMPLES = GL.GL_MAX_SAMPLES;
|
766
|
-
SAMPLES = GL.GL_SAMPLES;
|
767
|
-
|
768
|
-
ALIASED_LINE_WIDTH_RANGE = GL.GL_ALIASED_LINE_WIDTH_RANGE;
|
769
|
-
ALIASED_POINT_SIZE_RANGE = GL.GL_ALIASED_POINT_SIZE_RANGE;
|
770
|
-
|
771
|
-
DEPTH_BITS = GL.GL_DEPTH_BITS;
|
772
|
-
STENCIL_BITS = GL.GL_STENCIL_BITS;
|
773
|
-
|
774
|
-
CCW = GL.GL_CCW;
|
775
|
-
CW = GL.GL_CW;
|
776
|
-
|
777
|
-
VIEWPORT = GL.GL_VIEWPORT;
|
778
|
-
|
779
|
-
ARRAY_BUFFER = GL.GL_ARRAY_BUFFER;
|
780
|
-
ELEMENT_ARRAY_BUFFER = GL.GL_ELEMENT_ARRAY_BUFFER;
|
781
|
-
PIXEL_PACK_BUFFER = GL2ES3.GL_PIXEL_PACK_BUFFER;
|
782
|
-
|
783
|
-
MAX_VERTEX_ATTRIBS = GL2ES2.GL_MAX_VERTEX_ATTRIBS;
|
784
|
-
|
785
|
-
STATIC_DRAW = GL.GL_STATIC_DRAW;
|
786
|
-
DYNAMIC_DRAW = GL.GL_DYNAMIC_DRAW;
|
787
|
-
STREAM_DRAW = GL2ES2.GL_STREAM_DRAW;
|
788
|
-
STREAM_READ = GL2ES3.GL_STREAM_READ;
|
789
|
-
|
790
|
-
BUFFER_SIZE = GL.GL_BUFFER_SIZE;
|
791
|
-
BUFFER_USAGE = GL.GL_BUFFER_USAGE;
|
792
|
-
|
793
|
-
POINTS = GL.GL_POINTS;
|
794
|
-
LINE_STRIP = GL.GL_LINE_STRIP;
|
795
|
-
LINE_LOOP = GL.GL_LINE_LOOP;
|
796
|
-
LINES = GL.GL_LINES;
|
797
|
-
TRIANGLE_FAN = GL.GL_TRIANGLE_FAN;
|
798
|
-
TRIANGLE_STRIP = GL.GL_TRIANGLE_STRIP;
|
799
|
-
TRIANGLES = GL.GL_TRIANGLES;
|
800
|
-
|
801
|
-
CULL_FACE = GL.GL_CULL_FACE;
|
802
|
-
FRONT = GL.GL_FRONT;
|
803
|
-
BACK = GL.GL_BACK;
|
804
|
-
FRONT_AND_BACK = GL.GL_FRONT_AND_BACK;
|
805
|
-
|
806
|
-
POLYGON_OFFSET_FILL = GL.GL_POLYGON_OFFSET_FILL;
|
807
|
-
|
808
|
-
UNPACK_ALIGNMENT = GL.GL_UNPACK_ALIGNMENT;
|
809
|
-
PACK_ALIGNMENT = GL.GL_PACK_ALIGNMENT;
|
810
|
-
|
811
|
-
TEXTURE_2D = GL.GL_TEXTURE_2D;
|
812
|
-
TEXTURE_RECTANGLE = GL2GL3.GL_TEXTURE_RECTANGLE;
|
813
|
-
|
814
|
-
TEXTURE_BINDING_2D = GL.GL_TEXTURE_BINDING_2D;
|
815
|
-
TEXTURE_BINDING_RECTANGLE = GL2GL3.GL_TEXTURE_BINDING_RECTANGLE;
|
816
|
-
|
817
|
-
MAX_TEXTURE_SIZE = GL.GL_MAX_TEXTURE_SIZE;
|
818
|
-
TEXTURE_MAX_ANISOTROPY = GL.GL_TEXTURE_MAX_ANISOTROPY_EXT;
|
819
|
-
MAX_TEXTURE_MAX_ANISOTROPY = GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT;
|
820
|
-
|
821
|
-
MAX_VERTEX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS;
|
822
|
-
MAX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS;
|
823
|
-
MAX_COMBINED_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS;
|
824
|
-
|
825
|
-
NUM_COMPRESSED_TEXTURE_FORMATS = GL.GL_NUM_COMPRESSED_TEXTURE_FORMATS;
|
826
|
-
COMPRESSED_TEXTURE_FORMATS = GL.GL_COMPRESSED_TEXTURE_FORMATS;
|
827
|
-
|
828
|
-
NEAREST = GL.GL_NEAREST;
|
829
|
-
LINEAR = GL.GL_LINEAR;
|
830
|
-
LINEAR_MIPMAP_NEAREST = GL.GL_LINEAR_MIPMAP_NEAREST;
|
831
|
-
LINEAR_MIPMAP_LINEAR = GL.GL_LINEAR_MIPMAP_LINEAR;
|
832
|
-
|
833
|
-
CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE;
|
834
|
-
REPEAT = GL.GL_REPEAT;
|
835
|
-
|
836
|
-
TEXTURE0 = GL.GL_TEXTURE0;
|
837
|
-
TEXTURE1 = GL.GL_TEXTURE1;
|
838
|
-
TEXTURE2 = GL.GL_TEXTURE2;
|
839
|
-
TEXTURE3 = GL.GL_TEXTURE3;
|
840
|
-
TEXTURE_MIN_FILTER = GL.GL_TEXTURE_MIN_FILTER;
|
841
|
-
TEXTURE_MAG_FILTER = GL.GL_TEXTURE_MAG_FILTER;
|
842
|
-
TEXTURE_WRAP_S = GL.GL_TEXTURE_WRAP_S;
|
843
|
-
TEXTURE_WRAP_T = GL.GL_TEXTURE_WRAP_T;
|
844
|
-
TEXTURE_WRAP_R = GL2ES2.GL_TEXTURE_WRAP_R;
|
845
|
-
|
846
|
-
TEXTURE_CUBE_MAP = GL.GL_TEXTURE_CUBE_MAP;
|
847
|
-
TEXTURE_CUBE_MAP_POSITIVE_X = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
848
|
-
TEXTURE_CUBE_MAP_POSITIVE_Y = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
|
849
|
-
TEXTURE_CUBE_MAP_POSITIVE_Z = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
|
850
|
-
TEXTURE_CUBE_MAP_NEGATIVE_X = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
|
851
|
-
TEXTURE_CUBE_MAP_NEGATIVE_Y = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
|
852
|
-
TEXTURE_CUBE_MAP_NEGATIVE_Z = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
|
853
|
-
|
854
|
-
VERTEX_SHADER = GL2ES2.GL_VERTEX_SHADER;
|
855
|
-
FRAGMENT_SHADER = GL2ES2.GL_FRAGMENT_SHADER;
|
856
|
-
INFO_LOG_LENGTH = GL2ES2.GL_INFO_LOG_LENGTH;
|
857
|
-
SHADER_SOURCE_LENGTH = GL2ES2.GL_SHADER_SOURCE_LENGTH;
|
858
|
-
COMPILE_STATUS = GL2ES2.GL_COMPILE_STATUS;
|
859
|
-
LINK_STATUS = GL2ES2.GL_LINK_STATUS;
|
860
|
-
VALIDATE_STATUS = GL2ES2.GL_VALIDATE_STATUS;
|
861
|
-
SHADER_TYPE = GL2ES2.GL_SHADER_TYPE;
|
862
|
-
DELETE_STATUS = GL2ES2.GL_DELETE_STATUS;
|
863
|
-
|
864
|
-
FLOAT_VEC2 = GL2ES2.GL_FLOAT_VEC2;
|
865
|
-
FLOAT_VEC3 = GL2ES2.GL_FLOAT_VEC3;
|
866
|
-
FLOAT_VEC4 = GL2ES2.GL_FLOAT_VEC4;
|
867
|
-
FLOAT_MAT2 = GL2ES2.GL_FLOAT_MAT2;
|
868
|
-
FLOAT_MAT3 = GL2ES2.GL_FLOAT_MAT3;
|
869
|
-
FLOAT_MAT4 = GL2ES2.GL_FLOAT_MAT4;
|
870
|
-
INT_VEC2 = GL2ES2.GL_INT_VEC2;
|
871
|
-
INT_VEC3 = GL2ES2.GL_INT_VEC3;
|
872
|
-
INT_VEC4 = GL2ES2.GL_INT_VEC4;
|
873
|
-
BOOL_VEC2 = GL2ES2.GL_BOOL_VEC2;
|
874
|
-
BOOL_VEC3 = GL2ES2.GL_BOOL_VEC3;
|
875
|
-
BOOL_VEC4 = GL2ES2.GL_BOOL_VEC4;
|
876
|
-
SAMPLER_2D = GL2ES2.GL_SAMPLER_2D;
|
877
|
-
SAMPLER_CUBE = GL2ES2.GL_SAMPLER_CUBE;
|
878
|
-
|
879
|
-
LOW_FLOAT = GL2ES2.GL_LOW_FLOAT;
|
880
|
-
MEDIUM_FLOAT = GL2ES2.GL_MEDIUM_FLOAT;
|
881
|
-
HIGH_FLOAT = GL2ES2.GL_HIGH_FLOAT;
|
882
|
-
LOW_INT = GL2ES2.GL_LOW_INT;
|
883
|
-
MEDIUM_INT = GL2ES2.GL_MEDIUM_INT;
|
884
|
-
HIGH_INT = GL2ES2.GL_HIGH_INT;
|
885
|
-
|
886
|
-
CURRENT_VERTEX_ATTRIB = GL2ES2.GL_CURRENT_VERTEX_ATTRIB;
|
887
|
-
|
888
|
-
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING;
|
889
|
-
VERTEX_ATTRIB_ARRAY_ENABLED = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_ENABLED;
|
890
|
-
VERTEX_ATTRIB_ARRAY_SIZE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_SIZE;
|
891
|
-
VERTEX_ATTRIB_ARRAY_STRIDE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_STRIDE;
|
892
|
-
VERTEX_ATTRIB_ARRAY_TYPE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_TYPE;
|
893
|
-
VERTEX_ATTRIB_ARRAY_NORMALIZED = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED;
|
894
|
-
VERTEX_ATTRIB_ARRAY_POINTER = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_POINTER;
|
895
|
-
|
896
|
-
BLEND = GL.GL_BLEND;
|
897
|
-
ONE = GL.GL_ONE;
|
898
|
-
ZERO = GL.GL_ZERO;
|
899
|
-
SRC_ALPHA = GL.GL_SRC_ALPHA;
|
900
|
-
DST_ALPHA = GL.GL_DST_ALPHA;
|
901
|
-
ONE_MINUS_SRC_ALPHA = GL.GL_ONE_MINUS_SRC_ALPHA;
|
902
|
-
ONE_MINUS_DST_COLOR = GL.GL_ONE_MINUS_DST_COLOR;
|
903
|
-
ONE_MINUS_SRC_COLOR = GL.GL_ONE_MINUS_SRC_COLOR;
|
904
|
-
DST_COLOR = GL.GL_DST_COLOR;
|
905
|
-
SRC_COLOR = GL.GL_SRC_COLOR;
|
906
|
-
|
907
|
-
SAMPLE_ALPHA_TO_COVERAGE = GL.GL_SAMPLE_ALPHA_TO_COVERAGE;
|
908
|
-
SAMPLE_COVERAGE = GL.GL_SAMPLE_COVERAGE;
|
909
|
-
|
910
|
-
KEEP = GL.GL_KEEP;
|
911
|
-
REPLACE = GL.GL_REPLACE;
|
912
|
-
INCR = GL.GL_INCR;
|
913
|
-
DECR = GL.GL_DECR;
|
914
|
-
INVERT = GL.GL_INVERT;
|
915
|
-
INCR_WRAP = GL.GL_INCR_WRAP;
|
916
|
-
DECR_WRAP = GL.GL_DECR_WRAP;
|
917
|
-
NEVER = GL.GL_NEVER;
|
918
|
-
ALWAYS = GL.GL_ALWAYS;
|
919
|
-
|
920
|
-
EQUAL = GL.GL_EQUAL;
|
921
|
-
LESS = GL.GL_LESS;
|
922
|
-
LEQUAL = GL.GL_LEQUAL;
|
923
|
-
GREATER = GL.GL_GREATER;
|
924
|
-
GEQUAL = GL.GL_GEQUAL;
|
925
|
-
NOTEQUAL = GL.GL_NOTEQUAL;
|
926
|
-
|
927
|
-
FUNC_ADD = GL.GL_FUNC_ADD;
|
928
|
-
FUNC_MIN = GL2ES3.GL_MIN;
|
929
|
-
FUNC_MAX = GL2ES3.GL_MAX;
|
930
|
-
FUNC_REVERSE_SUBTRACT = GL.GL_FUNC_REVERSE_SUBTRACT;
|
931
|
-
FUNC_SUBTRACT = GL.GL_FUNC_SUBTRACT;
|
932
|
-
|
933
|
-
DITHER = GL.GL_DITHER;
|
934
|
-
|
935
|
-
CONSTANT_COLOR = GL2ES2.GL_CONSTANT_COLOR;
|
936
|
-
CONSTANT_ALPHA = GL2ES2.GL_CONSTANT_ALPHA;
|
937
|
-
ONE_MINUS_CONSTANT_COLOR = GL2ES2.GL_ONE_MINUS_CONSTANT_COLOR;
|
938
|
-
ONE_MINUS_CONSTANT_ALPHA = GL2ES2.GL_ONE_MINUS_CONSTANT_ALPHA;
|
939
|
-
SRC_ALPHA_SATURATE = GL.GL_SRC_ALPHA_SATURATE;
|
940
|
-
|
941
|
-
SCISSOR_TEST = GL.GL_SCISSOR_TEST;
|
942
|
-
STENCIL_TEST = GL.GL_STENCIL_TEST;
|
943
|
-
DEPTH_TEST = GL.GL_DEPTH_TEST;
|
944
|
-
DEPTH_WRITEMASK = GL.GL_DEPTH_WRITEMASK;
|
945
|
-
|
946
|
-
COLOR_BUFFER_BIT = GL.GL_COLOR_BUFFER_BIT;
|
947
|
-
DEPTH_BUFFER_BIT = GL.GL_DEPTH_BUFFER_BIT;
|
948
|
-
STENCIL_BUFFER_BIT = GL.GL_STENCIL_BUFFER_BIT;
|
949
|
-
|
950
|
-
FRAMEBUFFER = GL.GL_FRAMEBUFFER;
|
951
|
-
COLOR_ATTACHMENT0 = GL.GL_COLOR_ATTACHMENT0;
|
952
|
-
COLOR_ATTACHMENT1 = GL2ES2.GL_COLOR_ATTACHMENT1;
|
953
|
-
COLOR_ATTACHMENT2 = GL2ES2.GL_COLOR_ATTACHMENT2;
|
954
|
-
COLOR_ATTACHMENT3 = GL2ES2.GL_COLOR_ATTACHMENT3;
|
955
|
-
RENDERBUFFER = GL.GL_RENDERBUFFER;
|
956
|
-
DEPTH_ATTACHMENT = GL.GL_DEPTH_ATTACHMENT;
|
957
|
-
STENCIL_ATTACHMENT = GL.GL_STENCIL_ATTACHMENT;
|
958
|
-
READ_FRAMEBUFFER = GL.GL_READ_FRAMEBUFFER;
|
959
|
-
DRAW_FRAMEBUFFER = GL.GL_DRAW_FRAMEBUFFER;
|
960
|
-
|
961
|
-
RGBA8 = GL.GL_RGBA8;
|
962
|
-
DEPTH24_STENCIL8 = GL.GL_DEPTH24_STENCIL8;
|
963
|
-
|
964
|
-
DEPTH_COMPONENT = GL2ES2.GL_DEPTH_COMPONENT;
|
965
|
-
DEPTH_COMPONENT16 = GL.GL_DEPTH_COMPONENT16;
|
966
|
-
DEPTH_COMPONENT24 = GL.GL_DEPTH_COMPONENT24;
|
967
|
-
DEPTH_COMPONENT32 = GL.GL_DEPTH_COMPONENT32;
|
968
|
-
|
969
|
-
STENCIL_INDEX = GL2ES2.GL_STENCIL_INDEX;
|
970
|
-
STENCIL_INDEX1 = GL.GL_STENCIL_INDEX1;
|
971
|
-
STENCIL_INDEX4 = GL.GL_STENCIL_INDEX4;
|
972
|
-
STENCIL_INDEX8 = GL.GL_STENCIL_INDEX8;
|
973
|
-
|
974
|
-
DEPTH_STENCIL = GL.GL_DEPTH_STENCIL;
|
975
|
-
|
976
|
-
FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE;
|
977
|
-
FRAMEBUFFER_UNDEFINED = GL2ES3.GL_FRAMEBUFFER_UNDEFINED;
|
978
|
-
FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
979
|
-
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
|
980
|
-
FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
|
981
|
-
FRAMEBUFFER_INCOMPLETE_FORMATS = GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS;
|
982
|
-
FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER;
|
983
|
-
FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER;
|
984
|
-
FRAMEBUFFER_UNSUPPORTED = GL.GL_FRAMEBUFFER_UNSUPPORTED;
|
985
|
-
FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = GL.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
|
986
|
-
FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = GL3ES3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
|
987
|
-
|
988
|
-
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE;
|
989
|
-
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME;
|
990
|
-
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = GL.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL;
|
991
|
-
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = GL.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE;
|
992
|
-
|
993
|
-
RENDERBUFFER_WIDTH = GL.GL_RENDERBUFFER_WIDTH;
|
994
|
-
RENDERBUFFER_HEIGHT = GL.GL_RENDERBUFFER_HEIGHT;
|
995
|
-
RENDERBUFFER_RED_SIZE = GL.GL_RENDERBUFFER_RED_SIZE;
|
996
|
-
RENDERBUFFER_GREEN_SIZE = GL.GL_RENDERBUFFER_GREEN_SIZE;
|
997
|
-
RENDERBUFFER_BLUE_SIZE = GL.GL_RENDERBUFFER_BLUE_SIZE;
|
998
|
-
RENDERBUFFER_ALPHA_SIZE = GL.GL_RENDERBUFFER_ALPHA_SIZE;
|
999
|
-
RENDERBUFFER_DEPTH_SIZE = GL.GL_RENDERBUFFER_DEPTH_SIZE;
|
1000
|
-
RENDERBUFFER_STENCIL_SIZE = GL.GL_RENDERBUFFER_STENCIL_SIZE;
|
1001
|
-
RENDERBUFFER_INTERNAL_FORMAT = GL.GL_RENDERBUFFER_INTERNAL_FORMAT;
|
1002
|
-
|
1003
|
-
MULTISAMPLE = GL.GL_MULTISAMPLE;
|
1004
|
-
LINE_SMOOTH = GL.GL_LINE_SMOOTH;
|
1005
|
-
POLYGON_SMOOTH = GL2GL3.GL_POLYGON_SMOOTH;
|
1006
|
-
|
1007
|
-
SYNC_GPU_COMMANDS_COMPLETE = GL3ES3.GL_SYNC_GPU_COMMANDS_COMPLETE;
|
1008
|
-
ALREADY_SIGNALED = GL3ES3.GL_ALREADY_SIGNALED;
|
1009
|
-
CONDITION_SATISFIED = GL3ES3.GL_CONDITION_SATISFIED;
|
1010
|
-
}
|
1011
226
|
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
gl.glFlush();
|
1017
|
-
}
|
227
|
+
@Override
|
228
|
+
protected int getDepthBits() {
|
229
|
+
return capabilities.getDepthBits();
|
230
|
+
}
|
1018
231
|
|
1019
|
-
@Override
|
1020
|
-
public void finish() {
|
1021
|
-
gl.glFinish();
|
1022
|
-
}
|
1023
232
|
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
233
|
+
@Override
|
234
|
+
protected int getStencilBits() {
|
235
|
+
return capabilities.getStencilBits();
|
236
|
+
}
|
1028
237
|
|
1029
|
-
///////////////////////////////////////////////////////////
|
1030
|
-
// State and State Requests
|
1031
|
-
@Override
|
1032
|
-
public void enable(int value) {
|
1033
|
-
if (-1 < value) {
|
1034
|
-
gl.glEnable(value);
|
1035
|
-
}
|
1036
|
-
}
|
1037
238
|
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
239
|
+
@Override
|
240
|
+
protected float getPixelScale() {
|
241
|
+
PSurface surf = sketch.getSurface();
|
242
|
+
if (surf == null) {
|
243
|
+
return graphics.pixelDensity;
|
244
|
+
} else if (surf instanceof PSurfaceJOGL) {
|
245
|
+
return ((PSurfaceJOGL)surf).getPixelScale();
|
246
|
+
} else {
|
247
|
+
throw new RuntimeException("Renderer cannot find a JOGL surface");
|
1043
248
|
}
|
249
|
+
}
|
1044
250
|
|
1045
|
-
@Override
|
1046
|
-
public void getBooleanv(int value, IntBuffer data) {
|
1047
|
-
if (-1 < value) {
|
1048
|
-
if (byteBuffer.capacity() < data.capacity()) {
|
1049
|
-
byteBuffer = allocateDirectByteBuffer(data.capacity());
|
1050
|
-
}
|
1051
|
-
gl.glGetBooleanv(value, byteBuffer);
|
1052
|
-
for (int i = 0; i < data.capacity(); i++) {
|
1053
|
-
data.put(i, byteBuffer.get(i));
|
1054
|
-
}
|
1055
|
-
} else {
|
1056
|
-
fillIntBuffer(data, 0, data.capacity() - 1, 0);
|
1057
|
-
}
|
1058
|
-
}
|
1059
251
|
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
gl.glGetIntegerv(value, data);
|
1064
|
-
} else {
|
1065
|
-
fillIntBuffer(data, 0, data.capacity() - 1, 0);
|
1066
|
-
}
|
1067
|
-
}
|
252
|
+
@Override
|
253
|
+
protected void getGL(PGL pgl) {
|
254
|
+
PJOGL pjogl = (PJOGL)pgl;
|
1068
255
|
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
} else {
|
1074
|
-
fillFloatBuffer(data, 0, data.capacity() - 1, 0);
|
1075
|
-
}
|
1076
|
-
}
|
256
|
+
this.drawable = pjogl.drawable;
|
257
|
+
this.context = pjogl.context;
|
258
|
+
this.glContext = pjogl.glContext;
|
259
|
+
setThread(pjogl.glThread);
|
1077
260
|
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
261
|
+
this.gl = pjogl.gl;
|
262
|
+
this.gl2 = pjogl.gl2;
|
263
|
+
this.gl2x = pjogl.gl2x;
|
264
|
+
this.gl3 = pjogl.gl3;
|
265
|
+
this.gl3es3 = pjogl.gl3es3;
|
266
|
+
}
|
1082
267
|
|
1083
|
-
@Override
|
1084
|
-
public String getString(int name) {
|
1085
|
-
return gl.glGetString(name);
|
1086
|
-
}
|
1087
268
|
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
return gl.glGetError();
|
1093
|
-
}
|
269
|
+
public void getGL(GLAutoDrawable glDrawable) {
|
270
|
+
context = glDrawable.getContext();
|
271
|
+
glContext = context.hashCode();
|
272
|
+
setThread(Thread.currentThread());
|
1094
273
|
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
274
|
+
gl = context.getGL();
|
275
|
+
gl2 = gl.getGL2ES2();
|
276
|
+
try {
|
277
|
+
gl2x = gl.getGL2();
|
278
|
+
} catch (com.jogamp.opengl.GLException e) {
|
279
|
+
gl2x = null;
|
1098
280
|
}
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
public void genBuffers(int n, IntBuffer buffers) {
|
1104
|
-
gl.glGenBuffers(n, buffers);
|
281
|
+
try {
|
282
|
+
gl3 = gl.getGL2GL3();
|
283
|
+
} catch (com.jogamp.opengl.GLException e) {
|
284
|
+
gl3 = null;
|
1105
285
|
}
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
286
|
+
try {
|
287
|
+
gl3es3 = gl.getGL3ES3();
|
288
|
+
} catch (com.jogamp.opengl.GLException e) {
|
289
|
+
gl3es3 = null;
|
1110
290
|
}
|
291
|
+
}
|
1111
292
|
|
1112
|
-
@Override
|
1113
|
-
public void bindBuffer(int target, int buffer) {
|
1114
|
-
gl.glBindBuffer(target, buffer);
|
1115
|
-
}
|
1116
293
|
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
294
|
+
@Override
|
295
|
+
protected boolean canDraw() { return true; }
|
296
|
+
|
297
|
+
|
298
|
+
@Override
|
299
|
+
protected void requestFocus() {}
|
300
|
+
|
301
|
+
|
302
|
+
@Override
|
303
|
+
protected void requestDraw() {}
|
304
|
+
|
305
|
+
|
306
|
+
@Override
|
307
|
+
protected void swapBuffers() {
|
308
|
+
PSurfaceJOGL surf = (PSurfaceJOGL)sketch.getSurface();
|
309
|
+
surf.window.swapBuffers();
|
310
|
+
}
|
311
|
+
|
312
|
+
|
313
|
+
@Override
|
314
|
+
protected void initFBOLayer() {
|
315
|
+
if (0 < sketch.frameCount) {
|
316
|
+
if (isES()) initFBOLayerES();
|
317
|
+
else initFBOLayerGL();
|
318
|
+
}
|
319
|
+
}
|
320
|
+
|
321
|
+
|
322
|
+
private void initFBOLayerES() {
|
323
|
+
IntBuffer buf = allocateDirectIntBuffer(fboWidth * fboHeight);
|
324
|
+
|
325
|
+
if (hasReadBuffer()) readBuffer(BACK);
|
326
|
+
readPixelsImpl(0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
|
327
|
+
bindTexture(TEXTURE_2D, glColorTex.get(frontTex));
|
328
|
+
texSubImage2D(TEXTURE_2D, 0, 0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
|
329
|
+
|
330
|
+
bindTexture(TEXTURE_2D, glColorTex.get(backTex));
|
331
|
+
texSubImage2D(TEXTURE_2D, 0, 0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
|
332
|
+
|
333
|
+
bindTexture(TEXTURE_2D, 0);
|
334
|
+
bindFramebufferImpl(FRAMEBUFFER, 0);
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
private void initFBOLayerGL() {
|
339
|
+
// Copy the contents of the front and back screen buffers to the textures
|
340
|
+
// of the FBO, so they are properly initialized. Note that the front buffer
|
341
|
+
// of the default framebuffer (the screen) contains the previous frame:
|
342
|
+
// https://www.opengl.org/wiki/Default_Framebuffer
|
343
|
+
// so it is copied to the front texture of the FBO layer:
|
344
|
+
if (pclearColor || 0 < pgeomCount || !sketch.isLooping()) {
|
345
|
+
if (hasReadBuffer()) readBuffer(FRONT);
|
346
|
+
} else {
|
347
|
+
// ...except when the previous frame has not been cleared and nothing was
|
348
|
+
// rendered while looping. In this case the back buffer, which holds the
|
349
|
+
// initial state of the previous frame, still contains the most up-to-date
|
350
|
+
// screen state.
|
351
|
+
readBuffer(BACK);
|
352
|
+
}
|
353
|
+
bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0));
|
354
|
+
framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0,
|
355
|
+
TEXTURE_2D, glColorTex.get(frontTex), 0);
|
356
|
+
if (hasDrawBuffer()) drawBuffer(COLOR_ATTACHMENT0);
|
357
|
+
blitFramebuffer(0, 0, fboWidth, fboHeight,
|
358
|
+
0, 0, fboWidth, fboHeight,
|
359
|
+
COLOR_BUFFER_BIT, NEAREST);
|
360
|
+
|
361
|
+
readBuffer(BACK);
|
362
|
+
bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0));
|
363
|
+
framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0,
|
364
|
+
TEXTURE_2D, glColorTex.get(backTex), 0);
|
365
|
+
drawBuffer(COLOR_ATTACHMENT0);
|
366
|
+
blitFramebuffer(0, 0, fboWidth, fboHeight,
|
367
|
+
0, 0, fboWidth, fboHeight,
|
368
|
+
COLOR_BUFFER_BIT, NEAREST);
|
369
|
+
|
370
|
+
bindFramebufferImpl(FRAMEBUFFER, 0);
|
371
|
+
}
|
372
|
+
|
373
|
+
|
374
|
+
@Override
|
375
|
+
protected void beginGL() {
|
376
|
+
PMatrix3D proj = graphics.projection;
|
377
|
+
PMatrix3D mdl = graphics.modelview;
|
378
|
+
if (gl2x != null) {
|
379
|
+
if (projMatrix == null) {
|
380
|
+
projMatrix = new float[16];
|
381
|
+
}
|
382
|
+
gl2x.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
|
383
|
+
projMatrix[ 0] = proj.m00;
|
384
|
+
projMatrix[ 1] = proj.m10;
|
385
|
+
projMatrix[ 2] = proj.m20;
|
386
|
+
projMatrix[ 3] = proj.m30;
|
387
|
+
projMatrix[ 4] = proj.m01;
|
388
|
+
projMatrix[ 5] = proj.m11;
|
389
|
+
projMatrix[ 6] = proj.m21;
|
390
|
+
projMatrix[ 7] = proj.m31;
|
391
|
+
projMatrix[ 8] = proj.m02;
|
392
|
+
projMatrix[ 9] = proj.m12;
|
393
|
+
projMatrix[10] = proj.m22;
|
394
|
+
projMatrix[11] = proj.m32;
|
395
|
+
projMatrix[12] = proj.m03;
|
396
|
+
projMatrix[13] = proj.m13;
|
397
|
+
projMatrix[14] = proj.m23;
|
398
|
+
projMatrix[15] = proj.m33;
|
399
|
+
gl2x.glLoadMatrixf(projMatrix, 0);
|
400
|
+
|
401
|
+
if (mvMatrix == null) {
|
402
|
+
mvMatrix = new float[16];
|
403
|
+
}
|
404
|
+
gl2x.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
405
|
+
mvMatrix[ 0] = mdl.m00;
|
406
|
+
mvMatrix[ 1] = mdl.m10;
|
407
|
+
mvMatrix[ 2] = mdl.m20;
|
408
|
+
mvMatrix[ 3] = mdl.m30;
|
409
|
+
mvMatrix[ 4] = mdl.m01;
|
410
|
+
mvMatrix[ 5] = mdl.m11;
|
411
|
+
mvMatrix[ 6] = mdl.m21;
|
412
|
+
mvMatrix[ 7] = mdl.m31;
|
413
|
+
mvMatrix[ 8] = mdl.m02;
|
414
|
+
mvMatrix[ 9] = mdl.m12;
|
415
|
+
mvMatrix[10] = mdl.m22;
|
416
|
+
mvMatrix[11] = mdl.m32;
|
417
|
+
mvMatrix[12] = mdl.m03;
|
418
|
+
mvMatrix[13] = mdl.m13;
|
419
|
+
mvMatrix[14] = mdl.m23;
|
420
|
+
mvMatrix[15] = mdl.m33;
|
421
|
+
gl2x.glLoadMatrixf(mvMatrix, 0);
|
422
|
+
}
|
423
|
+
}
|
424
|
+
|
425
|
+
|
426
|
+
@Override
|
427
|
+
protected boolean hasFBOs() {
|
428
|
+
if (context.hasBasicFBOSupport()) return true;
|
429
|
+
else return super.hasFBOs();
|
430
|
+
}
|
431
|
+
|
432
|
+
|
433
|
+
@Override
|
434
|
+
protected boolean hasShaders() {
|
435
|
+
if (context.hasGLSL()) return true;
|
436
|
+
else return super.hasShaders();
|
437
|
+
}
|
438
|
+
|
439
|
+
|
440
|
+
public void init(GLAutoDrawable glDrawable) {
|
441
|
+
capabilities = glDrawable.getChosenGLCapabilities();
|
442
|
+
if (!hasFBOs()) {
|
443
|
+
throw new RuntimeException(MISSING_FBO_ERROR);
|
444
|
+
}
|
445
|
+
if (!hasShaders()) {
|
446
|
+
throw new RuntimeException(MISSING_GLSL_ERROR);
|
447
|
+
}
|
448
|
+
}
|
449
|
+
|
450
|
+
|
451
|
+
///////////////////////////////////////////////////////////
|
452
|
+
|
453
|
+
// Utility functions
|
454
|
+
|
455
|
+
|
456
|
+
@Override
|
457
|
+
protected void enableTexturing(int target) {
|
458
|
+
if (target == TEXTURE_2D) {
|
459
|
+
texturingTargets[0] = true;
|
460
|
+
} else if (target == TEXTURE_RECTANGLE) {
|
461
|
+
texturingTargets[1] = true;
|
462
|
+
}
|
463
|
+
}
|
464
|
+
|
465
|
+
|
466
|
+
@Override
|
467
|
+
protected void disableTexturing(int target) {
|
468
|
+
if (target == TEXTURE_2D) {
|
469
|
+
texturingTargets[0] = false;
|
470
|
+
} else if (target == TEXTURE_RECTANGLE) {
|
471
|
+
texturingTargets[1] = false;
|
1120
472
|
}
|
473
|
+
}
|
474
|
+
|
475
|
+
|
476
|
+
/**
|
477
|
+
* Convenience method to get a legit FontMetrics object. Where possible,
|
478
|
+
* override this any renderer subclass so that you're not using what's
|
479
|
+
* returned by getDefaultToolkit() to get your metrics.
|
480
|
+
*/
|
481
|
+
@SuppressWarnings("deprecation")
|
482
|
+
private FontMetrics getFontMetrics(Font font) { // ignore
|
483
|
+
return Toolkit.getDefaultToolkit().getFontMetrics(font);
|
484
|
+
}
|
1121
485
|
|
1122
|
-
@Override
|
1123
|
-
public void bufferSubData(int target, int offset, int size, Buffer data) {
|
1124
|
-
gl.glBufferSubData(target, offset, size, data);
|
1125
|
-
}
|
1126
486
|
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
487
|
+
/**
|
488
|
+
* Convenience method to jump through some Java2D hoops and get an FRC.
|
489
|
+
*/
|
490
|
+
private FontRenderContext getFontRenderContext(Font font) { // ignore
|
491
|
+
return getFontMetrics(font).getFontRenderContext();
|
492
|
+
}
|
1131
493
|
|
1132
|
-
@Override
|
1133
|
-
public void getBufferParameteriv(int target, int value, IntBuffer data) {
|
1134
|
-
gl.glGetBufferParameteriv(target, value, data);
|
1135
|
-
}
|
1136
494
|
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
495
|
+
@Override
|
496
|
+
protected int getFontAscent(Object font) {
|
497
|
+
return getFontMetrics((Font) font).getAscent();
|
498
|
+
}
|
1141
499
|
|
1142
|
-
@Override
|
1143
|
-
public ByteBuffer mapBufferRange(int target, int offset, int length, int access) {
|
1144
|
-
if (gl2x != null) {
|
1145
|
-
return gl2x.glMapBufferRange(target, offset, length, access);
|
1146
|
-
} else if (gl3 != null) {
|
1147
|
-
return gl3.glMapBufferRange(target, offset, length, access);
|
1148
|
-
} else {
|
1149
|
-
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glMapBufferRange()"));
|
1150
|
-
}
|
1151
|
-
}
|
1152
500
|
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
501
|
+
@Override
|
502
|
+
protected int getFontDescent(Object font) {
|
503
|
+
return getFontMetrics((Font) font).getDescent();
|
504
|
+
}
|
1157
505
|
|
1158
|
-
//////////////////////////////////////////////////////////////////////////////
|
1159
|
-
// Synchronization
|
1160
|
-
@Override
|
1161
|
-
public long fenceSync(int condition, int flags) {
|
1162
|
-
if (gl3es3 != null) {
|
1163
|
-
return gl3es3.glFenceSync(condition, flags);
|
1164
|
-
} else {
|
1165
|
-
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "fenceSync()"));
|
1166
|
-
}
|
1167
|
-
}
|
1168
506
|
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
}
|
507
|
+
@Override
|
508
|
+
protected int getTextWidth(Object font, char[] buffer, int start, int stop) {
|
509
|
+
// maybe should use one of the newer/fancier functions for this?
|
510
|
+
int length = stop - start;
|
511
|
+
FontMetrics metrics = getFontMetrics((Font) font);
|
512
|
+
return metrics.charsWidth(buffer, start, length);
|
513
|
+
}
|
1177
514
|
|
1178
|
-
@Override
|
1179
|
-
public int clientWaitSync(long sync, int flags, long timeout) {
|
1180
|
-
if (gl3es3 != null) {
|
1181
|
-
return gl3es3.glClientWaitSync(sync, flags, timeout);
|
1182
|
-
} else {
|
1183
|
-
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "clientWaitSync()"));
|
1184
|
-
}
|
1185
|
-
}
|
1186
515
|
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
gl.glDepthRangef(n, f);
|
1192
|
-
}
|
516
|
+
@Override
|
517
|
+
protected Object getDerivedFont(Object font, float size) {
|
518
|
+
return ((Font) font).deriveFont(size);
|
519
|
+
}
|
1193
520
|
|
1194
|
-
@Override
|
1195
|
-
public void viewport(int x, int y, int w, int h) {
|
1196
|
-
float scale = getPixelScale();
|
1197
|
-
viewportImpl((int) scale * x, (int) (scale * y), (int) (scale * w), (int) (scale * h));
|
1198
|
-
}
|
1199
521
|
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
522
|
+
@Override
|
523
|
+
protected int getGLSLVersion() {
|
524
|
+
VersionNumber vn = context.getGLSLVersionNumber();
|
525
|
+
return vn.getMajor() * 100 + vn.getMinor();
|
526
|
+
}
|
1204
527
|
|
1205
|
-
//////////////////////////////////////////////////////////////////////////////
|
1206
|
-
// Reading Pixels
|
1207
|
-
@Override
|
1208
|
-
protected void readPixelsImpl(int x, int y, int width, int height, int format, int type, Buffer buffer) {
|
1209
|
-
gl.glReadPixels(x, y, width, height, format, type, buffer);
|
1210
|
-
}
|
1211
528
|
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
529
|
+
@Override
|
530
|
+
protected String getGLSLVersionSuffix() {
|
531
|
+
VersionNumber vn = context.getGLSLVersionNumber();
|
532
|
+
if (context.isGLESProfile() && 1 < vn.getMajor()) {
|
533
|
+
return " es";
|
534
|
+
} else {
|
535
|
+
return "";
|
1215
536
|
}
|
537
|
+
}
|
1216
538
|
|
1217
|
-
//////////////////////////////////////////////////////////////////////////////
|
1218
|
-
// Vertices
|
1219
|
-
@Override
|
1220
|
-
public void vertexAttrib1f(int index, float value) {
|
1221
|
-
gl2.glVertexAttrib1f(index, value);
|
1222
|
-
}
|
1223
539
|
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
540
|
+
@Override
|
541
|
+
protected String[] loadVertexShader(String filename) {
|
542
|
+
return loadVertexShader(filename, getGLSLVersion(), getGLSLVersionSuffix());
|
543
|
+
}
|
1228
544
|
|
1229
|
-
@Override
|
1230
|
-
public void vertexAttrib3f(int index, float value0, float value1, float value2) {
|
1231
|
-
gl2.glVertexAttrib3f(index, value0, value1, value2);
|
1232
|
-
}
|
1233
545
|
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
546
|
+
@Override
|
547
|
+
protected String[] loadFragmentShader(String filename) {
|
548
|
+
return loadFragmentShader(filename, getGLSLVersion(), getGLSLVersionSuffix());
|
549
|
+
}
|
1238
550
|
|
1239
|
-
@Override
|
1240
|
-
public void vertexAttrib1fv(int index, FloatBuffer values) {
|
1241
|
-
gl2.glVertexAttrib1fv(index, values);
|
1242
|
-
}
|
1243
551
|
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
552
|
+
@Override
|
553
|
+
protected String[] loadVertexShader(URL url) {
|
554
|
+
return loadVertexShader(url, getGLSLVersion(), getGLSLVersionSuffix());
|
555
|
+
}
|
1248
556
|
|
1249
|
-
@Override
|
1250
|
-
public void vertexAttrib3fv(int index, FloatBuffer values) {
|
1251
|
-
gl2.glVertexAttrib3fv(index, values);
|
1252
|
-
}
|
1253
557
|
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
558
|
+
@Override
|
559
|
+
protected String[] loadFragmentShader(URL url) {
|
560
|
+
return loadFragmentShader(url, getGLSLVersion(), getGLSLVersionSuffix());
|
561
|
+
}
|
1258
562
|
|
1259
|
-
@Override
|
1260
|
-
public void vertexAttribPointer(int index, int size, int type, boolean normalized, int stride, int offset) {
|
1261
|
-
gl2.glVertexAttribPointer(index, size, type, normalized, stride, offset);
|
1262
|
-
}
|
1263
563
|
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
564
|
+
@Override
|
565
|
+
protected String[] loadFragmentShader(String filename, int version, String versionSuffix) {
|
566
|
+
String[] fragSrc0 = sketch.loadStrings(filename);
|
567
|
+
return preprocessFragmentSource(fragSrc0, version, versionSuffix);
|
568
|
+
}
|
1268
569
|
|
1269
|
-
@Override
|
1270
|
-
public void disableVertexAttribArray(int index) {
|
1271
|
-
gl2.glDisableVertexAttribArray(index);
|
1272
|
-
}
|
1273
570
|
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
571
|
+
@Override
|
572
|
+
protected String[] loadVertexShader(String filename, int version, String versionSuffix) {
|
573
|
+
String[] vertSrc0 = sketch.loadStrings(filename);
|
574
|
+
return preprocessVertexSource(vertSrc0, version, versionSuffix);
|
575
|
+
}
|
1278
576
|
|
1279
|
-
@Override
|
1280
|
-
public void drawElementsImpl(int mode, int count, int type, int offset) {
|
1281
|
-
gl.glDrawElements(mode, count, type, offset);
|
1282
|
-
}
|
1283
577
|
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
578
|
+
@Override
|
579
|
+
protected String[] loadFragmentShader(URL url, int version, String versionSuffix) {
|
580
|
+
try {
|
581
|
+
String[] fragSrc0 = PApplet.loadStrings(url.openStream());
|
582
|
+
return preprocessFragmentSource(fragSrc0, version, versionSuffix);
|
583
|
+
} catch (IOException e) {
|
584
|
+
PGraphics.showException("Cannot load fragment shader " + url.getFile());
|
1289
585
|
}
|
586
|
+
return null;
|
587
|
+
}
|
1290
588
|
|
1291
|
-
@Override
|
1292
|
-
public void frontFace(int dir) {
|
1293
|
-
gl.glFrontFace(dir);
|
1294
|
-
}
|
1295
589
|
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
590
|
+
@Override
|
591
|
+
protected String[] loadVertexShader(URL url, int version, String versionSuffix) {
|
592
|
+
try {
|
593
|
+
String[] vertSrc0 = PApplet.loadStrings(url.openStream());
|
594
|
+
return preprocessVertexSource(vertSrc0, version, versionSuffix);
|
595
|
+
} catch (IOException e) {
|
596
|
+
PGraphics.showException("Cannot load vertex shader " + url.getFile());
|
1299
597
|
}
|
598
|
+
return null;
|
599
|
+
}
|
1300
600
|
|
1301
|
-
@Override
|
1302
|
-
public void polygonOffset(float factor, float units) {
|
1303
|
-
gl.glPolygonOffset(factor, units);
|
1304
|
-
}
|
1305
601
|
|
1306
|
-
|
1307
|
-
// Pixel Rectangles
|
1308
|
-
@Override
|
1309
|
-
public void pixelStorei(int pname, int param) {
|
1310
|
-
gl.glPixelStorei(pname, param);
|
1311
|
-
}
|
602
|
+
///////////////////////////////////////////////////////////
|
1312
603
|
|
1313
|
-
|
1314
|
-
// Texturing
|
1315
|
-
@Override
|
1316
|
-
public void texImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, Buffer data) {
|
1317
|
-
gl.glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
|
1318
|
-
}
|
604
|
+
// Tessellator
|
1319
605
|
|
1320
|
-
@Override
|
1321
|
-
public void copyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border) {
|
1322
|
-
gl.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
|
1323
|
-
}
|
1324
606
|
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
607
|
+
@Override
|
608
|
+
protected Tessellator createTessellator(TessellatorCallback callback) {
|
609
|
+
return new Tessellator(callback);
|
610
|
+
}
|
1329
611
|
|
1330
|
-
@Override
|
1331
|
-
public void copyTexSubImage2D(int target, int level, int xOffset, int yOffset, int x, int y, int width, int height) {
|
1332
|
-
gl.glCopyTexSubImage2D(target, level, x, y, xOffset, yOffset, width, height);
|
1333
|
-
}
|
1334
612
|
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
613
|
+
protected static class Tessellator implements PGL.Tessellator {
|
614
|
+
protected GLUtessellator tess;
|
615
|
+
protected TessellatorCallback callback;
|
616
|
+
protected GLUCallback gluCallback;
|
1339
617
|
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
618
|
+
public Tessellator(TessellatorCallback callback) {
|
619
|
+
this.callback = callback;
|
620
|
+
tess = GLU.gluNewTess();
|
621
|
+
gluCallback = new GLUCallback();
|
1344
622
|
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
623
|
+
GLU.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, gluCallback);
|
624
|
+
GLU.gluTessCallback(tess, GLU.GLU_TESS_END, gluCallback);
|
625
|
+
GLU.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, gluCallback);
|
626
|
+
GLU.gluTessCallback(tess, GLU.GLU_TESS_COMBINE, gluCallback);
|
627
|
+
GLU.gluTessCallback(tess, GLU.GLU_TESS_ERROR, gluCallback);
|
1348
628
|
}
|
1349
629
|
|
1350
630
|
@Override
|
1351
|
-
public void
|
1352
|
-
|
631
|
+
public void setCallback(int flag) {
|
632
|
+
GLU.gluTessCallback(tess, flag, gluCallback);
|
1353
633
|
}
|
1354
634
|
|
1355
635
|
@Override
|
1356
|
-
public void
|
1357
|
-
|
636
|
+
public void setWindingRule(int rule) {
|
637
|
+
setProperty(GLU.GLU_TESS_WINDING_RULE, rule);
|
1358
638
|
}
|
1359
639
|
|
1360
|
-
|
1361
|
-
|
1362
|
-
gl.glTexParameterfv(target, pname, params);
|
640
|
+
public void setProperty(int property, int value) {
|
641
|
+
GLU.gluTessProperty(tess, property, value);
|
1363
642
|
}
|
1364
643
|
|
1365
644
|
@Override
|
1366
|
-
public void
|
1367
|
-
|
645
|
+
public void beginPolygon() {
|
646
|
+
beginPolygon(null);
|
1368
647
|
}
|
1369
648
|
|
1370
649
|
@Override
|
1371
|
-
public void
|
1372
|
-
|
650
|
+
public void beginPolygon(Object data) {
|
651
|
+
GLU.gluTessBeginPolygon(tess, data);
|
1373
652
|
}
|
1374
653
|
|
1375
654
|
@Override
|
1376
|
-
public void
|
1377
|
-
|
655
|
+
public void endPolygon() {
|
656
|
+
GLU.gluTessEndPolygon(tess);
|
1378
657
|
}
|
1379
658
|
|
1380
659
|
@Override
|
1381
|
-
public void
|
1382
|
-
|
660
|
+
public void beginContour() {
|
661
|
+
GLU.gluTessBeginContour(tess);
|
1383
662
|
}
|
1384
663
|
|
1385
664
|
@Override
|
1386
|
-
public void
|
1387
|
-
|
665
|
+
public void endContour() {
|
666
|
+
GLU.gluTessEndContour(tess);
|
1388
667
|
}
|
1389
668
|
|
1390
669
|
@Override
|
1391
|
-
public
|
1392
|
-
|
670
|
+
public void addVertex(double[] v) {
|
671
|
+
addVertex(v, 0, v);
|
1393
672
|
}
|
1394
673
|
|
1395
674
|
@Override
|
1396
|
-
|
1397
|
-
|
675
|
+
public void addVertex(double[] v, int n, Object data) {
|
676
|
+
GLU.gluTessVertex(tess, v, n, data);
|
1398
677
|
}
|
1399
678
|
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
679
|
+
protected class GLUCallback extends GLUtessellatorCallbackAdapter {
|
680
|
+
@Override
|
681
|
+
public void begin(int type) {
|
682
|
+
callback.begin(type);
|
683
|
+
}
|
1404
684
|
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
return gl2.glCreateShader(type);
|
1410
|
-
}
|
685
|
+
@Override
|
686
|
+
public void end() {
|
687
|
+
callback.end();
|
688
|
+
}
|
1411
689
|
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
690
|
+
@Override
|
691
|
+
public void vertex(Object data) {
|
692
|
+
callback.vertex(data);
|
693
|
+
}
|
1416
694
|
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
695
|
+
@Override
|
696
|
+
public void combine(double[] coords, Object[] data,
|
697
|
+
float[] weight, Object[] outData) {
|
698
|
+
callback.combine(coords, data, weight, outData);
|
699
|
+
}
|
1421
700
|
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
701
|
+
@Override
|
702
|
+
public void error(int errnum) {
|
703
|
+
callback.error(errnum);
|
704
|
+
}
|
1425
705
|
}
|
706
|
+
}
|
1426
707
|
|
1427
|
-
@Override
|
1428
|
-
public void deleteShader(int shader) {
|
1429
|
-
gl2.glDeleteShader(shader);
|
1430
|
-
}
|
1431
708
|
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
709
|
+
@Override
|
710
|
+
protected String tessError(int err) {
|
711
|
+
return glu.gluErrorString(err);
|
712
|
+
}
|
1436
713
|
|
1437
|
-
@Override
|
1438
|
-
public int createProgram() {
|
1439
|
-
return gl2.glCreateProgram();
|
1440
|
-
}
|
1441
714
|
|
1442
|
-
|
1443
|
-
public void attachShader(int program, int shader) {
|
1444
|
-
gl2.glAttachShader(program, shader);
|
1445
|
-
}
|
715
|
+
///////////////////////////////////////////////////////////
|
1446
716
|
|
1447
|
-
|
1448
|
-
public void detachShader(int program, int shader) {
|
1449
|
-
gl2.glDetachShader(program, shader);
|
1450
|
-
}
|
717
|
+
// Font outline
|
1451
718
|
|
1452
|
-
@Override
|
1453
|
-
public void linkProgram(int program) {
|
1454
|
-
gl2.glLinkProgram(program);
|
1455
|
-
}
|
1456
719
|
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
720
|
+
static {
|
721
|
+
SHAPE_TEXT_SUPPORTED = true;
|
722
|
+
SEG_MOVETO = PathIterator.SEG_MOVETO;
|
723
|
+
SEG_LINETO = PathIterator.SEG_LINETO;
|
724
|
+
SEG_QUADTO = PathIterator.SEG_QUADTO;
|
725
|
+
SEG_CUBICTO = PathIterator.SEG_CUBICTO;
|
726
|
+
SEG_CLOSE = PathIterator.SEG_CLOSE;
|
727
|
+
}
|
1461
728
|
|
1462
|
-
@Override
|
1463
|
-
public void deleteProgram(int program) {
|
1464
|
-
gl2.glDeleteProgram(program);
|
1465
|
-
}
|
1466
729
|
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
gl2.glGetActiveAttrib(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0);
|
1472
|
-
size.put(tmp[1]);
|
1473
|
-
type.put(tmp[2]);
|
1474
|
-
String name = new String(namebuf, 0, tmp[0]);
|
1475
|
-
return name;
|
1476
|
-
}
|
730
|
+
@Override
|
731
|
+
protected FontOutline createFontOutline(char ch, Object font) {
|
732
|
+
return new FontOutline(ch, (Font) font);
|
733
|
+
}
|
1477
734
|
|
1478
|
-
@Override
|
1479
|
-
public int getAttribLocation(int program, String name) {
|
1480
|
-
return gl2.glGetAttribLocation(program, name);
|
1481
|
-
}
|
1482
735
|
|
1483
|
-
|
1484
|
-
|
1485
|
-
gl2.glBindAttribLocation(program, index, name);
|
1486
|
-
}
|
736
|
+
protected class FontOutline implements PGL.FontOutline {
|
737
|
+
PathIterator iter;
|
1487
738
|
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
739
|
+
public FontOutline(char ch, Font font) {
|
740
|
+
char[] textArray = new char[] { ch };
|
741
|
+
FontRenderContext frc = getFontRenderContext(font);
|
742
|
+
GlyphVector gv = font.createGlyphVector(frc, textArray);
|
743
|
+
Shape shp = gv.getOutline();
|
744
|
+
iter = shp.getPathIterator(null);
|
1491
745
|
}
|
1492
746
|
|
1493
747
|
@Override
|
1494
|
-
public
|
1495
|
-
|
1496
|
-
byte[] namebuf = new byte[1024];
|
1497
|
-
gl2.glGetActiveUniform(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0);
|
1498
|
-
size.put(tmp[1]);
|
1499
|
-
type.put(tmp[2]);
|
1500
|
-
String name = new String(namebuf, 0, tmp[0]);
|
1501
|
-
return name;
|
748
|
+
public boolean isDone() {
|
749
|
+
return iter.isDone();
|
1502
750
|
}
|
1503
751
|
|
1504
752
|
@Override
|
1505
|
-
public
|
1506
|
-
|
753
|
+
public int currentSegment(float[] coords) {
|
754
|
+
return iter.currentSegment(coords);
|
1507
755
|
}
|
1508
756
|
|
1509
757
|
@Override
|
1510
|
-
public void
|
1511
|
-
|
758
|
+
public void next() {
|
759
|
+
iter.next();
|
1512
760
|
}
|
761
|
+
}
|
1513
762
|
|
1514
|
-
@Override
|
1515
|
-
public void uniform3i(int location, int value0, int value1, int value2) {
|
1516
|
-
gl2.glUniform3i(location, value0, value1, value2);
|
1517
|
-
}
|
1518
763
|
|
1519
|
-
|
1520
|
-
public void uniform4i(int location, int value0, int value1, int value2, int value3) {
|
1521
|
-
gl2.glUniform4i(location, value0, value1, value2, value3);
|
1522
|
-
}
|
764
|
+
///////////////////////////////////////////////////////////
|
1523
765
|
|
1524
|
-
|
1525
|
-
public void uniform1f(int location, float value) {
|
1526
|
-
gl2.glUniform1f(location, value);
|
1527
|
-
}
|
766
|
+
// Constants
|
1528
767
|
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
}
|
768
|
+
static {
|
769
|
+
FALSE = GL.GL_FALSE;
|
770
|
+
TRUE = GL.GL_TRUE;
|
1533
771
|
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
772
|
+
INT = GL2ES2.GL_INT;
|
773
|
+
BYTE = GL.GL_BYTE;
|
774
|
+
SHORT = GL.GL_SHORT;
|
775
|
+
FLOAT = GL.GL_FLOAT;
|
776
|
+
BOOL = GL2ES2.GL_BOOL;
|
777
|
+
UNSIGNED_INT = GL.GL_UNSIGNED_INT;
|
778
|
+
UNSIGNED_BYTE = GL.GL_UNSIGNED_BYTE;
|
779
|
+
UNSIGNED_SHORT = GL.GL_UNSIGNED_SHORT;
|
1538
780
|
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
781
|
+
RGB = GL.GL_RGB;
|
782
|
+
RGBA = GL.GL_RGBA;
|
783
|
+
ALPHA = GL.GL_ALPHA;
|
784
|
+
LUMINANCE = GL.GL_LUMINANCE;
|
785
|
+
LUMINANCE_ALPHA = GL.GL_LUMINANCE_ALPHA;
|
1543
786
|
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
}
|
787
|
+
UNSIGNED_SHORT_5_6_5 = GL.GL_UNSIGNED_SHORT_5_6_5;
|
788
|
+
UNSIGNED_SHORT_4_4_4_4 = GL.GL_UNSIGNED_SHORT_4_4_4_4;
|
789
|
+
UNSIGNED_SHORT_5_5_5_1 = GL.GL_UNSIGNED_SHORT_5_5_5_1;
|
1548
790
|
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
791
|
+
RGBA4 = GL.GL_RGBA4;
|
792
|
+
RGB5_A1 = GL.GL_RGB5_A1;
|
793
|
+
RGB565 = GL.GL_RGB565;
|
794
|
+
RGB8 = GL.GL_RGB8;
|
795
|
+
RGBA8 = GL.GL_RGBA8;
|
796
|
+
ALPHA8 = GL.GL_ALPHA8;
|
1553
797
|
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
}
|
798
|
+
READ_ONLY = GL2ES3.GL_READ_ONLY;
|
799
|
+
WRITE_ONLY = GL.GL_WRITE_ONLY;
|
800
|
+
READ_WRITE = GL2ES3.GL_READ_WRITE;
|
1558
801
|
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
}
|
802
|
+
TESS_WINDING_NONZERO = GLU.GLU_TESS_WINDING_NONZERO;
|
803
|
+
TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD;
|
804
|
+
TESS_EDGE_FLAG = GLU.GLU_TESS_EDGE_FLAG;
|
1563
805
|
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
806
|
+
GENERATE_MIPMAP_HINT = GL.GL_GENERATE_MIPMAP_HINT;
|
807
|
+
FASTEST = GL.GL_FASTEST;
|
808
|
+
NICEST = GL.GL_NICEST;
|
809
|
+
DONT_CARE = GL.GL_DONT_CARE;
|
1568
810
|
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
811
|
+
VENDOR = GL.GL_VENDOR;
|
812
|
+
RENDERER = GL.GL_RENDERER;
|
813
|
+
VERSION = GL.GL_VERSION;
|
814
|
+
EXTENSIONS = GL.GL_EXTENSIONS;
|
815
|
+
SHADING_LANGUAGE_VERSION = GL2ES2.GL_SHADING_LANGUAGE_VERSION;
|
1573
816
|
|
1574
|
-
|
1575
|
-
|
1576
|
-
gl2.glUniform3fv(location, count, v);
|
1577
|
-
}
|
817
|
+
MAX_SAMPLES = GL.GL_MAX_SAMPLES;
|
818
|
+
SAMPLES = GL.GL_SAMPLES;
|
1578
819
|
|
1579
|
-
|
1580
|
-
|
1581
|
-
gl2.glUniform4fv(location, count, v);
|
1582
|
-
}
|
820
|
+
ALIASED_LINE_WIDTH_RANGE = GL.GL_ALIASED_LINE_WIDTH_RANGE;
|
821
|
+
ALIASED_POINT_SIZE_RANGE = GL.GL_ALIASED_POINT_SIZE_RANGE;
|
1583
822
|
|
1584
|
-
|
1585
|
-
|
1586
|
-
gl2.glUniformMatrix2fv(location, count, transpose, mat);
|
1587
|
-
}
|
823
|
+
DEPTH_BITS = GL.GL_DEPTH_BITS;
|
824
|
+
STENCIL_BITS = GL.GL_STENCIL_BITS;
|
1588
825
|
|
1589
|
-
|
1590
|
-
|
1591
|
-
gl2.glUniformMatrix3fv(location, count, transpose, mat);
|
1592
|
-
}
|
826
|
+
CCW = GL.GL_CCW;
|
827
|
+
CW = GL.GL_CW;
|
1593
828
|
|
1594
|
-
|
1595
|
-
public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer mat) {
|
1596
|
-
gl2.glUniformMatrix4fv(location, count, transpose, mat);
|
1597
|
-
}
|
829
|
+
VIEWPORT = GL.GL_VIEWPORT;
|
1598
830
|
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
}
|
1603
|
-
|
1604
|
-
@Override
|
1605
|
-
public boolean isShader(int shader) {
|
1606
|
-
return gl2.glIsShader(shader);
|
1607
|
-
}
|
1608
|
-
|
1609
|
-
@Override
|
1610
|
-
public void getShaderiv(int shader, int pname, IntBuffer params) {
|
1611
|
-
gl2.glGetShaderiv(shader, pname, params);
|
1612
|
-
}
|
1613
|
-
|
1614
|
-
@Override
|
1615
|
-
public void getAttachedShaders(int program, int maxCount, IntBuffer count, IntBuffer shaders) {
|
1616
|
-
gl2.glGetAttachedShaders(program, maxCount, count, shaders);
|
1617
|
-
}
|
1618
|
-
|
1619
|
-
@Override
|
1620
|
-
public String getShaderInfoLog(int shader) {
|
1621
|
-
int[] val = {0};
|
1622
|
-
gl2.glGetShaderiv(shader, GL2ES2.GL_INFO_LOG_LENGTH, val, 0);
|
1623
|
-
int length = val[0];
|
1624
|
-
|
1625
|
-
byte[] log = new byte[length];
|
1626
|
-
gl2.glGetShaderInfoLog(shader, length, val, 0, log, 0);
|
1627
|
-
return new String(log);
|
1628
|
-
}
|
1629
|
-
|
1630
|
-
@Override
|
1631
|
-
public String getShaderSource(int shader) {
|
1632
|
-
int[] len = {0};
|
1633
|
-
byte[] buf = new byte[1024];
|
1634
|
-
gl2.glGetShaderSource(shader, 1024, len, 0, buf, 0);
|
1635
|
-
return new String(buf, 0, len[0]);
|
1636
|
-
}
|
1637
|
-
|
1638
|
-
@Override
|
1639
|
-
public void getShaderPrecisionFormat(int shaderType, int precisionType, IntBuffer range, IntBuffer precision) {
|
1640
|
-
gl2.glGetShaderPrecisionFormat(shaderType, precisionType, range, precision);
|
1641
|
-
}
|
1642
|
-
|
1643
|
-
@Override
|
1644
|
-
public void getVertexAttribfv(int index, int pname, FloatBuffer params) {
|
1645
|
-
gl2.glGetVertexAttribfv(index, pname, params);
|
1646
|
-
}
|
1647
|
-
|
1648
|
-
@Override
|
1649
|
-
public void getVertexAttribiv(int index, int pname, IntBuffer params) {
|
1650
|
-
gl2.glGetVertexAttribiv(index, pname, params);
|
1651
|
-
}
|
831
|
+
ARRAY_BUFFER = GL.GL_ARRAY_BUFFER;
|
832
|
+
ELEMENT_ARRAY_BUFFER = GL.GL_ELEMENT_ARRAY_BUFFER;
|
833
|
+
PIXEL_PACK_BUFFER = GL2ES3.GL_PIXEL_PACK_BUFFER;
|
1652
834
|
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
835
|
+
MAX_VERTEX_ATTRIBS = GL2ES2.GL_MAX_VERTEX_ATTRIBS;
|
836
|
+
|
837
|
+
STATIC_DRAW = GL.GL_STATIC_DRAW;
|
838
|
+
DYNAMIC_DRAW = GL.GL_DYNAMIC_DRAW;
|
839
|
+
STREAM_DRAW = GL2ES2.GL_STREAM_DRAW;
|
840
|
+
STREAM_READ = GL2ES3.GL_STREAM_READ;
|
841
|
+
|
842
|
+
BUFFER_SIZE = GL.GL_BUFFER_SIZE;
|
843
|
+
BUFFER_USAGE = GL.GL_BUFFER_USAGE;
|
844
|
+
|
845
|
+
POINTS = GL.GL_POINTS;
|
846
|
+
LINE_STRIP = GL.GL_LINE_STRIP;
|
847
|
+
LINE_LOOP = GL.GL_LINE_LOOP;
|
848
|
+
LINES = GL.GL_LINES;
|
849
|
+
TRIANGLE_FAN = GL.GL_TRIANGLE_FAN;
|
850
|
+
TRIANGLE_STRIP = GL.GL_TRIANGLE_STRIP;
|
851
|
+
TRIANGLES = GL.GL_TRIANGLES;
|
852
|
+
|
853
|
+
CULL_FACE = GL.GL_CULL_FACE;
|
854
|
+
FRONT = GL.GL_FRONT;
|
855
|
+
BACK = GL.GL_BACK;
|
856
|
+
FRONT_AND_BACK = GL.GL_FRONT_AND_BACK;
|
857
|
+
|
858
|
+
POLYGON_OFFSET_FILL = GL.GL_POLYGON_OFFSET_FILL;
|
859
|
+
|
860
|
+
UNPACK_ALIGNMENT = GL.GL_UNPACK_ALIGNMENT;
|
861
|
+
PACK_ALIGNMENT = GL.GL_PACK_ALIGNMENT;
|
862
|
+
|
863
|
+
TEXTURE_2D = GL.GL_TEXTURE_2D;
|
864
|
+
TEXTURE_RECTANGLE = GL2GL3.GL_TEXTURE_RECTANGLE;
|
865
|
+
|
866
|
+
TEXTURE_BINDING_2D = GL.GL_TEXTURE_BINDING_2D;
|
867
|
+
TEXTURE_BINDING_RECTANGLE = GL2GL3.GL_TEXTURE_BINDING_RECTANGLE;
|
868
|
+
|
869
|
+
MAX_TEXTURE_SIZE = GL.GL_MAX_TEXTURE_SIZE;
|
870
|
+
TEXTURE_MAX_ANISOTROPY = GL.GL_TEXTURE_MAX_ANISOTROPY_EXT;
|
871
|
+
MAX_TEXTURE_MAX_ANISOTROPY = GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT;
|
872
|
+
|
873
|
+
MAX_VERTEX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS;
|
874
|
+
MAX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS;
|
875
|
+
MAX_COMBINED_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS;
|
876
|
+
|
877
|
+
NUM_COMPRESSED_TEXTURE_FORMATS = GL.GL_NUM_COMPRESSED_TEXTURE_FORMATS;
|
878
|
+
COMPRESSED_TEXTURE_FORMATS = GL.GL_COMPRESSED_TEXTURE_FORMATS;
|
879
|
+
|
880
|
+
NEAREST = GL.GL_NEAREST;
|
881
|
+
LINEAR = GL.GL_LINEAR;
|
882
|
+
LINEAR_MIPMAP_NEAREST = GL.GL_LINEAR_MIPMAP_NEAREST;
|
883
|
+
LINEAR_MIPMAP_LINEAR = GL.GL_LINEAR_MIPMAP_LINEAR;
|
884
|
+
|
885
|
+
CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE;
|
886
|
+
REPEAT = GL.GL_REPEAT;
|
887
|
+
|
888
|
+
TEXTURE0 = GL.GL_TEXTURE0;
|
889
|
+
TEXTURE1 = GL.GL_TEXTURE1;
|
890
|
+
TEXTURE2 = GL.GL_TEXTURE2;
|
891
|
+
TEXTURE3 = GL.GL_TEXTURE3;
|
892
|
+
TEXTURE_MIN_FILTER = GL.GL_TEXTURE_MIN_FILTER;
|
893
|
+
TEXTURE_MAG_FILTER = GL.GL_TEXTURE_MAG_FILTER;
|
894
|
+
TEXTURE_WRAP_S = GL.GL_TEXTURE_WRAP_S;
|
895
|
+
TEXTURE_WRAP_T = GL.GL_TEXTURE_WRAP_T;
|
896
|
+
TEXTURE_WRAP_R = GL2ES2.GL_TEXTURE_WRAP_R;
|
897
|
+
|
898
|
+
TEXTURE_CUBE_MAP = GL.GL_TEXTURE_CUBE_MAP;
|
899
|
+
TEXTURE_CUBE_MAP_POSITIVE_X = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
900
|
+
TEXTURE_CUBE_MAP_POSITIVE_Y = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
|
901
|
+
TEXTURE_CUBE_MAP_POSITIVE_Z = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
|
902
|
+
TEXTURE_CUBE_MAP_NEGATIVE_X = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
|
903
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Y = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
|
904
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Z = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
|
905
|
+
|
906
|
+
VERTEX_SHADER = GL2ES2.GL_VERTEX_SHADER;
|
907
|
+
FRAGMENT_SHADER = GL2ES2.GL_FRAGMENT_SHADER;
|
908
|
+
INFO_LOG_LENGTH = GL2ES2.GL_INFO_LOG_LENGTH;
|
909
|
+
SHADER_SOURCE_LENGTH = GL2ES2.GL_SHADER_SOURCE_LENGTH;
|
910
|
+
COMPILE_STATUS = GL2ES2.GL_COMPILE_STATUS;
|
911
|
+
LINK_STATUS = GL2ES2.GL_LINK_STATUS;
|
912
|
+
VALIDATE_STATUS = GL2ES2.GL_VALIDATE_STATUS;
|
913
|
+
SHADER_TYPE = GL2ES2.GL_SHADER_TYPE;
|
914
|
+
DELETE_STATUS = GL2ES2.GL_DELETE_STATUS;
|
915
|
+
|
916
|
+
FLOAT_VEC2 = GL2ES2.GL_FLOAT_VEC2;
|
917
|
+
FLOAT_VEC3 = GL2ES2.GL_FLOAT_VEC3;
|
918
|
+
FLOAT_VEC4 = GL2ES2.GL_FLOAT_VEC4;
|
919
|
+
FLOAT_MAT2 = GL2ES2.GL_FLOAT_MAT2;
|
920
|
+
FLOAT_MAT3 = GL2ES2.GL_FLOAT_MAT3;
|
921
|
+
FLOAT_MAT4 = GL2ES2.GL_FLOAT_MAT4;
|
922
|
+
INT_VEC2 = GL2ES2.GL_INT_VEC2;
|
923
|
+
INT_VEC3 = GL2ES2.GL_INT_VEC3;
|
924
|
+
INT_VEC4 = GL2ES2.GL_INT_VEC4;
|
925
|
+
BOOL_VEC2 = GL2ES2.GL_BOOL_VEC2;
|
926
|
+
BOOL_VEC3 = GL2ES2.GL_BOOL_VEC3;
|
927
|
+
BOOL_VEC4 = GL2ES2.GL_BOOL_VEC4;
|
928
|
+
SAMPLER_2D = GL2ES2.GL_SAMPLER_2D;
|
929
|
+
SAMPLER_CUBE = GL2ES2.GL_SAMPLER_CUBE;
|
930
|
+
|
931
|
+
LOW_FLOAT = GL2ES2.GL_LOW_FLOAT;
|
932
|
+
MEDIUM_FLOAT = GL2ES2.GL_MEDIUM_FLOAT;
|
933
|
+
HIGH_FLOAT = GL2ES2.GL_HIGH_FLOAT;
|
934
|
+
LOW_INT = GL2ES2.GL_LOW_INT;
|
935
|
+
MEDIUM_INT = GL2ES2.GL_MEDIUM_INT;
|
936
|
+
HIGH_INT = GL2ES2.GL_HIGH_INT;
|
937
|
+
|
938
|
+
CURRENT_VERTEX_ATTRIB = GL2ES2.GL_CURRENT_VERTEX_ATTRIB;
|
939
|
+
|
940
|
+
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING;
|
941
|
+
VERTEX_ATTRIB_ARRAY_ENABLED = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_ENABLED;
|
942
|
+
VERTEX_ATTRIB_ARRAY_SIZE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_SIZE;
|
943
|
+
VERTEX_ATTRIB_ARRAY_STRIDE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_STRIDE;
|
944
|
+
VERTEX_ATTRIB_ARRAY_TYPE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_TYPE;
|
945
|
+
VERTEX_ATTRIB_ARRAY_NORMALIZED = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED;
|
946
|
+
VERTEX_ATTRIB_ARRAY_POINTER = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_POINTER;
|
947
|
+
|
948
|
+
BLEND = GL.GL_BLEND;
|
949
|
+
ONE = GL.GL_ONE;
|
950
|
+
ZERO = GL.GL_ZERO;
|
951
|
+
SRC_ALPHA = GL.GL_SRC_ALPHA;
|
952
|
+
DST_ALPHA = GL.GL_DST_ALPHA;
|
953
|
+
ONE_MINUS_SRC_ALPHA = GL.GL_ONE_MINUS_SRC_ALPHA;
|
954
|
+
ONE_MINUS_DST_COLOR = GL.GL_ONE_MINUS_DST_COLOR;
|
955
|
+
ONE_MINUS_SRC_COLOR = GL.GL_ONE_MINUS_SRC_COLOR;
|
956
|
+
DST_COLOR = GL.GL_DST_COLOR;
|
957
|
+
SRC_COLOR = GL.GL_SRC_COLOR;
|
958
|
+
|
959
|
+
SAMPLE_ALPHA_TO_COVERAGE = GL.GL_SAMPLE_ALPHA_TO_COVERAGE;
|
960
|
+
SAMPLE_COVERAGE = GL.GL_SAMPLE_COVERAGE;
|
961
|
+
|
962
|
+
KEEP = GL.GL_KEEP;
|
963
|
+
REPLACE = GL.GL_REPLACE;
|
964
|
+
INCR = GL.GL_INCR;
|
965
|
+
DECR = GL.GL_DECR;
|
966
|
+
INVERT = GL.GL_INVERT;
|
967
|
+
INCR_WRAP = GL.GL_INCR_WRAP;
|
968
|
+
DECR_WRAP = GL.GL_DECR_WRAP;
|
969
|
+
NEVER = GL.GL_NEVER;
|
970
|
+
ALWAYS = GL.GL_ALWAYS;
|
971
|
+
|
972
|
+
EQUAL = GL.GL_EQUAL;
|
973
|
+
LESS = GL.GL_LESS;
|
974
|
+
LEQUAL = GL.GL_LEQUAL;
|
975
|
+
GREATER = GL.GL_GREATER;
|
976
|
+
GEQUAL = GL.GL_GEQUAL;
|
977
|
+
NOTEQUAL = GL.GL_NOTEQUAL;
|
978
|
+
|
979
|
+
FUNC_ADD = GL.GL_FUNC_ADD;
|
980
|
+
FUNC_MIN = GL2ES3.GL_MIN;
|
981
|
+
FUNC_MAX = GL2ES3.GL_MAX;
|
982
|
+
FUNC_REVERSE_SUBTRACT = GL.GL_FUNC_REVERSE_SUBTRACT;
|
983
|
+
FUNC_SUBTRACT = GL.GL_FUNC_SUBTRACT;
|
984
|
+
|
985
|
+
DITHER = GL.GL_DITHER;
|
986
|
+
|
987
|
+
CONSTANT_COLOR = GL2ES2.GL_CONSTANT_COLOR;
|
988
|
+
CONSTANT_ALPHA = GL2ES2.GL_CONSTANT_ALPHA;
|
989
|
+
ONE_MINUS_CONSTANT_COLOR = GL2ES2.GL_ONE_MINUS_CONSTANT_COLOR;
|
990
|
+
ONE_MINUS_CONSTANT_ALPHA = GL2ES2.GL_ONE_MINUS_CONSTANT_ALPHA;
|
991
|
+
SRC_ALPHA_SATURATE = GL.GL_SRC_ALPHA_SATURATE;
|
992
|
+
|
993
|
+
SCISSOR_TEST = GL.GL_SCISSOR_TEST;
|
994
|
+
STENCIL_TEST = GL.GL_STENCIL_TEST;
|
995
|
+
DEPTH_TEST = GL.GL_DEPTH_TEST;
|
996
|
+
DEPTH_WRITEMASK = GL.GL_DEPTH_WRITEMASK;
|
997
|
+
|
998
|
+
COLOR_BUFFER_BIT = GL.GL_COLOR_BUFFER_BIT;
|
999
|
+
DEPTH_BUFFER_BIT = GL.GL_DEPTH_BUFFER_BIT;
|
1000
|
+
STENCIL_BUFFER_BIT = GL.GL_STENCIL_BUFFER_BIT;
|
1001
|
+
|
1002
|
+
FRAMEBUFFER = GL.GL_FRAMEBUFFER;
|
1003
|
+
COLOR_ATTACHMENT0 = GL.GL_COLOR_ATTACHMENT0;
|
1004
|
+
COLOR_ATTACHMENT1 = GL2ES2.GL_COLOR_ATTACHMENT1;
|
1005
|
+
COLOR_ATTACHMENT2 = GL2ES2.GL_COLOR_ATTACHMENT2;
|
1006
|
+
COLOR_ATTACHMENT3 = GL2ES2.GL_COLOR_ATTACHMENT3;
|
1007
|
+
RENDERBUFFER = GL.GL_RENDERBUFFER;
|
1008
|
+
DEPTH_ATTACHMENT = GL.GL_DEPTH_ATTACHMENT;
|
1009
|
+
STENCIL_ATTACHMENT = GL.GL_STENCIL_ATTACHMENT;
|
1010
|
+
READ_FRAMEBUFFER = GL.GL_READ_FRAMEBUFFER;
|
1011
|
+
DRAW_FRAMEBUFFER = GL.GL_DRAW_FRAMEBUFFER;
|
1012
|
+
|
1013
|
+
RGBA8 = GL.GL_RGBA8;
|
1014
|
+
DEPTH24_STENCIL8 = GL.GL_DEPTH24_STENCIL8;
|
1015
|
+
|
1016
|
+
DEPTH_COMPONENT = GL2ES2.GL_DEPTH_COMPONENT;
|
1017
|
+
DEPTH_COMPONENT16 = GL.GL_DEPTH_COMPONENT16;
|
1018
|
+
DEPTH_COMPONENT24 = GL.GL_DEPTH_COMPONENT24;
|
1019
|
+
DEPTH_COMPONENT32 = GL.GL_DEPTH_COMPONENT32;
|
1020
|
+
|
1021
|
+
STENCIL_INDEX = GL2ES2.GL_STENCIL_INDEX;
|
1022
|
+
STENCIL_INDEX1 = GL.GL_STENCIL_INDEX1;
|
1023
|
+
STENCIL_INDEX4 = GL.GL_STENCIL_INDEX4;
|
1024
|
+
STENCIL_INDEX8 = GL.GL_STENCIL_INDEX8;
|
1025
|
+
|
1026
|
+
DEPTH_STENCIL = GL.GL_DEPTH_STENCIL;
|
1027
|
+
|
1028
|
+
FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE;
|
1029
|
+
FRAMEBUFFER_UNDEFINED = GL2ES3.GL_FRAMEBUFFER_UNDEFINED;
|
1030
|
+
FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
1031
|
+
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
|
1032
|
+
FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
|
1033
|
+
FRAMEBUFFER_INCOMPLETE_FORMATS = GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS;
|
1034
|
+
FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER;
|
1035
|
+
FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER;
|
1036
|
+
FRAMEBUFFER_UNSUPPORTED = GL.GL_FRAMEBUFFER_UNSUPPORTED;
|
1037
|
+
FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = GL.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
|
1038
|
+
FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = GL3ES3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
|
1039
|
+
|
1040
|
+
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE;
|
1041
|
+
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME;
|
1042
|
+
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = GL.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL;
|
1043
|
+
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = GL.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE;
|
1044
|
+
|
1045
|
+
RENDERBUFFER_WIDTH = GL.GL_RENDERBUFFER_WIDTH;
|
1046
|
+
RENDERBUFFER_HEIGHT = GL.GL_RENDERBUFFER_HEIGHT;
|
1047
|
+
RENDERBUFFER_RED_SIZE = GL.GL_RENDERBUFFER_RED_SIZE;
|
1048
|
+
RENDERBUFFER_GREEN_SIZE = GL.GL_RENDERBUFFER_GREEN_SIZE;
|
1049
|
+
RENDERBUFFER_BLUE_SIZE = GL.GL_RENDERBUFFER_BLUE_SIZE;
|
1050
|
+
RENDERBUFFER_ALPHA_SIZE = GL.GL_RENDERBUFFER_ALPHA_SIZE;
|
1051
|
+
RENDERBUFFER_DEPTH_SIZE = GL.GL_RENDERBUFFER_DEPTH_SIZE;
|
1052
|
+
RENDERBUFFER_STENCIL_SIZE = GL.GL_RENDERBUFFER_STENCIL_SIZE;
|
1053
|
+
RENDERBUFFER_INTERNAL_FORMAT = GL.GL_RENDERBUFFER_INTERNAL_FORMAT;
|
1054
|
+
|
1055
|
+
MULTISAMPLE = GL.GL_MULTISAMPLE;
|
1056
|
+
LINE_SMOOTH = GL.GL_LINE_SMOOTH;
|
1057
|
+
POLYGON_SMOOTH = GL2GL3.GL_POLYGON_SMOOTH;
|
1058
|
+
|
1059
|
+
SYNC_GPU_COMMANDS_COMPLETE = GL3ES3.GL_SYNC_GPU_COMMANDS_COMPLETE;
|
1060
|
+
ALREADY_SIGNALED = GL3ES3.GL_ALREADY_SIGNALED;
|
1061
|
+
CONDITION_SATISFIED = GL3ES3.GL_CONDITION_SATISFIED;
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
///////////////////////////////////////////////////////////
|
1065
|
+
|
1066
|
+
// Special Functions
|
1067
|
+
|
1068
|
+
@Override
|
1069
|
+
public void flush() {
|
1070
|
+
gl.glFlush();
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
@Override
|
1074
|
+
public void finish() {
|
1075
|
+
gl.glFinish();
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
@Override
|
1079
|
+
public void hint(int target, int hint) {
|
1080
|
+
gl.glHint(target, hint);
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
///////////////////////////////////////////////////////////
|
1084
|
+
|
1085
|
+
// State and State Requests
|
1086
|
+
|
1087
|
+
@Override
|
1088
|
+
public void enable(int value) {
|
1089
|
+
if (-1 < value) {
|
1090
|
+
gl.glEnable(value);
|
1091
|
+
}
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
@Override
|
1095
|
+
public void disable(int value) {
|
1096
|
+
if (-1 < value) {
|
1097
|
+
gl.glDisable(value);
|
1098
|
+
}
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
@Override
|
1102
|
+
public void getBooleanv(int value, IntBuffer data) {
|
1103
|
+
if (-1 < value) {
|
1104
|
+
if (byteBuffer.capacity() < data.capacity()) {
|
1105
|
+
byteBuffer = allocateDirectByteBuffer(data.capacity());
|
1106
|
+
}
|
1107
|
+
gl.glGetBooleanv(value, byteBuffer);
|
1108
|
+
for (int i = 0; i < data.capacity(); i++) {
|
1109
|
+
data.put(i, byteBuffer.get(i));
|
1110
|
+
}
|
1111
|
+
} else {
|
1112
|
+
fillIntBuffer(data, 0, data.capacity() - 1, 0);
|
1113
|
+
}
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
@Override
|
1117
|
+
public void getIntegerv(int value, IntBuffer data) {
|
1118
|
+
if (-1 < value) {
|
1119
|
+
gl.glGetIntegerv(value, data);
|
1120
|
+
} else {
|
1121
|
+
fillIntBuffer(data, 0, data.capacity() - 1, 0);
|
1122
|
+
}
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
@Override
|
1126
|
+
public void getFloatv(int value, FloatBuffer data) {
|
1127
|
+
if (-1 < value) {
|
1128
|
+
gl.glGetFloatv(value, data);
|
1129
|
+
} else {
|
1130
|
+
fillFloatBuffer(data, 0, data.capacity() - 1, 0);
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
@Override
|
1135
|
+
public boolean isEnabled(int value) {
|
1136
|
+
return gl.glIsEnabled(value);
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
@Override
|
1140
|
+
public String getString(int name) {
|
1141
|
+
if (gl == null) {
|
1142
|
+
throw new PGL.GraphicsNotInitializedException("Context not initalized.");
|
1143
|
+
}
|
1144
|
+
return gl.glGetString(name);
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
///////////////////////////////////////////////////////////
|
1148
|
+
|
1149
|
+
// Error Handling
|
1150
|
+
|
1151
|
+
@Override
|
1152
|
+
public int getError() {
|
1153
|
+
return gl.glGetError();
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
@Override
|
1157
|
+
public String errorString(int err) {
|
1158
|
+
return glu.gluErrorString(err);
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
//////////////////////////////////////////////////////////////////////////////
|
1162
|
+
|
1163
|
+
// Buffer Objects
|
1164
|
+
|
1165
|
+
@Override
|
1166
|
+
public void genBuffers(int n, IntBuffer buffers) {
|
1167
|
+
gl.glGenBuffers(n, buffers);
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
@Override
|
1171
|
+
public void deleteBuffers(int n, IntBuffer buffers) {
|
1172
|
+
gl.glDeleteBuffers(n, buffers);
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
@Override
|
1176
|
+
public void bindBuffer(int target, int buffer) {
|
1177
|
+
gl.glBindBuffer(target, buffer);
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
@Override
|
1181
|
+
public void bufferData(int target, int size, Buffer data, int usage) {
|
1182
|
+
gl.glBufferData(target, size, data, usage);
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
@Override
|
1186
|
+
public void bufferSubData(int target, int offset, int size, Buffer data) {
|
1187
|
+
gl.glBufferSubData(target, offset, size, data);
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
@Override
|
1191
|
+
public void isBuffer(int buffer) {
|
1192
|
+
gl.glIsBuffer(buffer);
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
@Override
|
1196
|
+
public void getBufferParameteriv(int target, int value, IntBuffer data) {
|
1197
|
+
gl.glGetBufferParameteriv(target, value, data);
|
1198
|
+
}
|
1199
|
+
|
1200
|
+
@Override
|
1201
|
+
public ByteBuffer mapBuffer(int target, int access) {
|
1202
|
+
return gl2.glMapBuffer(target, access);
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
@Override
|
1206
|
+
public ByteBuffer mapBufferRange(int target, int offset, int length, int access) {
|
1207
|
+
if (gl2x != null) {
|
1208
|
+
return gl2x.glMapBufferRange(target, offset, length, access);
|
1209
|
+
} else if (gl3 != null) {
|
1210
|
+
return gl3.glMapBufferRange(target, offset, length, access);
|
1211
|
+
} else {
|
1212
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glMapBufferRange()"));
|
1213
|
+
}
|
1214
|
+
}
|
1215
|
+
|
1216
|
+
@Override
|
1217
|
+
public void unmapBuffer(int target) {
|
1218
|
+
gl2.glUnmapBuffer(target);
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
//////////////////////////////////////////////////////////////////////////////
|
1222
|
+
|
1223
|
+
// Synchronization
|
1224
|
+
|
1225
|
+
@Override
|
1226
|
+
public long fenceSync(int condition, int flags) {
|
1227
|
+
if (gl3es3 != null) {
|
1228
|
+
return gl3es3.glFenceSync(condition, flags);
|
1229
|
+
} else {
|
1230
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "fenceSync()"));
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
@Override
|
1235
|
+
public void deleteSync(long sync) {
|
1236
|
+
if (gl3es3 != null) {
|
1237
|
+
gl3es3.glDeleteSync(sync);
|
1238
|
+
} else {
|
1239
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "deleteSync()"));
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
@Override
|
1244
|
+
public int clientWaitSync(long sync, int flags, long timeout) {
|
1245
|
+
if (gl3es3 != null) {
|
1246
|
+
return gl3es3.glClientWaitSync(sync, flags, timeout);
|
1247
|
+
} else {
|
1248
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "clientWaitSync()"));
|
1249
|
+
}
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
//////////////////////////////////////////////////////////////////////////////
|
1253
|
+
|
1254
|
+
// Viewport and Clipping
|
1255
|
+
|
1256
|
+
@Override
|
1257
|
+
public void depthRangef(float n, float f) {
|
1258
|
+
gl.glDepthRangef(n, f);
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
@Override
|
1262
|
+
public void viewport(int x, int y, int w, int h) {
|
1263
|
+
float scale = getPixelScale();
|
1264
|
+
viewportImpl((int)scale * x, (int)(scale * y), (int)(scale * w), (int)(scale * h));
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
@Override
|
1268
|
+
protected void viewportImpl(int x, int y, int w, int h) {
|
1269
|
+
gl.glViewport(x, y, w, h);
|
1270
|
+
}
|
1271
|
+
|
1272
|
+
//////////////////////////////////////////////////////////////////////////////
|
1273
|
+
|
1274
|
+
// Reading Pixels
|
1275
|
+
|
1276
|
+
@Override
|
1277
|
+
protected void readPixelsImpl(int x, int y, int width, int height, int format, int type, Buffer buffer) {
|
1278
|
+
gl.glReadPixels(x, y, width, height, format, type, buffer);
|
1279
|
+
}
|
1280
|
+
|
1281
|
+
@Override
|
1282
|
+
protected void readPixelsImpl(int x, int y, int width, int height, int format, int type, long offset) {
|
1283
|
+
gl.glReadPixels(x, y, width, height, format, type, 0);
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
//////////////////////////////////////////////////////////////////////////////
|
1287
|
+
|
1288
|
+
// Vertices
|
1289
|
+
|
1290
|
+
@Override
|
1291
|
+
public void vertexAttrib1f(int index, float value) {
|
1292
|
+
gl2.glVertexAttrib1f(index, value);
|
1293
|
+
}
|
1294
|
+
|
1295
|
+
@Override
|
1296
|
+
public void vertexAttrib2f(int index, float value0, float value1) {
|
1297
|
+
gl2.glVertexAttrib2f(index, value0, value1);
|
1298
|
+
}
|
1299
|
+
|
1300
|
+
@Override
|
1301
|
+
public void vertexAttrib3f(int index, float value0, float value1, float value2) {
|
1302
|
+
gl2.glVertexAttrib3f(index, value0, value1, value2);
|
1303
|
+
}
|
1304
|
+
|
1305
|
+
@Override
|
1306
|
+
public void vertexAttrib4f(int index, float value0, float value1, float value2, float value3) {
|
1307
|
+
gl2.glVertexAttrib4f(index, value0, value1, value2, value3);
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
@Override
|
1311
|
+
public void vertexAttrib1fv(int index, FloatBuffer values) {
|
1312
|
+
gl2.glVertexAttrib1fv(index, values);
|
1313
|
+
}
|
1314
|
+
|
1315
|
+
@Override
|
1316
|
+
public void vertexAttrib2fv(int index, FloatBuffer values) {
|
1317
|
+
gl2.glVertexAttrib2fv(index, values);
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
@Override
|
1321
|
+
public void vertexAttrib3fv(int index, FloatBuffer values) {
|
1322
|
+
gl2.glVertexAttrib3fv(index, values);
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
@Override
|
1326
|
+
public void vertexAttrib4fv(int index, FloatBuffer values) {
|
1327
|
+
gl2.glVertexAttrib4fv(index, values);
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
@Override
|
1331
|
+
public void vertexAttribPointer(int index, int size, int type, boolean normalized, int stride, int offset) {
|
1332
|
+
gl2.glVertexAttribPointer(index, size, type, normalized, stride, offset);
|
1333
|
+
}
|
1334
|
+
|
1335
|
+
@Override
|
1336
|
+
public void enableVertexAttribArray(int index) {
|
1337
|
+
gl2.glEnableVertexAttribArray(index);
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
@Override
|
1341
|
+
public void disableVertexAttribArray(int index) {
|
1342
|
+
gl2.glDisableVertexAttribArray(index);
|
1343
|
+
}
|
1344
|
+
|
1345
|
+
@Override
|
1346
|
+
public void drawArraysImpl(int mode, int first, int count) {
|
1347
|
+
gl.glDrawArrays(mode, first, count);
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
@Override
|
1351
|
+
public void drawElementsImpl(int mode, int count, int type, int offset) {
|
1352
|
+
gl.glDrawElements(mode, count, type, offset);
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
//////////////////////////////////////////////////////////////////////////////
|
1356
|
+
|
1357
|
+
// Rasterization
|
1358
|
+
|
1359
|
+
@Override
|
1360
|
+
public void lineWidth(float width) {
|
1361
|
+
gl.glLineWidth(width);
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
@Override
|
1365
|
+
public void frontFace(int dir) {
|
1366
|
+
gl.glFrontFace(dir);
|
1367
|
+
}
|
1368
|
+
|
1369
|
+
@Override
|
1370
|
+
public void cullFace(int mode) {
|
1371
|
+
gl.glCullFace(mode);
|
1372
|
+
}
|
1373
|
+
|
1374
|
+
@Override
|
1375
|
+
public void polygonOffset(float factor, float units) {
|
1376
|
+
gl.glPolygonOffset(factor, units);
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
//////////////////////////////////////////////////////////////////////////////
|
1380
|
+
|
1381
|
+
// Pixel Rectangles
|
1382
|
+
|
1383
|
+
@Override
|
1384
|
+
public void pixelStorei(int pname, int param) {
|
1385
|
+
gl.glPixelStorei(pname, param);
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
///////////////////////////////////////////////////////////
|
1389
|
+
|
1390
|
+
// Texturing
|
1391
|
+
|
1392
|
+
@Override
|
1393
|
+
public void texImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, Buffer data) {
|
1394
|
+
gl.glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
|
1395
|
+
}
|
1396
|
+
|
1397
|
+
@Override
|
1398
|
+
public void copyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border) {
|
1399
|
+
gl.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
|
1400
|
+
}
|
1401
|
+
|
1402
|
+
@Override
|
1403
|
+
public void texSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, Buffer data) {
|
1404
|
+
gl.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, data);
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
@Override
|
1408
|
+
public void copyTexSubImage2D(int target, int level, int xOffset, int yOffset, int x, int y, int width, int height) {
|
1409
|
+
gl.glCopyTexSubImage2D(target, level, x, y, xOffset, yOffset, width, height);
|
1410
|
+
}
|
1411
|
+
|
1412
|
+
@Override
|
1413
|
+
public void compressedTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int imageSize, Buffer data) {
|
1414
|
+
gl.glCompressedTexImage2D(target, level, internalFormat, width, height, border, imageSize, data);
|
1415
|
+
}
|
1416
|
+
|
1417
|
+
@Override
|
1418
|
+
public void compressedTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int imageSize, Buffer data) {
|
1419
|
+
gl.glCompressedTexSubImage2D(target, level, xOffset, yOffset, width, height, format, imageSize, data);
|
1420
|
+
}
|
1421
|
+
|
1422
|
+
@Override
|
1423
|
+
public void texParameteri(int target, int pname, int param) {
|
1424
|
+
gl.glTexParameteri(target, pname, param);
|
1425
|
+
}
|
1426
|
+
|
1427
|
+
@Override
|
1428
|
+
public void texParameterf(int target, int pname, float param) {
|
1429
|
+
gl.glTexParameterf(target, pname, param);
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
@Override
|
1433
|
+
public void texParameteriv(int target, int pname, IntBuffer params) {
|
1434
|
+
gl.glTexParameteriv(target, pname, params);
|
1435
|
+
}
|
1436
|
+
|
1437
|
+
@Override
|
1438
|
+
public void texParameterfv(int target, int pname, FloatBuffer params) {
|
1439
|
+
gl.glTexParameterfv(target, pname, params);
|
1440
|
+
}
|
1441
|
+
|
1442
|
+
@Override
|
1443
|
+
public void generateMipmap(int target) {
|
1444
|
+
gl.glGenerateMipmap(target);
|
1445
|
+
}
|
1446
|
+
|
1447
|
+
@Override
|
1448
|
+
public void genTextures(int n, IntBuffer textures) {
|
1449
|
+
gl.glGenTextures(n, textures);
|
1450
|
+
}
|
1451
|
+
|
1452
|
+
@Override
|
1453
|
+
public void deleteTextures(int n, IntBuffer textures) {
|
1454
|
+
gl.glDeleteTextures(n, textures);
|
1455
|
+
}
|
1456
|
+
|
1457
|
+
@Override
|
1458
|
+
public void getTexParameteriv(int target, int pname, IntBuffer params) {
|
1459
|
+
gl.glGetTexParameteriv(target, pname, params);
|
1460
|
+
}
|
1461
|
+
|
1462
|
+
@Override
|
1463
|
+
public void getTexParameterfv(int target, int pname, FloatBuffer params) {
|
1464
|
+
gl.glGetTexParameterfv(target, pname, params);
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
@Override
|
1468
|
+
public boolean isTexture(int texture) {
|
1469
|
+
return gl.glIsTexture(texture);
|
1470
|
+
}
|
1471
|
+
|
1472
|
+
@Override
|
1473
|
+
protected void activeTextureImpl(int texture) {
|
1474
|
+
gl.glActiveTexture(texture);
|
1475
|
+
}
|
1476
|
+
|
1477
|
+
@Override
|
1478
|
+
protected void bindTextureImpl(int target, int texture) {
|
1479
|
+
gl.glBindTexture(target, texture);
|
1480
|
+
}
|
1481
|
+
|
1482
|
+
///////////////////////////////////////////////////////////
|
1483
|
+
|
1484
|
+
// Shaders and Programs
|
1485
|
+
|
1486
|
+
@Override
|
1487
|
+
public int createShader(int type) {
|
1488
|
+
return gl2.glCreateShader(type);
|
1489
|
+
}
|
1490
|
+
|
1491
|
+
@Override
|
1492
|
+
public void shaderSource(int shader, String source) {
|
1493
|
+
gl2.glShaderSource(shader, 1, new String[] { source }, null, 0);
|
1494
|
+
}
|
1495
|
+
|
1496
|
+
@Override
|
1497
|
+
public void compileShader(int shader) {
|
1498
|
+
gl2.glCompileShader(shader);
|
1499
|
+
}
|
1500
|
+
|
1501
|
+
@Override
|
1502
|
+
public void releaseShaderCompiler() {
|
1503
|
+
gl2.glReleaseShaderCompiler();
|
1504
|
+
}
|
1505
|
+
|
1506
|
+
@Override
|
1507
|
+
public void deleteShader(int shader) {
|
1508
|
+
gl2.glDeleteShader(shader);
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
@Override
|
1512
|
+
public void shaderBinary(int count, IntBuffer shaders, int binaryFormat, Buffer binary, int length) {
|
1513
|
+
gl2.glShaderBinary(count, shaders, binaryFormat, binary, length);
|
1514
|
+
}
|
1515
|
+
|
1516
|
+
@Override
|
1517
|
+
public int createProgram() {
|
1518
|
+
return gl2.glCreateProgram();
|
1519
|
+
}
|
1520
|
+
|
1521
|
+
@Override
|
1522
|
+
public void attachShader(int program, int shader) {
|
1523
|
+
gl2.glAttachShader(program, shader);
|
1524
|
+
}
|
1525
|
+
|
1526
|
+
@Override
|
1527
|
+
public void detachShader(int program, int shader) {
|
1528
|
+
gl2.glDetachShader(program, shader);
|
1529
|
+
}
|
1530
|
+
|
1531
|
+
@Override
|
1532
|
+
public void linkProgram(int program) {
|
1533
|
+
gl2.glLinkProgram(program);
|
1534
|
+
}
|
1535
|
+
|
1536
|
+
@Override
|
1537
|
+
public void useProgram(int program) {
|
1538
|
+
gl2.glUseProgram(program);
|
1539
|
+
}
|
1540
|
+
|
1541
|
+
@Override
|
1542
|
+
public void deleteProgram(int program) {
|
1543
|
+
gl2.glDeleteProgram(program);
|
1544
|
+
}
|
1545
|
+
|
1546
|
+
@Override
|
1547
|
+
public String getActiveAttrib(int program, int index, IntBuffer size, IntBuffer type) {
|
1548
|
+
int[] tmp = {0, 0, 0};
|
1549
|
+
byte[] namebuf = new byte[1024];
|
1550
|
+
gl2.glGetActiveAttrib(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0);
|
1551
|
+
size.put(tmp[1]);
|
1552
|
+
type.put(tmp[2]);
|
1553
|
+
String name = new String(namebuf, 0, tmp[0]);
|
1554
|
+
return name;
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
@Override
|
1558
|
+
public int getAttribLocation(int program, String name) {
|
1559
|
+
return gl2.glGetAttribLocation(program, name);
|
1560
|
+
}
|
1561
|
+
|
1562
|
+
@Override
|
1563
|
+
public void bindAttribLocation(int program, int index, String name) {
|
1564
|
+
gl2.glBindAttribLocation(program, index, name);
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
@Override
|
1568
|
+
public int getUniformLocation(int program, String name) {
|
1569
|
+
return gl2.glGetUniformLocation(program, name);
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
@Override
|
1573
|
+
public String getActiveUniform(int program, int index, IntBuffer size, IntBuffer type) {
|
1574
|
+
int[] tmp= {0, 0, 0};
|
1575
|
+
byte[] namebuf = new byte[1024];
|
1576
|
+
gl2.glGetActiveUniform(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0);
|
1577
|
+
size.put(tmp[1]);
|
1578
|
+
type.put(tmp[2]);
|
1579
|
+
String name = new String(namebuf, 0, tmp[0]);
|
1580
|
+
return name;
|
1581
|
+
}
|
1582
|
+
|
1583
|
+
@Override
|
1584
|
+
public void uniform1i(int location, int value) {
|
1585
|
+
gl2.glUniform1i(location, value);
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
@Override
|
1589
|
+
public void uniform2i(int location, int value0, int value1) {
|
1590
|
+
gl2.glUniform2i(location, value0, value1);
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
@Override
|
1594
|
+
public void uniform3i(int location, int value0, int value1, int value2) {
|
1595
|
+
gl2.glUniform3i(location, value0, value1, value2);
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
@Override
|
1599
|
+
public void uniform4i(int location, int value0, int value1, int value2, int value3) {
|
1600
|
+
gl2.glUniform4i(location, value0, value1, value2, value3);
|
1601
|
+
}
|
1602
|
+
|
1603
|
+
@Override
|
1604
|
+
public void uniform1f(int location, float value) {
|
1605
|
+
gl2.glUniform1f(location, value);
|
1606
|
+
}
|
1607
|
+
|
1608
|
+
@Override
|
1609
|
+
public void uniform2f(int location, float value0, float value1) {
|
1610
|
+
gl2.glUniform2f(location, value0, value1);
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
@Override
|
1614
|
+
public void uniform3f(int location, float value0, float value1, float value2) {
|
1615
|
+
gl2.glUniform3f(location, value0, value1, value2);
|
1616
|
+
}
|
1617
|
+
|
1618
|
+
@Override
|
1619
|
+
public void uniform4f(int location, float value0, float value1, float value2, float value3) {
|
1620
|
+
gl2.glUniform4f(location, value0, value1, value2, value3);
|
1621
|
+
}
|
1622
|
+
|
1623
|
+
@Override
|
1624
|
+
public void uniform1iv(int location, int count, IntBuffer v) {
|
1625
|
+
gl2.glUniform1iv(location, count, v);
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
@Override
|
1629
|
+
public void uniform2iv(int location, int count, IntBuffer v) {
|
1630
|
+
gl2.glUniform2iv(location, count, v);
|
1631
|
+
}
|
1632
|
+
|
1633
|
+
@Override
|
1634
|
+
public void uniform3iv(int location, int count, IntBuffer v) {
|
1635
|
+
gl2.glUniform3iv(location, count, v);
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
@Override
|
1639
|
+
public void uniform4iv(int location, int count, IntBuffer v) {
|
1640
|
+
gl2.glUniform4iv(location, count, v);
|
1641
|
+
}
|
1642
|
+
|
1643
|
+
@Override
|
1644
|
+
public void uniform1fv(int location, int count, FloatBuffer v) {
|
1645
|
+
gl2.glUniform1fv(location, count, v);
|
1646
|
+
}
|
1647
|
+
|
1648
|
+
@Override
|
1649
|
+
public void uniform2fv(int location, int count, FloatBuffer v) {
|
1650
|
+
gl2.glUniform2fv(location, count, v);
|
1651
|
+
}
|
1652
|
+
|
1653
|
+
@Override
|
1654
|
+
public void uniform3fv(int location, int count, FloatBuffer v) {
|
1655
|
+
gl2.glUniform3fv(location, count, v);
|
1656
|
+
}
|
1657
|
+
|
1658
|
+
@Override
|
1659
|
+
public void uniform4fv(int location, int count, FloatBuffer v) {
|
1660
|
+
gl2.glUniform4fv(location, count, v);
|
1661
|
+
}
|
1662
|
+
|
1663
|
+
@Override
|
1664
|
+
public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer mat) {
|
1665
|
+
gl2.glUniformMatrix2fv(location, count, transpose, mat);
|
1666
|
+
}
|
1667
|
+
|
1668
|
+
@Override
|
1669
|
+
public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer mat) {
|
1670
|
+
gl2.glUniformMatrix3fv(location, count, transpose, mat);
|
1671
|
+
}
|
1672
|
+
|
1673
|
+
@Override
|
1674
|
+
public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer mat) {
|
1675
|
+
gl2.glUniformMatrix4fv(location, count, transpose, mat);
|
1676
|
+
}
|
1677
|
+
|
1678
|
+
@Override
|
1679
|
+
public void validateProgram(int program) {
|
1680
|
+
gl2.glValidateProgram(program);
|
1681
|
+
}
|
1682
|
+
|
1683
|
+
@Override
|
1684
|
+
public boolean isShader(int shader) {
|
1685
|
+
return gl2.glIsShader(shader);
|
1686
|
+
}
|
1687
|
+
|
1688
|
+
@Override
|
1689
|
+
public void getShaderiv(int shader, int pname, IntBuffer params) {
|
1690
|
+
gl2.glGetShaderiv(shader, pname, params);
|
1691
|
+
}
|
1692
|
+
|
1693
|
+
@Override
|
1694
|
+
public void getAttachedShaders(int program, int maxCount, IntBuffer count, IntBuffer shaders) {
|
1695
|
+
gl2.glGetAttachedShaders(program, maxCount, count, shaders);
|
1696
|
+
}
|
1697
|
+
|
1698
|
+
@Override
|
1699
|
+
public String getShaderInfoLog(int shader) {
|
1700
|
+
int[] val = { 0 };
|
1701
|
+
gl2.glGetShaderiv(shader, GL2ES2.GL_INFO_LOG_LENGTH, val, 0);
|
1702
|
+
int length = val[0];
|
1703
|
+
|
1704
|
+
byte[] log = new byte[length];
|
1705
|
+
gl2.glGetShaderInfoLog(shader, length, val, 0, log, 0);
|
1706
|
+
return new String(log);
|
1707
|
+
}
|
1708
|
+
|
1709
|
+
@Override
|
1710
|
+
public String getShaderSource(int shader) {
|
1711
|
+
int[] len = {0};
|
1712
|
+
byte[] buf = new byte[1024];
|
1713
|
+
gl2.glGetShaderSource(shader, 1024, len, 0, buf, 0);
|
1714
|
+
return new String(buf, 0, len[0]);
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
@Override
|
1718
|
+
public void getShaderPrecisionFormat(int shaderType, int precisionType, IntBuffer range, IntBuffer precision) {
|
1719
|
+
gl2.glGetShaderPrecisionFormat(shaderType, precisionType, range, precision);
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
@Override
|
1723
|
+
public void getVertexAttribfv(int index, int pname, FloatBuffer params) {
|
1724
|
+
gl2.glGetVertexAttribfv(index, pname, params);
|
1725
|
+
}
|
1726
|
+
|
1727
|
+
@Override
|
1728
|
+
public void getVertexAttribiv(int index, int pname, IntBuffer params) {
|
1729
|
+
gl2.glGetVertexAttribiv(index, pname, params);
|
1730
|
+
}
|
1731
|
+
|
1732
|
+
@Override
|
1733
|
+
public void getVertexAttribPointerv(int index, int pname, ByteBuffer data) {
|
1734
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glGetVertexAttribPointerv()"));
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
@Override
|
1738
|
+
public void getUniformfv(int program, int location, FloatBuffer params) {
|
1739
|
+
gl2.glGetUniformfv(program, location, params);
|
1740
|
+
}
|
1741
|
+
|
1742
|
+
@Override
|
1743
|
+
public void getUniformiv(int program, int location, IntBuffer params) {
|
1744
|
+
gl2.glGetUniformiv(program, location, params);
|
1745
|
+
}
|
1746
|
+
|
1747
|
+
@Override
|
1748
|
+
public boolean isProgram(int program) {
|
1749
|
+
return gl2.glIsProgram(program);
|
1750
|
+
}
|
1751
|
+
|
1752
|
+
@Override
|
1753
|
+
public void getProgramiv(int program, int pname, IntBuffer params) {
|
1754
|
+
gl2.glGetProgramiv(program, pname, params);
|
1755
|
+
}
|
1756
|
+
|
1757
|
+
@Override
|
1758
|
+
public String getProgramInfoLog(int program) {
|
1759
|
+
int[] val = { 0 };
|
1760
|
+
gl2.glGetProgramiv(program, GL2ES2.GL_INFO_LOG_LENGTH, val, 0);
|
1761
|
+
int length = val[0];
|
1762
|
+
|
1763
|
+
if (0 < length) {
|
1764
|
+
byte[] log = new byte[length];
|
1765
|
+
gl2.glGetProgramInfoLog(program, length, val, 0, log, 0);
|
1766
|
+
return new String(log);
|
1767
|
+
} else {
|
1768
|
+
return "Unknown error";
|
1769
|
+
}
|
1770
|
+
}
|
1771
|
+
|
1772
|
+
///////////////////////////////////////////////////////////
|
1773
|
+
|
1774
|
+
// Per-Fragment Operations
|
1775
|
+
|
1776
|
+
@Override
|
1777
|
+
public void scissor(int x, int y, int w, int h) {
|
1778
|
+
float scale = getPixelScale();
|
1779
|
+
gl.glScissor((int)scale * x, (int)(scale * y), (int)(scale * w), (int)(scale * h));
|
1699
1780
|
// gl.glScissor(x, y, w, h);
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1781
|
+
}
|
1782
|
+
|
1783
|
+
@Override
|
1784
|
+
public void sampleCoverage(float value, boolean invert) {
|
1785
|
+
gl2.glSampleCoverage(value, invert);
|
1786
|
+
}
|
1787
|
+
|
1788
|
+
@Override
|
1789
|
+
public void stencilFunc(int func, int ref, int mask) {
|
1790
|
+
gl2.glStencilFunc(func, ref, mask);
|
1791
|
+
}
|
1792
|
+
|
1793
|
+
@Override
|
1794
|
+
public void stencilFuncSeparate(int face, int func, int ref, int mask) {
|
1795
|
+
gl2.glStencilFuncSeparate(face, func, ref, mask);
|
1796
|
+
}
|
1797
|
+
|
1798
|
+
@Override
|
1799
|
+
public void stencilOp(int sfail, int dpfail, int dppass) {
|
1800
|
+
gl2.glStencilOp(sfail, dpfail, dppass);
|
1801
|
+
}
|
1802
|
+
|
1803
|
+
@Override
|
1804
|
+
public void stencilOpSeparate(int face, int sfail, int dpfail, int dppass) {
|
1805
|
+
gl2.glStencilOpSeparate(face, sfail, dpfail, dppass);
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
@Override
|
1809
|
+
public void depthFunc(int func) {
|
1810
|
+
gl.glDepthFunc(func);
|
1811
|
+
}
|
1812
|
+
|
1813
|
+
@Override
|
1814
|
+
public void blendEquation(int mode) {
|
1815
|
+
gl.glBlendEquation(mode);
|
1816
|
+
}
|
1817
|
+
|
1818
|
+
@Override
|
1819
|
+
public void blendEquationSeparate(int modeRGB, int modeAlpha) {
|
1820
|
+
gl.glBlendEquationSeparate(modeRGB, modeAlpha);
|
1821
|
+
}
|
1822
|
+
|
1823
|
+
@Override
|
1824
|
+
public void blendFunc(int src, int dst) {
|
1825
|
+
gl.glBlendFunc(src, dst);
|
1826
|
+
}
|
1827
|
+
|
1828
|
+
@Override
|
1829
|
+
public void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
|
1830
|
+
gl.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
1831
|
+
}
|
1832
|
+
|
1833
|
+
@Override
|
1834
|
+
public void blendColor(float red, float green, float blue, float alpha) {
|
1835
|
+
gl2.glBlendColor(red, green, blue, alpha);
|
1836
|
+
}
|
1837
|
+
|
1838
|
+
// Whole Framebuffer Operations
|
1839
|
+
|
1840
|
+
@Override
|
1841
|
+
public void colorMask(boolean r, boolean g, boolean b, boolean a) {
|
1842
|
+
gl.glColorMask(r, g, b, a);
|
1843
|
+
}
|
1844
|
+
|
1845
|
+
@Override
|
1846
|
+
public void depthMask(boolean mask) {
|
1847
|
+
gl.glDepthMask(mask);
|
1848
|
+
}
|
1849
|
+
|
1850
|
+
@Override
|
1851
|
+
public void stencilMask(int mask) {
|
1852
|
+
gl.glStencilMask(mask);
|
1853
|
+
}
|
1854
|
+
|
1855
|
+
@Override
|
1856
|
+
public void stencilMaskSeparate(int face, int mask) {
|
1857
|
+
gl2.glStencilMaskSeparate(face, mask);
|
1858
|
+
}
|
1859
|
+
|
1860
|
+
@Override
|
1861
|
+
public void clearColor(float r, float g, float b, float a) {
|
1862
|
+
gl.glClearColor(r, g, b, a);
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
@Override
|
1866
|
+
public void clearDepth(float d) {
|
1867
|
+
gl.glClearDepth(d);
|
1868
|
+
}
|
1869
|
+
|
1870
|
+
@Override
|
1871
|
+
public void clearStencil(int s) {
|
1872
|
+
gl.glClearStencil(s);
|
1873
|
+
}
|
1874
|
+
|
1875
|
+
@Override
|
1876
|
+
public void clear(int buf) {
|
1877
|
+
gl.glClear(buf);
|
1878
|
+
}
|
1879
|
+
|
1880
|
+
///////////////////////////////////////////////////////////
|
1881
|
+
|
1882
|
+
// Framebuffers Objects
|
1883
|
+
|
1884
|
+
@Override
|
1885
|
+
protected void bindFramebufferImpl(int target, int framebuffer) {
|
1886
|
+
gl.glBindFramebuffer(target, framebuffer);
|
1887
|
+
}
|
1888
|
+
|
1889
|
+
@Override
|
1890
|
+
public void deleteFramebuffers(int n, IntBuffer framebuffers) {
|
1891
|
+
gl.glDeleteFramebuffers(n, framebuffers);
|
1892
|
+
}
|
1893
|
+
|
1894
|
+
@Override
|
1895
|
+
public void genFramebuffers(int n, IntBuffer framebuffers) {
|
1896
|
+
gl.glGenFramebuffers(n, framebuffers);
|
1897
|
+
}
|
1898
|
+
|
1899
|
+
@Override
|
1900
|
+
public void bindRenderbuffer(int target, int renderbuffer) {
|
1901
|
+
gl.glBindRenderbuffer(target, renderbuffer);
|
1902
|
+
}
|
1903
|
+
|
1904
|
+
@Override
|
1905
|
+
public void deleteRenderbuffers(int n, IntBuffer renderbuffers) {
|
1906
|
+
gl.glDeleteRenderbuffers(n, renderbuffers);
|
1907
|
+
}
|
1908
|
+
|
1909
|
+
@Override
|
1910
|
+
public void genRenderbuffers(int n, IntBuffer renderbuffers) {
|
1911
|
+
gl.glGenRenderbuffers(n, renderbuffers);
|
1912
|
+
}
|
1913
|
+
|
1914
|
+
@Override
|
1915
|
+
public void renderbufferStorage(int target, int internalFormat, int width, int height) {
|
1916
|
+
gl.glRenderbufferStorage(target, internalFormat, width, height);
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
@Override
|
1920
|
+
public void framebufferRenderbuffer(int target, int attachment, int rendbuferfTarget, int renderbuffer) {
|
1921
|
+
gl.glFramebufferRenderbuffer(target, attachment, rendbuferfTarget, renderbuffer);
|
1922
|
+
}
|
1923
|
+
|
1924
|
+
@Override
|
1925
|
+
public void framebufferTexture2D(int target, int attachment, int texTarget, int texture, int level) {
|
1926
|
+
gl.glFramebufferTexture2D(target, attachment, texTarget, texture, level);
|
1927
|
+
}
|
1928
|
+
|
1929
|
+
@Override
|
1930
|
+
public int checkFramebufferStatus(int target) {
|
1931
|
+
return gl.glCheckFramebufferStatus(target);
|
1932
|
+
}
|
1933
|
+
|
1934
|
+
@Override
|
1935
|
+
public boolean isFramebuffer(int framebuffer) {
|
1936
|
+
return gl2.glIsFramebuffer(framebuffer);
|
1937
|
+
}
|
1938
|
+
|
1939
|
+
@Override
|
1940
|
+
public void getFramebufferAttachmentParameteriv(int target, int attachment, int pname, IntBuffer params) {
|
1941
|
+
gl2.glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
|
1942
|
+
}
|
1943
|
+
|
1944
|
+
@Override
|
1945
|
+
public boolean isRenderbuffer(int renderbuffer) {
|
1946
|
+
return gl2.glIsRenderbuffer(renderbuffer);
|
1947
|
+
}
|
1948
|
+
|
1949
|
+
@Override
|
1950
|
+
public void getRenderbufferParameteriv(int target, int pname, IntBuffer params) {
|
1951
|
+
gl2.glGetRenderbufferParameteriv(target, pname, params);
|
1952
|
+
}
|
1953
|
+
|
1954
|
+
@Override
|
1955
|
+
public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) {
|
1956
|
+
if (gl2x != null) {
|
1957
|
+
gl2x.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
1958
|
+
} else if (gl3 != null) {
|
1959
|
+
gl3.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
1960
|
+
} else if (gl3es3 != null) {
|
1961
|
+
gl3es3.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
1962
|
+
} else {
|
1963
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glBlitFramebuffer()"));
|
1964
|
+
}
|
1965
|
+
}
|
1966
|
+
|
1967
|
+
@Override
|
1968
|
+
public void renderbufferStorageMultisample(int target, int samples, int format, int width, int height) {
|
1969
|
+
if (gl2x != null) {
|
1970
|
+
gl2x.glRenderbufferStorageMultisample(target, samples, format, width, height);
|
1971
|
+
} else if (gl3 != null) {
|
1972
|
+
gl3.glRenderbufferStorageMultisample(target, samples, format, width, height);
|
1973
|
+
} else if (gl3es3 != null) {
|
1974
|
+
gl3es3.glRenderbufferStorageMultisample(target, samples, format, width, height);
|
1975
|
+
} else {
|
1976
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glRenderbufferStorageMultisample()"));
|
1977
|
+
}
|
1978
|
+
}
|
1979
|
+
|
1980
|
+
@Override
|
1981
|
+
public void readBuffer(int buf) {
|
1982
|
+
if (gl2x != null) {
|
1983
|
+
gl2x.glReadBuffer(buf);
|
1984
|
+
} else if (gl3 != null) {
|
1985
|
+
gl3.glReadBuffer(buf);
|
1986
|
+
} else if (gl3es3 != null) {
|
1987
|
+
gl3es3.glReadBuffer(buf);
|
1988
|
+
} else {
|
1989
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glReadBuffer()"));
|
1990
|
+
}
|
1991
|
+
}
|
1992
|
+
|
1993
|
+
@Override
|
1994
|
+
public void drawBuffer(int buf) {
|
1995
|
+
if (gl2x != null) {
|
1996
|
+
gl2x.glDrawBuffer(buf);
|
1997
|
+
} else if (gl3 != null) {
|
1998
|
+
gl3.glDrawBuffer(buf);
|
1999
|
+
} else if (gl3es3 != null) {
|
2000
|
+
IntBuffer intBuffer = IntBuffer.allocate(1);
|
2001
|
+
intBuffer.put(buf);
|
2002
|
+
intBuffer.rewind();
|
2003
|
+
gl3es3.glDrawBuffers(1, intBuffer);
|
2004
|
+
} else {
|
2005
|
+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glDrawBuffer()"));
|
2006
|
+
}
|
2007
|
+
}
|
1925
2008
|
}
|