picrate 0.5.0-java → 0.6.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +3 -1
- data/README.md +1 -1
- data/Rakefile +8 -6
- data/docs/_editors/geany.md +5 -4
- data/docs/_editors/vim.md +6 -0
- data/docs/_includes/head.html +1 -0
- data/docs/_libraries/control_panel.md +2 -2
- data/docs/_libraries/gl_video.md +21 -0
- data/docs/_posts/2018-05-06-getting_started.md +10 -9
- data/docs/_posts/2018-05-06-install_jruby.md +19 -2
- data/docs/_posts/2018-06-26-auto_install_picrate.md +19 -4
- data/docs/_posts/2018-11-18-building-gem.md +18 -0
- data/docs/_posts/2018-11-27-getting_started_geany.md +38 -0
- data/docs/about.md +21 -10
- data/docs/assets/android-chrome-192x192.png +0 -0
- data/docs/assets/android-chrome-512x512.png +0 -0
- data/docs/assets/favicon.ico +0 -0
- data/docs/assets/geany.png +0 -0
- data/docs/assets/jwishy_picrate.png +0 -0
- data/docs/assets/picrate.svg +251 -0
- data/docs/index.html +8 -14
- data/lib/picrate/runner.rb +6 -2
- data/lib/picrate/version.rb +1 -1
- data/library/boids/boids.rb +10 -13
- data/mvnw +234 -0
- data/picrate.gemspec +2 -1
- data/pom.rb +1 -1
- data/pom.xml +1 -1
- data/src/main/java/japplemenubar/JAppleMenuBar.java +10 -2
- data/src/main/java/monkstone/ColorUtil.java +11 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -0
- data/src/main/java/monkstone/PicrateLibrary.java +1 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -0
- data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
- 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/SimpleSlider.java +8 -8
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/Slider.java +3 -3
- 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/vecmath/AppRender.java +1 -0
- data/src/main/java/monkstone/vecmath/JRender.java +1 -0
- data/src/main/java/monkstone/vecmath/ShapeRender.java +1 -0
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -0
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -0
- data/src/main/java/processing/awt/PGraphicsJava2D.java +85 -16
- data/src/main/java/processing/awt/PSurfaceAWT.java +1 -1
- data/src/main/java/processing/core/PApplet.java +18 -12
- data/src/main/java/processing/core/PShape.java +1182 -305
- data/src/main/java/processing/core/PStyle.java +1 -1
- data/src/main/java/processing/core/PSurface.java +1 -1
- data/src/main/java/processing/data/FloatDict.java +196 -54
- data/src/main/java/processing/data/FloatList.java +167 -54
- data/src/main/java/processing/data/IntDict.java +211 -56
- data/src/main/java/processing/data/IntList.java +185 -52
- data/src/main/java/processing/data/JSONArray.java +69 -20
- data/src/main/java/processing/data/JSONObject.java +53 -12
- data/src/main/java/processing/data/Sort.java +40 -10
- data/src/main/java/processing/data/StringDict.java +159 -49
- data/src/main/java/processing/data/StringList.java +147 -42
- data/src/main/java/processing/data/Table.java +778 -223
- data/src/main/java/processing/data/TableRow.java +26 -2
- data/src/main/java/processing/data/XML.java +190 -50
- data/src/main/java/processing/event/Event.java +93 -0
- data/src/main/java/processing/event/KeyEvent.java +55 -13
- data/src/main/java/processing/event/MouseEvent.java +77 -1
- data/src/main/java/processing/event/TouchEvent.java +14 -1
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +8 -0
- data/src/main/java/processing/opengl/FrameBuffer.java +228 -66
- data/src/main/java/processing/opengl/LinePath.java +131 -27
- data/src/main/java/processing/opengl/LineStroker.java +30 -5
- data/src/main/java/processing/opengl/PGL.java +4066 -865
- data/src/main/java/processing/opengl/PGraphics2D.java +38 -10
- data/src/main/java/processing/opengl/PGraphics3D.java +38 -6
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +1980 -474
- data/src/main/java/processing/opengl/PJOGL.java +1460 -248
- data/src/main/java/processing/opengl/PShader.java +904 -217
- data/src/main/java/processing/opengl/PShapeOpenGL.java +1811 -487
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +278 -71
- data/src/main/java/processing/opengl/Texture.java +610 -135
- data/src/main/java/processing/opengl/VertexBuffer.java +45 -9
- 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 +13 -6
- data/docs/assets/circle_collisions.png +0 -0
- data/docs/favicon.ico +0 -0
@@ -21,27 +21,84 @@
|
|
21
21
|
*/
|
22
22
|
package processing.event;
|
23
23
|
|
24
|
+
/**
|
25
|
+
*
|
26
|
+
* @author Martin Prout
|
27
|
+
*/
|
24
28
|
public class Event {
|
25
29
|
|
30
|
+
/**
|
31
|
+
*
|
32
|
+
*/
|
26
33
|
protected Object nativeObject;
|
27
34
|
|
35
|
+
/**
|
36
|
+
*
|
37
|
+
*/
|
28
38
|
protected long millis;
|
39
|
+
|
40
|
+
/**
|
41
|
+
*
|
42
|
+
*/
|
29
43
|
protected int action;
|
30
44
|
|
31
45
|
// These correspond to the java.awt.Event modifiers (not to be confused with
|
32
46
|
// the newer getModifiersEx), though they're not guaranteed to in the future.
|
47
|
+
|
48
|
+
/**
|
49
|
+
*
|
50
|
+
*/
|
33
51
|
static public final int SHIFT = 1;
|
52
|
+
|
53
|
+
/**
|
54
|
+
*
|
55
|
+
*/
|
34
56
|
static public final int CTRL = 1 << 1;
|
57
|
+
|
58
|
+
/**
|
59
|
+
*
|
60
|
+
*/
|
35
61
|
static public final int META = 1 << 2;
|
62
|
+
|
63
|
+
/**
|
64
|
+
*
|
65
|
+
*/
|
36
66
|
static public final int ALT = 1 << 3;
|
67
|
+
|
68
|
+
/**
|
69
|
+
*
|
70
|
+
*/
|
37
71
|
protected int modifiers;
|
38
72
|
|
39
73
|
// Types of events. As with all constants in Processing, brevity's preferred.
|
74
|
+
|
75
|
+
/**
|
76
|
+
*
|
77
|
+
*/
|
40
78
|
static public final int KEY = 1;
|
79
|
+
|
80
|
+
/**
|
81
|
+
*
|
82
|
+
*/
|
41
83
|
static public final int MOUSE = 2;
|
84
|
+
|
85
|
+
/**
|
86
|
+
*
|
87
|
+
*/
|
42
88
|
static public final int TOUCH = 3;
|
89
|
+
|
90
|
+
/**
|
91
|
+
*
|
92
|
+
*/
|
43
93
|
protected int flavor;
|
44
94
|
|
95
|
+
/**
|
96
|
+
*
|
97
|
+
* @param nativeObject
|
98
|
+
* @param millis
|
99
|
+
* @param action
|
100
|
+
* @param modifiers
|
101
|
+
*/
|
45
102
|
public Event(Object nativeObject, long millis, int action, int modifiers) {
|
46
103
|
this.nativeObject = nativeObject;
|
47
104
|
this.millis = millis;
|
@@ -49,6 +106,10 @@ public class Event {
|
|
49
106
|
this.modifiers = modifiers;
|
50
107
|
}
|
51
108
|
|
109
|
+
/**
|
110
|
+
*
|
111
|
+
* @return
|
112
|
+
*/
|
52
113
|
public int getFlavor() {
|
53
114
|
return flavor;
|
54
115
|
}
|
@@ -69,6 +130,11 @@ public class Event {
|
|
69
130
|
// public void setNative(Object nativeObject) {
|
70
131
|
// this.nativeObject = nativeObject;
|
71
132
|
// }
|
133
|
+
|
134
|
+
/**
|
135
|
+
*
|
136
|
+
* @return
|
137
|
+
*/
|
72
138
|
public long getMillis() {
|
73
139
|
return millis;
|
74
140
|
}
|
@@ -76,6 +142,11 @@ public class Event {
|
|
76
142
|
// public void setMillis(long millis) {
|
77
143
|
// this.millis = millis;
|
78
144
|
// }
|
145
|
+
|
146
|
+
/**
|
147
|
+
*
|
148
|
+
* @return
|
149
|
+
*/
|
79
150
|
public int getAction() {
|
80
151
|
return action;
|
81
152
|
}
|
@@ -83,6 +154,11 @@ public class Event {
|
|
83
154
|
// public void setAction(int action) {
|
84
155
|
// this.action = action;
|
85
156
|
// }
|
157
|
+
|
158
|
+
/**
|
159
|
+
*
|
160
|
+
* @return
|
161
|
+
*/
|
86
162
|
public int getModifiers() {
|
87
163
|
return modifiers;
|
88
164
|
}
|
@@ -90,18 +166,35 @@ public class Event {
|
|
90
166
|
// public void setModifiers(int modifiers) {
|
91
167
|
// this.modifiers = modifiers;
|
92
168
|
// }
|
169
|
+
|
170
|
+
/**
|
171
|
+
*
|
172
|
+
* @return
|
173
|
+
*/
|
93
174
|
public boolean isShiftDown() {
|
94
175
|
return (modifiers & SHIFT) != 0;
|
95
176
|
}
|
96
177
|
|
178
|
+
/**
|
179
|
+
*
|
180
|
+
* @return
|
181
|
+
*/
|
97
182
|
public boolean isControlDown() {
|
98
183
|
return (modifiers & CTRL) != 0;
|
99
184
|
}
|
100
185
|
|
186
|
+
/**
|
187
|
+
*
|
188
|
+
* @return
|
189
|
+
*/
|
101
190
|
public boolean isMetaDown() {
|
102
191
|
return (modifiers & META) != 0;
|
103
192
|
}
|
104
193
|
|
194
|
+
/**
|
195
|
+
*
|
196
|
+
* @return
|
197
|
+
*/
|
105
198
|
public boolean isAltDown() {
|
106
199
|
return (modifiers & ALT) != 0;
|
107
200
|
}
|
@@ -22,19 +22,42 @@
|
|
22
22
|
|
23
23
|
package processing.event;
|
24
24
|
|
25
|
-
|
25
|
+
/**
|
26
|
+
*
|
27
|
+
* @author Martin Prout
|
28
|
+
*/
|
26
29
|
public class KeyEvent extends Event {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
|
31
|
+
/**
|
32
|
+
*
|
33
|
+
*/
|
34
|
+
static public final int PRESS = 1;
|
35
|
+
|
36
|
+
/**
|
37
|
+
*
|
38
|
+
*/
|
39
|
+
static public final int RELEASE = 2;
|
40
|
+
|
41
|
+
/**
|
42
|
+
*
|
43
|
+
*/
|
44
|
+
static public final int TYPE = 3;
|
30
45
|
|
31
46
|
char key;
|
32
47
|
int keyCode;
|
33
48
|
|
34
49
|
boolean isAutoRepeat;
|
35
50
|
|
36
|
-
|
37
|
-
|
51
|
+
/**
|
52
|
+
*
|
53
|
+
* @param nativeObject
|
54
|
+
* @param millis
|
55
|
+
* @param action
|
56
|
+
* @param modifiers
|
57
|
+
* @param key
|
58
|
+
* @param keyCode
|
59
|
+
*/
|
60
|
+
public KeyEvent(Object nativeObject,
|
38
61
|
long millis, int action, int modifiers,
|
39
62
|
char key, int keyCode) {
|
40
63
|
super(nativeObject, millis, action, modifiers);
|
@@ -43,7 +66,17 @@ public class KeyEvent extends Event {
|
|
43
66
|
this.keyCode = keyCode;
|
44
67
|
}
|
45
68
|
|
46
|
-
|
69
|
+
/**
|
70
|
+
*
|
71
|
+
* @param nativeObject
|
72
|
+
* @param millis
|
73
|
+
* @param action
|
74
|
+
* @param modifiers
|
75
|
+
* @param key
|
76
|
+
* @param keyCode
|
77
|
+
* @param isAutoRepeat
|
78
|
+
*/
|
79
|
+
public KeyEvent(Object nativeObject,
|
47
80
|
long millis, int action, int modifiers,
|
48
81
|
char key, int keyCode, boolean isAutoRepeat) {
|
49
82
|
super(nativeObject, millis, action, modifiers);
|
@@ -53,18 +86,27 @@ public class KeyEvent extends Event {
|
|
53
86
|
this.isAutoRepeat = isAutoRepeat;
|
54
87
|
}
|
55
88
|
|
56
|
-
|
57
|
-
|
89
|
+
/**
|
90
|
+
*
|
91
|
+
* @return
|
92
|
+
*/
|
93
|
+
public char getKey() {
|
58
94
|
return key;
|
59
95
|
}
|
60
96
|
|
61
|
-
|
62
|
-
|
97
|
+
/**
|
98
|
+
*
|
99
|
+
* @return
|
100
|
+
*/
|
101
|
+
public int getKeyCode() {
|
63
102
|
return keyCode;
|
64
103
|
}
|
65
104
|
|
66
|
-
|
67
|
-
|
105
|
+
/**
|
106
|
+
*
|
107
|
+
* @return
|
108
|
+
*/
|
109
|
+
public boolean isAutoRepeat() {
|
68
110
|
return isAutoRepeat;
|
69
111
|
}
|
70
112
|
}
|
@@ -22,21 +22,73 @@
|
|
22
22
|
package processing.event;
|
23
23
|
|
24
24
|
//import processing.core.PConstants;
|
25
|
+
|
26
|
+
/**
|
27
|
+
*
|
28
|
+
* @author Martin Prout
|
29
|
+
*/
|
25
30
|
public class MouseEvent extends Event {
|
26
31
|
|
32
|
+
/**
|
33
|
+
*
|
34
|
+
*/
|
27
35
|
static public final int PRESS = 1;
|
36
|
+
|
37
|
+
/**
|
38
|
+
*
|
39
|
+
*/
|
28
40
|
static public final int RELEASE = 2;
|
41
|
+
|
42
|
+
/**
|
43
|
+
*
|
44
|
+
*/
|
29
45
|
static public final int CLICK = 3;
|
46
|
+
|
47
|
+
/**
|
48
|
+
*
|
49
|
+
*/
|
30
50
|
static public final int DRAG = 4;
|
51
|
+
|
52
|
+
/**
|
53
|
+
*
|
54
|
+
*/
|
31
55
|
static public final int MOVE = 5;
|
56
|
+
|
57
|
+
/**
|
58
|
+
*
|
59
|
+
*/
|
32
60
|
static public final int ENTER = 6;
|
61
|
+
|
62
|
+
/**
|
63
|
+
*
|
64
|
+
*/
|
33
65
|
static public final int EXIT = 7;
|
66
|
+
|
67
|
+
/**
|
68
|
+
*
|
69
|
+
*/
|
34
70
|
static public final int WHEEL = 8;
|
35
71
|
|
36
|
-
|
72
|
+
/**
|
73
|
+
*
|
74
|
+
*/
|
75
|
+
protected int x,
|
76
|
+
|
77
|
+
/**
|
78
|
+
*
|
79
|
+
*/
|
80
|
+
y;
|
81
|
+
|
82
|
+
/**
|
83
|
+
*
|
84
|
+
*/
|
37
85
|
protected int button;
|
38
86
|
// protected int clickCount;
|
39
87
|
// protected float amount;
|
88
|
+
|
89
|
+
/**
|
90
|
+
*
|
91
|
+
*/
|
40
92
|
protected int count;
|
41
93
|
|
42
94
|
// public MouseEvent(int x, int y) {
|
@@ -44,6 +96,18 @@ public class MouseEvent extends Event {
|
|
44
96
|
// System.currentTimeMillis(), PRESSED, 0,
|
45
97
|
// x, y, PConstants.LEFT, 1);
|
46
98
|
// }
|
99
|
+
|
100
|
+
/**
|
101
|
+
*
|
102
|
+
* @param nativeObject
|
103
|
+
* @param millis
|
104
|
+
* @param action
|
105
|
+
* @param modifiers
|
106
|
+
* @param x
|
107
|
+
* @param y
|
108
|
+
* @param button
|
109
|
+
* @param count
|
110
|
+
*/
|
47
111
|
public MouseEvent(Object nativeObject,
|
48
112
|
long millis, int action, int modifiers,
|
49
113
|
int x, int y, int button, int count) { //float amount) { //int clickCount) {
|
@@ -57,10 +121,18 @@ public class MouseEvent extends Event {
|
|
57
121
|
this.count = count;
|
58
122
|
}
|
59
123
|
|
124
|
+
/**
|
125
|
+
*
|
126
|
+
* @return
|
127
|
+
*/
|
60
128
|
public int getX() {
|
61
129
|
return x;
|
62
130
|
}
|
63
131
|
|
132
|
+
/**
|
133
|
+
*
|
134
|
+
* @return
|
135
|
+
*/
|
64
136
|
public int getY() {
|
65
137
|
return y;
|
66
138
|
}
|
@@ -141,6 +213,10 @@ public class MouseEvent extends Event {
|
|
141
213
|
}
|
142
214
|
}
|
143
215
|
|
216
|
+
/**
|
217
|
+
*
|
218
|
+
* @return
|
219
|
+
*/
|
144
220
|
@Override
|
145
221
|
public String toString() {
|
146
222
|
return String.format("<MouseEvent %s@%d,%d count:%d button:%d>",
|
@@ -48,9 +48,22 @@ Pointer and gesture events (Windows)
|
|
48
48
|
http://msdn.microsoft.com/en-US/library/ie/hh673557.aspx
|
49
49
|
|
50
50
|
*/
|
51
|
+
|
52
|
+
/**
|
53
|
+
*
|
54
|
+
* @author Martin Prout
|
55
|
+
*/
|
56
|
+
|
51
57
|
public class TouchEvent extends Event {
|
52
58
|
|
53
|
-
|
59
|
+
/**
|
60
|
+
*
|
61
|
+
* @param nativeObject
|
62
|
+
* @param millis
|
63
|
+
* @param action
|
64
|
+
* @param modifiers
|
65
|
+
*/
|
66
|
+
public TouchEvent(Object nativeObject, long millis, int action, int modifiers) {
|
54
67
|
super(nativeObject, millis, action, modifiers);
|
55
68
|
this.flavor = TOUCH;
|
56
69
|
}
|
@@ -8,8 +8,16 @@ import processing.core.PMatrix3D;
|
|
8
8
|
import processing.core.PShape;
|
9
9
|
import processing.core.PSurface;
|
10
10
|
|
11
|
+
/**
|
12
|
+
*
|
13
|
+
* @author Martin Prout
|
14
|
+
*/
|
11
15
|
public class PGraphicsFX2D extends PGraphics{
|
12
16
|
final String message = "FX2D renderer not supported in this version of picrate";
|
17
|
+
|
18
|
+
/**
|
19
|
+
*
|
20
|
+
*/
|
13
21
|
public PGraphicsFX2D(){
|
14
22
|
}
|
15
23
|
|
@@ -42,33 +42,107 @@ import java.nio.IntBuffer;
|
|
42
42
|
*/
|
43
43
|
|
44
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
45
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
46
|
+
/**
|
47
|
+
*
|
48
|
+
*/
|
49
|
+
protected PGraphicsOpenGL pg;
|
50
|
+
|
51
|
+
/**
|
52
|
+
*
|
53
|
+
*/
|
54
|
+
protected PGL pgl;
|
55
|
+
|
56
|
+
/**
|
57
|
+
*
|
58
|
+
*/
|
59
|
+
protected int context; // The context that created this framebuffer.
|
60
|
+
|
61
|
+
/**
|
62
|
+
*
|
63
|
+
*/
|
64
|
+
public int glFbo;
|
65
|
+
|
66
|
+
/**
|
67
|
+
*
|
68
|
+
*/
|
69
|
+
public int glDepth;
|
70
|
+
|
71
|
+
/**
|
72
|
+
*
|
73
|
+
*/
|
74
|
+
public int glStencil;
|
75
|
+
|
76
|
+
/**
|
77
|
+
*
|
78
|
+
*/
|
79
|
+
public int glDepthStencil;
|
80
|
+
|
81
|
+
/**
|
82
|
+
*
|
83
|
+
*/
|
84
|
+
public int glMultisample;
|
85
|
+
|
86
|
+
/**
|
87
|
+
*
|
88
|
+
*/
|
89
|
+
public int width;
|
90
|
+
|
91
|
+
/**
|
92
|
+
*
|
93
|
+
*/
|
94
|
+
public int height;
|
95
|
+
private GLResourceFrameBuffer glres;
|
70
96
|
|
71
|
-
|
97
|
+
/**
|
98
|
+
*
|
99
|
+
*/
|
100
|
+
protected int depthBits;
|
101
|
+
|
102
|
+
/**
|
103
|
+
*
|
104
|
+
*/
|
105
|
+
protected int stencilBits;
|
106
|
+
|
107
|
+
/**
|
108
|
+
*
|
109
|
+
*/
|
110
|
+
protected boolean packedDepthStencil;
|
111
|
+
|
112
|
+
/**
|
113
|
+
*
|
114
|
+
*/
|
115
|
+
protected boolean multisample;
|
116
|
+
|
117
|
+
/**
|
118
|
+
*
|
119
|
+
*/
|
120
|
+
protected int nsamples;
|
121
|
+
|
122
|
+
/**
|
123
|
+
*
|
124
|
+
*/
|
125
|
+
protected int numColorBuffers;
|
126
|
+
|
127
|
+
/**
|
128
|
+
*
|
129
|
+
*/
|
130
|
+
protected Texture[] colorBufferTex;
|
131
|
+
|
132
|
+
/**
|
133
|
+
*
|
134
|
+
*/
|
135
|
+
protected boolean screenFb;
|
136
|
+
|
137
|
+
/**
|
138
|
+
*
|
139
|
+
*/
|
140
|
+
protected boolean noDepth;
|
141
|
+
|
142
|
+
/**
|
143
|
+
*
|
144
|
+
*/
|
145
|
+
protected IntBuffer pixelBuffer;
|
72
146
|
|
73
147
|
|
74
148
|
FrameBuffer(PGraphicsOpenGL pg) {
|
@@ -150,8 +224,10 @@ public class FrameBuffer implements PConstants {
|
|
150
224
|
this(pg, w, h, 1, 1, 0, 0, false, screen);
|
151
225
|
}
|
152
226
|
|
153
|
-
|
154
|
-
|
227
|
+
/**
|
228
|
+
*
|
229
|
+
*/
|
230
|
+
public void clear() {
|
155
231
|
pg.pushFramebuffer();
|
156
232
|
pg.setFramebuffer(this);
|
157
233
|
pgl.clearDepth(1);
|
@@ -163,19 +239,36 @@ public class FrameBuffer implements PConstants {
|
|
163
239
|
pg.popFramebuffer();
|
164
240
|
}
|
165
241
|
|
166
|
-
|
242
|
+
/**
|
243
|
+
*
|
244
|
+
* @param dest
|
245
|
+
*/
|
246
|
+
public void copyColor(FrameBuffer dest) {
|
167
247
|
copy(dest, PGL.COLOR_BUFFER_BIT);
|
168
248
|
}
|
169
249
|
|
170
|
-
|
250
|
+
/**
|
251
|
+
*
|
252
|
+
* @param dest
|
253
|
+
*/
|
254
|
+
public void copyDepth(FrameBuffer dest) {
|
171
255
|
copy(dest, PGL.DEPTH_BUFFER_BIT);
|
172
256
|
}
|
173
257
|
|
174
|
-
|
258
|
+
/**
|
259
|
+
*
|
260
|
+
* @param dest
|
261
|
+
*/
|
262
|
+
public void copyStencil(FrameBuffer dest) {
|
175
263
|
copy(dest, PGL.STENCIL_BUFFER_BIT);
|
176
264
|
}
|
177
265
|
|
178
|
-
|
266
|
+
/**
|
267
|
+
*
|
268
|
+
* @param dest
|
269
|
+
* @param mask
|
270
|
+
*/
|
271
|
+
public void copy(FrameBuffer dest, int mask) {
|
179
272
|
pgl.bindFramebufferImpl(PGL.READ_FRAMEBUFFER, this.glFbo);
|
180
273
|
pgl.bindFramebufferImpl(PGL.DRAW_FRAMEBUFFER, dest.glFbo);
|
181
274
|
pgl.blitFramebuffer(0, 0, this.width, this.height,
|
@@ -184,15 +277,24 @@ public class FrameBuffer implements PConstants {
|
|
184
277
|
pgl.bindFramebufferImpl(PGL.DRAW_FRAMEBUFFER, pg.getCurrentFB().glFbo);
|
185
278
|
}
|
186
279
|
|
187
|
-
|
280
|
+
/**
|
281
|
+
*
|
282
|
+
*/
|
283
|
+
public void bind() {
|
188
284
|
pgl.bindFramebufferImpl(PGL.FRAMEBUFFER, glFbo);
|
189
285
|
}
|
190
286
|
|
191
|
-
|
287
|
+
/**
|
288
|
+
*
|
289
|
+
*/
|
290
|
+
public void disableDepthTest() {
|
192
291
|
noDepth = true;
|
193
292
|
}
|
194
293
|
|
195
|
-
|
294
|
+
/**
|
295
|
+
*
|
296
|
+
*/
|
297
|
+
public void finish() {
|
196
298
|
if (noDepth) {
|
197
299
|
// No need to clear depth buffer because depth testing was disabled.
|
198
300
|
if (pg.getHint(ENABLE_DEPTH_TEST)) {
|
@@ -203,33 +305,56 @@ public class FrameBuffer implements PConstants {
|
|
203
305
|
}
|
204
306
|
}
|
205
307
|
|
206
|
-
|
308
|
+
/**
|
309
|
+
*
|
310
|
+
*/
|
311
|
+
public void readPixels() {
|
207
312
|
if (pixelBuffer == null) createPixelBuffer();
|
208
313
|
pixelBuffer.rewind();
|
209
314
|
pgl.readPixels(0, 0, width, height, PGL.RGBA, PGL.UNSIGNED_BYTE,
|
210
315
|
pixelBuffer);
|
211
316
|
}
|
212
317
|
|
213
|
-
|
318
|
+
/**
|
319
|
+
*
|
320
|
+
* @param pixels
|
321
|
+
*/
|
322
|
+
public void getPixels(int[] pixels) {
|
214
323
|
if (pixelBuffer != null) {
|
215
324
|
pixelBuffer.get(pixels, 0, pixels.length);
|
216
325
|
pixelBuffer.rewind();
|
217
326
|
}
|
218
327
|
}
|
219
328
|
|
220
|
-
|
329
|
+
/**
|
330
|
+
*
|
331
|
+
* @return
|
332
|
+
*/
|
333
|
+
public IntBuffer getPixelBuffer() {
|
221
334
|
return pixelBuffer;
|
222
335
|
}
|
223
336
|
|
224
|
-
|
337
|
+
/**
|
338
|
+
*
|
339
|
+
* @return
|
340
|
+
*/
|
341
|
+
public boolean hasDepthBuffer() {
|
225
342
|
return 0 < depthBits;
|
226
343
|
}
|
227
344
|
|
228
|
-
|
345
|
+
/**
|
346
|
+
*
|
347
|
+
* @return
|
348
|
+
*/
|
349
|
+
public boolean hasStencilBuffer() {
|
229
350
|
return 0 < stencilBits;
|
230
351
|
}
|
231
352
|
|
232
|
-
|
353
|
+
/**
|
354
|
+
*
|
355
|
+
* @param id
|
356
|
+
*/
|
357
|
+
public void setFBO(int id) {
|
233
358
|
if (screenFb) {
|
234
359
|
glFbo = id;
|
235
360
|
}
|
@@ -239,18 +364,28 @@ public class FrameBuffer implements PConstants {
|
|
239
364
|
|
240
365
|
// Color buffer setters.
|
241
366
|
|
242
|
-
|
243
|
-
|
367
|
+
/**
|
368
|
+
*
|
369
|
+
* @param tex
|
370
|
+
*/
|
371
|
+
public void setColorBuffer(Texture tex) {
|
244
372
|
setColorBuffers(new Texture[] { tex }, 1);
|
245
373
|
}
|
246
374
|
|
247
|
-
|
248
|
-
|
375
|
+
/**
|
376
|
+
*
|
377
|
+
* @param textures
|
378
|
+
*/
|
379
|
+
public void setColorBuffers(Texture[] textures) {
|
249
380
|
setColorBuffers(textures, textures.length);
|
250
381
|
}
|
251
382
|
|
252
|
-
|
253
|
-
|
383
|
+
/**
|
384
|
+
*
|
385
|
+
* @param textures
|
386
|
+
* @param n
|
387
|
+
*/
|
388
|
+
public void setColorBuffers(Texture[] textures, int n) {
|
254
389
|
if (screenFb) return;
|
255
390
|
|
256
391
|
if (numColorBuffers != PApplet.min(n, textures.length)) {
|
@@ -282,8 +417,10 @@ public class FrameBuffer implements PConstants {
|
|
282
417
|
pg.popFramebuffer();
|
283
418
|
}
|
284
419
|
|
285
|
-
|
286
|
-
|
420
|
+
/**
|
421
|
+
*
|
422
|
+
*/
|
423
|
+
public void swapColorBuffers() {
|
287
424
|
for (int i = 0; i < numColorBuffers - 1; i++) {
|
288
425
|
int i1 = (i + 1);
|
289
426
|
Texture tmp = colorBufferTex[i];
|
@@ -303,8 +440,11 @@ public class FrameBuffer implements PConstants {
|
|
303
440
|
pg.popFramebuffer();
|
304
441
|
}
|
305
442
|
|
306
|
-
|
307
|
-
|
443
|
+
/**
|
444
|
+
*
|
445
|
+
* @return
|
446
|
+
*/
|
447
|
+
public int getDefaultReadBuffer() {
|
308
448
|
if (screenFb) {
|
309
449
|
return pgl.getDefaultReadBuffer();
|
310
450
|
} else {
|
@@ -312,8 +452,11 @@ public class FrameBuffer implements PConstants {
|
|
312
452
|
}
|
313
453
|
}
|
314
454
|
|
315
|
-
|
316
|
-
|
455
|
+
/**
|
456
|
+
*
|
457
|
+
* @return
|
458
|
+
*/
|
459
|
+
public int getDefaultDrawBuffer() {
|
317
460
|
if (screenFb) {
|
318
461
|
return pgl.getDefaultDrawBuffer();
|
319
462
|
} else {
|
@@ -326,6 +469,10 @@ public class FrameBuffer implements PConstants {
|
|
326
469
|
|
327
470
|
// Allocate/release framebuffer.
|
328
471
|
|
472
|
+
/**
|
473
|
+
*
|
474
|
+
*/
|
475
|
+
|
329
476
|
|
330
477
|
protected void allocate() {
|
331
478
|
dispose(); // Just in the case this object is being re-allocated.
|
@@ -353,8 +500,10 @@ public class FrameBuffer implements PConstants {
|
|
353
500
|
}
|
354
501
|
}
|
355
502
|
|
356
|
-
|
357
|
-
|
503
|
+
/**
|
504
|
+
*
|
505
|
+
*/
|
506
|
+
protected void dispose() {
|
358
507
|
if (screenFb) return;
|
359
508
|
if (glres != null) {
|
360
509
|
glres.dispose();
|
@@ -367,8 +516,11 @@ public class FrameBuffer implements PConstants {
|
|
367
516
|
}
|
368
517
|
}
|
369
518
|
|
370
|
-
|
371
|
-
|
519
|
+
/**
|
520
|
+
*
|
521
|
+
* @return
|
522
|
+
*/
|
523
|
+
protected boolean contextIsOutdated() {
|
372
524
|
if (screenFb) return false;
|
373
525
|
|
374
526
|
boolean outdated = !pgl.contextIsCurrent(context);
|
@@ -381,8 +533,10 @@ public class FrameBuffer implements PConstants {
|
|
381
533
|
return outdated;
|
382
534
|
}
|
383
535
|
|
384
|
-
|
385
|
-
|
536
|
+
/**
|
537
|
+
*
|
538
|
+
*/
|
539
|
+
protected void initColorBufferMultisample() {
|
386
540
|
if (screenFb) return;
|
387
541
|
|
388
542
|
pg.pushFramebuffer();
|
@@ -397,8 +551,10 @@ public class FrameBuffer implements PConstants {
|
|
397
551
|
pg.popFramebuffer();
|
398
552
|
}
|
399
553
|
|
400
|
-
|
401
|
-
|
554
|
+
/**
|
555
|
+
*
|
556
|
+
*/
|
557
|
+
protected void initPackedDepthStencilBuffer() {
|
402
558
|
if (screenFb) return;
|
403
559
|
|
404
560
|
if (width == 0 || height == 0) {
|
@@ -426,8 +582,10 @@ public class FrameBuffer implements PConstants {
|
|
426
582
|
pg.popFramebuffer();
|
427
583
|
}
|
428
584
|
|
429
|
-
|
430
|
-
|
585
|
+
/**
|
586
|
+
*
|
587
|
+
*/
|
588
|
+
protected void initDepthBuffer() {
|
431
589
|
if (screenFb) return;
|
432
590
|
|
433
591
|
if (width == 0 || height == 0) {
|
@@ -461,8 +619,10 @@ public class FrameBuffer implements PConstants {
|
|
461
619
|
pg.popFramebuffer();
|
462
620
|
}
|
463
621
|
|
464
|
-
|
465
|
-
|
622
|
+
/**
|
623
|
+
*
|
624
|
+
*/
|
625
|
+
protected void initStencilBuffer() {
|
466
626
|
if (screenFb) return;
|
467
627
|
|
468
628
|
if (width == 0 || height == 0) {
|
@@ -495,8 +655,10 @@ public class FrameBuffer implements PConstants {
|
|
495
655
|
pg.popFramebuffer();
|
496
656
|
}
|
497
657
|
|
498
|
-
|
499
|
-
|
658
|
+
/**
|
659
|
+
*
|
660
|
+
*/
|
661
|
+
protected void createPixelBuffer() {
|
500
662
|
pixelBuffer = IntBuffer.allocate(width * height);
|
501
663
|
pixelBuffer.rewind();
|
502
664
|
}
|