Skip to content

Commit 358651d

Browse files
committed
latest gl updates
1 parent 29bc987 commit 358651d

File tree

3 files changed

+145
-101
lines changed

3 files changed

+145
-101
lines changed

core/src/processing/opengl/PGL.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,8 @@ private void createFBOLayer() {
878878
fboHeight = nextPowerOfTwo((int)(scale * graphics.height));
879879
}
880880

881-
int maxs = maxSamples();
882-
if (hasFboMultisampleSupport() && 1 < maxs) {
881+
if (hasFboMultisampleSupport()) {
882+
int maxs = maxSamples();
883883
numSamples = PApplet.min(reqNumSamples, maxs);
884884
} else {
885885
numSamples = 1;
@@ -959,7 +959,7 @@ private void createFBOLayer() {
959959

960960
protected void saveFirstFrame() {
961961
firstFrame = allocateDirectIntBuffer(graphics.width * graphics.height);
962-
readBuffer(BACK);
962+
if (hasReadBuffer()) readBuffer(BACK);
963963
readPixelsImpl(0, 0, graphics.width, graphics.height, RGBA, UNSIGNED_BYTE, firstFrame);
964964
}
965965

@@ -2188,6 +2188,24 @@ protected boolean hasPBOs() {
21882188
}
21892189

21902190

2191+
protected boolean hasReadBuffer() {
2192+
int[] version = getGLVersion();
2193+
if (isES()) {
2194+
return version[0] >= 3;
2195+
}
2196+
return version[0] >= 2;
2197+
}
2198+
2199+
2200+
protected boolean hasDrawBuffer() {
2201+
int[] version = getGLVersion();
2202+
if (isES()) {
2203+
return version[0] >= 3;
2204+
}
2205+
return version[0] >= 2;
2206+
}
2207+
2208+
21912209
protected int maxSamples() {
21922210
intBuffer.rewind();
21932211
getIntegerv(MAX_SAMPLES, intBuffer);

core/src/processing/opengl/PGLES.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ protected void initFBOLayer() {
226226
if (0 < sketch.frameCount) {
227227
IntBuffer buf = allocateDirectIntBuffer(fboWidth * fboHeight);
228228

229-
readBuffer(BACK);
229+
if (hasReadBuffer()) readBuffer(BACK);
230230
readPixelsImpl(0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
231231
bindTexture(TEXTURE_2D, glColorTex.get(frontTex));
232232
texSubImage2D(TEXTURE_2D, 0, 0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);

0 commit comments

Comments
 (0)