I’m wondering how I would render a cube with a different PNG Texture on each side, and I’d like to stay away from other Third-Party Libraries other than LWJGL.
Advertisement
Answer
As of LWJGL3 bindings for the STB library have been included. This is a small single-file utility library that does things like loading textures, sound files or fonts.
For rendering a cube with a different texture on each side you have two options:
- Render each face separately with another texture bound. This is the more straightforward option.
- Make a texture atlas of all the textures and render the whole cube once. This is not as easy to do but will give better performance, especially when rendering multiple cubes.
Introductory tutorial on how to use textures. (It is in C++, but should be easy to convert to Java.)