* 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
3.0
sha..rd 13 years ago
parent 768a2b9783
commit ffce10b8da
  1. 3
      engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java
  2. 6
      engine/src/android/com/jme3/system/JmeSystem.java
  3. 8
      engine/src/core/com/jme3/renderer/Renderer.java
  4. 11
      engine/src/core/com/jme3/system/JmeVersion.java
  5. 3
      engine/src/core/com/jme3/system/NullRenderer.java
  6. 17
      engine/src/desktop/com/jme3/system/awt/AwtPanel.java
  7. 3
      engine/src/lwjgl-ogl/com/jme3/renderer/lwjgl/LwjglGL1Renderer.java
  8. 9
      engine/src/lwjgl-ogl/com/jme3/renderer/lwjgl/LwjglRenderer.java
  9. 4
      engine/src/test/jme3test/awt/TestAwtPanels.java

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

@ -207,6 +207,14 @@ public interface Renderer {
*/
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
* 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;
/**
*
* @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;
@ -1528,7 +1529,15 @@ 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…
Cancel
Save