mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-22 05:45:07 +00:00
Hack in crude OSMesa support
Mostly this is quick, "do nothing" ifdefs when built with SYSTEM=linux-osmesa, to support the off-screen rendering mode of Mesa in headless tests. Support in glewinfo and visualinfo is enough to get them compile, but insufficient for them to run successfully.
This commit is contained in:
parent
4718d42dde
commit
11e24d4a9b
@ -204,7 +204,8 @@ $(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(_WIN32)" >> $@
|
||||
echo -e "\n#if defined(GLEW_OSMESA)" >> $@
|
||||
echo -e "\n#elif defined(_WIN32)" >> $@
|
||||
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) >> $@
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include <GL/glew.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
# define GLAPI extern
|
||||
# include <GL/osmesa.h>
|
||||
#elif defined(_WIN32)
|
||||
# include <GL/wglew.h>
|
||||
#elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))
|
||||
# include <GL/glxew.h>
|
||||
@ -137,7 +140,9 @@ void* NSGLGetProcAddress (const GLubyte *name)
|
||||
/*
|
||||
* Define glewGetProcAddress.
|
||||
*/
|
||||
#if defined(GLEW_REGAL)
|
||||
#if 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)
|
||||
|
@ -39,6 +39,8 @@ GLenum GLEWAPIENTRY glewInit (void)
|
||||
GLenum r;
|
||||
r = glewContextInit();
|
||||
if ( r != 0 ) return r;
|
||||
#if defined(GLEW_OSMESA)
|
||||
return r;
|
||||
#if defined(_WIN32)
|
||||
return wglewInit();
|
||||
#elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) /* _UNIX */
|
||||
|
@ -4,7 +4,8 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#if defined(GLEW_MX)
|
||||
GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext* ctx, const char* name)
|
||||
|
@ -2,7 +2,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#define GLAPI extern
|
||||
#include <GL/osmesa.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <GL/wglew.h>
|
||||
#elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX)
|
||||
#include <GL/glxew.h>
|
||||
@ -21,7 +24,8 @@ static FILE* f;
|
||||
#ifdef GLEW_MX
|
||||
GLEWContext _glewctx;
|
||||
#define glewGetContext() (&_glewctx)
|
||||
#ifdef _WIN32
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
WGLEWContext _wglewctx;
|
||||
#define wglewGetContext() (&_wglewctx)
|
||||
#elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX)
|
||||
@ -34,7 +38,8 @@ GLXEWContext _glxewctx;
|
||||
|
||||
struct createParams
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
int pixelformat;
|
||||
#elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX)
|
||||
const char* display;
|
||||
|
@ -9,7 +9,8 @@ int main (int argc, char** argv)
|
||||
GLuint err;
|
||||
struct createParams params =
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
-1, /* pixelformat */
|
||||
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||
"", /* display */
|
||||
@ -24,7 +25,8 @@ int main (int argc, char** argv)
|
||||
if (glewParseArgs(argc-1, argv+1, ¶ms))
|
||||
{
|
||||
fprintf(stderr, "Usage: glewinfo "
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
"[-pf <pixelformat>] "
|
||||
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||
"[-display <display>] "
|
||||
@ -46,7 +48,8 @@ int main (int argc, char** argv)
|
||||
glewExperimental = GL_TRUE;
|
||||
#ifdef GLEW_MX
|
||||
err = glewContextInit(glewGetContext());
|
||||
#ifdef _WIN32
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
err = err || wglewContextInit(wglewGetContext());
|
||||
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||
err = err || glxewContextInit(glxewGetContext());
|
||||
@ -76,7 +79,8 @@ int main (int argc, char** argv)
|
||||
fprintf(f, " GLEW Extension Info\n");
|
||||
fprintf(f, "---------------------------\n\n");
|
||||
fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION));
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
fprintf(f, "Reporting capabilities of pixelformat %d\n", params.pixelformat);
|
||||
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||
fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n",
|
||||
@ -86,7 +90,8 @@ int main (int argc, char** argv)
|
||||
glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
||||
fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
|
||||
glewInfo();
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
wglewInfo();
|
||||
#else
|
||||
glxewInfo();
|
||||
@ -150,7 +155,22 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
OSMesaContext ctx;
|
||||
|
||||
GLboolean glewCreateContext ()
|
||||
{
|
||||
ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
|
||||
if (NULL == ctx) return GL_TRUE;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
void glewDestroyContext ()
|
||||
{
|
||||
if (NULL != ctx) OSMesaDestroyContext(ctx);
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
HWND wnd = NULL;
|
||||
HDC dc = NULL;
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
|
||||
static void wglewInfo ()
|
||||
{
|
||||
|
36
config/Makefile.linux-osmesa
Normal file
36
config/Makefile.linux-osmesa
Normal file
@ -0,0 +1,36 @@
|
||||
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
|
||||
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)
|
@ -34,7 +34,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#define GLAPI extern
|
||||
#include <GL/osmesa.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <GL/wglew.h>
|
||||
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
@ -57,7 +60,9 @@ GLXEWContext _glxewctx;
|
||||
|
||||
typedef struct GLContextStruct
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(GLEW_OSMESA)
|
||||
OSMesaContext ctx;
|
||||
#elif defined(_WIN32)
|
||||
HWND wnd;
|
||||
HDC dc;
|
||||
HGLRC rc;
|
||||
@ -180,7 +185,8 @@ main (int argc, char** argv)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* extensions string */
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
/* WGL extensions */
|
||||
if (WGLEW_ARB_extensions_string || WGLEW_EXT_extensions_string)
|
||||
{
|
||||
@ -1003,7 +1009,26 @@ VisualInfo (GLContext* ctx)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(GLEW_OSMESA)
|
||||
void InitContext (GLContext* ctx)
|
||||
{
|
||||
ctx->ctx = NULL;
|
||||
}
|
||||
|
||||
GLboolean CreateContext (GLContext* ctx)
|
||||
{
|
||||
if (NULL == ctx) return GL_TRUE;
|
||||
ctx->ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
|
||||
if (NULL == ctx->ctx) return GL_TRUE;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
void DestroyContext (GLContext* ctx)
|
||||
{
|
||||
if (NULL == ctx) return;
|
||||
if (NULL != ctx->ctx) OSMesaDestroyContext(ctx->ctx);
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
|
||||
void InitContext (GLContext* ctx)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user