package aurelienribon.bodyeditor.ui;

import aurelienribon.bodyeditor.Ctx;
import aurelienribon.bodyeditor.canvas.Canvas;
import com.badlogic.gdx.backends.lwjgl.LwjglCanvas;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.json.JSONException;

/**
 * @author Aurelien Ribon | http://www.aurelienribon.com/
 */
public class Main {
    public static void main(final String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override public void run() {
				try {
					UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
				} catch (ClassNotFoundException ex) {
				} catch (InstantiationException ex) {
				} catch (IllegalAccessException ex) {
				} catch (UnsupportedLookAndFeelException ex) {
				}

				LwjglCanvas glCanvas = new LwjglCanvas(new Canvas());
				MainWindow mw = Ctx.window;

				Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
				mw.setSize(
					Math.min(1150, screenSize.width - 100),
					Math.min(800, screenSize.height - 100)
				);

				mw.setCanvas(glCanvas.getCanvas());
				mw.setLocationRelativeTo(null);
				mw.setVisible(true);

				parseArgs(args);
			}
		});
    }

	private static void parseArgs(String[] args) {
		for (int i=1; i<args.length; i++) {
			if (args[i-1].equals("-f")) {
				try {
					File file = new File(args[i]).getCanonicalFile();
					Ctx.io.setProjectFile(file);
					Ctx.io.importFromFile();
				} catch (IOException ex) {
				} catch (JSONException ex) {
				}
			}
		}
	}
}

@@ -110,24 +110,95 @@
 nvas.Canvas;
+%0A%0Aimport com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
 %0Aimport com.
@@ -972,16 +972,123 @@
 %0A%09%09%09%09%7D%0A%0A
+%09%09%09%09LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();%0A%09%09%09%09config.useGL30 = true;%0A
 %09%09%09%09Lwjg
@@ -1130,24 +1130,32 @@
 new Canvas()
+, config
 );%0A%09%09%09%09MainW

Configure LwjglApplication to use GL 3.0. Fixes https://github.com/MovingBlocks/box2d-editor/issues/35.