<div dir="ltr">Hi,<div><br></div><div>I'm doing some wayland binding experiments with jextract and FFM.</div><div>So far, so good.</div><div><br></div><div>But there's one thing that could be better, or I am doing it wrong (Please, excuse me if it's my mistake.).</div><div><br></div><div>The eglChooseConfig call expects the pointer of an address on the second argument.</div><div><a href="https://registry.khronos.org/EGL/sdk/docs/man/html/eglChooseConfig.xhtml">https://registry.khronos.org/EGL/sdk/docs/man/html/eglChooseConfig.xhtml</a><br></div><div><br></div><div>The below code works, but I feel it could be simpler. Maybe a call like attributes.addressPointer() ?</div><div><div style="background-color:rgb(30,31,34);color:rgb(188,190,196)"><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt">MemorySegment eglDisplay = EGL.<span style="font-style:italic">eglGetDisplay</span>(display.getSegment());<br><span style="font-style:italic">eglBindAPI</span>(<span style="font-style:italic">EGL_OPENGL_API</span>());<br><br><span style="color:rgb(207,142,109)">if </span>(eglDisplay.equals(<span style="font-style:italic">EGL_NO_DISPLAY</span>())) {<br>    System.<span style="color:rgb(199,125,187);font-style:italic">out</span>.println(<span style="color:rgb(106,171,115)">"NO DISPLAY"</span>);<br>    <span style="color:rgb(207,142,109)">return null</span>;<br>}<br><br><span style="color:rgb(207,142,109)">if </span>(<span style="font-style:italic">eglInitialize</span>(eglDisplay, MemorySegment.<span style="color:rgb(199,125,187);font-style:italic">NULL</span>, MemorySegment.<span style="color:rgb(199,125,187);font-style:italic">NULL</span>) == <span style="color:rgb(42,172,184)">0</span>) {<br>    System.<span style="color:rgb(199,125,187);font-style:italic">out</span>.println(<span style="color:rgb(106,171,115)">"eglInitialize Failed"</span>);<br>    <span style="color:rgb(207,142,109)">return null</span>;<br>};<br><br><span style="color:rgb(207,142,109)">int</span>[] attribs = {<br>    <span style="font-style:italic">EGL_RENDERABLE_TYPE</span>(),<br>    <span style="font-style:italic">EGL_OPENGL_BIT</span>(),<br>    <span style="font-style:italic">EGL_SURFACE_TYPE</span>(),<br>    <span style="font-style:italic">EGL_WINDOW_BIT</span>(),<br>    <span style="font-style:italic">EGL_RED_SIZE</span>(),<br>    <span style="color:rgb(42,172,184)">8</span>,<br>    <span style="font-style:italic">EGL_GREEN_SIZE</span>(),<br>    <span style="color:rgb(42,172,184)">8</span>,<br>    <span style="font-style:italic">EGL_BLUE_SIZE</span>(),<br>    <span style="color:rgb(42,172,184)">8</span>,<br>    <span style="font-style:italic">EGL_ALPHA_SIZE</span>(),<br>    <span style="color:rgb(42,172,184)">8</span>,<br>    <span style="font-style:italic">EGL_NONE</span>()<br>};<br><br>MemorySegment eglConfig = Arena.<span style="font-style:italic">global</span>().allocate(<span style="color:rgb(199,125,187);font-style:italic">C_POINTER</span>);<br>MemorySegment numConfigs = Arena.<span style="font-style:italic">global</span>().allocate(<span style="color:rgb(199,125,187);font-style:italic">EGLint</span>);<br>MemorySegment attributes = Arena.<span style="font-style:italic">global</span>().allocateFrom(<span style="color:rgb(199,125,187);font-style:italic">EGLint</span>, attribs);<br><br><span style="color:rgb(207,142,109)">if </span>(EGL.<span style="font-style:italic">eglChooseConfig</span>(eglDisplay, MemorySegment.<span style="font-style:italic">ofAddress</span>(attributes.address()), eglConfig, <span style="color:rgb(42,172,184)">1</span>, numConfigs) == <span style="color:rgb(42,172,184)">0</span>) {<br>    System.<span style="color:rgb(199,125,187);font-style:italic">out</span>.println(<span style="color:rgb(106,171,115)">"eglChooseConfig Failed"</span>);<br>    <span style="color:rgb(207,142,109)">return null</span>;<br>}</pre></div></div></div>