* Added AwtPanel.attachTo() argument that allows attaching panel to main framebuffer instead of replacing it on the viewports
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8481 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
768a2b9783
commit
ffce10b8da
@ -1567,6 +1567,9 @@ public class OGLESShaderRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public void setMainFrameBufferOverride(FrameBuffer fb){
|
||||||
|
}
|
||||||
|
|
||||||
public void setFrameBuffer(FrameBuffer fb) {
|
public void setFrameBuffer(FrameBuffer fb) {
|
||||||
if (verboseLogging) {
|
if (verboseLogging) {
|
||||||
logger.warning("setFrameBuffer is not supported.");
|
logger.warning("setFrameBuffer is not supported.");
|
||||||
|
@ -5,13 +5,7 @@ import android.content.res.Resources;
|
|||||||
import com.jme3.util.AndroidLogHandler;
|
import com.jme3.util.AndroidLogHandler;
|
||||||
import com.jme3.asset.AndroidAssetManager;
|
import com.jme3.asset.AndroidAssetManager;
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.audio.AudioNode;
|
|
||||||
import com.jme3.audio.AudioData;
|
|
||||||
import com.jme3.audio.AudioParam;
|
|
||||||
import com.jme3.audio.AudioRenderer;
|
import com.jme3.audio.AudioRenderer;
|
||||||
import com.jme3.audio.Environment;
|
|
||||||
import com.jme3.audio.Listener;
|
|
||||||
import com.jme3.audio.ListenerParam;
|
|
||||||
import com.jme3.audio.android.AndroidAudioRenderer;
|
import com.jme3.audio.android.AndroidAudioRenderer;
|
||||||
//import com.jme3.audio.DummyAudioRenderer;
|
//import com.jme3.audio.DummyAudioRenderer;
|
||||||
import com.jme3.system.JmeContext.Type;
|
import com.jme3.system.JmeContext.Type;
|
||||||
|
@ -207,6 +207,14 @@ public interface Renderer {
|
|||||||
*/
|
*/
|
||||||
public void setFrameBuffer(FrameBuffer fb);
|
public void setFrameBuffer(FrameBuffer fb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the framebuffer that will be set instead of the main framebuffer
|
||||||
|
* when a call to setFrameBuffer(null) is made.
|
||||||
|
*
|
||||||
|
* @param fb
|
||||||
|
*/
|
||||||
|
public void setMainFrameBufferOverride(FrameBuffer fb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the pixels currently stored in the specified framebuffer
|
* Reads the pixels currently stored in the specified framebuffer
|
||||||
* into the given ByteBuffer object.
|
* into the given ByteBuffer object.
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
/*
|
|
||||||
* To change this template, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package com.jme3.system;
|
package com.jme3.system;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author normenhansen
|
|
||||||
*/
|
|
||||||
public class JmeVersion {
|
public class JmeVersion {
|
||||||
public static final String FULL_NAME = "jMonkeyEngine 3.0beta";
|
public static final String FULL_NAME = "jMonkeyEngine 3.0.0 Beta";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,9 @@ public class NullRenderer implements Renderer {
|
|||||||
public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyDepth) {
|
public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyDepth) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMainFrameBufferOverride(FrameBuffer fb) {
|
||||||
|
}
|
||||||
|
|
||||||
public void setFrameBuffer(FrameBuffer fb) {
|
public void setFrameBuffer(FrameBuffer fb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import java.awt.BufferCapabilities;
|
|||||||
import java.awt.Canvas;
|
import java.awt.Canvas;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.ImageCapabilities;
|
import java.awt.ImageCapabilities;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.event.ComponentAdapter;
|
import java.awt.event.ComponentAdapter;
|
||||||
@ -30,6 +29,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
public class AwtPanel extends Canvas implements SceneProcessor {
|
public class AwtPanel extends Canvas implements SceneProcessor {
|
||||||
|
|
||||||
|
private boolean attachAsMain = false;
|
||||||
|
|
||||||
private BufferedImage img;
|
private BufferedImage img;
|
||||||
private FrameBuffer fb;
|
private FrameBuffer fb;
|
||||||
private ByteBuffer byteBuf;
|
private ByteBuffer byteBuf;
|
||||||
@ -186,7 +187,7 @@ public class AwtPanel extends Canvas implements SceneProcessor {
|
|||||||
return paintMode != PaintMode.OnRequest && showing.get();
|
return paintMode != PaintMode.OnRequest && showing.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachTo(ViewPort ... vps){
|
public void attachTo(boolean overrideMainFramebuffer, ViewPort ... vps){
|
||||||
if (viewPorts.size() > 0){
|
if (viewPorts.size() > 0){
|
||||||
for (ViewPort vp : viewPorts){
|
for (ViewPort vp : viewPorts){
|
||||||
vp.setOutputFrameBuffer(null);
|
vp.setOutputFrameBuffer(null);
|
||||||
@ -196,6 +197,8 @@ public class AwtPanel extends Canvas implements SceneProcessor {
|
|||||||
|
|
||||||
viewPorts.addAll(Arrays.asList(vps));
|
viewPorts.addAll(Arrays.asList(vps));
|
||||||
viewPorts.get(viewPorts.size()-1).addProcessor(this);
|
viewPorts.get(viewPorts.size()-1).addProcessor(this);
|
||||||
|
|
||||||
|
this.attachAsMain = overrideMainFramebuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(RenderManager rm, ViewPort vp) {
|
public void initialize(RenderManager rm, ViewPort vp) {
|
||||||
@ -214,6 +217,10 @@ public class AwtPanel extends Canvas implements SceneProcessor {
|
|||||||
fb.setDepthBuffer(Format.Depth);
|
fb.setDepthBuffer(Format.Depth);
|
||||||
fb.setColorBuffer(Format.RGB8);
|
fb.setColorBuffer(Format.RGB8);
|
||||||
|
|
||||||
|
if (attachAsMain){
|
||||||
|
rm.getRenderer().setMainFrameBufferOverride(fb);
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (lock){
|
synchronized (lock){
|
||||||
img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
}
|
}
|
||||||
@ -227,7 +234,9 @@ public class AwtPanel extends Canvas implements SceneProcessor {
|
|||||||
transformOp = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
|
transformOp = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
|
||||||
|
|
||||||
for (ViewPort vp : viewPorts){
|
for (ViewPort vp : viewPorts){
|
||||||
|
if (!attachAsMain){
|
||||||
vp.setOutputFrameBuffer(fb);
|
vp.setOutputFrameBuffer(fb);
|
||||||
|
}
|
||||||
vp.getCamera().resize(width, height, true);
|
vp.getCamera().resize(width, height, true);
|
||||||
|
|
||||||
// NOTE: Hack alert. This is done ONLY for custom framebuffers.
|
// NOTE: Hack alert. This is done ONLY for custom framebuffers.
|
||||||
@ -255,7 +264,7 @@ public class AwtPanel extends Canvas implements SceneProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void postFrame(FrameBuffer out) {
|
public void postFrame(FrameBuffer out) {
|
||||||
if (out != fb){
|
if (!attachAsMain && out != fb){
|
||||||
throw new IllegalStateException("Why did you change the output framebuffer?");
|
throw new IllegalStateException("Why did you change the output framebuffer?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1158,6 +1158,9 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyDepth) {
|
public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyDepth) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMainFrameBufferOverride(FrameBuffer fb){
|
||||||
|
}
|
||||||
|
|
||||||
public void setFrameBuffer(FrameBuffer fb) {
|
public void setFrameBuffer(FrameBuffer fb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +147,7 @@ public class LwjglRenderer implements Renderer {
|
|||||||
private int maxDepthTexSamples;
|
private int maxDepthTexSamples;
|
||||||
private boolean tdc;
|
private boolean tdc;
|
||||||
private FrameBuffer lastFb = null;
|
private FrameBuffer lastFb = null;
|
||||||
|
private FrameBuffer mainFbOverride = null;
|
||||||
private final Statistics statistics = new Statistics();
|
private final Statistics statistics = new Statistics();
|
||||||
private int vpX, vpY, vpW, vpH;
|
private int vpX, vpY, vpW, vpH;
|
||||||
private int clipX, clipY, clipW, clipH;
|
private int clipX, clipY, clipW, clipH;
|
||||||
@ -1528,7 +1529,15 @@ public class LwjglRenderer implements Renderer {
|
|||||||
return samplePositions;
|
return samplePositions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMainFrameBufferOverride(FrameBuffer fb){
|
||||||
|
mainFbOverride = fb;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFrameBuffer(FrameBuffer fb) {
|
public void setFrameBuffer(FrameBuffer fb) {
|
||||||
|
if (fb == null && mainFbOverride != null){
|
||||||
|
fb = mainFbOverride;
|
||||||
|
}
|
||||||
|
|
||||||
if (lastFb == fb) {
|
if (lastFb == fb) {
|
||||||
if (fb == null || !fb.isUpdateNeeded()){
|
if (fb == null || !fb.isUpdateNeeded()){
|
||||||
return;
|
return;
|
||||||
|
@ -81,8 +81,8 @@ public class TestAwtPanels extends SimpleApplication {
|
|||||||
geom.setMaterial(mat);
|
geom.setMaterial(mat);
|
||||||
rootNode.attachChild(geom);
|
rootNode.attachChild(geom);
|
||||||
|
|
||||||
panel.attachTo(viewPort);
|
panel.attachTo(true, viewPort);
|
||||||
guiViewPort.setClearFlags(true, true, true);
|
guiViewPort.setClearFlags(true, true, true);
|
||||||
panel2.attachTo(guiViewPort);
|
panel2.attachTo(false, guiViewPort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user