Taking screen shot in jme on ubuntu machine

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 ?!

1 Like

in JME there already is something like:

ScreenshotAppState screenShotState = new ScreenshotAppState();
this.stateManager.attach(screenShotState);

with documentation:

https://wiki.jmonkeyengine.org/jme3/advanced/screenshots.html

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:


and add issue(if none exist)

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.

Also note that our SceneProcessors are flakey: Try it with a clear stack first.
Also try it with lwjgl2 and 3 and fullscreen or not.

postFrame is called automatically when you add the processor to the viewport, you shouldn’t call it.

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!

1 Like

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));

1 Like

It was bad of me to hijack the thread. Can anyone help the original poster, whose issue seems to be unrelated to mine?

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.

yes, but please read all i wrote.

imo you should say if key based screenshot work on ubuntu, if it dont, it sounds like ubuntu issue so you should create issue on github.

The problem i found is the following : -

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 ?