Screenshots are now supported on Android. Be Aware, file location for screenshots is now based on JmeSystem.getStorageFolder. This means that on Desktop systems, the screenshots will be placed in the user.home location instead of the application directory. Other changes include: Moved ScreenshotAppState to core, added takeScreenShot method, force glViewPort to full screen to handle cases where the last postView ViewPort isn't full screen. See post http://jmonkeyengine.org/groups/android/forum/topic/screenshotappstate-for-android/

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9595 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
pot..om 13 years ago
parent 7756c21d4a
commit 0deeb597f1
  1. 10
      engine/src/core/com/jme3/app/state/ScreenshotAppState.java

@ -55,6 +55,10 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen
} }
} }
public void takeScreenshot() {
capture = true;
}
public void initialize(RenderManager rm, ViewPort vp) { public void initialize(RenderManager rm, ViewPort vp) {
renderer = rm.getRenderer(); renderer = rm.getRenderer();
reshape(vp, vp.getCamera().getWidth(), vp.getCamera().getHeight()); reshape(vp, vp.getCamera().getWidth(), vp.getCamera().getHeight());
@ -82,8 +86,12 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen
capture = false; capture = false;
shotIndex++; shotIndex++;
renderer.setViewPort(0, 0, width, height);
renderer.readFrameBuffer(out, outBuf); 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; OutputStream outStream = null;
try { try {
outStream = new FileOutputStream(file); outStream = new FileOutputStream(file);
Loading…
Cancel
Save