|
@@ -31,7 +31,7 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen
|
|
|
private String appName;
|
|
private String appName;
|
|
|
private int shotIndex = 0;
|
|
private int shotIndex = 0;
|
|
|
private int width, height;
|
|
private int width, height;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void initialize(AppStateManager stateManager, Application app) {
|
|
public void initialize(AppStateManager stateManager, Application app) {
|
|
|
if (!super.isInitialized()){
|
|
if (!super.isInitialized()){
|
|
@@ -45,7 +45,7 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen
|
|
|
|
|
|
|
|
appName = app.getClass().getSimpleName();
|
|
appName = app.getClass().getSimpleName();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
super.initialize(stateManager, app);
|
|
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) {
|
|
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);
|