Hello Guest

glfwGetCursorPos usage

  • 2 Replies
  • 7187 Views
glfwGetCursorPos usage
« 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 :

Code: [Select]
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#
« Last Edit: December 01, 2014, 17:21:47 by SmartVirtue »

*

Offline spasi

  • *****
  • 2229
    • WebHotelier
Re: glfwGetCursorPos usage
« Reply #1 on: December 01, 2014, 18:57:23 »
You have to use direct buffers. The easiest method is:

Code: [Select]
ByteBuffer x = BufferUtils.createByteBuffer(8);
// or
DoubleBuffer x = BufferUtils.createDoubleBuffer(1);
The BufferUtils class documentation contains more information.

Re: glfwGetCursorPos usage
« Reply #2 on: December 01, 2014, 19:48:53 »
You have to use direct buffers. The easiest method is:

Code: [Select]
ByteBuffer x = BufferUtils.createByteBuffer(8);
// or
DoubleBuffer x = BufferUtils.createDoubleBuffer(1);
The BufferUtils class documentation contains more information.

thank you!!!