- Use new AWT lightweight panel in SDK (should fix linux issues, freezes and more)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8338 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent fa92c00a20
commit dc50b0c457
  1. 28
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java
  2. 12
      sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java
  3. 4
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java

@ -48,6 +48,8 @@ import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.Spatial.CullHint; import com.jme3.scene.Spatial.CullHint;
import com.jme3.system.AppSettings; import com.jme3.system.AppSettings;
import com.jme3.system.awt.AwtPanel;
import com.jme3.system.awt.AwtPanelsContext;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
@ -108,11 +110,14 @@ public class SceneApplication extends Application implements LookupProvider, Loo
private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening SceneViewer.."); private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening SceneViewer..");
private String lastError = ""; private String lastError = "";
private boolean started = false; private boolean started = false;
private AwtPanel panel;
private ViewPort overlayView;
public SceneApplication() { public SceneApplication() {
progressHandle.start(7); progressHandle.start(7);
try { try {
AppSettings newSetting = new AppSettings(true); AppSettings newSetting = new AppSettings(true);
newSetting.setCustomRenderer(AwtPanelsContext.class);
newSetting.setFrameRate(30); newSetting.setFrameRate(30);
setSettings(newSetting); setSettings(newSetting);
@ -123,9 +128,9 @@ public class SceneApplication extends Application implements LookupProvider, Loo
//add listener for project selection //add listener for project selection
nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(JmeSpatial.class); nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(JmeSpatial.class);
nodeSelectionResult.addLookupListener(this); nodeSelectionResult.addLookupListener(this);
// createCanvas();
// startCanvas(true);
createCanvas();
startCanvas(true);
progressHandle.progress("initialize Base Application", 1); progressHandle.progress("initialize Base Application", 1);
} catch (Exception e) { } catch (Exception e) {
getProgressHandle().finish(); getProgressHandle().finish();
@ -136,6 +141,20 @@ public class SceneApplication extends Application implements LookupProvider, Loo
SceneViewerTopComponent.showOpenGLError(e.toString()); SceneViewerTopComponent.showOpenGLError(e.toString());
Exceptions.printStackTrace(e); Exceptions.printStackTrace(e);
} }
start();
}
public AwtPanel getMainPanel() {
if (panel == null) {
panel = ((AwtPanelsContext) getContext()).createPanel(true);
panel.attachTo(viewPort, guiViewPort, overlayView);
((AwtPanelsContext) getContext()).setInputSource(panel);
}
return panel;
}
public ViewPort getOverlayView(){
return overlayView;
} }
private void loadFPSText() { private void loadFPSText() {
@ -160,6 +179,11 @@ public class SceneApplication extends Application implements LookupProvider, Loo
public void initialize() { public void initialize() {
try { try {
super.initialize(); super.initialize();
{
overlayView = getRenderManager().createMainView("Overlay", cam);
overlayView.setClearFlags(false, true, false);
guiViewPort.setClearFlags(false, false, false);
}
getProgressHandle().progress("Setup Camera Controller", 2); getProgressHandle().progress("Setup Camera Controller", 2);
//create camera controler //create camera controler
camController = new SceneCameraController(cam, inputManager); camController = new SceneCameraController(cam, inputManager);

@ -29,8 +29,8 @@ import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.core.scene.SceneRequest; import com.jme3.gde.core.scene.SceneRequest;
import com.jme3.input.awt.AwtKeyInput; import com.jme3.input.awt.AwtKeyInput;
import com.jme3.input.event.KeyInputEvent; import com.jme3.input.event.KeyInputEvent;
import com.jme3.system.JmeCanvasContext; import com.jme3.system.awt.AwtPanel;
import java.awt.Canvas; import com.jme3.system.awt.AwtPanelsContext;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
@ -64,7 +64,8 @@ public final class SceneViewerTopComponent extends TopComponent {
private static final String PREFERRED_ID = "SceneViewerTopComponent"; private static final String PREFERRED_ID = "SceneViewerTopComponent";
private SceneApplication app; private SceneApplication app;
private HelpCtx helpContext = new HelpCtx("com.jme3.gde.core.sceneviewer"); private HelpCtx helpContext = new HelpCtx("com.jme3.gde.core.sceneviewer");
private Canvas oglCanvas; // private Canvas oglCanvas;
private AwtPanel oglCanvas;
public SceneViewerTopComponent() { public SceneViewerTopComponent() {
initComponents(); initComponents();
@ -75,7 +76,8 @@ public final class SceneViewerTopComponent extends TopComponent {
setIcon(ImageUtilities.loadImage(ICON_PATH, true)); setIcon(ImageUtilities.loadImage(ICON_PATH, true));
try { try {
app = SceneApplication.getApplication(); app = SceneApplication.getApplication();
oglCanvas = ((JmeCanvasContext) app.getContext()).getCanvas(); // oglCanvas = ((JmeCanvasContext) app.getContext()).getCanvas();
oglCanvas = app.getMainPanel();
oGLPanel.add(oglCanvas); oGLPanel.add(oglCanvas);
} catch (Exception e) { } catch (Exception e) {
@ -292,6 +294,7 @@ public final class SceneViewerTopComponent extends TopComponent {
@Override @Override
public void componentOpened() { public void componentOpened() {
super.componentOpened(); super.componentOpened();
oglCanvas.setActiveUpdates(true);
} }
@Override @Override
@ -307,6 +310,7 @@ public final class SceneViewerTopComponent extends TopComponent {
@Override @Override
public void componentClosed() { public void componentClosed() {
super.componentClosed(); super.componentClosed();
oglCanvas.setActiveUpdates(false);
SceneRequest req = SceneApplication.getApplication().getCurrentSceneRequest(); SceneRequest req = SceneApplication.getApplication().getCurrentSceneRequest();
if (req != null) { if (req != null) {
SceneApplication.getApplication().closeScene(req); SceneApplication.getApplication().closeScene(req);

@ -65,8 +65,8 @@ public class SceneComposerToolController extends SceneToolController {
// a node in a viewport that will always render on top // a node in a viewport that will always render on top
onTopToolsNode = new Node("OverlayNode"); onTopToolsNode = new Node("OverlayNode");
overlayView = SceneApplication.getApplication().getRenderManager().createMainView("Overlay", this.cameraController.getCamera()); overlayView = SceneApplication.getApplication().getOverlayView();
overlayView.setClearFlags(false, true, false); // overlayView.setClearFlags(false, true, false);
overlayView.attachScene(onTopToolsNode); overlayView.attachScene(onTopToolsNode);
} }

Loading…
Cancel
Save