Fix up the way we create our display to play nicely with the JmeCanvasApp.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3821 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -94,16 +94,6 @@ public class JmeApp
|
|||||||
public boolean init ()
|
public boolean init ()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// load up our renderer configuration
|
|
||||||
_properties = new PropertiesIO(getConfigPath("jme.cfg"));
|
|
||||||
readDisplayConfig();
|
|
||||||
|
|
||||||
// create an appropriate timer
|
|
||||||
_timer = Timer.getTimer(_properties.getRenderer());
|
|
||||||
|
|
||||||
// default to 60 fps
|
|
||||||
setTargetFrameRate(60);
|
|
||||||
|
|
||||||
// initialize the rendering system
|
// initialize the rendering system
|
||||||
initDisplay();
|
initDisplay();
|
||||||
if (!_display.isCreated()) {
|
if (!_display.isCreated()) {
|
||||||
@@ -111,6 +101,12 @@ public class JmeApp
|
|||||||
"Failed to initialize display?");
|
"Failed to initialize display?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create an appropriate timer
|
||||||
|
_timer = Timer.getTimer(_api);
|
||||||
|
|
||||||
|
// default to 60 fps
|
||||||
|
setTargetFrameRate(60);
|
||||||
|
|
||||||
// initialize our main camera controls and user input handling
|
// initialize our main camera controls and user input handling
|
||||||
initInput();
|
initInput();
|
||||||
|
|
||||||
@@ -217,15 +213,15 @@ public class JmeApp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads in the contents of our display properties. Derivations may
|
* Determines the display configuration and creates the display. This must
|
||||||
* wish to override this and configure the display properties from
|
* fill in {@link #_api} as a side-effect.
|
||||||
* some other source.
|
|
||||||
*/
|
*/
|
||||||
protected void readDisplayConfig ()
|
protected DisplaySystem createDisplay ()
|
||||||
{
|
{
|
||||||
if (!_properties.load()) {
|
PropertiesIO props = new PropertiesIO(getConfigPath("jme.cfg"));
|
||||||
|
if (!props.load()) {
|
||||||
LWJGLPropertiesDialog dialog =
|
LWJGLPropertiesDialog dialog =
|
||||||
new LWJGLPropertiesDialog(_properties, (String)null);
|
new LWJGLPropertiesDialog(props, (String)null);
|
||||||
while (dialog.isVisible()) {
|
while (dialog.isVisible()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5);
|
Thread.sleep(5);
|
||||||
@@ -235,6 +231,12 @@ public class JmeApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_api = props.getRenderer();
|
||||||
|
DisplaySystem display = DisplaySystem.getDisplaySystem(_api);
|
||||||
|
display.createWindow(props.getWidth(), props.getHeight(),
|
||||||
|
props.getDepth(), props.getFreq(),
|
||||||
|
props.getFullscreen());
|
||||||
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,16 +246,8 @@ public class JmeApp
|
|||||||
protected void initDisplay ()
|
protected void initDisplay ()
|
||||||
throws JmeException
|
throws JmeException
|
||||||
{
|
{
|
||||||
// create the main display system (JmeCanvasApp creates the
|
// create the main display system
|
||||||
// display and the window earlier and in a different way, so we
|
_display = createDisplay();
|
||||||
// need to avoid doing that here if it's already been done)
|
|
||||||
if (_display == null) {
|
|
||||||
_display = DisplaySystem.getDisplaySystem(_properties.getRenderer());
|
|
||||||
_display.createWindow(
|
|
||||||
_properties.getWidth(), _properties.getHeight(),
|
|
||||||
_properties.getDepth(), _properties.getFreq(),
|
|
||||||
_properties.getFullscreen());
|
|
||||||
}
|
|
||||||
_display.setVSyncEnabled(true);
|
_display.setVSyncEnabled(true);
|
||||||
|
|
||||||
// create a camera
|
// create a camera
|
||||||
@@ -276,9 +270,6 @@ public class JmeApp
|
|||||||
// tell the renderer to keep track of rendering information (total
|
// tell the renderer to keep track of rendering information (total
|
||||||
// triangles drawn, etc.)
|
// triangles drawn, etc.)
|
||||||
_display.getRenderer().enableStatistics(true);
|
_display.getRenderer().enableStatistics(true);
|
||||||
|
|
||||||
// // set our display title
|
|
||||||
// _display.setTitle("TBD");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -288,7 +279,7 @@ public class JmeApp
|
|||||||
protected void initInput ()
|
protected void initInput ()
|
||||||
{
|
{
|
||||||
_camhand = createCameraHandler(_camera);
|
_camhand = createCameraHandler(_camera);
|
||||||
_input = createInputHandler(_camhand, _properties.getRenderer());
|
_input = createInputHandler(_camhand);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -304,7 +295,7 @@ public class JmeApp
|
|||||||
* Creates the input handler used to control our camera and manage non-UI
|
* Creates the input handler used to control our camera and manage non-UI
|
||||||
* keyboard input.
|
* keyboard input.
|
||||||
*/
|
*/
|
||||||
protected InputHandler createInputHandler (CameraHandler camhand, String api)
|
protected InputHandler createInputHandler (CameraHandler hand)
|
||||||
{
|
{
|
||||||
return new InputHandler();
|
return new InputHandler();
|
||||||
}
|
}
|
||||||
@@ -526,7 +517,7 @@ public class JmeApp
|
|||||||
protected Thread _dispatchThread;
|
protected Thread _dispatchThread;
|
||||||
protected Queue _evqueue = new Queue();
|
protected Queue _evqueue = new Queue();
|
||||||
|
|
||||||
protected PropertiesIO _properties;
|
protected String _api;
|
||||||
protected DisplaySystem _display;
|
protected DisplaySystem _display;
|
||||||
protected Camera _camera;
|
protected Camera _camera;
|
||||||
protected CameraHandler _camhand;
|
protected CameraHandler _camhand;
|
||||||
|
|||||||
@@ -92,9 +92,15 @@ public class JmeCanvasApp extends JmeApp
|
|||||||
return EventQueue.isDispatchThread();
|
return EventQueue.isDispatchThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// documentation inherited
|
||||||
* Initializes our user interface bits.
|
protected DisplaySystem createDisplay ()
|
||||||
*/
|
{
|
||||||
|
// we've already created our display earlier so just return it
|
||||||
|
_api = "LWJGL";
|
||||||
|
return _display;
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
protected void initInterface ()
|
protected void initInterface ()
|
||||||
{
|
{
|
||||||
_iface = new Node("Interface");
|
_iface = new Node("Interface");
|
||||||
|
|||||||
@@ -29,16 +29,15 @@ public class GodViewHandler extends InputHandler
|
|||||||
* Creates the handler.
|
* Creates the handler.
|
||||||
*
|
*
|
||||||
* @param cam The camera to move with this handler.
|
* @param cam The camera to move with this handler.
|
||||||
* @param api The API from which to create a KeyBindingManager.
|
|
||||||
*/
|
*/
|
||||||
public GodViewHandler (CameraHandler camhand, String api)
|
public GodViewHandler (CameraHandler camhand)
|
||||||
{
|
{
|
||||||
_camhand = camhand;
|
_camhand = camhand;
|
||||||
setKeyBindings(api);
|
setKeyBindings();
|
||||||
addActions();
|
addActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setKeyBindings (String api)
|
protected void setKeyBindings ()
|
||||||
{
|
{
|
||||||
KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager();
|
KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user