From be366b5b5301ecbfce7c32c41b7d0b59a5918129 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Fri, 17 Jun 2011 22:26:41 +0000 Subject: [PATCH] FilterPostProcessor fixed resizing issue with canvas git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7654 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/post/FilterPostProcessor.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/engine/src/core/com/jme3/post/FilterPostProcessor.java b/engine/src/core/com/jme3/post/FilterPostProcessor.java index b55794e96..3f10e8863 100644 --- a/engine/src/core/com/jme3/post/FilterPostProcessor.java +++ b/engine/src/core/com/jme3/post/FilterPostProcessor.java @@ -135,15 +135,18 @@ public class FilterPostProcessor implements SceneProcessor, Savable { fsQuad = new Picture("filter full screen quad"); Camera cam = vp.getCamera(); + + + //save view port diensions left = cam.getViewPortLeft(); right = cam.getViewPortRight(); top = cam.getViewPortTop(); bottom = cam.getViewPortBottom(); - //Changing the viewPort to the filter cam an reseting the viewport of the viewport cam originalWidth = cam.getWidth(); originalHeight = cam.getHeight(); - cam.setViewPort(0, 1, 0, 1); + //first call to reshape reshape(vp, cam.getWidth(), cam.getHeight()); + } /** @@ -364,11 +367,25 @@ public class FilterPostProcessor implements SceneProcessor, Savable { } public void reshape(ViewPort vp, int w, int h) { + //this has no effect at first init but is useful when resizing the canvas with multi views + Camera cam = vp.getCamera(); + cam.setViewPort(left, right, bottom, top); + //resizing the camera to fit the new viewport and saving original dimensions + cam.resize(w, h, false); + left = cam.getViewPortLeft(); + right = cam.getViewPortRight(); + top = cam.getViewPortTop(); + bottom = cam.getViewPortBottom(); + originalWidth = w; + originalHeight = h; + cam.setViewPort(0, 1, 0, 1); + + //computing real dimension of the viewport and resizing he camera width = (int) (w * (Math.abs(right - left))); height = (int) (h * (Math.abs(bottom - top))); width = Math.max(1, width); height = Math.max(1, height); - vp.getCamera().resize(width, height, false); + cam.resize(width, height, false); cameraInit = true; computeDepth = false;