LWJGL Forum

Programming => General Java Game Development => Topic started by: SmartVirtue on December 01, 2014, 17:19:21

Title: glfwGetCursorPos usage
Post by: SmartVirtue on December 01, 2014, 17:19:21
Hello, im Serge and im porting game from C# to java using lwjgl 3
i need to get cursor(mouse) position i found that glfwGetCurcorPos can do it.
so i use this :

ByteBuffer x = ByteBuffer.allocate(8);
ByteBuffer y = ByteBuffer.allocate(8);
GLFW.glfwGetCursorPos(AntiheusLab.window , x , y);


and i get 0 in x and 0 in y. ofc it can be a bug because same(adapted) code workin in c#
Title: Re: glfwGetCursorPos usage
Post by: spasi on December 01, 2014, 18:57:23
You have to use direct buffers. The easiest method is:

ByteBuffer x = BufferUtils.createByteBuffer(8);
// or
DoubleBuffer x = BufferUtils.createDoubleBuffer(1);

The BufferUtils class documentation contains more information.
Title: Re: glfwGetCursorPos usage
Post by: SmartVirtue on December 01, 2014, 19:48:53
Quote from: spasi on December 01, 2014, 18:57:23
You have to use direct buffers. The easiest method is:

ByteBuffer x = BufferUtils.createByteBuffer(8);
// or
DoubleBuffer x = BufferUtils.createDoubleBuffer(1);

The BufferUtils class documentation contains more information.

thank you!!!