From 6bb5fcfb04f544cd8a2895d341ad403b0c32c65c Mon Sep 17 00:00:00 2001 From: Nicholas Hansen Date: Fri, 27 Feb 2015 12:25:04 +1000 Subject: [PATCH] Fix for incorrect viewport sizes Fixed an issue where viewport sizes could be a pixel smaller in either dimension in certain situations. This caused gaps to appear between adjacent viewports at certain resolutions. Forum Reference: http://hub.jmonkeyengine.org/t/fix-for-rounding-errors-in-viewport-dimensions/31751 --- jme3-core/src/main/java/com/jme3/renderer/RenderManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java index 2c0c8a4b8..311a3bcfc 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java +++ b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java @@ -865,8 +865,8 @@ public class RenderManager { if (cam != prevCam || cam.isViewportChanged()) { viewX = (int) (cam.getViewPortLeft() * cam.getWidth()); viewY = (int) (cam.getViewPortBottom() * cam.getHeight()); - viewWidth = (int) ((cam.getViewPortRight() - cam.getViewPortLeft()) * cam.getWidth()); - viewHeight = (int) ((cam.getViewPortTop() - cam.getViewPortBottom()) * cam.getHeight()); + viewWidth = ((int)(cam.getViewPortRight() * cam.getWidth())) - ((int)(cam.getViewPortLeft() * cam.getWidth())); + viewHeight = ((int)(cam.getViewPortTop() * cam.getHeight())) - ((int)(cam.getViewPortBottom() * cam.getHeight())); uniformBindingManager.setViewPort(viewX, viewY, viewWidth, viewHeight); renderer.setViewPort(viewX, viewY, viewWidth, viewHeight); renderer.setClipRect(viewX, viewY, viewWidth, viewHeight);