mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
allocate in setSize()
This commit is contained in:
@@ -570,6 +570,17 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
width = iwidth;
|
||||
height = iheight;
|
||||
|
||||
allocate();
|
||||
|
||||
// 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;
|
||||
|
||||
sized = true;
|
||||
}
|
||||
|
||||
@@ -1579,8 +1590,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
public void requestDraw() {
|
||||
if (primarySurface) {
|
||||
if (initialized) {
|
||||
if (sized) reinitPrimary();
|
||||
|
||||
if (sized) pgl.reinitSurface();
|
||||
pgl.requestDraw();
|
||||
} else {
|
||||
initPrimary();
|
||||
@@ -5963,27 +5973,6 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
|
||||
|
||||
protected void reinitPrimary() {
|
||||
allocate();
|
||||
|
||||
// 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