From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:ac8:24e7:: with SMTP id t36mr5727712qtt.98.1589481642934; Thu, 14 May 2020 11:40:42 -0700 (PDT) X-Received: by 2002:a05:6808:aa5:: with SMTP id r5mr20940272oij.109.1589481642660; Thu, 14 May 2020 11:40:42 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 14 May 2020 11:40:42 -0700 (PDT) In-Reply-To: <705052ba-5cff-46af-a28c-1e25e60e2eef@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=80.114.173.191; posting-account=BtkjvAoAAADwEquGb07eykXfyiDMOxfl NNTP-Posting-Host: 80.114.173.191 References: <705052ba-5cff-46af-a28c-1e25e60e2eef@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <13f6fe0c-be41-4937-a877-457e1f8aca18@googlegroups.com> Subject: Re: Xlib, (GLX or EGL), OpenGL. Stuck at double buffering not working properly. From: onox Injection-Date: Thu, 14 May 2020 18:40:42 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:58688 Date: 2020-05-14T11:40:42-07:00 List-Id: On Wednesday, May 13, 2020 at 1:15:10 AM UTC+2, Olivier Henley wrote: > Hi to all, >=20 > In my spare time I am working on a cross-platform windowing lib for OpenG= L in Ada.=20 >=20 > In a nutshell, a GLFW replacement. >=20 > I come to you because on Linux, wrapping, and driving Xlib with GLX or EG= L in Ada, I am failing to get double buffering to work.=20 >=20 > Generally its working, eg. I get sample code from OpenGLAda rendering fin= e in the window but if I try to resize a window rapidly, I get black tearin= g and sometimes dropped frames. I did fix this problem on windows by thread= ing the rendering out of the window message pump, but for Linux, threading = over X11 makes things explode. I looked into XInitThread but the documentat= ion leave me cold. >=20 > I tried two other Ada projects that paint some OpenGL in a native Linux w= indow using (Xlib and GLX) namely Globe3D and AdaOGL. Both suffer from the = same tearing and/or dropped frame when resizing the window. >=20 > Now if I compile an equivalent simple GLFW C example code, it works like = a charm, no dropped frame, no tearing. I looked at their code and they do n= ot seem to make much more than I do. I also found, compiled, and tried a re= ally simple C source code file using Xlib/GLX and it works. (http://andrewd= .ces.clemson.edu/courses/graphics/examples/glx-simple/glxsimple.c) >=20 > Anyone is aware of what is going on here? Something special about the Ada= runtime that I should know about or is it just me that does not handle the= Xlib window message pump incorrectly? >=20 > Any insights welcome. >=20 > Thanks, >=20 > Olivier=20 >=20 > Note: Now because the threading problem over X11 looks like mostly coming= from the whole needed 'same thread context for window and GL' I was thinki= ng rendering GL to a double buffer of Pixmaps/pBuffer (XLib off-screen rend= er targets) from a separate thread and then just blit myself to the window = at the 'Expose' events. Make sense, any thoughts on that? X11 seems to have a single event queue so event processing can occur on any= task. The GLFW maintainer explains a bit how all the platform do their eve= nt and window management in #5 at https://discourse.glfw.org/t/multithreadi= ng-glfw/573/5 I'm not sure how you can get tearing. Do you still get it when you explicit= ly set swap interval to 1? Is there a particular reason you're trying this on X11? I've been thinking = a lot about a GLFW replacement written in Ada, because GLFW tries to mainta= in too many backends (X11 and macOS are dead platforms for gaming/3D IMO) a= nd development is slow. A replacement that just supports WGL+win32 and Wayl= and+EGL would be nice and feasible. Also I would like to have more control = over the frame latency via accurate frame presentation feedback (presentati= on-time Wayland protocol) Have you considered putting your code under some OSS license? (Preferably A= pache License 2.0 or MIT license) It would be nice if we could team up to m= ake this happen :)