LWJGL is something completly different than AWT. When we are talking about LWJGL, we are (in this case) talking about OpenGL, which is a library specification for a 3D hardware pipeline.
AWT uses can use OpenGL, but can also switch to software rendering, if needed.
OpenGL is usually used from C / C++, since it’s written in C (usually… It’s only a specification, so it’s actually implemented by your drivers…), and therefore we have LWJGL, which wraps OpenGL and makes it accessible in Java.
You can use LWJGL just like any other Java library but with natives (native libraries (C libs)). In LWJGL you setup a window like this:
try {
Display.setDisplayMode(new DisplayMode(800 /* Display width */, 600 /* Display height */));
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
Then you initialize your OpenGL code like this:
public void resize(int width, int height) {
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
}
// Init:
glLoadIdentity();
resize(Display.getWidth(), Display.getHeight());
And finally you draw your Polygon like this:
public void render() {
// Assume you have your polygon's vertices stored in a "Vec2[]".
// Use GL_POLYGON if you don't want to stroke the polygon,
// but fill the polygon with a color. To set the filling color
// use "glColor3f(1, 1, 1)" (= white).
glBegin(GL_LINE_LOOP);
for (int i = 0; i < poly.vertices.length; i++) {
glVertex2f(poly.vertices[i].x, poly.vertices[i].y);
}
// This call will "calculate" the geometry:
glEnd();
// This call will render the geometry using all your GPU Power:
Display.update(); // Call this once a frame
}
This is only to show you how using LWJGL would look like. (to use all those methods you need to static-import the class GL11. This is done by writing this to the imports: static import org.lwjgl.opengl.GL11.*;
)
Get more information and the library itself, at the LWJGL website or at it’s wiki page.
There is also a forum, but personally I’ve found this forum to be more helpful in LWJGL-related questions…
Also, you don’t need to use LWJGL. There are game engines and libraries written on top of LWJGL. Just google for libGDX, Slick2D or the (not very famous) JRabbit engine, for example. There are many more.
And: There is another wrapper for OpenGL for java out there: JOGL, also known as the JogAmp project. I don’t suggest using this library, since it’s pretty complicated for newbies, but you could consider moving to JOGL when having more experience with Java, or especially OpenGL.
And yes. It (fucking) is worth it 