mirror of
https://github.com/processing/processing4.git
synced 2026-02-14 02:45:36 +01:00
Changed setSize logic:
SetSize only sets the sized flag. All the rest is done directly before draw. Force reallocation of lights and transformation matrices (might get garbled during resize...). Do not perform a full init of the primary surface but rather a light version...
This commit is contained in:
@@ -559,22 +559,6 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
width = iwidth;
|
||||
height = iheight;
|
||||
|
||||
allocate();
|
||||
reapplySettings();
|
||||
|
||||
// init perspective projection based on new dimensions
|
||||
cameraFOV = 60 * DEG_TO_RAD; // at least for now
|
||||
cameraX = width / 2.0f;
|
||||
cameraY = height / 2.0f;
|
||||
cameraZ = cameraY / ((float) Math.tan(cameraFOV / 2.0f));
|
||||
cameraNear = cameraZ / 10.0f;
|
||||
cameraFar = cameraZ * 10.0f;
|
||||
cameraAspect = (float) width / (float) height;
|
||||
|
||||
// Forces a restart of OpenGL so the canvas has the right size.
|
||||
restartPGL();
|
||||
|
||||
// set this flag so that beginDraw() will do an update to the camera.
|
||||
sized = true;
|
||||
}
|
||||
|
||||
@@ -1582,6 +1566,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
public void requestDraw() {
|
||||
if (primarySurface) {
|
||||
if (initialized) {
|
||||
if (sized) reinitPrimary();
|
||||
|
||||
pgl.requestDraw();
|
||||
} else {
|
||||
initPrimary();
|
||||
@@ -5961,6 +5947,32 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
|
||||
|
||||
protected void reinitPrimary() {
|
||||
lightsAllocated = false;
|
||||
matricesAllocated = false;
|
||||
|
||||
allocate();
|
||||
|
||||
reapplySettings();
|
||||
|
||||
// init perspective projection based on new dimensions
|
||||
cameraFOV = 60 * DEG_TO_RAD; // at least for now
|
||||
cameraX = width / 2.0f;
|
||||
cameraY = height / 2.0f;
|
||||
cameraZ = cameraY / ((float) Math.tan(cameraFOV / 2.0f));
|
||||
cameraNear = cameraZ / 10.0f;
|
||||
cameraFar = cameraZ * 10.0f;
|
||||
cameraAspect = (float) width / (float) height;
|
||||
|
||||
// Forces a restart of OpenGL so the canvas has the right size.
|
||||
// restartPGL();
|
||||
|
||||
// System.out.println("hasbeenSized");
|
||||
|
||||
pgl.reinitSurface();
|
||||
}
|
||||
|
||||
|
||||
protected void beginOnscreenDraw() {
|
||||
pgl.beginDraw(clearColorBuffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user