takeScreenShot grabScreenContents twisted image result

Hi,

I reopen the bug from this spot:

http://hub.jmonkeyengine.org/groups/general-2/forum/topic/take-screenshot-generates-twisted-image



I’m using grabScreenContents to print a capture of my engine view.

The problem is the result is completely twisted: geometries are deformed and i have the wrong colors(gray for the most part)

Of course I have exactly the same issue with takeScreenShot.

Anyone has an idea how to deal with this?



Thanks.

anyone working on jme2 knows about this issue?

Theres nobody working “on” jME2 here anymore, only people working with it maybe.

I guess it matters when you call that method. You want to call it right before swapBuffers() … I am guessing that might be at simpleRender (for SimpleGame)?

I work with my own game based on AbstractGame.



I call the method takeScreenShot (or grabScreenContents) in the update method (of the game or one of the states I added to the GameStateManager) but maybe I’m wrong.

same issue if I call it in the render method

here is how my render method looks like:



@Override

protected void render(float interpolation) {

try {

if (this.getRenderer() != null) {

this.getRenderer().clearBuffers();

this.getRenderer().displayBackBuffer();

}



// Execute renderQueue item

if (GameTaskQueueManager.getManager() != null)

GameTaskQueueManager.getManager().getQueue(GameTaskQueue.RENDER).execute();



// Render the GameStates

if (GameStateManager.getInstance() != null)

GameStateManager.getInstance().render(interpolation);



} catch (Exception e) {

e.printStackTrace();

logger.error(“Error”, e);

}

}

I don’t exactly remember how jME2 works.

Do you have to handle clearing and displaying back buffer manually?

If so then fixing this issue should be fairly simple.

Just place the take screenshot part either before a clearBuffers() or after displayBackBuffer()

Either of those places should have the complete frame. Only difference is that before clearBuffers() you need to read the front buffer and not the backbuffer …



[java]try {

if (this.getRenderer() != null) {

this.getRenderer().clearBuffers();

this.getRenderer().displayBackBuffer();

}[/java]

I don’t get this part, you clear the buffer, then you render it? You’re wasting performance if thats the case.

This part is not my code but I can change it.

I joined the project 3 months after the beginning .



Without this part the nodes of the state are not rendered so…



What do think I should do? I have indeed a lack of performance.

taking screenshot either before clearBuffers() or after displayBackBuffer() doesn’t change a thing, still a twisted image

Okay then I don’t know. You might have to provide more code. Check your calls and make sure you’re doing it similarly to SimpleGame