-
-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add single output buffer support #179
Comments
You can create slices/views of the same Buffer and use those as the separate buffer arguments: IntBuffer major = ...;
IntBuffer minor = major.slice();
minor.position(1);
IntBuffer rev = major.slice()
rev.position(2); It looks a bit ugly, but works. :) |
This case is too rare to deserve special support in the generator, there are maybe 1 or 2 such functions in each binding. However, I agree that it's annoying in Java. Maybe new memSlice methods in MemoryUtil would help? MemoryStack stack = stackPush();
try {
// Multiple buffers
IntBuffer major = stack.mallocInt(1);
IntBuffer minor = stack.mallocInt(1);
IntBuffer rev = stack.mallocInt(1);
glfwGetVersion(major, minor, rev);
// Unsafe
IntBuffer nv = stack.mallocInt(3);
long a = memAddress(nv);
nglfwGetVersion(a, a + 4, a + 8);
// If we add new memSlice methods to MemoryUtil
IntBuffer v = stack.mallocInt(3);
glfwGetVersion(v, memSlice(v, 1, 1), memSlice(v, 2, 1));
} finally {
stack.pop();
} |
I like the memSlice idea more and your right it is a bit rare so it probably shouldn't have its own thing in the generator though I do think a clear, clean way of splitting a single buffer so it can be used as multiple arguments should be included (memSlice would do this perfectly) |
There are several methods that output values to different buffers. In C these can be simplified to output to a single array using pointer math and simply telling it to place the value in different parts of the array however there is no way of doing this directly in LWJGL however it can be done by simply calling the native version of the methods and passing in the modified address.
For example this method in GLFW
Would have an override that would look similar to this
This would return all three values in one buffer sequentially without needing to use the native type method directly.
The text was updated successfully, but these errors were encountered: