Basic 2D Textures (Sprites) Solely Using LWJGL

Started by cholo71796, April 20, 2012, 02:10:57

Previous topic - Next topic

cholo71796

I'm trying to draw 2D images using LWJGL. When I search for this in Google I get stuff about doing it in C++. If I add "LWJGL" I get a thread on this forum directing the OP to NeHe... I also get the Space Invaders example on the LWJGL wiki. However, since I don't understand how to do what I want to do, the vaguely commented code there doesn't help much.

Can someone explain rendering textures to a quad in LWJGL for me or direct me to a source that does? It would be greatly appreciated.

mattdesl

Since LWJGL is just a thin wrapper around OpenGL, most tutorials will tend to be in C++ or another non-Java language. Also, most tutorials expect you to have at least a basic understanding of what OpenGL is and how it works.

So I'd suggest reading up on the basics, first:
http://arcsynthesis.org/gltut/

LWJGL ports:
https://github.com/rosickteam/OpenGL

Since OpenGL doesn't know anything about image decoders (PNG, GIF, JPG, etc) you will have to either write those yourself, or use an existing set of decoders like ImageIO (converting BufferedImage to ByteBuffer), or TWL's image decoders.

Alternatively, you could use Slick-Util, which packages some of these decoders into a small utility library. The space invaders tutorial should get you started with Slick-Util.

If all of this means nothing to you, then maybe you'd be better off starting with a higher-level library like Slick2D or LibGDX.