When running the program, it crashes with “Failed to initialize GLFW”. And with error_callback there is error: [65543]: OSMesa: Failed to create context.
What is the correct approach to switch the normal mode to osmesa?
Thanks!
I would first check you have OSMesa installed, and also remove all window hints except for glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_OSMESA_CONTEXT_API); as it’s possible the selection of hints you have requested are not compatible with OSMesa.
I have run sudo yum install mesa-libOSMesa-devel and there is /usr/lib/libOSMesa.so. It looks OK after removing all window hints except for glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_OSMESA_CONTEXT_API)! Thanks!
Further step. It currently works with X11 forwarding, etc. with environment variable DISPLAY=xxx.
Finally, I want the program to run on the server without a screen device and X serer, I think there will be no such DISPLAY variable. So I run unset DISPLAY, and run the program. It crushes with message [65550]: Failed to detect any supported platform and Failed to initialize GLFW.
According to my understanding, OSMesa is for the purpose of running off-screen. How do I fix this? In compilation or runtime?
Thanks a lot for helping with my stupid question
It works! Now my whole program runs successfully and correctly.
I have struggled with it for many days, to find a way to run glfw headless. I have tried things like xvfb, osmesa, egl. I encountered various errors and always wondered if I was using OSMesa correctly. It seems that OSMesa headless is a new feature in recent versions, some usage details like ‘remove hints’ and ‘set GLFW_PLATFORM_NULL’ are missing. Adding some example code or test cases would be user-friendly.
Thank you very much!