Linking to the latest version of LWJGL

Hi all,

I’m using JME2 and I’m just wondering if anyone is working on linking it to the latest LWJGL. Here are my problems:

Currently, the stable JME2 version links to lwjgl 2.2.1 - everything works ok except that when it runs as an applet, mouse grab would not work properly.

So I upgraded to lwjgl 2.2.2, and now mouse grab works great in applet mode. However, lwjgl 2.2.2 breaks the ATI graphics driver.

When I upgrade to later versions of lwjgl, sound does not work as JME uses direct buffer and lwjgl versions 2.3+ does not.

So I’m kind of stuck… any suggestions?


Ok, so I looked at the jME 2.0.1 source code more closely and found the problem: from lwjgl 2.3 onwards, they changed to use direct byte buffer for audio – but the code to allocate audio buffer in jME 2.0.1 is this (inside the AudioLoader class’ read method):

ByteBuffer data = BufferUtils.createByteBufferOnHeap(bytes);

When I look at the BufferUtils.createByteBufferOnHeap method, I found it to be:

public static ByteBuffer createByteBufferOnHeap(int size) {

ByteBuffer buf = ByteBuffer.allocate(size).order(ByteOrder.nativeOrder());


return buf;


As it is using the allocate instead of allocateDirect method to create the ByteBuffer, the new lwjgl won’t take it. I didn’t want to modify the createByteBufferOnHeap method since it may be used by other parts of the system, so I simply patch the AudioLoader class to look like:

ByteBuffer data = ByteBuffer.allocateDirect(bytes).order(ByteOrder.nativeOrder());


This works for my purpose as my software now runs well with the latest version of lwjgl (2.6). For the jME developers, is this going to work well? Is there a better way?


This is okay. I don’t know why they used heap buffers in the first place really.