comp.lang.ada
 help / color / mirror / Atom feed
From: onox <denkpadje@gmail.com>
Subject: Re: Xlib, (GLX or EGL), OpenGL. Stuck at double buffering not working properly.
Date: Thu, 14 May 2020 11:40:42 -0700 (PDT)
Date: 2020-05-14T11:40:42-07:00	[thread overview]
Message-ID: <13f6fe0c-be41-4937-a877-457e1f8aca18@googlegroups.com> (raw)
In-Reply-To: <705052ba-5cff-46af-a28c-1e25e60e2eef@googlegroups.com>

On Wednesday, May 13, 2020 at 1:15:10 AM UTC+2, Olivier Henley wrote:
> Hi to all,
> 
> In my spare time I am working on a cross-platform windowing lib for OpenGL in Ada. 
> 
> In a nutshell, a GLFW replacement.
> 
> I come to you because on Linux, wrapping, and driving Xlib with GLX or EGL in Ada, I am failing to get double buffering to work. 
> 
> Generally its working, eg. I get sample code from OpenGLAda rendering fine in the window but if I try to resize a window rapidly, I get black tearing and sometimes dropped frames. I did fix this problem on windows by threading the rendering out of the window message pump, but for Linux, threading over X11 makes things explode. I looked into XInitThread but the documentation leave me cold.
> 
> I tried two other Ada projects that paint some OpenGL in a native Linux window using (Xlib and GLX) namely Globe3D and AdaOGL. Both suffer from the same tearing and/or dropped frame when resizing the window.
> 
> 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 not seem to make much more than I do. I also found, compiled, and tried a really simple C source code file using Xlib/GLX and it works. (http://andrewd.ces.clemson.edu/courses/graphics/examples/glx-simple/glxsimple.c)
> 
> 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?
> 
> Any insights welcome.
> 
> Thanks,
> 
> Olivier 
> 
> 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 thinking rendering GL to a double buffer of Pixmaps/pBuffer (XLib off-screen render 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 event and window management in #5 at https://discourse.glfw.org/t/multithreading-glfw/573/5

I'm not sure how you can get tearing. Do you still get it when you explicitly 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 maintain too many backends (X11 and macOS are dead platforms for gaming/3D IMO) and development is slow. A replacement that just supports WGL+win32 and Wayland+EGL would be nice and feasible. Also I would like to have more control over the frame latency via accurate frame presentation feedback (presentation-time Wayland protocol)

Have you considered putting your code under some OSS license? (Preferably Apache License 2.0 or MIT license) It would be nice if we could team up to make this happen :)

  reply	other threads:[~2020-05-14 18:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 23:15 Xlib, (GLX or EGL), OpenGL. Stuck at double buffering not working properly Olivier Henley
2020-05-14 18:40 ` onox [this message]
2020-05-15 20:00   ` Olivier Henley
2020-05-16  5:51     ` onox
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox