From 6b537307fdee1767b69ead05a7be49bb024457c1 Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Fri, 6 May 2011 01:50:47 +0000 Subject: [PATCH] * Deprecated ViewPort.setClearEnabled, since we have separate clear flags for each channel in the framebuffer git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7455 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/app/Application.java | 4 +-- .../core/com/jme3/renderer/RenderManager.java | 10 ++++--- .../src/core/com/jme3/renderer/ViewPort.java | 26 +++++++++++++------ .../com/jme3/water/SimpleWaterProcessor.java | 4 +-- .../com/jme3/water/WaterFilter.java | 2 +- .../jme3test/niftygui/TestNiftyToMesh.java | 4 +-- .../jme3test/post/TestMultiRenderTarget.java | 2 +- .../jme3test/post/TestRenderToMemory.java | 2 +- .../jme3test/post/TestRenderToTexture.java | 2 +- .../jme3test/renderer/TestMultiViews.java | 6 ++--- 10 files changed, 37 insertions(+), 25 deletions(-) diff --git a/engine/src/core/com/jme3/app/Application.java b/engine/src/core/com/jme3/app/Application.java index da98a237d..28a8c5e01 100644 --- a/engine/src/core/com/jme3/app/Application.java +++ b/engine/src/core/com/jme3/app/Application.java @@ -201,12 +201,12 @@ public class Application implements SystemListener { //Remy - 09/14/2010 setted the timer in the renderManager renderManager.setTimer(timer); viewPort = renderManager.createMainView("Default", cam); - viewPort.setClearEnabled(true); + viewPort.setClearFlags(true, true, true); // Create a new cam for the gui Camera guiCam = new Camera(settings.getWidth(), settings.getHeight()); guiViewPort = renderManager.createPostView("Gui Default", guiCam); - guiViewPort.setClearEnabled(false); + guiViewPort.setClearFlags(false, false, false); } /** diff --git a/engine/src/core/com/jme3/renderer/RenderManager.java b/engine/src/core/com/jme3/renderer/RenderManager.java index 1de08c028..a96d887b7 100644 --- a/engine/src/core/com/jme3/renderer/RenderManager.java +++ b/engine/src/core/com/jme3/renderer/RenderManager.java @@ -691,11 +691,13 @@ public class RenderManager { renderer.setFrameBuffer(vp.getOutputFrameBuffer()); setCamera(vp.getCamera(), false); - if (vp.isClearEnabled()) { - renderer.setBackgroundColor(vp.getBackgroundColor()); + if (vp.isClearDepth() || vp.isClearColor() || vp.isClearStencil()) { + if (vp.isClearColor()){ + renderer.setBackgroundColor(vp.getBackgroundColor()); + } renderer.clearBuffers(vp.isClearColor(), - vp.isClearDepth(), - vp.isClearStencil()); + vp.isClearDepth(), + vp.isClearStencil()); } List scenes = vp.getScenes(); diff --git a/engine/src/core/com/jme3/renderer/ViewPort.java b/engine/src/core/com/jme3/renderer/ViewPort.java index a3f5e1a87..2391b9236 100644 --- a/engine/src/core/com/jme3/renderer/ViewPort.java +++ b/engine/src/core/com/jme3/renderer/ViewPort.java @@ -50,8 +50,7 @@ public class ViewPort { protected FrameBuffer out = null; protected final ColorRGBA backColor = new ColorRGBA(0,0,0,0); - protected boolean clearEnabled = false; - protected boolean clearDepth = true, clearColor = true, clearStencil = true; + protected boolean clearDepth = false, clearColor = false, clearStencil = false; private boolean enabled = true; public ViewPort(String name, Camera cam) { @@ -76,8 +75,24 @@ public class ViewPort { processor.cleanup(); } + /** + * Does nothing. + * @deprecated Use {@link ViewPort#setClearColor(boolean) } and similar + * methods. + */ + @Deprecated public boolean isClearEnabled() { - return clearEnabled; + return clearDepth && clearColor && clearStencil; + } + + /** + * Does nothing. + * @deprecated Use {@link ViewPort#setClearColor(boolean) } and similar + * methods. + */ + @Deprecated + public void setClearEnabled(boolean clearEnabled) { + clearDepth = clearColor = clearStencil = clearEnabled; } public boolean isClearDepth() { @@ -104,12 +119,7 @@ public class ViewPort { this.clearStencil = clearStencil; } - public void setClearEnabled(boolean clearEnabled) { - this.clearEnabled = clearEnabled; - } - public void setClearFlags(boolean color, boolean depth, boolean stencil){ - this.clearEnabled = true; this.clearColor = color; this.clearDepth = depth; this.clearStencil = stencil; diff --git a/engine/src/desktop-fx/com/jme3/water/SimpleWaterProcessor.java b/engine/src/desktop-fx/com/jme3/water/SimpleWaterProcessor.java index 0d691d48e..73d6ac730 100644 --- a/engine/src/desktop-fx/com/jme3/water/SimpleWaterProcessor.java +++ b/engine/src/desktop-fx/com/jme3/water/SimpleWaterProcessor.java @@ -259,7 +259,7 @@ public class SimpleWaterProcessor implements SceneProcessor { // create a pre-view. a view that is rendered before the main view reflectionView = new ViewPort("Reflection View", reflectionCam); - reflectionView.setClearEnabled(true); + reflectionView.setClearFlags(true, true, true); reflectionView.setBackgroundColor(ColorRGBA.Black); // create offscreen framebuffer reflectionBuffer = new FrameBuffer(renderWidth, renderHeight, 1); @@ -275,7 +275,7 @@ public class SimpleWaterProcessor implements SceneProcessor { // create a pre-view. a view that is rendered before the main view refractionView = new ViewPort("Refraction View", refractionCam); - refractionView.setClearEnabled(true); + refractionView.setClearFlags(true, true, true); refractionView.setBackgroundColor(ColorRGBA.Black); // create offscreen framebuffer refractionBuffer = new FrameBuffer(renderWidth, renderHeight, 1); diff --git a/engine/src/desktop-fx/com/jme3/water/WaterFilter.java b/engine/src/desktop-fx/com/jme3/water/WaterFilter.java index 0d9010c80..12782b87e 100644 --- a/engine/src/desktop-fx/com/jme3/water/WaterFilter.java +++ b/engine/src/desktop-fx/com/jme3/water/WaterFilter.java @@ -188,7 +188,7 @@ public class WaterFilter extends Filter { reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth); reflectionCam = new Camera(reflectionMapSize, reflectionMapSize); reflectionView = new ViewPort("reflectionView", reflectionCam); - reflectionView.setClearEnabled(true); + reflectionView.setClearFlags(true, true, true); reflectionView.attachScene(reflectionScene); reflectionView.setOutputFrameBuffer(reflectionPass.getRenderFrameBuffer()); plane = new Plane(Vector3f.UNIT_Y, new Vector3f(0, waterHeight, 0).dot(Vector3f.UNIT_Y)); diff --git a/engine/src/test/jme3test/niftygui/TestNiftyToMesh.java b/engine/src/test/jme3test/niftygui/TestNiftyToMesh.java index 33e5c714f..2aacbc97b 100644 --- a/engine/src/test/jme3test/niftygui/TestNiftyToMesh.java +++ b/engine/src/test/jme3test/niftygui/TestNiftyToMesh.java @@ -58,7 +58,7 @@ public class TestNiftyToMesh extends SimpleApplication{ public void simpleInitApp() { ViewPort niftyView = renderManager.createPreView("NiftyView", new Camera(1024, 768)); - niftyView.setClearEnabled(true); + niftyView.setClearFlags(true, true, true); NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, @@ -76,7 +76,7 @@ public class TestNiftyToMesh extends SimpleApplication{ tex.setMagFilter(MagFilter.Bilinear); fb.setColorTexture(tex); - niftyView.setClearEnabled(true); + niftyView.setClearFlags(true, true, true); niftyView.setOutputFrameBuffer(fb); Box b = new Box(Vector3f.ZERO, 1, 1, 1); diff --git a/engine/src/test/jme3test/post/TestMultiRenderTarget.java b/engine/src/test/jme3test/post/TestMultiRenderTarget.java index 8e200e635..5cc3d2bb3 100644 --- a/engine/src/test/jme3test/post/TestMultiRenderTarget.java +++ b/engine/src/test/jme3test/post/TestMultiRenderTarget.java @@ -116,7 +116,7 @@ public class TestMultiRenderTarget extends SimpleApplication implements ScenePro public void initialize(RenderManager rm, ViewPort vp) { reshape(vp, vp.getCamera().getWidth(), vp.getCamera().getHeight()); viewPort.setOutputFrameBuffer(fb); - guiViewPort.setClearEnabled(true); + guiViewPort.setClearFlags(true, true, true); guiNode.attachChild(display); // guiNode.attachChild(display1); // guiNode.attachChild(display2); diff --git a/engine/src/test/jme3test/post/TestRenderToMemory.java b/engine/src/test/jme3test/post/TestRenderToMemory.java index 12892cbf5..c7c5ceb03 100644 --- a/engine/src/test/jme3test/post/TestRenderToMemory.java +++ b/engine/src/test/jme3test/post/TestRenderToMemory.java @@ -176,7 +176,7 @@ public class TestRenderToMemory extends SimpleApplication implements SceneProces // create a pre-view. a view that is rendered before the main view offView = renderManager.createPreView("Offscreen View", offCamera); offView.setBackgroundColor(ColorRGBA.DarkGray); - offView.setClearEnabled(true); + offView.setClearFlags(true, true, true); // this will let us know when the scene has been rendered to the // frame buffer diff --git a/engine/src/test/jme3test/post/TestRenderToTexture.java b/engine/src/test/jme3test/post/TestRenderToTexture.java index f61af99da..d3b033ac8 100644 --- a/engine/src/test/jme3test/post/TestRenderToTexture.java +++ b/engine/src/test/jme3test/post/TestRenderToTexture.java @@ -69,7 +69,7 @@ public class TestRenderToTexture extends SimpleApplication implements ActionList Camera offCamera = new Camera(512, 512); offView = renderManager.createPreView("Offscreen View", offCamera); - offView.setClearEnabled(true); + offView.setClearFlags(true, true, true); offView.setBackgroundColor(ColorRGBA.DarkGray); // create offscreen framebuffer diff --git a/engine/src/test/jme3test/renderer/TestMultiViews.java b/engine/src/test/jme3test/renderer/TestMultiViews.java index 64be9a8c9..73f3bdc8e 100644 --- a/engine/src/test/jme3test/renderer/TestMultiViews.java +++ b/engine/src/test/jme3test/renderer/TestMultiViews.java @@ -73,7 +73,7 @@ public class TestMultiViews extends SimpleApplication { cam2.setRotation(new Quaternion(0.0010108891f, 0.99857414f, -0.04928594f, 0.020481428f)); ViewPort view2 = renderManager.createMainView("Bottom Left", cam2); - view2.setClearEnabled(true); + view2.setClearFlags(true, true, true); view2.attachScene(rootNode); // Setup third view @@ -83,7 +83,7 @@ public class TestMultiViews extends SimpleApplication { cam3.setRotation(new Quaternion(0.004381671f, 0.72363687f, -0.69015175f, 0.0045953835f)); ViewPort view3 = renderManager.createMainView("Top Left", cam3); - view3.setClearEnabled(true); + view3.setClearFlags(true, true, true); view3.attachScene(rootNode); // Setup fourth view @@ -93,7 +93,7 @@ public class TestMultiViews extends SimpleApplication { cam4.setRotation(new Quaternion(0.02356979f, -0.74957186f, 0.026729556f, 0.66096294f)); ViewPort view4 = renderManager.createMainView("Top Right", cam4); - view4.setClearEnabled(true); + view4.setClearFlags(true, true, true); view4.attachScene(rootNode); } }