From fd49b2baff6c47e4c0893d7a729b95cb603b7af1 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Thu, 8 Oct 2015 22:03:16 +1000 Subject: [PATCH] Touch-ups for GLEW_OSMESA build support --- .travis.yml | 2 ++ auto/Makefile | 5 ++--- auto/src/glew_head.c | 6 +++--- auto/src/glew_init_tail.c | 6 +++--- auto/src/glew_str_glx.c | 2 +- auto/src/glew_str_wgl.c | 3 +-- auto/src/glewinfo_glx.c | 2 +- auto/src/glewinfo_head.c | 5 ++--- auto/src/glewinfo_tail.c | 5 +++-- auto/src/glewinfo_wgl.c | 3 +-- build/cmake/CMakeLists.txt | 13 ++++++++++++ config/Makefile.linux-osmesa | 38 +++--------------------------------- src/visualinfo.c | 9 ++++++++- 13 files changed, 43 insertions(+), 56 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2eabd21..5f3029f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,9 @@ script: - make extensions - make dist-src - make clean; SYSTEM=linux make +- make clean; SYSTEM=linux-osmesa make - pushd build/cmake; git clean -xdf .; cmake -G 'Unix Makefiles' . ; make; popd +- pushd build/cmake; git clean -xdf .; cmake -G 'Unix Makefiles' -DGLEW_OSMESA=1 .; make; popd addons: artifacts: bucket: glew diff --git a/auto/Makefile b/auto/Makefile index af66a8e..953660e 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) >> $@ @@ -214,7 +213,7 @@ $(S.DEST)/glew.c: $(EXT)/.dummy cat $(SRC)/glew_init_wgl.c >> $@ $(BIN)/make_list.pl $(WGL_EXT_SPEC) >> $@ echo -e "\n return GLEW_OK;\n}" >> $@; - echo -e "\n#elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))" >> $@ + echo -e "\n#elif !defined(GLEW_OSMESA) && !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))" >> $@ $(BIN)/make_def_fun.pl GLX $(GLX_CORE_SPEC) >> $@ $(BIN)/make_def_fun.pl GLX $(GLX_EXT_SPEC) >> $@ echo -e "\n#if !defined(GLEW_MX)" >> $@; 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 0ef2ad8..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; -#if defined(_WIN32) +#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_glx.c b/auto/src/glew_str_glx.c index e841475..785c23a 100644 --- a/auto/src/glew_str_glx.c +++ b/auto/src/glew_str_glx.c @@ -4,7 +4,7 @@ return ret; } -#elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX) +#elif !defined(GLEW_OSMESA) && !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX) #if defined(GLEW_MX) GLboolean glxewContextIsSupported (const GLXEWContext* ctx, const char* name) 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_glx.c b/auto/src/glewinfo_glx.c index 287d7e1..ead3051 100644 --- a/auto/src/glewinfo_glx.c +++ b/auto/src/glewinfo_glx.c @@ -1,6 +1,6 @@ } -#else /* _UNIX */ +#elif !defined(GLEW_OSMESA) /* _UNIX */ static void glxewInfo () { 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_tail.c b/auto/src/glewinfo_tail.c index 56814e8..1774de7 100644 --- a/auto/src/glewinfo_tail.c +++ b/auto/src/glewinfo_tail.c @@ -129,7 +129,8 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params) else return GL_TRUE; ++p; } -#if defined(_WIN32) +#if defined(GLEW_OSMESA) +#elif defined(_WIN32) else if (!strcmp(argv[p], "-pf") || !strcmp(argv[p], "-pixelformat")) { if (++p >= argc) return GL_TRUE; @@ -158,7 +159,7 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params) #if defined(GLEW_OSMESA) OSMesaContext ctx; -GLboolean glewCreateContext () +GLboolean glewCreateContext (struct createParams *params) { ctx = OSMesaCreateContext(OSMESA_RGBA, NULL); if (NULL == ctx) return GL_TRUE; 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 68b0039..c8d4dd2 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -14,6 +14,7 @@ set(CMAKE_DEBUG_POSTFIX d) option (BUILD_UTILS "utilities" ON) option (GLEW_REGAL "Regal mode" FALSE) +option (GLEW_OSMESA "OSMesa mode" FALSE) set (GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) @@ -54,6 +55,18 @@ if (GLEW_REGAL) set (GLEW_LIBRARIES ${REGAL_LIB_NAME}) endif () +#### OSMesa mode #### + +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) diff --git a/config/Makefile.linux-osmesa b/config/Makefile.linux-osmesa index c8d1e95..c957872 100644 --- a/config/Makefile.linux-osmesa +++ b/config/Makefile.linux-osmesa @@ -1,36 +1,4 @@ -NAME = $(GLEW_NAME) -CC = cc -LD = cc -M_ARCH ?= $(shell uname -m) -ARCH64 = false -ifeq (x86_64,${M_ARCH}) - ARCH64 = true -endif -ifeq (ppc64,${M_ARCH}) - ARCH64 = true -endif -ifeq (${ARCH64},true) - LDFLAGS.EXTRA = -L/usr/lib64 - LIBDIR = $(GLEW_DEST)/lib64 -else - LDFLAGS.EXTRA = -L/usr/lib - LIBDIR = $(GLEW_DEST)/lib -endif +include config/Makefile.linux + LDFLAGS.GL = -lOSMesa -LDFLAGS.STATIC = -Wl,-Bstatic -LDFLAGS.DYNAMIC = -Wl,-Bdynamic -NAME = GLEW -WARN = -Wall -W -POPT = -O2 -CFLAGS.EXTRA += -fPIC -DGLEW_OSMESA -BIN.SUFFIX = -LIB.SONAME = lib$(NAME).so.$(SO_MAJOR) -LIB.DEVLNK = lib$(NAME).so -LIB.SHARED = lib$(NAME).so.$(SO_VERSION) -LIB.STATIC = lib$(NAME).a -LDFLAGS.SO = -shared -Wl,-soname=$(LIB.SONAME) -LIB.SONAME.MX = lib$(NAME)mx.so.$(SO_MAJOR) -LIB.DEVLNK.MX = lib$(NAME)mx.so -LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION) -LIB.STATIC.MX = lib$(NAME)mx.a -LDFLAGS.SO.MX = -shared -Wl,-soname=$(LIB.SONAME.MX) +CFLAGS.EXTRA += -DGLEW_OSMESA diff --git a/src/visualinfo.c b/src/visualinfo.c index eb89fd9..2cd000a 100644 --- a/src/visualinfo.c +++ b/src/visualinfo.c @@ -264,7 +264,14 @@ void PrintExtensions (const char* s) /* ---------------------------------------------------------------------- */ -#if defined(_WIN32) +#if defined(GLEW_OSMESA) + +void +VisualInfo (GLContext* ctx) +{ +} + +#elif defined(_WIN32) void VisualInfoARB (GLContext* ctx)