diff --git a/.travis.yml b/.travis.yml index 59b0d7f..c091bb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: cpp #sudo: false install: -- sudo apt-get install git dos2unix +- sudo apt-get install git dos2unix libosmesa-dev script: - make -C auto clobber - make extensions diff --git a/auto/Makefile b/auto/Makefile index af66a8e..a384bd6 100644 --- a/auto/Makefile +++ b/auto/Makefile @@ -204,8 +204,7 @@ $(S.DEST)/glew.c: $(EXT)/.dummy $(BIN)/make_list.pl $(GL_CORE_SPEC) | grep -v '\"GL_VERSION' >> $@ $(BIN)/make_list.pl $(GL_EXT_SPEC) >> $@ echo -e "\n return GLEW_OK;\n}\n" >> $@ - echo -e "\n#if defined(GLEW_OSMESA)" >> $@ - echo -e "\n#elif defined(_WIN32)" >> $@ + echo -e "\n#if defined(_WIN32) && ! defined(GLEW_OSMESA)" >> $@ echo -e "\n#if !defined(GLEW_MX)" >> $@ $(BIN)/make_def_fun.pl WGL $(WGL_EXT_SPEC) >> $@ $(BIN)/make_def_var.pl WGL $(WGL_EXT_SPEC) >> $@ diff --git a/auto/src/glew_head.c b/auto/src/glew_head.c index fd9c0d3..1b4ed77 100644 --- a/auto/src/glew_head.c +++ b/auto/src/glew_head.c @@ -140,10 +140,10 @@ void* NSGLGetProcAddress (const GLubyte *name) /* * Define glewGetProcAddress. */ -#if defined(GLEW_OSMESA) +#if defined(GLEW_REGAL) +# define glewGetProcAddress(name) regalGetProcAddress((const GLchar *)name) +#elif defined(GLEW_OSMESA) # define glewGetProcAddress(name) OSMesaGetProcAddress((const char *)name) -#elif defined(GLEW_REGAL) -# define glewGetProcAddress(name) regalGetProcAddress((const GLchar *) name) #elif defined(_WIN32) # define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name) #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) diff --git a/auto/src/glew_init_tail.c b/auto/src/glew_init_tail.c index f0e2573..ba68ccf 100644 --- a/auto/src/glew_init_tail.c +++ b/auto/src/glew_init_tail.c @@ -39,11 +39,11 @@ GLenum GLEWAPIENTRY glewInit (void) GLenum r; r = glewContextInit(); if ( r != 0 ) return r; -#if defined(GLEW_OSMESA) +#if defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__) return r; #elif defined(_WIN32) return wglewInit(); -#elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) /* _UNIX */ +#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ return glxewInit(); #else return r; diff --git a/auto/src/glew_str_wgl.c b/auto/src/glew_str_wgl.c index 4fd37fd..01055a4 100644 --- a/auto/src/glew_str_wgl.c +++ b/auto/src/glew_str_wgl.c @@ -4,8 +4,7 @@ return ret; } -#if defined(GLEW_OSMESA) -#elif defined(_WIN32) +#if defined(_WIN32) && !defined(GLEW_OSMESA) #if defined(GLEW_MX) GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext* ctx, const char* name) diff --git a/auto/src/glewinfo_head.c b/auto/src/glewinfo_head.c index 96108e8..fd4bead 100644 --- a/auto/src/glewinfo_head.c +++ b/auto/src/glewinfo_head.c @@ -24,11 +24,10 @@ static FILE* f; #ifdef GLEW_MX GLEWContext _glewctx; #define glewGetContext() (&_glewctx) -#if defined(GLEW_OSMESA) -#elif defined(_WIN32) +#if defined(_WIN32) WGLEWContext _wglewctx; #define wglewGetContext() (&_wglewctx) -#elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX) +#elif !defined(GLEW_OSMESA) && !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX) GLXEWContext _glxewctx; #define glxewGetContext() (&_glxewctx) #endif diff --git a/auto/src/glewinfo_wgl.c b/auto/src/glewinfo_wgl.c index b2c2242..c80264e 100644 --- a/auto/src/glewinfo_wgl.c +++ b/auto/src/glewinfo_wgl.c @@ -2,8 +2,7 @@ /* ------------------------------------------------------------------------ */ -#if defined(GLEW_OSMESA) -#elif defined(_WIN32) +#if defined(_WIN32) && !defined(GLEW_OSMESA) static void wglewInfo () { diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index 1563f9f..425fffb 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -13,6 +13,7 @@ endif() set(CMAKE_DEBUG_POSTFIX d) option (BUILD_UTILS "utilities" ON) +option (GLEW_OSMESA "OSMesa mode" FALSE) set (GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) @@ -41,6 +42,20 @@ set (GLEW_LIBRARIES ${OPENGL_LIBRARIES}) add_definitions (-DGLEW_NO_GLU) +#### OSMesa #### + +if (GLEW_OSMESA) + if (WIN32) + set (OSMESA_LIB_NAME osmesa) + else () + set (OSMESA_LIB_NAME OSMesa) + endif () + add_definitions (-DGLEW_OSMESA) + set (GLEW_LIBRARIES ${OSMESA_LIB_NAME} ${OPENGL_LIBRARIES}) +endif () + +#### GLEW #### + include_directories (${GLEW_DIR}/include) add_library (glew SHARED ${GLEW_DIR}/src/glew.c)