this.ships = SpaceshipState.stateType.newArray(maxItems);
final GLProfile glp = GLProfile.get(GLProfile.GL3);
final GLCapabilitiesImmutable glcaps = (GLCapabilitiesImmutable) new GLCapabilities(glp);
final GLAutoDrawable drawable;
final GLCapabilities tGLCapabilities = new GLCapabilities(glp);
tGLCapabilities.setSampleBuffers(true);
tGLCapabilities.setNumSamples(1);
// tGLCapabilities.setAccumAlphaBits(16);
// tGLCapabilities.setAccumBlueBits(16);
// tGLCapabilities.setAccumGreenBits(16);
// tGLCapabilities.setAccumRedBits(16);
if (TOOLKIT == Toolkit.NEWT || TOOLKIT == Toolkit.NEWT_CANVAS) {
final GLWindow newt = GLWindow.create(glcaps);
final NewtListener listener = new NewtListener();
newt.addKeyListener(listener);
newt.addMouseListener(listener);
drawable = newt;
} else {
final GLCanvas glCanvas = new GLCanvas(glcaps);
final AwtListener listener = new AwtListener();
glCanvas.addKeyListener(listener);
glCanvas.addMouseListener(listener);
glCanvas.addMouseMotionListener(listener);
glCanvas.addMouseWheelListener(listener);
drawable = glCanvas;
}
animator = new FPSAnimator(drawable, 30);
if (TOOLKIT == Toolkit.NEWT) {
final GLWindow window = (GLWindow) drawable;
window.addWindowListener(new com.jogamp.newt.event.WindowAdapter() {
@Override
public void windowDestroyNotify(com.jogamp.newt.event.WindowEvent arg0) {
animator.stop();
System.exit(0);
}
});
window.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
window.setTitle(WINDOW_TITLE);
window.setVisible(true);
this.window = window;
} else {
final Component canvas;
if (TOOLKIT == Toolkit.NEWT_CANVAS)
canvas = new NewtCanvasAWT((GLWindow) drawable);
else
canvas = (GLCanvas) drawable;
final Frame window = new Frame();
window.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent windowevent) {
animator.stop();
window.remove(canvas);
window.dispose();
System.exit(0);
}
});
window.add(canvas);
window.pack();
canvas.requestFocusInWindow();
window.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
window.setTitle(WINDOW_TITLE);
window.setVisible(true);
this.window = window;
}
drawable.addGLEventListener(this);
animator.start();
}