You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.8 KiB
57 lines
1.8 KiB
14 years ago
|
package jme3test.awt;
|
||
|
|
||
|
import com.jme3.app.SimpleApplication;
|
||
|
import com.jme3.material.Material;
|
||
|
import com.jme3.math.Vector3f;
|
||
|
import com.jme3.scene.Geometry;
|
||
|
import com.jme3.scene.shape.Box;
|
||
|
import com.jme3.system.AppSettings;
|
||
|
import com.jme3.system.JmeCanvasContext;
|
||
|
import java.awt.Canvas;
|
||
|
import java.awt.event.WindowAdapter;
|
||
|
import java.awt.event.WindowEvent;
|
||
|
import javax.swing.JFrame;
|
||
|
|
||
|
public class TestSafeCanvas extends SimpleApplication {
|
||
|
|
||
|
public static void main(String[] args){
|
||
|
AppSettings settings = new AppSettings(true);
|
||
|
settings.setWidth(640);
|
||
|
settings.setHeight(480);
|
||
|
|
||
|
final TestSafeCanvas app = new TestSafeCanvas();
|
||
|
app.setPauseOnLostFocus(false);
|
||
|
app.setSettings(settings);
|
||
|
app.createCanvas();
|
||
|
|
||
|
JmeCanvasContext context = (JmeCanvasContext) app.getContext();
|
||
|
Canvas canvas = context.getCanvas();
|
||
|
canvas.setSize(settings.getWidth(), settings.getHeight());
|
||
|
|
||
|
JFrame frame = new JFrame("Test");
|
||
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||
|
frame.addWindowListener(new WindowAdapter() {
|
||
|
@Override
|
||
|
public void windowClosing(WindowEvent e) {
|
||
|
app.stop();
|
||
|
}
|
||
|
});
|
||
|
frame.getContentPane().add(canvas);
|
||
|
frame.pack();
|
||
|
frame.setLocationRelativeTo(null);
|
||
|
frame.setVisible(true);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void simpleInitApp() {
|
||
|
flyCam.setDragToRotate(true);
|
||
|
|
||
|
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
|
||
|
Geometry geom = new Geometry("Box", b);
|
||
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
||
|
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||
|
geom.setMaterial(mat);
|
||
|
rootNode.attachChild(geom);
|
||
|
}
|
||
|
}
|