Skip to content

Commit 3eec84d

Browse files
committed
changes in Texture from desktop gl
1 parent 364de27 commit 3eec84d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/src/processing/opengl/Texture.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ public void disposeSourceBuffer() {
882882
}
883883

884884
public void getBufferPixels(int[] pixels) {
885+
boolean addToUsed = false;
885886
BufferData data = null;
886887
if (usedBuffers != null && 0 < usedBuffers.size()) {
887888
// the last used buffer is the one currently stored in the opengl
@@ -890,12 +891,24 @@ public void getBufferPixels(int[] pixels) {
890891
} else if (bufferCache != null && 0 < bufferCache.size()) {
891892
// The first buffer in the cache will be uploaded to the opengl texture
892893
// the next time it is rendered
893-
data = bufferCache.getFirst();
894+
data = bufferCache.remove(0);
895+
addToUsed = true;
894896
}
895897
if (data != null) {
898+
if ((data.w != width) || (data.h != height)) {
899+
init(data.w, data.h);
900+
}
901+
896902
data.rgbBuf.rewind();
897903
data.rgbBuf.get(pixels);
898904
convertToARGB(pixels);
905+
906+
if (addToUsed) {
907+
if (usedBuffers == null) {
908+
usedBuffers = new LinkedList<BufferData>();
909+
}
910+
usedBuffers.add(data);
911+
}
899912
}
900913
}
901914

0 commit comments

Comments
 (0)