From cdbc12821f3114bba0403402e9789cc3d866d881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 20 Mar 2013 12:22:09 +0100 Subject: [PATCH] Fixed NaCl issues with gl2.h. Headers gl2.h and gl2ext.h shipped with NaCl are different to the official ones, which is causing linker issues, thus using NaCl's own gl2.h. They are otherwise similar, thus it should cause no compatibility issues. On the other hand, gl2ext.h shipped with NaCl is slightly outdated with some recent extensions missing. We are including the NaCl's one and then the official one over it (undefining the include guard). The symbols are guarded also by extensions, so it should cause no conflicts. --- external/OpenGL/GLES2/CMakeLists.txt | 12 +++++++++++- external/OpenGL/KHR/CMakeLists.txt | 5 ++++- src/OpenGL.h | 12 ++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/external/OpenGL/GLES2/CMakeLists.txt b/external/OpenGL/GLES2/CMakeLists.txt index 3115869a1..ffd77ee75 100644 --- a/external/OpenGL/GLES2/CMakeLists.txt +++ b/external/OpenGL/GLES2/CMakeLists.txt @@ -22,4 +22,14 @@ # DEALINGS IN THE SOFTWARE. # -install(FILES gl2.h gl2platform.h gl2ext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/OpenGL/GLES2) +set(MagnumOpenGL_HEADERS + gl2ext.h) + +# NaCl has its own gl2.h, this one causes linker issues +if(NOT TARGET_NACL) + set(MagnumOpenGL_HEADERS ${MagnumOpenGL_HEADERS} + gl2platform.h + gl2.h) +endif() + +install(FILES ${MagnumOpenGL_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/OpenGL/GLES2) diff --git a/external/OpenGL/KHR/CMakeLists.txt b/external/OpenGL/KHR/CMakeLists.txt index 9e8e1bd57..1ca8ca9ec 100644 --- a/external/OpenGL/KHR/CMakeLists.txt +++ b/external/OpenGL/KHR/CMakeLists.txt @@ -22,4 +22,7 @@ # DEALINGS IN THE SOFTWARE. # -install(FILES khrplatform.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/OpenGL/KHR) +# NaCl has its own gl2.h, this one causes linker issues +if(NOT TARGET_NACL) + install(FILES khrplatform.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/OpenGL/KHR) +endif() diff --git a/src/OpenGL.h b/src/OpenGL.h index e02765a5c..463ad9d6f 100644 --- a/src/OpenGL.h +++ b/src/OpenGL.h @@ -34,6 +34,8 @@ #include #include #else + +#ifndef MAGNUM_TARGET_NACL #include #ifndef MAGNUM_TARGET_GLES2 #include @@ -43,6 +45,16 @@ #include #include #endif + +/* NaCl has its own gl2.h, the official one causes linker issues. Additionaly + to NaCl's gl2ext.h we are including our own to prevent undeclared symbol + errors with some recent extensions. */ +#else +#include +#include +#undef __gl2ext_h_ +#include #endif #endif +#endif