I am creating a class called “ScreenshotAppState” extends AbstractAppState implements ActionListener, SceneProcessor{…} to take screen shots when a certain flag is set to true.
It is running normally on windows, but when i tried it on ubuntu the output images are always black.
Also I noticed that @Override
public void postFrame(FrameBuffer out) {…} is always working even i dont call it anywhere in the code.
can someone help me, please ?!
The default screenshot key is KeyInput.KEY_SYSRQ, alos known as “System Request / Print Screen key. On Mac keyboards, this key does not exist, so on Mac OS you take screenshots using Command+Shift+3 (fullscreen) or Command+Shift+4 (windowed: press space to select a window and then click).
i dont see anything more in documentation, so maybe its just ubuntu issue.
so idk why ubuntu have them black, but anyway if postFramealways run, it might be intended, depends if there is condition inside or not.
if this is really ubuntu issue, you should go here:
I wrote my own icon renderer which is basically just a screenshot appstate that doesn’t save to file but to ram, and it worked just fine on Ubuntu. Maybe try the official screenshot app state and see if that one works.
The official ScreenshotAppState (in com.jme3.app.state) is tricky to use on some Linux systems (including mine) because the appstate is hardcoded to listen for the PrtSc key (known to JMonkeyEngine as KeyInput.KEY_SYSRQ).
My window manager (I honestly don’t even know which one I’m using) appears to intercept the PrtSc key, so the JMonkeyEngine appstate never sees it. Has anyone come up with a workaround for this?
Oh you mean the OS tries to make a screenshot?
An easy workaround would be to add an additional constructor specifying a KeyInput, sounds reasonable to me!
Note that nothing prevents you from adding the existing ScreenShotAppState to whatever key mapping you want since it does the (bad practice but helpful here) of implementing the action listener directly.
Edit: you an even just set the key that calls the mapping yourself to something different:
inputManager.addMapping(“ScreenShot”, new KeyTrigger(KeyInput.KEY_SYSRQ));
well I am not taking the screen shot, when a certain key is pressed. I take the screen shot based on some conditions in my code. so using this :-
ScreenshotAppState screenShotState = new ScreenshotAppState();
this.stateManager.attach(screenShotState);
doesn’t provide me with functionality needed.
Public void postframe (FrameBuffer out){} is called automatically, whenever i try to get frame buffer from viewport out side this method it is always zero (all elements = zero).
I find that odd as this problem didn’t occur in windows as i was reading framebuffer from another method and it wasn’t zero.
can you tell me the problem or am I doing something wrong ?