propane 3.9.0-java → 3.10.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +2 -2
- data/README.md +3 -3
- data/Rakefile +6 -6
- data/lib/java/japplemenubar/JAppleMenuBar.java +88 -0
- data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
- data/lib/java/monkstone/ColorUtil.java +127 -0
- data/lib/java/monkstone/MathToolModule.java +287 -0
- data/lib/java/monkstone/PropaneLibrary.java +46 -0
- data/lib/java/monkstone/core/LibraryProxy.java +136 -0
- data/lib/java/monkstone/fastmath/DegLutTables.java +111 -0
- data/lib/java/monkstone/fastmath/Deglut.java +71 -0
- data/lib/java/monkstone/fastmath/package-info.java +6 -0
- data/lib/java/monkstone/filechooser/Chooser.java +39 -0
- data/{src/main → lib}/java/monkstone/noise/FastTerrain.java +0 -0
- data/{src/main → lib}/java/monkstone/noise/Noise.java +0 -0
- data/{src/main → lib}/java/monkstone/noise/NoiseGenerator.java +0 -0
- data/{src/main → lib}/java/monkstone/noise/NoiseMode.java +0 -0
- data/lib/java/monkstone/noise/OpenSimplex2F.java +881 -0
- data/lib/java/monkstone/noise/OpenSimplex2S.java +1106 -0
- data/{src/main → lib}/java/monkstone/noise/SmoothTerrain.java +0 -0
- data/lib/java/monkstone/slider/CustomHorizontalSlider.java +164 -0
- data/lib/java/monkstone/slider/CustomVerticalSlider.java +178 -0
- data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +145 -0
- data/lib/java/monkstone/slider/SimpleSlider.java +166 -0
- data/lib/java/monkstone/slider/SimpleVerticalSlider.java +157 -0
- data/lib/java/monkstone/slider/Slider.java +61 -0
- data/lib/java/monkstone/slider/SliderBar.java +245 -0
- data/lib/java/monkstone/slider/SliderGroup.java +56 -0
- data/lib/java/monkstone/slider/WheelHandler.java +35 -0
- data/lib/java/monkstone/vecmath/GfxRender.java +86 -0
- data/lib/java/monkstone/vecmath/JRender.java +56 -0
- data/lib/java/monkstone/vecmath/ShapeRender.java +87 -0
- data/lib/java/monkstone/vecmath/package-info.java +20 -0
- data/lib/java/monkstone/vecmath/vec2/Vec2.java +802 -0
- data/lib/java/monkstone/vecmath/vec2/package-info.java +6 -0
- data/lib/java/monkstone/vecmath/vec3/Vec3.java +727 -0
- data/lib/java/monkstone/vecmath/vec3/package-info.java +6 -0
- data/lib/java/monkstone/videoevent/CaptureEvent.java +27 -0
- data/lib/java/monkstone/videoevent/MovieEvent.java +32 -0
- data/lib/java/monkstone/videoevent/package-info.java +20 -0
- data/lib/java/processing/awt/PGraphicsJava2D.java +3040 -0
- data/lib/java/processing/awt/PImageAWT.java +377 -0
- data/lib/java/processing/awt/PShapeJava2D.java +387 -0
- data/lib/java/processing/awt/PSurfaceAWT.java +1581 -0
- data/lib/java/processing/awt/ShimAWT.java +581 -0
- data/lib/java/processing/core/PApplet.java +15156 -0
- data/lib/java/processing/core/PConstants.java +523 -0
- data/lib/java/processing/core/PFont.java +1126 -0
- data/lib/java/processing/core/PGraphics.java +8600 -0
- data/lib/java/processing/core/PImage.java +3377 -0
- data/lib/java/processing/core/PMatrix.java +208 -0
- data/lib/java/processing/core/PMatrix2D.java +562 -0
- data/lib/java/processing/core/PMatrix3D.java +890 -0
- data/lib/java/processing/core/PShape.java +3561 -0
- data/lib/java/processing/core/PShapeOBJ.java +483 -0
- data/lib/java/processing/core/PShapeSVG.java +2016 -0
- data/lib/java/processing/core/PStyle.java +63 -0
- data/lib/java/processing/core/PSurface.java +198 -0
- data/lib/java/processing/core/PSurfaceNone.java +431 -0
- data/lib/java/processing/core/PVector.java +1066 -0
- data/lib/java/processing/core/ThinkDifferent.java +115 -0
- data/lib/java/processing/data/DoubleDict.java +850 -0
- data/lib/java/processing/data/DoubleList.java +928 -0
- data/lib/java/processing/data/FloatDict.java +847 -0
- data/lib/java/processing/data/FloatList.java +936 -0
- data/lib/java/processing/data/IntDict.java +807 -0
- data/lib/java/processing/data/IntList.java +936 -0
- data/lib/java/processing/data/JSONArray.java +1260 -0
- data/lib/java/processing/data/JSONObject.java +2282 -0
- data/lib/java/processing/data/JSONTokener.java +435 -0
- data/lib/java/processing/data/LongDict.java +802 -0
- data/lib/java/processing/data/LongList.java +937 -0
- data/lib/java/processing/data/Sort.java +46 -0
- data/lib/java/processing/data/StringDict.java +613 -0
- data/lib/java/processing/data/StringList.java +800 -0
- data/lib/java/processing/data/Table.java +4936 -0
- data/lib/java/processing/data/TableRow.java +198 -0
- data/lib/java/processing/data/XML.java +1156 -0
- data/lib/java/processing/dxf/RawDXF.java +404 -0
- data/lib/java/processing/event/Event.java +125 -0
- data/lib/java/processing/event/KeyEvent.java +70 -0
- data/lib/java/processing/event/MouseEvent.java +114 -0
- data/lib/java/processing/event/TouchEvent.java +57 -0
- data/lib/java/processing/javafx/PGraphicsFX2D.java +32 -0
- data/lib/java/processing/javafx/PSurfaceFX.java +173 -0
- data/lib/java/processing/net/Client.java +744 -0
- data/lib/java/processing/net/Server.java +388 -0
- data/lib/java/processing/opengl/FontTexture.java +378 -0
- data/lib/java/processing/opengl/FrameBuffer.java +513 -0
- data/lib/java/processing/opengl/LinePath.java +627 -0
- data/lib/java/processing/opengl/LineStroker.java +681 -0
- data/lib/java/processing/opengl/PGL.java +3483 -0
- data/lib/java/processing/opengl/PGraphics2D.java +615 -0
- data/lib/java/processing/opengl/PGraphics3D.java +281 -0
- data/lib/java/processing/opengl/PGraphicsOpenGL.java +13753 -0
- data/lib/java/processing/opengl/PJOGL.java +2008 -0
- data/lib/java/processing/opengl/PShader.java +1484 -0
- data/lib/java/processing/opengl/PShapeOpenGL.java +5269 -0
- data/lib/java/processing/opengl/PSurfaceJOGL.java +1385 -0
- data/lib/java/processing/opengl/Texture.java +1696 -0
- data/lib/java/processing/opengl/VertexBuffer.java +88 -0
- data/lib/java/processing/opengl/cursors/arrow.png +0 -0
- data/lib/java/processing/opengl/cursors/cross.png +0 -0
- data/lib/java/processing/opengl/cursors/hand.png +0 -0
- data/lib/java/processing/opengl/cursors/license.txt +27 -0
- data/lib/java/processing/opengl/cursors/move.png +0 -0
- data/lib/java/processing/opengl/cursors/text.png +0 -0
- data/lib/java/processing/opengl/cursors/wait.png +0 -0
- data/lib/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
- data/lib/java/processing/opengl/shaders/ColorVert.glsl +34 -0
- data/lib/java/processing/opengl/shaders/LightFrag.glsl +33 -0
- data/lib/java/processing/opengl/shaders/LightVert.glsl +151 -0
- data/lib/java/processing/opengl/shaders/LineFrag.glsl +32 -0
- data/lib/java/processing/opengl/shaders/LineVert.glsl +100 -0
- data/lib/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
- data/lib/java/processing/opengl/shaders/PointFrag.glsl +32 -0
- data/lib/java/processing/opengl/shaders/PointVert.glsl +56 -0
- data/lib/java/processing/opengl/shaders/TexFrag.glsl +37 -0
- data/lib/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
- data/lib/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
- data/lib/java/processing/opengl/shaders/TexVert.glsl +38 -0
- data/lib/java/processing/pdf/PGraphicsPDF.java +581 -0
- data/lib/java/processing/svg/PGraphicsSVG.java +378 -0
- data/lib/propane/app.rb +8 -13
- data/lib/propane/version.rb +1 -1
- data/mvnw +3 -3
- data/mvnw.cmd +2 -2
- data/pom.rb +7 -2
- data/pom.xml +14 -2
- data/propane.gemspec +2 -2
- data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
- data/src/main/java/monkstone/MathToolModule.java +30 -30
- data/src/main/java/monkstone/PropaneLibrary.java +2 -0
- data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
- data/src/main/java/monkstone/fastmath/DegLutTables.java +15 -15
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/OpenSimplex2F.java +752 -820
- data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -1106
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/JRender.java +6 -6
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +20 -19
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +12 -12
- data/src/main/java/processing/awt/PGraphicsJava2D.java +11 -3
- data/src/main/java/processing/core/PApplet.java +89 -89
- data/src/main/java/processing/core/PConstants.java +155 -163
- data/src/main/java/processing/opengl/PJOGL.java +6 -5
- data/vendors/Rakefile +1 -1
- metadata +136 -19
@@ -0,0 +1,513 @@
|
|
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
|
+
System.arraycopy(textures, 0, colorBufferTex, 0, numColorBuffers);
|
262
|
+
|
263
|
+
pg.pushFramebuffer();
|
264
|
+
pg.setFramebuffer(this);
|
265
|
+
|
266
|
+
// Making sure nothing is attached.
|
267
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
268
|
+
pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
|
269
|
+
PGL.TEXTURE_2D, 0, 0);
|
270
|
+
}
|
271
|
+
|
272
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
273
|
+
pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
|
274
|
+
colorBufferTex[i].glTarget,
|
275
|
+
colorBufferTex[i].glName, 0);
|
276
|
+
}
|
277
|
+
|
278
|
+
pgl.validateFramebuffer();
|
279
|
+
|
280
|
+
pg.popFramebuffer();
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
public void swapColorBuffers() {
|
285
|
+
for (int i = 0; i < numColorBuffers - 1; i++) {
|
286
|
+
int i1 = (i + 1);
|
287
|
+
Texture tmp = colorBufferTex[i];
|
288
|
+
colorBufferTex[i] = colorBufferTex[i1];
|
289
|
+
colorBufferTex[i1] = tmp;
|
290
|
+
}
|
291
|
+
|
292
|
+
pg.pushFramebuffer();
|
293
|
+
pg.setFramebuffer(this);
|
294
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
295
|
+
pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i,
|
296
|
+
colorBufferTex[i].glTarget,
|
297
|
+
colorBufferTex[i].glName, 0);
|
298
|
+
}
|
299
|
+
pgl.validateFramebuffer();
|
300
|
+
|
301
|
+
pg.popFramebuffer();
|
302
|
+
}
|
303
|
+
|
304
|
+
|
305
|
+
public int getDefaultReadBuffer() {
|
306
|
+
if (screenFb) {
|
307
|
+
return pgl.getDefaultReadBuffer();
|
308
|
+
} else {
|
309
|
+
return PGL.COLOR_ATTACHMENT0;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
|
314
|
+
public int getDefaultDrawBuffer() {
|
315
|
+
if (screenFb) {
|
316
|
+
return pgl.getDefaultDrawBuffer();
|
317
|
+
} else {
|
318
|
+
return PGL.COLOR_ATTACHMENT0;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
|
323
|
+
///////////////////////////////////////////////////////////
|
324
|
+
|
325
|
+
// Allocate/release framebuffer.
|
326
|
+
|
327
|
+
|
328
|
+
protected final void allocate() {
|
329
|
+
dispose(); // Just in the case this object is being re-allocated.
|
330
|
+
|
331
|
+
context = pgl.getCurrentContext();
|
332
|
+
glres = new GLResourceFrameBuffer(this); // create the FBO resources...
|
333
|
+
|
334
|
+
if (screenFb) {
|
335
|
+
glFbo = 0;
|
336
|
+
} else {
|
337
|
+
if (multisample) {
|
338
|
+
initColorBufferMultisample();
|
339
|
+
}
|
340
|
+
|
341
|
+
if (packedDepthStencil) {
|
342
|
+
initPackedDepthStencilBuffer();
|
343
|
+
} else {
|
344
|
+
if (0 < depthBits) {
|
345
|
+
initDepthBuffer();
|
346
|
+
}
|
347
|
+
if (0 < stencilBits) {
|
348
|
+
initStencilBuffer();
|
349
|
+
}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
|
354
|
+
|
355
|
+
protected void dispose() {
|
356
|
+
if (screenFb) return;
|
357
|
+
if (glres != null) {
|
358
|
+
glres.dispose();
|
359
|
+
glFbo = 0;
|
360
|
+
glDepth = 0;
|
361
|
+
glStencil = 0;
|
362
|
+
glMultisample = 0;
|
363
|
+
glDepthStencil = 0;
|
364
|
+
glres = null;
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
|
369
|
+
protected boolean contextIsOutdated() {
|
370
|
+
if (screenFb) return false;
|
371
|
+
|
372
|
+
boolean outdated = !pgl.contextIsCurrent(context);
|
373
|
+
if (outdated) {
|
374
|
+
dispose();
|
375
|
+
for (int i = 0; i < numColorBuffers; i++) {
|
376
|
+
colorBufferTex[i] = null;
|
377
|
+
}
|
378
|
+
}
|
379
|
+
return outdated;
|
380
|
+
}
|
381
|
+
|
382
|
+
|
383
|
+
protected void initColorBufferMultisample() {
|
384
|
+
if (screenFb) return;
|
385
|
+
|
386
|
+
pg.pushFramebuffer();
|
387
|
+
pg.setFramebuffer(this);
|
388
|
+
|
389
|
+
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glMultisample);
|
390
|
+
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples,
|
391
|
+
PGL.RGBA8, width, height);
|
392
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0,
|
393
|
+
PGL.RENDERBUFFER, glMultisample);
|
394
|
+
|
395
|
+
pg.popFramebuffer();
|
396
|
+
}
|
397
|
+
|
398
|
+
|
399
|
+
protected void initPackedDepthStencilBuffer() {
|
400
|
+
if (screenFb) return;
|
401
|
+
|
402
|
+
if (width == 0 || height == 0) {
|
403
|
+
throw new RuntimeException("PFramebuffer: size undefined.");
|
404
|
+
}
|
405
|
+
|
406
|
+
pg.pushFramebuffer();
|
407
|
+
pg.setFramebuffer(this);
|
408
|
+
|
409
|
+
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepthStencil);
|
410
|
+
|
411
|
+
if (multisample) {
|
412
|
+
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples,
|
413
|
+
PGL.DEPTH24_STENCIL8, width, height);
|
414
|
+
} else {
|
415
|
+
pgl.renderbufferStorage(PGL.RENDERBUFFER, PGL.DEPTH24_STENCIL8,
|
416
|
+
width, height);
|
417
|
+
}
|
418
|
+
|
419
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.DEPTH_ATTACHMENT,
|
420
|
+
PGL.RENDERBUFFER, glDepthStencil);
|
421
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.STENCIL_ATTACHMENT,
|
422
|
+
PGL.RENDERBUFFER, glDepthStencil);
|
423
|
+
|
424
|
+
pg.popFramebuffer();
|
425
|
+
}
|
426
|
+
|
427
|
+
|
428
|
+
protected void initDepthBuffer() {
|
429
|
+
if (screenFb) return;
|
430
|
+
|
431
|
+
if (width == 0 || height == 0) {
|
432
|
+
throw new RuntimeException("PFramebuffer: size undefined.");
|
433
|
+
}
|
434
|
+
|
435
|
+
pg.pushFramebuffer();
|
436
|
+
pg.setFramebuffer(this);
|
437
|
+
|
438
|
+
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepth);
|
439
|
+
|
440
|
+
int glConst = PGL.DEPTH_COMPONENT16;
|
441
|
+
switch (depthBits) {
|
442
|
+
case 16:
|
443
|
+
glConst = PGL.DEPTH_COMPONENT16;
|
444
|
+
break;
|
445
|
+
case 24:
|
446
|
+
glConst = PGL.DEPTH_COMPONENT24;
|
447
|
+
break;
|
448
|
+
case 32:
|
449
|
+
glConst = PGL.DEPTH_COMPONENT32;
|
450
|
+
break;
|
451
|
+
default:
|
452
|
+
break;
|
453
|
+
}
|
454
|
+
|
455
|
+
if (multisample) {
|
456
|
+
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
|
457
|
+
width, height);
|
458
|
+
} else {
|
459
|
+
pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height);
|
460
|
+
}
|
461
|
+
|
462
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.DEPTH_ATTACHMENT,
|
463
|
+
PGL.RENDERBUFFER, glDepth);
|
464
|
+
|
465
|
+
pg.popFramebuffer();
|
466
|
+
}
|
467
|
+
|
468
|
+
|
469
|
+
protected void initStencilBuffer() {
|
470
|
+
if (screenFb) return;
|
471
|
+
|
472
|
+
if (width == 0 || height == 0) {
|
473
|
+
throw new RuntimeException("PFramebuffer: size undefined.");
|
474
|
+
}
|
475
|
+
|
476
|
+
pg.pushFramebuffer();
|
477
|
+
pg.setFramebuffer(this);
|
478
|
+
|
479
|
+
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glStencil);
|
480
|
+
|
481
|
+
int glConst = PGL.STENCIL_INDEX1;
|
482
|
+
switch (stencilBits) {
|
483
|
+
case 1:
|
484
|
+
glConst = PGL.STENCIL_INDEX1;
|
485
|
+
break;
|
486
|
+
case 4:
|
487
|
+
glConst = PGL.STENCIL_INDEX4;
|
488
|
+
break;
|
489
|
+
case 8:
|
490
|
+
glConst = PGL.STENCIL_INDEX8;
|
491
|
+
break;
|
492
|
+
default:
|
493
|
+
break;
|
494
|
+
}
|
495
|
+
if (multisample) {
|
496
|
+
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
|
497
|
+
width, height);
|
498
|
+
} else {
|
499
|
+
pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height);
|
500
|
+
}
|
501
|
+
|
502
|
+
pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.STENCIL_ATTACHMENT,
|
503
|
+
PGL.RENDERBUFFER, glStencil);
|
504
|
+
|
505
|
+
pg.popFramebuffer();
|
506
|
+
}
|
507
|
+
|
508
|
+
|
509
|
+
protected void createPixelBuffer() {
|
510
|
+
pixelBuffer = IntBuffer.allocate(width * height);
|
511
|
+
pixelBuffer.rewind();
|
512
|
+
}
|
513
|
+
}
|