LWJGL and breaking awt/swing dependencies

I’m currently in the process of making my entire game engine in LWJGL only. I’ve learned the hard-way that Swing won’t give me the raw performance I want and mixing Swing and OpenGL is a tricky proposition for games.

Now that I’m mostly through the process (active rendering with LWJGL and custom GUI components) I’m wondering how far should I take it? Right now I’m completely free of Swing but I still rely on awt for font metrics.

  1. Is it possible to be completely free of awt i.e. never import anything from java.awt? Can one obtain enough display information from LWJGL to calculate DPI and scaling?
  2. Is it worthwhile to do so? I’m imagining future deployments of my game and would cutting out the awt/Swing libraries really save that much download space? I can see a benefit if I write for Android etc. I figure there won’t be any awt there.

I sort of think of AWT as Swing’s virtual dad. Unless you have a ton of time, being AWT-Free is like reinventing the wheel. Plus, the L in LWJGL stands for Lightweight, so don’t expect too much from it. AWT takes up less space than swing does, so it’s better to use AWT than swing if you’re concerned about download space. This is just my 2¢ on this topic.

For fonts you could bring in code from either slick-util or gdx-freetype, or use J2D as an intermediate: https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-&-Java2D

It would only save download space if you are distributing your own JRE. If you do that you should consider Compact Profiles.

Great thanks for the links and thoughts.

Compact profiles look like they won’t be of much help unless I am completely free of java.awt.* and it the grand scheme of things it will only save about 30 MB if I go down the route of building and distributing the JRE.