Skip to content

Instantly share code, notes, and snippets.

@void256
Created June 27, 2013 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save void256/498c687c7facef4132e0 to your computer and use it in GitHub Desktop.
Save void256/498c687c7facef4132e0 to your computer and use it in GitHub Desktop.
jogl
public static void run(final String[] args, final Callback callback) throws Exception {
InputStream input = null;
try {
input = LoggerShortFormat.class.getClassLoader().getResourceAsStream("logging.properties");
LogManager.getLogManager().readConfiguration(input);
} finally {
if (input != null) {
input.close();
}
}
if (args.length == 1) {
useBatchedRenderer = "batch".equals(args[0]);
useBatchedCoreRenderer = "core".equals(args[0]);
if (useBatchedCoreRenderer) {
useBatchedRenderer = true;
}
}
Runnable run = new Runnable() {
@Override
public void run() {
canvas = new GLCanvas(new GLCapabilities(getProfile(useBatchedCoreRenderer)));
canvas.setAutoSwapBufferMode(true);
canvas.setSize(CANVAS_WIDTH, CANVAS_HEIGHT);
canvas.addGLEventListener(new JOGLNiftyRunner(callback));
final FPSAnimator animator = new FPSAnimator(canvas, FPS, false);
frame = new Frame(getCaption(useBatchedRenderer, useBatchedCoreRenderer));
frame.setSize(CANVAS_WIDTH, CANVAS_HEIGHT);
frame.add(canvas);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
animator.stop();
frame.remove(canvas);
System.exit(0);
}
});
animator.start();
}
};
SwingUtilities.invokeAndWait(run);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment