diff --git a/engine/src/desktop/com/jme3/app/state/ScreenshotAppState.java b/engine/src/core/com/jme3/app/state/ScreenshotAppState.java similarity index 90% rename from engine/src/desktop/com/jme3/app/state/ScreenshotAppState.java rename to engine/src/core/com/jme3/app/state/ScreenshotAppState.java index 639eaee6d..f970265fc 100644 --- a/engine/src/desktop/com/jme3/app/state/ScreenshotAppState.java +++ b/engine/src/core/com/jme3/app/state/ScreenshotAppState.java @@ -31,7 +31,7 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen private String appName; private int shotIndex = 0; private int width, height; - + @Override public void initialize(AppStateManager stateManager, Application app) { if (!super.isInitialized()){ @@ -45,7 +45,7 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen appName = app.getClass().getSimpleName(); } - + super.initialize(stateManager, app); } @@ -55,6 +55,10 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen } } + public void takeScreenshot() { + capture = true; + } + public void initialize(RenderManager rm, ViewPort vp) { renderer = rm.getRenderer(); reshape(vp, vp.getCamera().getWidth(), vp.getCamera().getHeight()); @@ -82,8 +86,12 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen capture = false; shotIndex++; + renderer.setViewPort(0, 0, width, height); renderer.readFrameBuffer(out, outBuf); - File file = new File(appName + shotIndex + ".png").getAbsoluteFile(); + + File file = new File(JmeSystem.getStorageFolder() + File.separator + appName + shotIndex + ".png").getAbsoluteFile(); + logger.log(Level.INFO, "Saving ScreenShot to: {0}", file.getAbsolutePath()); + OutputStream outStream = null; try { outStream = new FileOutputStream(file);