Initial work on making use of full-screen exclusive mode and additional
rendering optimizations available in JDK 1.4. Use a BufferStrategy, and changed AnimatedPanel to extend Canvas rather than JPanel. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@847 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
//
|
||||
// $Id: ViewerApp.java,v 1.22 2001/12/16 06:52:11 shaper Exp $
|
||||
// $Id: ViewerApp.java,v 1.23 2002/01/08 22:16:59 shaper Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
@@ -43,9 +47,26 @@ public class ViewerApp
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// create and size the main application frame
|
||||
_frame = new ViewerFrame();
|
||||
_frame.setSize(WIDTH, HEIGHT);
|
||||
// get the graphics environment
|
||||
GraphicsEnvironment env =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
|
||||
// get the target graphics device
|
||||
GraphicsDevice gd = env.getDefaultScreenDevice();
|
||||
Log.info("Graphics device [dev=" + gd +
|
||||
", mem=" + gd.getAvailableAcceleratedMemory() +
|
||||
", displayChange=" + gd.isDisplayChangeSupported() +
|
||||
", fullScreen=" + gd.isFullScreenSupported() + "].");
|
||||
|
||||
// get the graphics configuration and display mode information
|
||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||
DisplayMode dm = gd.getDisplayMode();
|
||||
Log.info("Display mode [bits=" + dm.getBitDepth() +
|
||||
", wid=" + dm.getWidth() + ", hei=" + dm.getHeight() +
|
||||
", refresh=" + dm.getRefreshRate() + "].");
|
||||
|
||||
// create the window
|
||||
_frame = new ViewerFrame(gc);
|
||||
|
||||
// we don't need to configure anything
|
||||
_config = new Config();
|
||||
@@ -88,6 +109,18 @@ public class ViewerApp
|
||||
Log.logStackTrace(e);
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// size and position the window, entering full-screen exclusive
|
||||
// mode if available
|
||||
if (gd.isFullScreenSupported()) {
|
||||
Log.info("Entering full-screen exclusive mode.");
|
||||
gd.setFullScreenWindow(_frame);
|
||||
|
||||
} else {
|
||||
Log.warning("Full-screen exclusive mode not available.");
|
||||
_frame.pack();
|
||||
SwingUtil.centerWindow(_frame);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,8 +146,7 @@ public class ViewerApp
|
||||
*/
|
||||
public void run ()
|
||||
{
|
||||
_frame.pack();
|
||||
SwingUtil.centerWindow(_frame);
|
||||
// show the window
|
||||
_frame.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
//
|
||||
// $Id: ViewerFrame.java,v 1.28 2001/11/18 04:09:21 mdb Exp $
|
||||
// $Id: ViewerFrame.java,v 1.29 2002/01/08 22:16:59 shaper Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.samskivert.swing.GroupLayout;
|
||||
import com.samskivert.swing.VGroupLayout;
|
||||
|
||||
/**
|
||||
* The viewer frame is the main application window.
|
||||
@@ -14,14 +20,32 @@ public class ViewerFrame extends JFrame
|
||||
/**
|
||||
* Creates a frame in which the viewer application can operate.
|
||||
*/
|
||||
public ViewerFrame ()
|
||||
public ViewerFrame (GraphicsConfiguration gc)
|
||||
{
|
||||
super("Scene Viewer");
|
||||
super(gc);
|
||||
|
||||
// set up the frame options
|
||||
setTitle("Scene Viewer");
|
||||
// setUndecorated(true);
|
||||
setIgnoreRepaint(true);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
|
||||
// center the scene view within the frame
|
||||
GroupLayout gl = new VGroupLayout();
|
||||
gl.setJustification(GroupLayout.CENTER);
|
||||
gl.setOffAxisJustification(GroupLayout.CENTER);
|
||||
getContentPane().setLayout(gl);
|
||||
|
||||
// set the frame and content panel background to black
|
||||
setBackground(Color.black);
|
||||
getContentPane().setBackground(Color.black);
|
||||
}
|
||||
|
||||
public void setPanel (JPanel panel)
|
||||
/**
|
||||
* Sets the panel displayed by this frame.
|
||||
*/
|
||||
public void setPanel (Component panel)
|
||||
{
|
||||
// if we had an old panel, remove it
|
||||
if (_panel != null) {
|
||||
@@ -33,5 +57,5 @@ public class ViewerFrame extends JFrame
|
||||
getContentPane().add(_panel);
|
||||
}
|
||||
|
||||
protected JPanel _panel;
|
||||
protected Component _panel;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
//
|
||||
// $Id: ViewerSceneViewPanel.java,v 1.36 2001/12/16 06:52:11 shaper Exp $
|
||||
// $Id: ViewerSceneViewPanel.java,v 1.37 2002/01/08 22:16:59 shaper Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
@@ -45,7 +46,7 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
super(ctx.getConfig(), spritemgr);
|
||||
|
||||
// create an animation manager for this panel
|
||||
_animmgr = new AnimationManager(spritemgr, this);
|
||||
_animmgr = new AnimationManager(spritemgr, this);
|
||||
|
||||
// create the character descriptors
|
||||
_descUser = CastUtil.getRandomDescriptor(crepo);
|
||||
@@ -126,9 +127,9 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void paintComponent (Graphics g)
|
||||
public void render (Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
super.render(g);
|
||||
PerformanceMonitor.tick(this, "paint");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user