Passing pointer of address
Thiago Milczarek Sayão
thiago.sayao at gmail.com
Mon Apr 29 10:45:54 UTC 2024
Hi,
I'm doing some wayland binding experiments with jextract and FFM.
So far, so good.
But there's one thing that could be better, or I am doing it wrong (Please,
excuse me if it's my mistake.).
The eglChooseConfig call expects the pointer of an address on the second
argument.
https://registry.khronos.org/EGL/sdk/docs/man/html/eglChooseConfig.xhtml
The below code works, but I feel it could be simpler. Maybe a call like
attributes.addressPointer() ?
MemorySegment eglDisplay = EGL.eglGetDisplay(display.getSegment());
eglBindAPI(EGL_OPENGL_API());
if (eglDisplay.equals(EGL_NO_DISPLAY())) {
System.out.println("NO DISPLAY");
return null;
}
if (eglInitialize(eglDisplay, MemorySegment.NULL, MemorySegment.NULL) == 0) {
System.out.println("eglInitialize Failed");
return null;
};
int[] attribs = {
EGL_RENDERABLE_TYPE(),
EGL_OPENGL_BIT(),
EGL_SURFACE_TYPE(),
EGL_WINDOW_BIT(),
EGL_RED_SIZE(),
8,
EGL_GREEN_SIZE(),
8,
EGL_BLUE_SIZE(),
8,
EGL_ALPHA_SIZE(),
8,
EGL_NONE()
};
MemorySegment eglConfig = Arena.global().allocate(C_POINTER);
MemorySegment numConfigs = Arena.global().allocate(EGLint);
MemorySegment attributes = Arena.global().allocateFrom(EGLint, attribs);
if (EGL.eglChooseConfig(eglDisplay,
MemorySegment.ofAddress(attributes.address()), eglConfig, 1,
numConfigs) == 0) {
System.out.println("eglChooseConfig Failed");
return null;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20240429/f1371a8b/attachment.htm>
More information about the panama-dev
mailing list