Force PyOpenGL to load a specific GL dynamic library

Tiago Nobrega <[email protected]> Fri, 1 Sep 2017 14:55:36 -0300
Newsgroups gmane.comp.python.opengl.devel
Message-ID <CAL2FxJsFw+uCWQk_khyTQYDwGsX7QUOM0zFeUfoJHBR-oNyzGA@mail.gmail.com>
--===============2194142544622496805==
Content-Type: multipart/alternative; boundary="94eb2c1120700d3f1c055824793b"

--94eb2c1120700d3f1c055824793b
Content-Type: text/plain; charset="UTF-8"

Hi,

My application has the requirement to run in environments that might not
provide hardware-accelerated OpenGL (such as Remote Desktop on Windows).
Since we'd like to use hardware acceleration if available, we have code
that detects the local support at runtime and loads a bundled GL lib
(Mesa+llvmpipe) if necessary.

As far as I understand it, PyOpenGL uses ctypes to load the GL lib at
runtime. On Windows, I can update the PATH environment variable to have
PyOpenGL find my OpenGL32.dll first, and it works as expected.

On Linux, it looks like ctypes does a straight dlopen() on the candidate
names (libGL.so, libGL.so.1, etc). Apparently it's too late to update
LD_LIBRARY_PATH to have the loader find my lib first (ref:
https://stackoverflow.com/questions/856116/changing-ld-library-path-at-runtime-for-ctypes),
so PyOpenGL finds another dynamic library and I end up with two loaded
libs, which as expected doesn't work. My application has other, non-Python
OpenGL dependencies and those are resolved by loading (via ctypes) the full
name to our bundled libGL.so, so PyOpenGL is our last remaining loose end.

I'm writing to ask if my reasoning here is correct and if PyOpenGL has
another mechanism through which I could say "load this dynamic lib please".
I did some research but couldn't find anything. If no mechanism is
available, would the maintainers be interested in adding it? I figured an
environment variable called something like PYOPENGL_GL_LIB_FILE and
pointing to the full path of my local libGL.so would be interesting, and
that would solve my issue. I would be glad to work on a patch to add this
feature, as it looks like I might have to patch our local PyOpenGL build
anyway.

Thank you,

Tiago

--94eb2c1120700d3f1c055824793b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div><div>Hi,<br><br></div>My application h=
as the requirement to run in environments that might not provide hardware-a=
ccelerated OpenGL (such as Remote Desktop on Windows). Since we&#39;d like =
to use hardware acceleration if available, we have code that detects the lo=
cal support at runtime and loads a bundled GL lib (Mesa+llvmpipe) if necess=
ary.<br><br></div>As far as I understand it, PyOpenGL uses ctypes to load t=
he GL lib at runtime. On Windows, I can update the PATH environment variabl=
e to have PyOpenGL find my OpenGL32.dll first, and it works as expected.<br=
><br></div>On Linux, it looks like ctypes does a straight dlopen() on the c=
andidate names (libGL.so, libGL.so.1, etc). Apparently it&#39;s too late to=
 update LD_LIBRARY_PATH to have the loader find my lib first (ref: <a href=
=3D"https://stackoverflow.com/questions/856116/changing-ld-library-path-at-=
runtime-for-ctypes">https://stackoverflow.com/questions/856116/changing-ld-=
library-path-at-runtime-for-ctypes</a>), so PyOpenGL finds another dynamic =
library and I end up with two loaded libs, which as expected doesn&#39;t wo=
rk. My application has other, non-Python OpenGL dependencies and those are =
resolved by loading (via ctypes) the full name to our bundled libGL.so, so =
PyOpenGL is our last remaining loose end.<br><br></div>I&#39;m writing to a=
sk if my reasoning here is correct and if PyOpenGL has another mechanism th=
rough which I could say &quot;load this dynamic lib please&quot;. I did som=
e research but couldn&#39;t find anything. If no mechanism is available, wo=
uld the maintainers be interested in adding it? I figured an environment va=
riable called something like PYOPENGL_GL_LIB_FILE and pointing to the full =
path of my local libGL.so would be interesting, and that would solve my iss=
ue. I would be glad to work on a patch to add this feature, as it looks lik=
e I might have to patch our local PyOpenGL build anyway.</div><div><br></di=
v><div>Thank you,</div><div><br></div><div>Tiago<br></div></div>

--94eb2c1120700d3f1c055824793b--


--===============2194142544622496805==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--===============2194142544622496805==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-devel

--===============2194142544622496805==--