libigl icon indicating copy to clipboard operation
libigl copied to clipboard

Can I specify what OpenGL version to use in libigl?

Open ghost opened this issue 6 years ago • 2 comments

Describe your issue

It seems to me that libigl can only use OpenGL 3.3. Is there any chance that I can specify a particular OpenGL version, say 4.6? It would be even better that libigl can detect the highest available OpenGL version installed and use it automatically. Thanks.

Check all that apply (change to [x])

  • [x] Windows
  • [ ] Mac OS X
  • [x] Linux
  • [ ] I have tried the dev branch and the problem persists

See https://libigl.github.io/CONTRIBUTING/#bugreport for more tips.

ghost avatar Aug 08 '19 20:08 ghost

Hi. Libigl uses glad to load OpenGL headers in a cross-platform way. If you provide your own glad target before including libigl in your project, you can actually override what version of OpenGL will be loader by glad. You can use glad's webservice to obtain the version you want. Then simply mimic the CMake we have set up for glad to integrate into your project.

That being said we do set explicitly the glfwWindowHint to tell GLFW about which version of OpenGL we're using. We could have some extra argument to override this value if that is an issue to you.

jdumas avatar Aug 08 '19 20:08 jdumas

I had to change the OpenGL version for another project. In addition to the generating the glad target as Jeremie discussed, you need to somehow tell the viewer to generate a GL context with your requested version. We do this automatically for 3.3 in the viewer here.

In my other project, I forked the repository and changed the values in the line above. It might make sense to make the requested gl context version an optional parameter to viewer::launch()

fwilliams avatar Aug 08 '19 21:08 fwilliams