Fixed ScreenshotAppState, VideoRecorderAppSate, AwtPanel and TestRenderToMemory so the frameBuffer is read with an BGRA8 format

experimental
Nehon 10 years ago
parent 8b3e335d33
commit 50ec3023d4
  1. 3
      jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java
  2. 3
      jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java
  3. 4
      jme3-desktop/src/main/java/com/jme3/system/awt/AwtPanel.java
  4. 3
      jme3-examples/src/main/java/jme3test/post/TestRenderToMemory.java

@ -44,6 +44,7 @@ import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue;
import com.jme3.system.JmeSystem; import com.jme3.system.JmeSystem;
import com.jme3.texture.FrameBuffer; import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;
import com.jme3.util.BufferUtils; import com.jme3.util.BufferUtils;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -229,7 +230,7 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen
int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight()); int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());
renderer.setViewPort(0, 0, width, height); renderer.setViewPort(0, 0, width, height);
renderer.readFrameBuffer(out, outBuf); renderer.readFrameBufferWithFormat(out, outBuf, Image.Format.BGRA8);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight); renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
File file; File file;

@ -40,6 +40,7 @@ import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue;
import com.jme3.system.Timer; import com.jme3.system.Timer;
import com.jme3.texture.FrameBuffer; import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;
import com.jme3.util.BufferUtils; import com.jme3.util.BufferUtils;
import com.jme3.util.Screenshots; import com.jme3.util.Screenshots;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -228,7 +229,7 @@ public class VideoRecorderAppState extends AbstractAppState {
final WorkItem item = freeItems.take(); final WorkItem item = freeItems.take();
usedItems.add(item); usedItems.add(item);
item.buffer.clear(); item.buffer.clear();
renderer.readFrameBuffer(out, item.buffer); renderer.readFrameBufferWithFormat(out, item.buffer, Image.Format.BGRA8);
executor.submit(new Callable<Void>() { executor.submit(new Callable<Void>() {
public Void call() throws Exception { public Void call() throws Exception {

@ -155,7 +155,7 @@ public class AwtPanel extends Canvas implements SceneProcessor {
public void repaintInThread(){ public void repaintInThread(){
// Convert screenshot. // Convert screenshot.
byteBuf.clear(); byteBuf.clear();
rm.getRenderer().readFrameBuffer(fb, byteBuf); rm.getRenderer().readFrameBufferWithFormat(fb, byteBuf,Format.BGRA8);
synchronized (lock){ synchronized (lock){
// All operations on img must be synchronized // All operations on img must be synchronized
@ -168,7 +168,7 @@ public class AwtPanel extends Canvas implements SceneProcessor {
public void drawFrameInThread(){ public void drawFrameInThread(){
// Convert screenshot. // Convert screenshot.
byteBuf.clear(); byteBuf.clear();
rm.getRenderer().readFrameBuffer(fb, byteBuf); rm.getRenderer().readFrameBufferWithFormat(fb, byteBuf,Format.BGRA8);
Screenshots.convertScreenShot2(intBuf, img); Screenshots.convertScreenShot2(intBuf, img);
synchronized (lock){ synchronized (lock){

@ -48,6 +48,7 @@ import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings; import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext.Type; import com.jme3.system.JmeContext.Type;
import com.jme3.texture.FrameBuffer; import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;
import com.jme3.texture.Image.Format; import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture2D; import com.jme3.texture.Texture2D;
import com.jme3.util.BufferUtils; import com.jme3.util.BufferUtils;
@ -158,7 +159,7 @@ public class TestRenderToMemory extends SimpleApplication implements SceneProces
public void updateImageContents(){ public void updateImageContents(){
cpuBuf.clear(); cpuBuf.clear();
renderer.readFrameBuffer(offBuffer, cpuBuf); renderer.readFrameBufferWithFormat(offBuffer, cpuBuf, Image.Format.BGRA8);
synchronized (image) { synchronized (image) {
Screenshots.convertScreenShot(cpuBuf, image); Screenshots.convertScreenShot(cpuBuf, image);

Loading…
Cancel
Save