Skip to content

Define APIENTRY in osmesa build if not defined.

glew.h undefines APIENTRY and also prevents gl.h from being included by defining its include guard. This means that APIENTRY is not defined within osmesa.h which usually relies on gl.h to define it.

If APIENTRY is not defined when importing osmesa.h, we define it temporarily and then undefine when done. This is similar to the existing workaround for GLAPI which likely exists for the same reason as above. It seems that only clang fails to compile when APIENTRY is not defined, but it seems like it should be defined regardless of compiler. With this change, I can build osmesa for osx without issue.

I am currently using this in a custom conda feedstock and it seems to work well. https://github.com/FoundationLLM/vtk-feedstock/blob/main/recipe/patches/define-apientry-osmesa-osx.patch

Merge request reports