0

I am trying to figure out how to use LWJGL3 directly from clojure. The only stumbling block I found so far is a function that sometimes requires an argument to be null, but it's type is long in the fingerprint. The specific function in question is glfwCreateWindow​ from the org.lwjgl.glfw.GLFW class. The last two arguments are long, but they should be null when using windowed mode, for the first one, or not sharing the gl context, for the second one. The problem is interop calls check the fingerprint of the function and see it should be a long, so passing nil results in an IllegalArgumentException.

I've looked all around, but nobody seems to have addressed this particular problem. It's not about nil-punning, since the argument should sometimes be nil.

This is my code that already works: https://gist.github.com/Efimero/2c0af4ae3aeaf2c85136aa06ff077919

But it only works because the default zero values are fine for my setup, but they're not abstract.

When I pass nil I want the function to be called normally, but I get an exception.

1 Answer 1

2

This doesn't make sense. A long cannot be null anywhere. It seems that this is a miscommunication in the documentation, where the wrapped C or C++ library leaks through.

I'd strongly guess that passing 0 where the documentation says NULL is correct.

Sign up to request clarification or add additional context in comments.

2 Comments

That's what I thought, but check it out yourself: javadoc.lwjgl.org/org/lwjgl/glfw/… You use null to not share the context.
in C, 0 == NULL (actually there’s subtlety here but wtf). I agree that this doc is just the underlying C poking through. There is no way to pass null for an unboxed long.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.