mirror of
https://github.com/processing/processing4.git
synced 2026-05-30 20:19:27 +02:00
Recreate framebuffer objects when opengl context changes
This commit is contained in:
@@ -402,6 +402,25 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
protected boolean contextIsOutdated() {
|
||||
boolean outdated = !pgl.contextIsCurrent(context);
|
||||
if (outdated) {
|
||||
glFboID = 0;
|
||||
glDepthBufferID = 0;
|
||||
glStencilBufferID = 0;
|
||||
glDepthStencilBufferID = 0;
|
||||
glColorBufferMultisampleID = 0;
|
||||
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
colorBufferTex[i] = null;
|
||||
}
|
||||
|
||||
backupTexture = null;
|
||||
}
|
||||
return outdated;
|
||||
}
|
||||
|
||||
|
||||
protected void createColorBufferMultisample() {
|
||||
if (screenFb) return;
|
||||
|
||||
|
||||
@@ -1376,7 +1376,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
} else {
|
||||
if (!pgl.initialized) {
|
||||
initOffscreen();
|
||||
}
|
||||
} else {
|
||||
boolean outdated = offscreenFramebuffer != null && offscreenFramebuffer.contextIsOutdated();
|
||||
boolean outdatedMulti = offscreenFramebufferMultisample != null && offscreenFramebufferMultisample.contextIsOutdated();
|
||||
if (outdated || outdatedMulti) {
|
||||
pgl.initialized = false;
|
||||
initOffscreen();
|
||||
}
|
||||
}
|
||||
|
||||
pushFramebuffer();
|
||||
if (offscreenMultisample) {
|
||||
@@ -4851,7 +4858,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
protected void loadTextureImpl(int sampling) {
|
||||
if (width == 0 || height == 0) return;
|
||||
if (texture == null) {
|
||||
if (texture == null || texture.contextIsOutdated()) {
|
||||
PTexture.Parameters params = PTexture.newParameters(ARGB, sampling);
|
||||
texture = new PTexture(parent, width, height, params);
|
||||
texture.setFlippedY(true);
|
||||
|
||||
Reference in New Issue
Block a user