dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
85 stars 20 forks source link

Update to use a modern OpenGL version, e.g. 3.2 #309

Closed dmurdoch closed 1 year ago

dmurdoch commented 1 year ago

This would make the code more similar between C++ and the WebGL code, allowing shaders in R, etc.

It looks as though the glad and GLFW libraries would make this reasonably straightforward.

dmurdoch commented 1 year ago

It turns out not to be so easy. Those libs assume that Macs are using the native Apple OpenGL. It looks nice, and doesn't seem to require Xquartz, but it has been deprecated by Apple and some of the code in rgl (e.g. text) doesn't work with it. Maybe that could be fixed, but after a while trying, I'm giving up.

glad with GLX (without GLFW) might work, but there's still the assumption that Macs are using the Apple libs, not what comes in Xquartz. I couldn't figure out the right patch.

I'll try again with my own loader. According to what I've read, Macs should support OpenGL 2.1, and just about everyone else should too. I think that's all I'd need for shaders. Macs will only support 3.2 using the core profile, i.e. legacy code (of which there's a lot in rgl) won't be supported. And that may not even still be true, due to their deprecation plans.

dmurdoch commented 1 year ago

PR #319 allows newer versions to be used if present. Currently almost nothing makes use of the new features, but features up to 3.0 are available if supported on the system. Increasing beyond that would just require generating a new glad loader.