* 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) {
|
||||
if (verboseLogging) {
|
||||
logger.warning("setFrameBuffer is not supported.");
|
||||
|
@ -5,13 +5,7 @@ import android.content.res.Resources;
|
||||
import com.jme3.util.AndroidLogHandler;
|
||||
import com.jme3.asset.AndroidAssetManager;
|
||||
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.Environment;
|
||||
import com.jme3.audio.Listener;
|
||||
import com.jme3.audio.ListenerParam;
|
||||
import com.jme3.audio.android.AndroidAudioRenderer;
|
||||
//import com.jme3.audio.DummyAudioRenderer;
|
||||
import com.jme3.system.JmeContext.Type;
|
||||
|
@ -206,6 +206,14 @@ public interface Renderer {
|
||||
* Sets the framebuffer that will be drawn to.
|
||||
*/
|
||||
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
|
||||
|
@ -1,14 +1,5 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.jme3.system;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author normenhansen
|
||||
*/
|
||||
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 setMainFrameBufferOverride(FrameBuffer fb) {
|
||||
}
|
||||
|
||||
public void setFrameBuffer(FrameBuffer fb) {
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import java.awt.BufferCapabilities;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.ImageCapabilities;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
@ -30,6 +29,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class AwtPanel extends Canvas implements SceneProcessor {
|
||||
|
||||
private boolean attachAsMain = false;
|
||||
|
||||
private BufferedImage img;
|
||||
private FrameBuffer fb;
|
||||
private ByteBuffer byteBuf;
|
||||
@ -186,7 +187,7 @@ public class AwtPanel extends Canvas implements SceneProcessor {
|
||||
return paintMode != PaintMode.OnRequest && showing.get();
|
||||
}
|
||||
|
||||
public void attachTo(ViewPort ... vps){
|
||||
public void attachTo(boolean overrideMainFramebuffer, ViewPort ... vps){
|
||||
if (viewPorts.size() > 0){
|
||||
for (ViewPort vp : viewPorts){
|
||||
vp.setOutputFrameBuffer(null);
|
||||
@ -196,6 +197,8 @@ public class AwtPanel extends Canvas implements SceneProcessor {
|
||||
|
||||
viewPorts.addAll(Arrays.asList(vps));
|
||||
viewPorts.get(viewPorts.size()-1).addProcessor(this);
|
||||
|
||||
this.attachAsMain = overrideMainFramebuffer;
|
||||
}
|
||||
|
||||
public void initialize(RenderManager rm, ViewPort vp) {
|
||||
@ -214,6 +217,10 @@ public class AwtPanel extends Canvas implements SceneProcessor {
|
||||
fb.setDepthBuffer(Format.Depth);
|
||||
fb.setColorBuffer(Format.RGB8);
|
||||
|
||||
if (attachAsMain){
|
||||
rm.getRenderer().setMainFrameBufferOverride(fb);
|
||||
}
|
||||
|
||||
synchronized (lock){
|
||||
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);
|
||||
|
||||
for (ViewPort vp : viewPorts){
|
||||
vp.setOutputFrameBuffer(fb);
|
||||
if (!attachAsMain){
|
||||
vp.setOutputFrameBuffer(fb);
|
||||
}
|
||||
vp.getCamera().resize(width, height, true);
|
||||
|
||||
// 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) {
|
||||
if (out != fb){
|
||||
if (!attachAsMain && out != fb){
|
||||
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 setMainFrameBufferOverride(FrameBuffer fb){
|
||||
}
|
||||
|
||||
public void setFrameBuffer(FrameBuffer fb) {
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,7 @@ public class LwjglRenderer implements Renderer {
|
||||
private int maxDepthTexSamples;
|
||||
private boolean tdc;
|
||||
private FrameBuffer lastFb = null;
|
||||
private FrameBuffer mainFbOverride = null;
|
||||
private final Statistics statistics = new Statistics();
|
||||
private int vpX, vpY, vpW, vpH;
|
||||
private int clipX, clipY, clipW, clipH;
|
||||
@ -1527,8 +1528,16 @@ public class LwjglRenderer implements Renderer {
|
||||
}
|
||||
return samplePositions;
|
||||
}
|
||||
|
||||
public void setMainFrameBufferOverride(FrameBuffer fb){
|
||||
mainFbOverride = fb;
|
||||
}
|
||||
|
||||
public void setFrameBuffer(FrameBuffer fb) {
|
||||
if (fb == null && mainFbOverride != null){
|
||||
fb = mainFbOverride;
|
||||
}
|
||||
|
||||
if (lastFb == fb) {
|
||||
if (fb == null || !fb.isUpdateNeeded()){
|
||||
return;
|
||||
|
@ -81,8 +81,8 @@ public class TestAwtPanels extends SimpleApplication {
|
||||
geom.setMaterial(mat);
|
||||
rootNode.attachChild(geom);
|
||||
|
||||
panel.attachTo(viewPort);
|
||||
panel.attachTo(true, viewPort);
|
||||
guiViewPort.setClearFlags(true, true, true);
|
||||
panel2.attachTo(guiViewPort);
|
||||
panel2.attachTo(false, guiViewPort);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user