propane 3.1.0.pre-java → 3.2.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -0
- data/CHANGELOG.md +1 -5
- data/README.md +23 -12
- data/Rakefile +23 -12
- data/lib/propane/helpers/version_error.rb +6 -0
- data/lib/propane/runner.rb +12 -0
- data/lib/propane/version.rb +1 -1
- data/library/slider/slider.rb +1 -1
- data/mvnw +234 -0
- data/mvnw.cmd +145 -0
- data/pom.xml +28 -27
- data/propane.gemspec +2 -2
- data/src/main/java/japplemenubar/JAppleMenuBar.java +41 -47
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/MathToolModule.java +12 -11
- data/src/main/java/monkstone/PropaneLibrary.java +9 -10
- data/src/main/java/monkstone/core/LibraryProxy.java +124 -113
- data/src/main/java/monkstone/fastmath/Deglut.java +86 -89
- data/src/main/java/monkstone/filechooser/Chooser.java +7 -13
- data/src/main/java/monkstone/noise/SimplexNoise.java +0 -1
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +4 -4
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +9 -9
- data/src/main/java/monkstone/slider/SimpleSlider.java +0 -9
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +11 -13
- data/src/main/java/monkstone/slider/Slider.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 +8 -9
- data/src/main/java/monkstone/vecmath/AppRender.java +2 -2
- data/src/main/java/monkstone/vecmath/ShapeRender.java +2 -2
- data/src/main/java/monkstone/vecmath/package-info.java +2 -2
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +2 -2
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/VideoInterface.java +11 -5
- data/src/main/java/monkstone/videoevent/package-info.java +2 -2
- data/src/main/java/processing/awt/PGraphicsJava2D.java +1742 -2243
- data/src/main/java/processing/awt/PShapeJava2D.java +268 -270
- data/src/main/java/processing/awt/PSurfaceAWT.java +821 -920
- data/src/main/java/processing/core/DesktopHandler.java +94 -0
- data/src/main/java/processing/core/PApplet.java +14170 -14082
- data/src/main/java/processing/core/PConstants.java +447 -473
- data/src/main/java/processing/core/PFont.java +867 -873
- data/src/main/java/processing/core/PGraphics.java +7193 -7428
- data/src/main/java/processing/core/PImage.java +3051 -3117
- data/src/main/java/processing/core/PMatrix.java +159 -172
- data/src/main/java/processing/core/PMatrix2D.java +403 -444
- data/src/main/java/processing/core/PMatrix3D.java +735 -749
- data/src/main/java/processing/core/PShape.java +2651 -2793
- data/src/main/java/processing/core/PShapeOBJ.java +415 -422
- data/src/main/java/processing/core/PShapeSVG.java +1466 -1475
- data/src/main/java/processing/core/PStyle.java +37 -40
- data/src/main/java/processing/core/PSurface.java +98 -103
- data/src/main/java/processing/core/PSurfaceNone.java +208 -236
- data/src/main/java/processing/core/PVector.java +961 -990
- data/src/main/java/processing/data/DoubleDict.java +709 -753
- data/src/main/java/processing/data/DoubleList.java +695 -748
- data/src/main/java/processing/data/FloatDict.java +702 -746
- data/src/main/java/processing/data/FloatList.java +697 -751
- data/src/main/java/processing/data/IntDict.java +673 -718
- data/src/main/java/processing/data/IntList.java +633 -699
- data/src/main/java/processing/data/JSONArray.java +873 -931
- data/src/main/java/processing/data/JSONObject.java +1165 -1262
- data/src/main/java/processing/data/JSONTokener.java +341 -351
- data/src/main/java/processing/data/LongDict.java +662 -707
- data/src/main/java/processing/data/LongList.java +634 -700
- data/src/main/java/processing/data/Sort.java +41 -37
- data/src/main/java/processing/data/StringDict.java +486 -522
- data/src/main/java/processing/data/StringList.java +580 -624
- data/src/main/java/processing/data/Table.java +3508 -3686
- data/src/main/java/processing/data/TableRow.java +183 -182
- data/src/main/java/processing/data/XML.java +883 -957
- data/src/main/java/processing/event/Event.java +66 -87
- data/src/main/java/processing/event/KeyEvent.java +41 -48
- data/src/main/java/processing/event/MouseEvent.java +93 -103
- data/src/main/java/processing/event/TouchEvent.java +6 -10
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +5 -69
- data/src/main/java/processing/javafx/PSurfaceFX.java +2 -7
- data/src/main/java/processing/opengl/FontTexture.java +270 -290
- data/src/main/java/processing/opengl/FrameBuffer.java +363 -375
- data/src/main/java/processing/opengl/LinePath.java +500 -543
- data/src/main/java/processing/opengl/LineStroker.java +582 -593
- data/src/main/java/processing/opengl/PGL.java +2881 -2904
- data/src/main/java/processing/opengl/PGraphics2D.java +315 -408
- data/src/main/java/processing/opengl/PGraphics3D.java +72 -107
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12043 -12230
- data/src/main/java/processing/opengl/PJOGL.java +1681 -1745
- data/src/main/java/processing/opengl/PShader.java +1257 -1260
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4599 -4662
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1030 -1047
- data/src/main/java/processing/opengl/Texture.java +1397 -1462
- data/src/main/java/processing/opengl/VertexBuffer.java +55 -57
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/vendors/Rakefile +1 -1
- metadata +12 -8
- data/src/main/java/processing/core/ThinkDifferent.java +0 -70
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
|
2
|
-
|
|
3
1
|
/*
|
|
4
2
|
Part of the Processing project - http://processing.org
|
|
5
3
|
|
|
@@ -20,8 +18,7 @@
|
|
|
20
18
|
Public License along with this library; if not, write to the
|
|
21
19
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
22
20
|
Boston, MA 02111-1307 USA
|
|
23
|
-
*/
|
|
24
|
-
|
|
21
|
+
*/
|
|
25
22
|
package processing.opengl;
|
|
26
23
|
|
|
27
24
|
import processing.core.PApplet;
|
|
@@ -31,473 +28,464 @@ import processing.opengl.PGraphicsOpenGL.GLResourceFrameBuffer;
|
|
|
31
28
|
import java.nio.IntBuffer;
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
|
-
* Encapsulates a Frame Buffer Object for offscreen rendering.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* not available.
|
|
31
|
+
* Encapsulates a Frame Buffer Object for offscreen rendering. When created with
|
|
32
|
+
* onscreen == true, it represents the normal framebuffer. Needed by the stack
|
|
33
|
+
* mechanism in OPENGL2 to return to onscreen rendering after a sequence of
|
|
34
|
+
* pushFramebuffer calls. It transparently handles the situations when the FBO
|
|
35
|
+
* extension is not available.
|
|
40
36
|
*
|
|
41
37
|
* By Andres Colubri.
|
|
42
38
|
*/
|
|
43
|
-
|
|
44
39
|
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
40
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
protected PGraphicsOpenGL pg;
|
|
42
|
+
protected PGL pgl;
|
|
43
|
+
protected int context; // The context that created this framebuffer.
|
|
61
44
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
public int glFbo;
|
|
46
|
+
public int glDepth;
|
|
47
|
+
public int glStencil;
|
|
48
|
+
public int glDepthStencil;
|
|
49
|
+
public int glMultisample;
|
|
50
|
+
public int width;
|
|
51
|
+
public int height;
|
|
52
|
+
private GLResourceFrameBuffer glres;
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
protected IntBuffer pixelBuffer;
|
|
54
|
+
protected int depthBits;
|
|
55
|
+
protected int stencilBits;
|
|
56
|
+
protected boolean packedDepthStencil;
|
|
72
57
|
|
|
58
|
+
protected boolean multisample;
|
|
59
|
+
protected int nsamples;
|
|
73
60
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
pgl = pg.pgl;
|
|
77
|
-
context = pgl.createEmptyContext();
|
|
78
|
-
}
|
|
61
|
+
protected int numColorBuffers;
|
|
62
|
+
protected Texture[] colorBufferTex;
|
|
79
63
|
|
|
64
|
+
protected boolean screenFb;
|
|
65
|
+
protected boolean noDepth;
|
|
80
66
|
|
|
81
|
-
|
|
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
|
-
}
|
|
67
|
+
protected IntBuffer pixelBuffer;
|
|
152
68
|
|
|
69
|
+
FrameBuffer(PGraphicsOpenGL pg) {
|
|
70
|
+
this.pg = pg;
|
|
71
|
+
pgl = pg.pgl;
|
|
72
|
+
context = pgl.createEmptyContext();
|
|
73
|
+
}
|
|
153
74
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
75
|
+
FrameBuffer(PGraphicsOpenGL pg, int w, int h, int samples, int colorBuffers,
|
|
76
|
+
int depthBits, int stencilBits, boolean packedDepthStencil,
|
|
77
|
+
boolean screen) {
|
|
78
|
+
this(pg);
|
|
79
|
+
|
|
80
|
+
glFbo = 0;
|
|
81
|
+
glDepth = 0;
|
|
82
|
+
glStencil = 0;
|
|
83
|
+
glDepthStencil = 0;
|
|
84
|
+
glMultisample = 0;
|
|
85
|
+
|
|
86
|
+
if (screen) {
|
|
87
|
+
// If this framebuffer is used to represent a on-screen buffer,
|
|
88
|
+
// then it doesn't make it sense for it to have multisampling,
|
|
89
|
+
// color, depth or stencil buffers.
|
|
90
|
+
depthBits = stencilBits = samples = colorBuffers = 0;
|
|
91
|
+
}
|
|
165
92
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
93
|
+
width = w;
|
|
94
|
+
height = h;
|
|
169
95
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
96
|
+
if (1 < samples) {
|
|
97
|
+
multisample = true;
|
|
98
|
+
nsamples = samples;
|
|
99
|
+
} else {
|
|
100
|
+
multisample = false;
|
|
101
|
+
nsamples = 1;
|
|
102
|
+
}
|
|
173
103
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
104
|
+
numColorBuffers = colorBuffers;
|
|
105
|
+
colorBufferTex = new Texture[numColorBuffers];
|
|
106
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
|
107
|
+
colorBufferTex[i] = null;
|
|
108
|
+
}
|
|
177
109
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
110
|
+
if (depthBits < 1 && stencilBits < 1) {
|
|
111
|
+
this.depthBits = 0;
|
|
112
|
+
this.stencilBits = 0;
|
|
113
|
+
this.packedDepthStencil = false;
|
|
114
|
+
} else {
|
|
115
|
+
if (packedDepthStencil) {
|
|
116
|
+
// When combined depth/stencil format is required, the depth and stencil
|
|
117
|
+
// bits are overriden and the 24/8 combination for a 32 bits surface is
|
|
118
|
+
// used.
|
|
119
|
+
this.depthBits = 24;
|
|
120
|
+
this.stencilBits = 8;
|
|
121
|
+
this.packedDepthStencil = true;
|
|
122
|
+
} else {
|
|
123
|
+
this.depthBits = depthBits;
|
|
124
|
+
this.stencilBits = stencilBits;
|
|
125
|
+
this.packedDepthStencil = false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
186
128
|
|
|
187
|
-
|
|
188
|
-
pgl.bindFramebufferImpl(PGL.FRAMEBUFFER, glFbo);
|
|
189
|
-
}
|
|
129
|
+
screenFb = screen;
|
|
190
130
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
131
|
+
allocate();
|
|
132
|
+
noDepth = false;
|
|
194
133
|
|
|
195
|
-
|
|
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
|
-
}
|
|
134
|
+
pixelBuffer = null;
|
|
203
135
|
}
|
|
204
|
-
}
|
|
205
136
|
|
|
206
|
-
|
|
207
|
-
|
|
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();
|
|
137
|
+
FrameBuffer(PGraphicsOpenGL pg, int w, int h) {
|
|
138
|
+
this(pg, w, h, 1, 1, 0, 0, false, false);
|
|
217
139
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
public IntBuffer getPixelBuffer() {
|
|
221
|
-
return pixelBuffer;
|
|
222
|
-
}
|
|
223
140
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
public boolean hasStencilBuffer() {
|
|
229
|
-
return 0 < stencilBits;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public void setFBO(int id) {
|
|
233
|
-
if (screenFb) {
|
|
234
|
-
glFbo = id;
|
|
141
|
+
FrameBuffer(PGraphicsOpenGL pg, int w, int h, boolean screen) {
|
|
142
|
+
this(pg, w, h, 1, 1, 0, 0, false, screen);
|
|
235
143
|
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
///////////////////////////////////////////////////////////
|
|
239
|
-
|
|
240
|
-
// Color buffer setters.
|
|
241
|
-
|
|
242
144
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
145
|
+
public void clear() {
|
|
146
|
+
pg.pushFramebuffer();
|
|
147
|
+
pg.setFramebuffer(this);
|
|
148
|
+
pgl.clearDepth(1);
|
|
149
|
+
pgl.clearStencil(0);
|
|
150
|
+
pgl.clearColor(0, 0, 0, 0);
|
|
151
|
+
pgl.clear(PGL.DEPTH_BUFFER_BIT
|
|
152
|
+
| PGL.STENCIL_BUFFER_BIT
|
|
153
|
+
| PGL.COLOR_BUFFER_BIT);
|
|
154
|
+
pg.popFramebuffer();
|
|
155
|
+
}
|
|
251
156
|
|
|
157
|
+
public void copyColor(FrameBuffer dest) {
|
|
158
|
+
copy(dest, PGL.COLOR_BUFFER_BIT);
|
|
159
|
+
}
|
|
252
160
|
|
|
253
|
-
|
|
254
|
-
|
|
161
|
+
public void copyDepth(FrameBuffer dest) {
|
|
162
|
+
copy(dest, PGL.DEPTH_BUFFER_BIT);
|
|
163
|
+
}
|
|
255
164
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
"buffers.");
|
|
165
|
+
public void copyStencil(FrameBuffer dest) {
|
|
166
|
+
copy(dest, PGL.STENCIL_BUFFER_BIT);
|
|
259
167
|
}
|
|
260
168
|
|
|
261
|
-
|
|
262
|
-
|
|
169
|
+
public void copy(FrameBuffer dest, int mask) {
|
|
170
|
+
pgl.bindFramebufferImpl(PGL.READ_FRAMEBUFFER, this.glFbo);
|
|
171
|
+
pgl.bindFramebufferImpl(PGL.DRAW_FRAMEBUFFER, dest.glFbo);
|
|
172
|
+
pgl.blitFramebuffer(0, 0, this.width, this.height,
|
|
173
|
+
0, 0, dest.width, dest.height, mask, PGL.NEAREST);
|
|
174
|
+
pgl.bindFramebufferImpl(PGL.READ_FRAMEBUFFER, pg.getCurrentFB().glFbo);
|
|
175
|
+
pgl.bindFramebufferImpl(PGL.DRAW_FRAMEBUFFER, pg.getCurrentFB().glFbo);
|
|
263
176
|
}
|
|
264
177
|
|
|
265
|
-
|
|
266
|
-
|
|
178
|
+
public void bind() {
|
|
179
|
+
pgl.bindFramebufferImpl(PGL.FRAMEBUFFER, glFbo);
|
|
180
|
+
}
|
|
267
181
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
|
|
271
|
-
PGL.TEXTURE_2D, 0, 0);
|
|
182
|
+
public void disableDepthTest() {
|
|
183
|
+
noDepth = true;
|
|
272
184
|
}
|
|
273
185
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
186
|
+
public void finish() {
|
|
187
|
+
if (noDepth) {
|
|
188
|
+
// No need to clear depth buffer because depth testing was disabled.
|
|
189
|
+
if (pg.getHint(ENABLE_DEPTH_TEST)) {
|
|
190
|
+
pgl.enable(PGL.DEPTH_TEST);
|
|
191
|
+
} else {
|
|
192
|
+
pgl.disable(PGL.DEPTH_TEST);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
278
195
|
}
|
|
279
196
|
|
|
280
|
-
|
|
197
|
+
public void readPixels() {
|
|
198
|
+
if (pixelBuffer == null) {
|
|
199
|
+
createPixelBuffer();
|
|
200
|
+
}
|
|
201
|
+
pixelBuffer.rewind();
|
|
202
|
+
pgl.readPixels(0, 0, width, height, PGL.RGBA, PGL.UNSIGNED_BYTE,
|
|
203
|
+
pixelBuffer);
|
|
204
|
+
}
|
|
281
205
|
|
|
282
|
-
|
|
283
|
-
|
|
206
|
+
public void getPixels(int[] pixels) {
|
|
207
|
+
if (pixelBuffer != null) {
|
|
208
|
+
pixelBuffer.get(pixels, 0, pixels.length);
|
|
209
|
+
pixelBuffer.rewind();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
284
212
|
|
|
213
|
+
public IntBuffer getPixelBuffer() {
|
|
214
|
+
return pixelBuffer;
|
|
215
|
+
}
|
|
285
216
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
int i1 = (i + 1);
|
|
289
|
-
Texture tmp = colorBufferTex[i];
|
|
290
|
-
colorBufferTex[i] = colorBufferTex[i1];
|
|
291
|
-
colorBufferTex[i1] = tmp;
|
|
217
|
+
public boolean hasDepthBuffer() {
|
|
218
|
+
return 0 < depthBits;
|
|
292
219
|
}
|
|
293
220
|
|
|
294
|
-
|
|
295
|
-
|
|
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);
|
|
221
|
+
public boolean hasStencilBuffer() {
|
|
222
|
+
return 0 < stencilBits;
|
|
300
223
|
}
|
|
301
|
-
pgl.validateFramebuffer();
|
|
302
224
|
|
|
303
|
-
|
|
304
|
-
|
|
225
|
+
public void setFBO(int id) {
|
|
226
|
+
if (screenFb) {
|
|
227
|
+
glFbo = id;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
305
230
|
|
|
231
|
+
///////////////////////////////////////////////////////////
|
|
232
|
+
// Color buffer setters.
|
|
233
|
+
public void setColorBuffer(Texture tex) {
|
|
234
|
+
setColorBuffers(new Texture[]{tex}, 1);
|
|
235
|
+
}
|
|
306
236
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
return pgl.getDefaultReadBuffer();
|
|
310
|
-
} else {
|
|
311
|
-
return PGL.COLOR_ATTACHMENT0;
|
|
237
|
+
public void setColorBuffers(Texture[] textures) {
|
|
238
|
+
setColorBuffers(textures, textures.length);
|
|
312
239
|
}
|
|
313
|
-
}
|
|
314
240
|
|
|
241
|
+
public void setColorBuffers(Texture[] textures, int n) {
|
|
242
|
+
if (screenFb) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
315
245
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return PGL.COLOR_ATTACHMENT0;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
246
|
+
if (numColorBuffers != PApplet.min(n, textures.length)) {
|
|
247
|
+
throw new RuntimeException("Wrong number of textures to set the color "
|
|
248
|
+
+ "buffers.");
|
|
249
|
+
}
|
|
323
250
|
|
|
251
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
|
252
|
+
colorBufferTex[i] = textures[i];
|
|
253
|
+
}
|
|
324
254
|
|
|
325
|
-
|
|
255
|
+
pg.pushFramebuffer();
|
|
256
|
+
pg.setFramebuffer(this);
|
|
326
257
|
|
|
327
|
-
|
|
258
|
+
// Making sure nothing is attached.
|
|
259
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
|
260
|
+
pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
|
|
261
|
+
PGL.TEXTURE_2D, 0, 0);
|
|
262
|
+
}
|
|
328
263
|
|
|
264
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
|
265
|
+
pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
|
|
266
|
+
colorBufferTex[i].glTarget,
|
|
267
|
+
colorBufferTex[i].glName, 0);
|
|
268
|
+
}
|
|
329
269
|
|
|
330
|
-
|
|
331
|
-
dispose(); // Just in the case this object is being re-allocated.
|
|
270
|
+
pgl.validateFramebuffer();
|
|
332
271
|
|
|
333
|
-
|
|
334
|
-
|
|
272
|
+
pg.popFramebuffer();
|
|
273
|
+
}
|
|
335
274
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
275
|
+
public void swapColorBuffers() {
|
|
276
|
+
for (int i = 0; i < numColorBuffers - 1; i++) {
|
|
277
|
+
int i1 = (i + 1);
|
|
278
|
+
Texture tmp = colorBufferTex[i];
|
|
279
|
+
colorBufferTex[i] = colorBufferTex[i1];
|
|
280
|
+
colorBufferTex[i1] = tmp;
|
|
281
|
+
}
|
|
342
282
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
283
|
+
pg.pushFramebuffer();
|
|
284
|
+
pg.setFramebuffer(this);
|
|
285
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
|
286
|
+
pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
|
|
287
|
+
colorBufferTex[i].glTarget,
|
|
288
|
+
colorBufferTex[i].glName, 0);
|
|
348
289
|
}
|
|
349
|
-
|
|
350
|
-
|
|
290
|
+
pgl.validateFramebuffer();
|
|
291
|
+
|
|
292
|
+
pg.popFramebuffer();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
public int getDefaultReadBuffer() {
|
|
296
|
+
if (screenFb) {
|
|
297
|
+
return pgl.getDefaultReadBuffer();
|
|
298
|
+
} else {
|
|
299
|
+
return PGL.COLOR_ATTACHMENT0;
|
|
351
300
|
}
|
|
352
|
-
}
|
|
353
301
|
}
|
|
354
|
-
}
|
|
355
302
|
|
|
303
|
+
public int getDefaultDrawBuffer() {
|
|
304
|
+
if (screenFb) {
|
|
305
|
+
return pgl.getDefaultDrawBuffer();
|
|
306
|
+
} else {
|
|
307
|
+
return PGL.COLOR_ATTACHMENT0;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
356
310
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
311
|
+
///////////////////////////////////////////////////////////
|
|
312
|
+
// Allocate/release framebuffer.
|
|
313
|
+
protected void allocate() {
|
|
314
|
+
dispose(); // Just in the case this object is being re-allocated.
|
|
315
|
+
|
|
316
|
+
context = pgl.getCurrentContext();
|
|
317
|
+
glres = new GLResourceFrameBuffer(this); // create the FBO resources...
|
|
318
|
+
|
|
319
|
+
if (screenFb) {
|
|
320
|
+
glFbo = 0;
|
|
321
|
+
} else {
|
|
322
|
+
if (multisample) {
|
|
323
|
+
initColorBufferMultisample();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (packedDepthStencil) {
|
|
327
|
+
initPackedDepthStencilBuffer();
|
|
328
|
+
} else {
|
|
329
|
+
if (0 < depthBits) {
|
|
330
|
+
initDepthBuffer();
|
|
331
|
+
}
|
|
332
|
+
if (0 < stencilBits) {
|
|
333
|
+
initStencilBuffer();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
367
337
|
}
|
|
368
|
-
}
|
|
369
338
|
|
|
339
|
+
protected void dispose() {
|
|
340
|
+
if (screenFb) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (glres != null) {
|
|
344
|
+
glres.dispose();
|
|
345
|
+
glFbo = 0;
|
|
346
|
+
glDepth = 0;
|
|
347
|
+
glStencil = 0;
|
|
348
|
+
glMultisample = 0;
|
|
349
|
+
glDepthStencil = 0;
|
|
350
|
+
glres = null;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
370
353
|
|
|
371
|
-
|
|
372
|
-
|
|
354
|
+
protected boolean contextIsOutdated() {
|
|
355
|
+
if (screenFb) {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
373
358
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
359
|
+
boolean outdated = !pgl.contextIsCurrent(context);
|
|
360
|
+
if (outdated) {
|
|
361
|
+
dispose();
|
|
362
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
|
363
|
+
colorBufferTex[i] = null;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return outdated;
|
|
380
367
|
}
|
|
381
|
-
return outdated;
|
|
382
|
-
}
|
|
383
368
|
|
|
369
|
+
protected void initColorBufferMultisample() {
|
|
370
|
+
if (screenFb) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
384
373
|
|
|
385
|
-
|
|
386
|
-
|
|
374
|
+
pg.pushFramebuffer();
|
|
375
|
+
pg.setFramebuffer(this);
|
|
387
376
|
|
|
388
|
-
|
|
389
|
-
|
|
377
|
+
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glMultisample);
|
|
378
|
+
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples,
|
|
379
|
+
PGL.RGBA8, width, height);
|
|
380
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0,
|
|
381
|
+
PGL.RENDERBUFFER, glMultisample);
|
|
390
382
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
PGL.RGBA8, width, height);
|
|
394
|
-
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0,
|
|
395
|
-
PGL.RENDERBUFFER, glMultisample);
|
|
383
|
+
pg.popFramebuffer();
|
|
384
|
+
}
|
|
396
385
|
|
|
397
|
-
|
|
398
|
-
|
|
386
|
+
protected void initPackedDepthStencilBuffer() {
|
|
387
|
+
if (screenFb) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
399
390
|
|
|
391
|
+
if (width == 0 || height == 0) {
|
|
392
|
+
throw new RuntimeException("PFramebuffer: size undefined.");
|
|
393
|
+
}
|
|
400
394
|
|
|
401
|
-
|
|
402
|
-
|
|
395
|
+
pg.pushFramebuffer();
|
|
396
|
+
pg.setFramebuffer(this);
|
|
403
397
|
|
|
404
|
-
|
|
405
|
-
throw new RuntimeException("PFramebuffer: size undefined.");
|
|
406
|
-
}
|
|
398
|
+
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepthStencil);
|
|
407
399
|
|
|
408
|
-
|
|
409
|
-
|
|
400
|
+
if (multisample) {
|
|
401
|
+
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples,
|
|
402
|
+
PGL.DEPTH24_STENCIL8, width, height);
|
|
403
|
+
} else {
|
|
404
|
+
pgl.renderbufferStorage(PGL.RENDERBUFFER, PGL.DEPTH24_STENCIL8,
|
|
405
|
+
width, height);
|
|
406
|
+
}
|
|
410
407
|
|
|
411
|
-
|
|
408
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.DEPTH_ATTACHMENT,
|
|
409
|
+
PGL.RENDERBUFFER, glDepthStencil);
|
|
410
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.STENCIL_ATTACHMENT,
|
|
411
|
+
PGL.RENDERBUFFER, glDepthStencil);
|
|
412
412
|
|
|
413
|
-
|
|
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);
|
|
413
|
+
pg.popFramebuffer();
|
|
419
414
|
}
|
|
420
415
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
pg.popFramebuffer();
|
|
427
|
-
}
|
|
416
|
+
protected void initDepthBuffer() {
|
|
417
|
+
if (screenFb) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
428
420
|
|
|
421
|
+
if (width == 0 || height == 0) {
|
|
422
|
+
throw new RuntimeException("PFramebuffer: size undefined.");
|
|
423
|
+
}
|
|
429
424
|
|
|
430
|
-
|
|
431
|
-
|
|
425
|
+
pg.pushFramebuffer();
|
|
426
|
+
pg.setFramebuffer(this);
|
|
432
427
|
|
|
433
|
-
|
|
434
|
-
throw new RuntimeException("PFramebuffer: size undefined.");
|
|
435
|
-
}
|
|
428
|
+
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepth);
|
|
436
429
|
|
|
437
|
-
|
|
438
|
-
|
|
430
|
+
int glConst = PGL.DEPTH_COMPONENT16;
|
|
431
|
+
if (depthBits == 16) {
|
|
432
|
+
glConst = PGL.DEPTH_COMPONENT16;
|
|
433
|
+
} else if (depthBits == 24) {
|
|
434
|
+
glConst = PGL.DEPTH_COMPONENT24;
|
|
435
|
+
} else if (depthBits == 32) {
|
|
436
|
+
glConst = PGL.DEPTH_COMPONENT32;
|
|
437
|
+
}
|
|
439
438
|
|
|
440
|
-
|
|
439
|
+
if (multisample) {
|
|
440
|
+
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
|
|
441
|
+
width, height);
|
|
442
|
+
} else {
|
|
443
|
+
pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height);
|
|
444
|
+
}
|
|
441
445
|
|
|
442
|
-
|
|
443
|
-
|
|
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
|
-
}
|
|
446
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.DEPTH_ATTACHMENT,
|
|
447
|
+
PGL.RENDERBUFFER, glDepth);
|
|
450
448
|
|
|
451
|
-
|
|
452
|
-
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
|
|
453
|
-
width, height);
|
|
454
|
-
} else {
|
|
455
|
-
pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height);
|
|
449
|
+
pg.popFramebuffer();
|
|
456
450
|
}
|
|
457
451
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
452
|
+
protected void initStencilBuffer() {
|
|
453
|
+
if (screenFb) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
463
456
|
|
|
457
|
+
if (width == 0 || height == 0) {
|
|
458
|
+
throw new RuntimeException("PFramebuffer: size undefined.");
|
|
459
|
+
}
|
|
464
460
|
|
|
465
|
-
|
|
466
|
-
|
|
461
|
+
pg.pushFramebuffer();
|
|
462
|
+
pg.setFramebuffer(this);
|
|
467
463
|
|
|
468
|
-
|
|
469
|
-
throw new RuntimeException("PFramebuffer: size undefined.");
|
|
470
|
-
}
|
|
464
|
+
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glStencil);
|
|
471
465
|
|
|
472
|
-
|
|
473
|
-
|
|
466
|
+
int glConst = PGL.STENCIL_INDEX1;
|
|
467
|
+
if (stencilBits == 1) {
|
|
468
|
+
glConst = PGL.STENCIL_INDEX1;
|
|
469
|
+
} else if (stencilBits == 4) {
|
|
470
|
+
glConst = PGL.STENCIL_INDEX4;
|
|
471
|
+
} else if (stencilBits == 8) {
|
|
472
|
+
glConst = PGL.STENCIL_INDEX8;
|
|
473
|
+
}
|
|
474
|
+
if (multisample) {
|
|
475
|
+
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
|
|
476
|
+
width, height);
|
|
477
|
+
} else {
|
|
478
|
+
pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height);
|
|
479
|
+
}
|
|
474
480
|
|
|
475
|
-
|
|
481
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.STENCIL_ATTACHMENT,
|
|
482
|
+
PGL.RENDERBUFFER, glStencil);
|
|
476
483
|
|
|
477
|
-
|
|
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);
|
|
484
|
+
pg.popFramebuffer();
|
|
490
485
|
}
|
|
491
486
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
protected void createPixelBuffer() {
|
|
500
|
-
pixelBuffer = IntBuffer.allocate(width * height);
|
|
501
|
-
pixelBuffer.rewind();
|
|
502
|
-
}
|
|
487
|
+
protected void createPixelBuffer() {
|
|
488
|
+
pixelBuffer = IntBuffer.allocate(width * height);
|
|
489
|
+
pixelBuffer.rewind();
|
|
490
|
+
}
|
|
503
491
|
}
|