UPDATE:
The code is undergoing changes. It’s now becoming more of a utility library (the likes of SlickUtil, but cleaner and more modernized) rather than a bare-bones set of minimal code examples. Eventually I hope to turn it into a third party utility library for LWJGL 3.0.
The original minimal examples will be hosted on the Wiki. Small guides or tutorials may be included there, as well:
–
There are plenty of tutorials and guides on the web, but not a lot of “complete source examples” that demonstrate the bare essentials of a modern GL app in Java (i.e. no fixed function). This isn’t meant to be a tutorial/guide (at least not yet), but rather a source code reference for those trying to build their own 2D shader-based engines. It covers only the basics to get you started:
[]Basic LWJGL display creation
[]A simple Texture utility class to decode PNG files and load them into OpenGL textures
[]A simple ShaderProgram utility class to load and bind shaders (inspired by ra4king’s code)
[]A simple abstraction of “vertex data” – aka for Vertex Arrays, Vertex Buffer Objects, etc. (So far only vertex arrays has been implemented.)
[]Utilities for creating an orthographic 2D projection matrix (origin top-left)
[]A simple SpriteBatch, demonstrating how to put it all together to draw potentially thousands of sprites efficiently
–
Source: https://github.com/mattdesl/lwjgl-basics (BSD license)
It’s an early work in progress – I hope to add more documentation and more examples, e.g. geometry shaders.
For now it uses VertexArrays (which are sometimes faster than VBOs). At some point I hope to add VBOs.
I didn’t use GL3+ code or context since I’m running a 2.1 machine (as are many other Mac users). So while it may not truly be “modern GL,” it does not use any fixed-function pipeline like glVertex2f or glTranslatef, and the concepts are more or less the same. Since we are using GLSL 120, attribute locations need to be passed to ShaderProgram, rather than defined in GLSL.
Cheers. Let me know if there are features/extensions you’d like added…
P.S. Yes, you can probably tell the package structure was inspired by LibGDX…