FilterPostProcessor fixed resizing issue with canvas

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7654 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent bb916a02c2
commit be366b5b53
  1. 23
      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"); fsQuad = new Picture("filter full screen quad");
Camera cam = vp.getCamera(); Camera cam = vp.getCamera();
//save view port diensions
left = cam.getViewPortLeft(); left = cam.getViewPortLeft();
right = cam.getViewPortRight(); right = cam.getViewPortRight();
top = cam.getViewPortTop(); top = cam.getViewPortTop();
bottom = cam.getViewPortBottom(); bottom = cam.getViewPortBottom();
//Changing the viewPort to the filter cam an reseting the viewport of the viewport cam
originalWidth = cam.getWidth(); originalWidth = cam.getWidth();
originalHeight = cam.getHeight(); originalHeight = cam.getHeight();
cam.setViewPort(0, 1, 0, 1); //first call to reshape
reshape(vp, cam.getWidth(), cam.getHeight()); 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) { 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))); width = (int) (w * (Math.abs(right - left)));
height = (int) (h * (Math.abs(bottom - top))); height = (int) (h * (Math.abs(bottom - top)));
width = Math.max(1, width); width = Math.max(1, width);
height = Math.max(1, height); height = Math.max(1, height);
vp.getCamera().resize(width, height, false); cam.resize(width, height, false);
cameraInit = true; cameraInit = true;
computeDepth = false; computeDepth = false;

Loading…
Cancel
Save