propane 2.7.2-java → 2.8.0.pre-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -0
  3. data/CHANGELOG.md +1 -1
  4. data/README.md +10 -8
  5. data/Rakefile +1 -1
  6. data/lib/propane/app.rb +3 -3
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{processing-core.jar → propane-2.8.0.jar} +0 -0
  9. data/library/control_panel/control_panel.rb +3 -2
  10. data/pom.rb +89 -88
  11. data/pom.xml +75 -46
  12. data/propane.gemspec +1 -2
  13. data/src/main/java/japplemenubar/JAppleMenuBar.java +88 -0
  14. data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  15. data/src/{monkstone → main/java/monkstone}/ColorUtil.java +0 -0
  16. data/src/{monkstone → main/java/monkstone}/MathToolModule.java +0 -0
  17. data/src/{monkstone → main/java/monkstone}/PropaneLibrary.java +0 -0
  18. data/src/{monkstone → main/java/monkstone}/core/LibraryProxy.java +0 -0
  19. data/src/{monkstone → main/java/monkstone}/fastmath/Deglut.java +0 -0
  20. data/src/{monkstone → main/java/monkstone}/fastmath/package-info.java +0 -0
  21. data/src/{monkstone → main/java/monkstone}/filechooser/Chooser.java +0 -0
  22. data/src/{monkstone → main/java/monkstone}/noise/SimplexNoise.java +0 -0
  23. data/src/{monkstone → main/java/monkstone}/slider/CustomHorizontalSlider.java +0 -0
  24. data/src/{monkstone → main/java/monkstone}/slider/CustomVerticalSlider.java +0 -0
  25. data/src/{monkstone → main/java/monkstone}/slider/SimpleHorizontalSlider.java +0 -0
  26. data/src/{monkstone → main/java/monkstone}/slider/SimpleSlider.java +0 -0
  27. data/src/{monkstone → main/java/monkstone}/slider/SimpleVerticalSlider.java +0 -0
  28. data/src/{monkstone → main/java/monkstone}/slider/Slider.java +0 -0
  29. data/src/{monkstone → main/java/monkstone}/slider/SliderBar.java +0 -0
  30. data/src/{monkstone → main/java/monkstone}/slider/SliderGroup.java +0 -0
  31. data/src/{monkstone → main/java/monkstone}/slider/WheelHandler.java +0 -0
  32. data/src/{monkstone → main/java/monkstone}/vecmath/AppRender.java +0 -0
  33. data/src/{monkstone → main/java/monkstone}/vecmath/JRender.java +0 -0
  34. data/src/{monkstone → main/java/monkstone}/vecmath/ShapeRender.java +0 -0
  35. data/src/{monkstone → main/java/monkstone}/vecmath/package-info.java +0 -0
  36. data/src/{monkstone → main/java/monkstone}/vecmath/vec2/Vec2.java +0 -0
  37. data/src/{monkstone → main/java/monkstone}/vecmath/vec2/package-info.java +0 -0
  38. data/src/{monkstone → main/java/monkstone}/vecmath/vec3/Vec3.java +0 -0
  39. data/src/{monkstone → main/java/monkstone}/vecmath/vec3/package-info.java +0 -0
  40. data/src/{monkstone → main/java/monkstone}/videoevent/VideoInterface.java +0 -0
  41. data/src/{monkstone → main/java/monkstone}/videoevent/package-info.java +0 -0
  42. data/src/main/java/processing/awt/PGraphicsJava2D.java +3029 -0
  43. data/src/main/java/processing/awt/PShapeJava2D.java +377 -0
  44. data/src/main/java/processing/awt/PSurfaceAWT.java +1567 -0
  45. data/src/main/java/processing/core/PApplet.java +15709 -0
  46. data/src/main/java/processing/core/PConstants.java +527 -0
  47. data/src/main/java/processing/core/PFont.java +1098 -0
  48. data/src/main/java/processing/core/PGraphics.java +8467 -0
  49. data/src/main/java/processing/core/PImage.java +3438 -0
  50. data/src/main/java/processing/core/PMatrix.java +208 -0
  51. data/src/main/java/processing/core/PMatrix2D.java +534 -0
  52. data/src/main/java/processing/core/PMatrix3D.java +877 -0
  53. data/src/main/java/processing/core/PShape.java +3445 -0
  54. data/src/main/java/processing/core/PShapeOBJ.java +469 -0
  55. data/src/main/java/processing/core/PShapeSVG.java +1787 -0
  56. data/src/main/java/processing/core/PStyle.java +63 -0
  57. data/src/main/java/processing/core/PSurface.java +161 -0
  58. data/src/main/java/processing/core/PSurfaceNone.java +374 -0
  59. data/src/main/java/processing/core/PVector.java +1063 -0
  60. data/src/main/java/processing/data/FloatDict.java +829 -0
  61. data/src/main/java/processing/data/FloatList.java +912 -0
  62. data/src/main/java/processing/data/IntDict.java +796 -0
  63. data/src/main/java/processing/data/IntList.java +913 -0
  64. data/src/main/java/processing/data/JSONArray.java +1260 -0
  65. data/src/main/java/processing/data/JSONObject.java +2282 -0
  66. data/src/main/java/processing/data/JSONTokener.java +435 -0
  67. data/src/main/java/processing/data/Sort.java +46 -0
  68. data/src/main/java/processing/data/StringDict.java +601 -0
  69. data/src/main/java/processing/data/StringList.java +775 -0
  70. data/src/main/java/processing/data/Table.java +4923 -0
  71. data/src/main/java/processing/data/TableRow.java +198 -0
  72. data/src/main/java/processing/data/XML.java +1149 -0
  73. data/src/main/java/processing/event/Event.java +125 -0
  74. data/src/main/java/processing/event/KeyEvent.java +70 -0
  75. data/src/main/java/processing/event/MouseEvent.java +149 -0
  76. data/src/main/java/processing/event/TouchEvent.java +57 -0
  77. data/src/main/java/processing/opengl/FontTexture.java +379 -0
  78. data/src/main/java/processing/opengl/FrameBuffer.java +503 -0
  79. data/src/main/java/processing/opengl/LinePath.java +623 -0
  80. data/src/main/java/processing/opengl/LineStroker.java +685 -0
  81. data/src/main/java/processing/opengl/PGL.java +3366 -0
  82. data/src/main/java/processing/opengl/PGraphics2D.java +615 -0
  83. data/src/main/java/processing/opengl/PGraphics3D.java +281 -0
  84. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13634 -0
  85. data/src/main/java/processing/opengl/PJOGL.java +1966 -0
  86. data/src/main/java/processing/opengl/PShader.java +1478 -0
  87. data/src/main/java/processing/opengl/PShapeOpenGL.java +5234 -0
  88. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1315 -0
  89. data/src/main/java/processing/opengl/Texture.java +1670 -0
  90. data/src/main/java/processing/opengl/VertexBuffer.java +88 -0
  91. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  92. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  93. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  94. data/src/main/java/processing/opengl/cursors/license.txt +27 -0
  95. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  96. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  97. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  98. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
  99. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +34 -0
  100. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +33 -0
  101. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +154 -0
  102. data/src/main/java/processing/opengl/shaders/LightVert.glsl +151 -0
  103. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +32 -0
  104. data/src/main/java/processing/opengl/shaders/LineVert.glsl +100 -0
  105. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
  106. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +32 -0
  107. data/src/main/java/processing/opengl/shaders/PointVert.glsl +56 -0
  108. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +37 -0
  109. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
  110. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +160 -0
  111. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
  112. data/src/main/java/processing/opengl/shaders/TexVert.glsl +38 -0
  113. data/src/main/resources/icon/icon-1024.png +0 -0
  114. data/src/main/resources/icon/icon-128.png +0 -0
  115. data/src/main/resources/icon/icon-16.png +0 -0
  116. data/src/main/resources/icon/icon-256.png +0 -0
  117. data/src/main/resources/icon/icon-32.png +0 -0
  118. data/src/main/resources/icon/icon-48.png +0 -0
  119. data/src/main/resources/icon/icon-512.png +0 -0
  120. data/src/main/resources/icon/icon-64.png +0 -0
  121. data/src/main/resources/license.txt +508 -0
  122. data/vendors/Rakefile +5 -20
  123. metadata +115 -33
  124. data/lib/propane.jar +0 -0
@@ -0,0 +1,503 @@
1
+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+ /*
4
+ Part of the Processing project - http://processing.org
5
+
6
+ Copyright (c) 2012-15 The Processing Foundation
7
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
8
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
9
+
10
+ This library is free software; you can redistribute it and/or
11
+ modify it under the terms of the GNU Lesser General Public
12
+ License as published by the Free Software Foundation, version 2.1.
13
+
14
+ This library is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ Lesser General Public License for more details.
18
+
19
+ You should have received a copy of the GNU Lesser General
20
+ Public License along with this library; if not, write to the
21
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
+ Boston, MA 02111-1307 USA
23
+ */
24
+
25
+ package processing.opengl;
26
+
27
+ import processing.core.PApplet;
28
+ import processing.core.PConstants;
29
+ import processing.opengl.PGraphicsOpenGL.GLResourceFrameBuffer;
30
+
31
+ import java.nio.IntBuffer;
32
+
33
+ /**
34
+ * Encapsulates a Frame Buffer Object for offscreen rendering.
35
+ * When created with onscreen == true, it represents the normal
36
+ * framebuffer. Needed by the stack mechanism in OPENGL2 to return
37
+ * to onscreen rendering after a sequence of pushFramebuffer calls.
38
+ * It transparently handles the situations when the FBO extension is
39
+ * not available.
40
+ *
41
+ * By Andres Colubri.
42
+ */
43
+
44
+ public class FrameBuffer implements PConstants {
45
+ protected PGraphicsOpenGL pg;
46
+ protected PGL pgl;
47
+ protected int context; // The context that created this framebuffer.
48
+
49
+ public int glFbo;
50
+ public int glDepth;
51
+ public int glStencil;
52
+ public int glDepthStencil;
53
+ public int glMultisample;
54
+ public int width;
55
+ public int height;
56
+ private GLResourceFrameBuffer glres;
57
+
58
+ protected int depthBits;
59
+ protected int stencilBits;
60
+ protected boolean packedDepthStencil;
61
+
62
+ protected boolean multisample;
63
+ protected int nsamples;
64
+
65
+ protected int numColorBuffers;
66
+ protected Texture[] colorBufferTex;
67
+
68
+ protected boolean screenFb;
69
+ protected boolean noDepth;
70
+
71
+ protected IntBuffer pixelBuffer;
72
+
73
+
74
+ FrameBuffer(PGraphicsOpenGL pg) {
75
+ this.pg = pg;
76
+ pgl = pg.pgl;
77
+ context = pgl.createEmptyContext();
78
+ }
79
+
80
+
81
+ FrameBuffer(PGraphicsOpenGL pg, int w, int h, int samples, int colorBuffers,
82
+ int depthBits, int stencilBits, boolean packedDepthStencil,
83
+ boolean screen) {
84
+ this(pg);
85
+
86
+ glFbo = 0;
87
+ glDepth = 0;
88
+ glStencil = 0;
89
+ glDepthStencil = 0;
90
+ glMultisample = 0;
91
+
92
+ if (screen) {
93
+ // If this framebuffer is used to represent a on-screen buffer,
94
+ // then it doesn't make it sense for it to have multisampling,
95
+ // color, depth or stencil buffers.
96
+ depthBits = stencilBits = samples = colorBuffers = 0;
97
+ }
98
+
99
+ width = w;
100
+ height = h;
101
+
102
+ if (1 < samples) {
103
+ multisample = true;
104
+ nsamples = samples;
105
+ } else {
106
+ multisample = false;
107
+ nsamples = 1;
108
+ }
109
+
110
+ numColorBuffers = colorBuffers;
111
+ colorBufferTex = new Texture[numColorBuffers];
112
+ for (int i = 0; i < numColorBuffers; i++) {
113
+ colorBufferTex[i] = null;
114
+ }
115
+
116
+ if (depthBits < 1 && stencilBits < 1) {
117
+ this.depthBits = 0;
118
+ this.stencilBits = 0;
119
+ this.packedDepthStencil = false;
120
+ } else {
121
+ if (packedDepthStencil) {
122
+ // When combined depth/stencil format is required, the depth and stencil
123
+ // bits are overriden and the 24/8 combination for a 32 bits surface is
124
+ // used.
125
+ this.depthBits = 24;
126
+ this.stencilBits = 8;
127
+ this.packedDepthStencil = true;
128
+ } else {
129
+ this.depthBits = depthBits;
130
+ this.stencilBits = stencilBits;
131
+ this.packedDepthStencil = false;
132
+ }
133
+ }
134
+
135
+ screenFb = screen;
136
+
137
+ allocate();
138
+ noDepth = false;
139
+
140
+ pixelBuffer = null;
141
+ }
142
+
143
+
144
+ FrameBuffer(PGraphicsOpenGL pg, int w, int h) {
145
+ this(pg, w, h, 1, 1, 0, 0, false, false);
146
+ }
147
+
148
+
149
+ FrameBuffer(PGraphicsOpenGL pg, int w, int h, boolean screen) {
150
+ this(pg, w, h, 1, 1, 0, 0, false, screen);
151
+ }
152
+
153
+
154
+ public void clear() {
155
+ pg.pushFramebuffer();
156
+ pg.setFramebuffer(this);
157
+ pgl.clearDepth(1);
158
+ pgl.clearStencil(0);
159
+ pgl.clearColor(0, 0, 0, 0);
160
+ pgl.clear(PGL.DEPTH_BUFFER_BIT |
161
+ PGL.STENCIL_BUFFER_BIT |
162
+ PGL.COLOR_BUFFER_BIT);
163
+ pg.popFramebuffer();
164
+ }
165
+
166
+ public void copyColor(FrameBuffer dest) {
167
+ copy(dest, PGL.COLOR_BUFFER_BIT);
168
+ }
169
+
170
+ public void copyDepth(FrameBuffer dest) {
171
+ copy(dest, PGL.DEPTH_BUFFER_BIT);
172
+ }
173
+
174
+ public void copyStencil(FrameBuffer dest) {
175
+ copy(dest, PGL.STENCIL_BUFFER_BIT);
176
+ }
177
+
178
+ public void copy(FrameBuffer dest, int mask) {
179
+ pgl.bindFramebufferImpl(PGL.READ_FRAMEBUFFER, this.glFbo);
180
+ pgl.bindFramebufferImpl(PGL.DRAW_FRAMEBUFFER, dest.glFbo);
181
+ pgl.blitFramebuffer(0, 0, this.width, this.height,
182
+ 0, 0, dest.width, dest.height, mask, PGL.NEAREST);
183
+ pgl.bindFramebufferImpl(PGL.READ_FRAMEBUFFER, pg.getCurrentFB().glFbo);
184
+ pgl.bindFramebufferImpl(PGL.DRAW_FRAMEBUFFER, pg.getCurrentFB().glFbo);
185
+ }
186
+
187
+ public void bind() {
188
+ pgl.bindFramebufferImpl(PGL.FRAMEBUFFER, glFbo);
189
+ }
190
+
191
+ public void disableDepthTest() {
192
+ noDepth = true;
193
+ }
194
+
195
+ public void finish() {
196
+ if (noDepth) {
197
+ // No need to clear depth buffer because depth testing was disabled.
198
+ if (pg.getHint(ENABLE_DEPTH_TEST)) {
199
+ pgl.enable(PGL.DEPTH_TEST);
200
+ } else {
201
+ pgl.disable(PGL.DEPTH_TEST);
202
+ }
203
+ }
204
+ }
205
+
206
+ public void readPixels() {
207
+ if (pixelBuffer == null) createPixelBuffer();
208
+ pixelBuffer.rewind();
209
+ pgl.readPixels(0, 0, width, height, PGL.RGBA, PGL.UNSIGNED_BYTE,
210
+ pixelBuffer);
211
+ }
212
+
213
+ public void getPixels(int[] pixels) {
214
+ if (pixelBuffer != null) {
215
+ pixelBuffer.get(pixels, 0, pixels.length);
216
+ pixelBuffer.rewind();
217
+ }
218
+ }
219
+
220
+ public IntBuffer getPixelBuffer() {
221
+ return pixelBuffer;
222
+ }
223
+
224
+ public boolean hasDepthBuffer() {
225
+ return 0 < depthBits;
226
+ }
227
+
228
+ public boolean hasStencilBuffer() {
229
+ return 0 < stencilBits;
230
+ }
231
+
232
+ public void setFBO(int id) {
233
+ if (screenFb) {
234
+ glFbo = id;
235
+ }
236
+ }
237
+
238
+ ///////////////////////////////////////////////////////////
239
+
240
+ // Color buffer setters.
241
+
242
+
243
+ public void setColorBuffer(Texture tex) {
244
+ setColorBuffers(new Texture[] { tex }, 1);
245
+ }
246
+
247
+
248
+ public void setColorBuffers(Texture[] textures) {
249
+ setColorBuffers(textures, textures.length);
250
+ }
251
+
252
+
253
+ public void setColorBuffers(Texture[] textures, int n) {
254
+ if (screenFb) return;
255
+
256
+ if (numColorBuffers != PApplet.min(n, textures.length)) {
257
+ throw new RuntimeException("Wrong number of textures to set the color " +
258
+ "buffers.");
259
+ }
260
+
261
+ for (int i = 0; i < numColorBuffers; i++) {
262
+ colorBufferTex[i] = textures[i];
263
+ }
264
+
265
+ pg.pushFramebuffer();
266
+ pg.setFramebuffer(this);
267
+
268
+ // Making sure nothing is attached.
269
+ for (int i = 0; i < numColorBuffers; i++) {
270
+ pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
271
+ PGL.TEXTURE_2D, 0, 0);
272
+ }
273
+
274
+ for (int i = 0; i < numColorBuffers; i++) {
275
+ pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
276
+ colorBufferTex[i].glTarget,
277
+ colorBufferTex[i].glName, 0);
278
+ }
279
+
280
+ pgl.validateFramebuffer();
281
+
282
+ pg.popFramebuffer();
283
+ }
284
+
285
+
286
+ public void swapColorBuffers() {
287
+ for (int i = 0; i < numColorBuffers - 1; i++) {
288
+ int i1 = (i + 1);
289
+ Texture tmp = colorBufferTex[i];
290
+ colorBufferTex[i] = colorBufferTex[i1];
291
+ colorBufferTex[i1] = tmp;
292
+ }
293
+
294
+ pg.pushFramebuffer();
295
+ pg.setFramebuffer(this);
296
+ for (int i = 0; i < numColorBuffers; i++) {
297
+ pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
298
+ colorBufferTex[i].glTarget,
299
+ colorBufferTex[i].glName, 0);
300
+ }
301
+ pgl.validateFramebuffer();
302
+
303
+ pg.popFramebuffer();
304
+ }
305
+
306
+
307
+ public int getDefaultReadBuffer() {
308
+ if (screenFb) {
309
+ return pgl.getDefaultReadBuffer();
310
+ } else {
311
+ return PGL.COLOR_ATTACHMENT0;
312
+ }
313
+ }
314
+
315
+
316
+ public int getDefaultDrawBuffer() {
317
+ if (screenFb) {
318
+ return pgl.getDefaultDrawBuffer();
319
+ } else {
320
+ return PGL.COLOR_ATTACHMENT0;
321
+ }
322
+ }
323
+
324
+
325
+ ///////////////////////////////////////////////////////////
326
+
327
+ // Allocate/release framebuffer.
328
+
329
+
330
+ protected void allocate() {
331
+ dispose(); // Just in the case this object is being re-allocated.
332
+
333
+ context = pgl.getCurrentContext();
334
+ glres = new GLResourceFrameBuffer(this); // create the FBO resources...
335
+
336
+ if (screenFb) {
337
+ glFbo = 0;
338
+ } else {
339
+ if (multisample) {
340
+ initColorBufferMultisample();
341
+ }
342
+
343
+ if (packedDepthStencil) {
344
+ initPackedDepthStencilBuffer();
345
+ } else {
346
+ if (0 < depthBits) {
347
+ initDepthBuffer();
348
+ }
349
+ if (0 < stencilBits) {
350
+ initStencilBuffer();
351
+ }
352
+ }
353
+ }
354
+ }
355
+
356
+
357
+ protected void dispose() {
358
+ if (screenFb) return;
359
+ if (glres != null) {
360
+ glres.dispose();
361
+ glFbo = 0;
362
+ glDepth = 0;
363
+ glStencil = 0;
364
+ glMultisample = 0;
365
+ glDepthStencil = 0;
366
+ glres = null;
367
+ }
368
+ }
369
+
370
+
371
+ protected boolean contextIsOutdated() {
372
+ if (screenFb) return false;
373
+
374
+ boolean outdated = !pgl.contextIsCurrent(context);
375
+ if (outdated) {
376
+ dispose();
377
+ for (int i = 0; i < numColorBuffers; i++) {
378
+ colorBufferTex[i] = null;
379
+ }
380
+ }
381
+ return outdated;
382
+ }
383
+
384
+
385
+ protected void initColorBufferMultisample() {
386
+ if (screenFb) return;
387
+
388
+ pg.pushFramebuffer();
389
+ pg.setFramebuffer(this);
390
+
391
+ pgl.bindRenderbuffer(PGL.RENDERBUFFER, glMultisample);
392
+ pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples,
393
+ PGL.RGBA8, width, height);
394
+ pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0,
395
+ PGL.RENDERBUFFER, glMultisample);
396
+
397
+ pg.popFramebuffer();
398
+ }
399
+
400
+
401
+ protected void initPackedDepthStencilBuffer() {
402
+ if (screenFb) return;
403
+
404
+ if (width == 0 || height == 0) {
405
+ throw new RuntimeException("PFramebuffer: size undefined.");
406
+ }
407
+
408
+ pg.pushFramebuffer();
409
+ pg.setFramebuffer(this);
410
+
411
+ pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepthStencil);
412
+
413
+ if (multisample) {
414
+ pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples,
415
+ PGL.DEPTH24_STENCIL8, width, height);
416
+ } else {
417
+ pgl.renderbufferStorage(PGL.RENDERBUFFER, PGL.DEPTH24_STENCIL8,
418
+ width, height);
419
+ }
420
+
421
+ pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.DEPTH_ATTACHMENT,
422
+ PGL.RENDERBUFFER, glDepthStencil);
423
+ pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.STENCIL_ATTACHMENT,
424
+ PGL.RENDERBUFFER, glDepthStencil);
425
+
426
+ pg.popFramebuffer();
427
+ }
428
+
429
+
430
+ protected void initDepthBuffer() {
431
+ if (screenFb) return;
432
+
433
+ if (width == 0 || height == 0) {
434
+ throw new RuntimeException("PFramebuffer: size undefined.");
435
+ }
436
+
437
+ pg.pushFramebuffer();
438
+ pg.setFramebuffer(this);
439
+
440
+ pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepth);
441
+
442
+ int glConst = PGL.DEPTH_COMPONENT16;
443
+ if (depthBits == 16) {
444
+ glConst = PGL.DEPTH_COMPONENT16;
445
+ } else if (depthBits == 24) {
446
+ glConst = PGL.DEPTH_COMPONENT24;
447
+ } else if (depthBits == 32) {
448
+ glConst = PGL.DEPTH_COMPONENT32;
449
+ }
450
+
451
+ if (multisample) {
452
+ pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
453
+ width, height);
454
+ } else {
455
+ pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height);
456
+ }
457
+
458
+ pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.DEPTH_ATTACHMENT,
459
+ PGL.RENDERBUFFER, glDepth);
460
+
461
+ pg.popFramebuffer();
462
+ }
463
+
464
+
465
+ protected void initStencilBuffer() {
466
+ if (screenFb) return;
467
+
468
+ if (width == 0 || height == 0) {
469
+ throw new RuntimeException("PFramebuffer: size undefined.");
470
+ }
471
+
472
+ pg.pushFramebuffer();
473
+ pg.setFramebuffer(this);
474
+
475
+ pgl.bindRenderbuffer(PGL.RENDERBUFFER, glStencil);
476
+
477
+ int glConst = PGL.STENCIL_INDEX1;
478
+ if (stencilBits == 1) {
479
+ glConst = PGL.STENCIL_INDEX1;
480
+ } else if (stencilBits == 4) {
481
+ glConst = PGL.STENCIL_INDEX4;
482
+ } else if (stencilBits == 8) {
483
+ glConst = PGL.STENCIL_INDEX8;
484
+ }
485
+ if (multisample) {
486
+ pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
487
+ width, height);
488
+ } else {
489
+ pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height);
490
+ }
491
+
492
+ pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.STENCIL_ATTACHMENT,
493
+ PGL.RENDERBUFFER, glStencil);
494
+
495
+ pg.popFramebuffer();
496
+ }
497
+
498
+
499
+ protected void createPixelBuffer() {
500
+ pixelBuffer = IntBuffer.allocate(width * height);
501
+ pixelBuffer.rewind();
502
+ }
503
+ }