add option for newer Linux demos to dynamically load X11, glX and OpenGL 1 functions

(and avoid having to link against X, glx and GL)
-DGLEW_INIT_OPENGL11_FUNCTIONS
-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
-DDYNAMIC_LOAD_X11_FUNCTIONS
and link against libdl (for example usingi -ldl)
This commit is contained in:
Erwin Coumans (Google)
2014-07-11 14:25:32 -07:00
parent 72ae3b6afb
commit 433d349369
6 changed files with 537 additions and 155 deletions

View File

@@ -4,24 +4,24 @@
** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
** Copyright (C) 2002, Lev Povalahev
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** * The name of the author may be used to endorse or promote products
** * The name of the author may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
@@ -31,6 +31,7 @@
#define GLEW_NO_GLU
//#define GLEW_INIT_OPENGL11_FUNCTIONS 1
//#define GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS 1
/*
* Mesa 3-D graphics library
@@ -58,7 +59,7 @@
/*
** Copyright (c) 2007 The Khronos Group Inc.
**
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
@@ -66,10 +67,10 @@
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -19061,6 +19062,10 @@ GLEWAPI const GLubyte * GLEWAPIENTRY glewGetString (GLenum name);
GLEWAPI GLboolean GLEWAPIENTRY glewOpenGL11Init(void);
#endif //GLEW_INIT_OPENGL11_FUNCTIONS
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
GLEWAPI GLboolean GLEWAPIENTRY glewXInit(void);
#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#ifdef __cplusplus
}
#endif

View File

@@ -4,24 +4,24 @@
** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
** Copyright (C) 2002, Lev Povalahev
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** * The name of the author may be used to endorse or promote products
** * The name of the author may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
@@ -55,7 +55,7 @@
/*
** Copyright (c) 2007 The Khronos Group Inc.
**
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
@@ -63,10 +63,10 @@
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -97,7 +97,7 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xmd.h>
#include <GL/glew.h>
#include "glew.h"
#ifdef __cplusplus
extern "C" {
@@ -141,8 +141,50 @@ typedef struct __glXContextRec *GLXContext;
typedef struct __GLXcontextRec *GLXContext;
#endif
typedef unsigned int GLXVideoDeviceNV;
typedef unsigned int GLXVideoDeviceNV;
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
typedef Bool (* PFNGLXQUERYEXTENSION) (Display *dpy, int *errorBase, int *eventBase);
#define glXQueryExtension GLXEW_GET_FUN(__glewXQueryExtension)
typedef Bool (* PFNGLXQUERYVERSION) (Display *dpy, int *major, int *minor);
#define glXQueryVersion GLXEW_GET_FUN(__glewXQueryVersion)
typedef int (* PFNGLXGETCONFIG) (Display *dpy, XVisualInfo *vis, int attrib, int *value);
#define glXGetConfig GLXEW_GET_FUN(__glewXGetConfig)
typedef XVisualInfo* (* PFNGLXCHOOSEVISUAL) (Display *dpy, int screen, int *attribList);
#define glXChooseVisual GLXEW_GET_FUN(__glewXChooseVisual)
//extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap);
//extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix);
typedef GLXContext (* PFNGLXCREATECONTEXT) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
#define glXCreateContext GLXEW_GET_FUN(__glewXCreateContext)
typedef void (*PFNGLXDESTROYCONTEXT) (Display *dpy, GLXContext ctx);
#define glXDestroyContext GLXEW_GET_FUN(__glewXDestroyContext)
typedef Bool (* PFNGLXISDIRECT) (Display *dpy, GLXContext ctx);
#define glXIsDirect GLXEW_GET_FUN(__glewXIsDirect)
//extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask);
typedef Bool (*PFNGLXMAKECURRENT) (Display *dpy, GLXDrawable drawable, GLXContext ctx);
#define glXMakeCurrent GLXEW_GET_FUN(__glewXMakeCurrent)
//extern GLXContext glXGetCurrentContext (void);
//extern GLXDrawable glXGetCurrentDrawable (void);
//extern void glXWaitGL (void);
//extern void glXWaitX (void);
typedef void (*PFNGLXSWAPBUFFERS) (Display *dpy, GLXDrawable drawable);
#define glXSwapBuffers GLXEW_GET_FUN(__glewXSwapBuffers)
//extern void glXUseXFont (Font font, int first, int count, int listBase);
#else//GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase);
extern Bool glXQueryVersion (Display *dpy, int *major, int *minor);
extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value);
@@ -160,6 +202,7 @@ extern void glXWaitGL (void);
extern void glXWaitX (void);
extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable);
extern void glXUseXFont (Font font, int first, int count, int listBase);
#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0)
@@ -174,9 +217,22 @@ extern void glXUseXFont (Font font, int first, int count, int listBase);
#define GLX_VERSION 0x2
#define GLX_EXTENSIONS 0x3
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
typedef const char* (*PFNGLXQUERYEXTENSIONSSTRING) (Display *dpy, int screen);
#define glXQueryExtensionsString GLXEW_GET_FUN(__glewXQueryExtensionsString)
typedef const char* (*PFNGLXGETCLIENTSTRING) (Display *dpy, int name);
#define glXGetClientString GLXEW_GET_FUN(__glewXGetClientString)
typedef const char* (*PFNGLXQUERYSERVERSTRING) (Display *dpy, int screen, int name);
#define glXQueryServerString GLXEW_GET_FUN(__glewXQueryServerString)
#else//GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
extern const char* glXQueryExtensionsString (Display *dpy, int screen);
extern const char* glXGetClientString (Display *dpy, int name);
extern const char* glXQueryServerString (Display *dpy, int screen, int name);
#endif//GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1)
@@ -263,21 +319,21 @@ typedef XID GLXWindow;
typedef struct __GLXFBConfigRec *GLXFBConfig;
typedef struct {
int event_type;
int draw_type;
unsigned long serial;
Bool send_event;
Display *display;
GLXDrawable drawable;
unsigned int buffer_mask;
unsigned int aux_buffer;
int x, y;
int width, height;
int count;
int event_type;
int draw_type;
unsigned long serial;
Bool send_event;
Display *display;
GLXDrawable drawable;
unsigned int buffer_mask;
unsigned int aux_buffer;
int x, y;
int width, height;
int count;
} GLXPbufferClobberEvent;
typedef union __GLXEvent {
GLXPbufferClobberEvent glxpbufferclobber;
long pad[24];
GLXPbufferClobberEvent glxpbufferclobber;
long pad[24];
} GLXEvent;
typedef GLXFBConfig* ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
@@ -460,7 +516,13 @@ typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBCo
#ifndef GLX_ARB_get_proc_address
#define GLX_ARB_get_proc_address 1
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
typedef void* ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName);
#define glXGetProcAddressARB GLXEW_GET_FUN(__glewXGetProcAddressARB)
#else//GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
extern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void);
#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#define GLXEW_ARB_get_proc_address GLXEW_GET_VAR(__GLXEW_ARB_get_proc_address)
@@ -1161,32 +1223,32 @@ typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLX
#define GLX_HYPERPIPE_ID_SGIX 0x8030
typedef struct {
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int networkId;
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int networkId;
} GLXHyperpipeNetworkSGIX;
typedef struct {
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int XOrigin;
int YOrigin;
int maxHeight;
int maxWidth;
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int XOrigin;
int YOrigin;
int maxHeight;
int maxWidth;
} GLXPipeRectLimits;
typedef struct {
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int channel;
unsigned int participationType;
int timeSlice;
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int channel;
unsigned int participationType;
int timeSlice;
} GLXHyperpipeConfigSGIX;
typedef struct {
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int srcXOrigin;
int srcYOrigin;
int srcWidth;
int srcHeight;
int destXOrigin;
int destYOrigin;
int destWidth;
int destHeight;
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int srcXOrigin;
int srcYOrigin;
int srcWidth;
int srcHeight;
int destXOrigin;
int destYOrigin;
int destWidth;
int destHeight;
} GLXPipeRect;
typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);
@@ -1421,6 +1483,24 @@ typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window,
#define GLXEW_VAR_EXPORT GLEW_VAR_EXPORT
#endif /* GLEW_MX */
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
GLXEW_FUN_EXPORT PFNGLXGETPROCADDRESSARBPROC __glewXGetProcAddressARB;
GLXEW_FUN_EXPORT PFNGLXQUERYEXTENSION __glewXQueryExtension;
GLXEW_FUN_EXPORT PFNGLXQUERYVERSION __glewXQueryVersion;
GLXEW_FUN_EXPORT PFNGLXGETCONFIG __glewXGetConfig;
GLXEW_FUN_EXPORT PFNGLXCHOOSEVISUAL __glewXChooseVisual;
GLXEW_FUN_EXPORT PFNGLXCREATECONTEXT __glewXCreateContext;
GLXEW_FUN_EXPORT PFNGLXDESTROYCONTEXT __glewXDestroyContext;
GLXEW_FUN_EXPORT PFNGLXISDIRECT __glewXIsDirect;
GLXEW_FUN_EXPORT PFNGLXMAKECURRENT __glewXMakeCurrent;
GLXEW_FUN_EXPORT PFNGLXQUERYEXTENSIONSSTRING __glewXQueryExtensionsString;
GLXEW_FUN_EXPORT PFNGLXGETCLIENTSTRING __glewXGetClientString;
GLXEW_FUN_EXPORT PFNGLXQUERYSERVERSTRING __glewXQueryServerString;
GLXEW_FUN_EXPORT PFNGLXSWAPBUFFERS __glewXSwapBuffers;
#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
GLXEW_FUN_EXPORT PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay;
GLXEW_FUN_EXPORT PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig;
@@ -1453,6 +1533,7 @@ GLXEW_FUN_EXPORT PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __glewXMakeAssociated
GLXEW_FUN_EXPORT PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB;
GLXEW_FUN_EXPORT PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI;
GLXEW_FUN_EXPORT PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI;
GLXEW_FUN_EXPORT PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI;

View File

@@ -4,24 +4,24 @@
** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
** Copyright (C) 2002, Lev Povalahev
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** * The name of the author may be used to endorse or promote products
** * The name of the author may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
@@ -34,7 +34,38 @@
#if defined(_WIN32)
# include <GL/wglew.h>
#elif !defined(__ANDROID__) && !defined(__native_client__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))
# include <GL/glxew.h>
# include "GL/glxew.h"
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
void* dlglXGetProcAddressARB(const GLubyte* name)
{
static void* h = NULL;
static void* gpa;
if (h == NULL)
{
if ((h = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL)) == NULL)
{
return NULL;
}
gpa = dlsym(h, "glXGetProcAddressARB");
}
if (gpa != NULL)
return ((void*(*)(const GLubyte*))gpa)(name);
else
return dlsym(h, (const char*)name);
}
#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#endif
/*
@@ -102,7 +133,7 @@ void* NSGLGetProcAddress (const GLubyte *name)
{
static void* image = NULL;
void* addr;
if (NULL == image)
if (NULL == image)
{
#ifdef GLEW_REGAL
image = dlopen("libRegal.dylib", RTLD_LAZY);
@@ -169,7 +200,11 @@ void* NSGLGetProcAddress (const GLubyte *name)
#elif defined(__native_client__)
# define glewGetProcAddress(name) NULL /* TODO */
#else /* __linux */
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
# define glewGetProcAddress(name) dlglXGetProcAddressARB(name)
#else//GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name)
#endif//GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#endif
/*
@@ -9469,7 +9504,7 @@ static GLboolean _glewInit_GL_WIN_swap_hint (GLEW_CONTEXT_ARG_DEF_INIT)
/* ------------------------------------------------------------------------- */
GLboolean GLEWAPIENTRY glewGetExtension (const char* name)
{
{
const GLubyte* start;
const GLubyte* end;
start = (const GLubyte*)glGetString(GL_EXTENSIONS);
@@ -9496,7 +9531,7 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
dot = _glewStrCLen(s, '.');
if (dot == 0)
return GLEW_ERROR_NO_GL_VERSION;
major = s[dot-1]-'0';
minor = s[dot+1]-'0';
@@ -9504,7 +9539,7 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
minor = 0;
if (major<0 || major>9)
return GLEW_ERROR_NO_GL_VERSION;
if (major == 1 && minor == 0)
{
@@ -9521,12 +9556,12 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
CONST_CAST(GLEW_VERSION_3_2) = GLEW_VERSION_3_3 == GL_TRUE || ( major == 3 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_3_1) = GLEW_VERSION_3_2 == GL_TRUE || ( major == 3 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_3_0) = GLEW_VERSION_3_1 == GL_TRUE || ( major == 3 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_2_1) = GLEW_VERSION_3_0 == GL_TRUE || ( major == 2 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_2_1) = GLEW_VERSION_3_0 == GL_TRUE || ( major == 2 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_2_0) = GLEW_VERSION_2_1 == GL_TRUE || ( major == 2 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_1_5) = GLEW_VERSION_2_0 == GL_TRUE || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_1_4) = GLEW_VERSION_1_5 == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_1_3) = GLEW_VERSION_1_4 == GL_TRUE || ( major == 1 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_1_2_1) = GLEW_VERSION_1_3 == GL_TRUE ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_1_2_1) = GLEW_VERSION_1_3 == GL_TRUE ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_1_2) = GLEW_VERSION_1_2_1 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
CONST_CAST(GLEW_VERSION_1_1) = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
}
@@ -12099,7 +12134,7 @@ static PFNWGLGETEXTENSIONSSTRINGARBPROC _wglewGetExtensionsStringARB = NULL;
static PFNWGLGETEXTENSIONSSTRINGEXTPROC _wglewGetExtensionsStringEXT = NULL;
GLboolean GLEWAPIENTRY wglewGetExtension (const char* name)
{
{
const GLubyte* start;
const GLubyte* end;
if (_wglewGetExtensionsStringARB == NULL)
@@ -12326,6 +12361,24 @@ GLenum GLEWAPIENTRY wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST)
#elif !defined(__ANDROID__) && !defined(__native_client__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
PFNGLXGETPROCADDRESSARBPROC __glewXGetProcAddressARB = NULL;
PFNGLXQUERYEXTENSION __glewXQueryExtension=NULL;
PFNGLXQUERYVERSION __glewXQueryVersion=NULL;
PFNGLXGETCONFIG __glewXGetConfig=NULL;
PFNGLXCHOOSEVISUAL __glewXChooseVisual=NULL;
PFNGLXCREATECONTEXT __glewXCreateContext=NULL;
PFNGLXDESTROYCONTEXT __glewXDestroyContext=NULL;
PFNGLXISDIRECT __glewXIsDirect=NULL;
PFNGLXMAKECURRENT __glewXMakeCurrent=NULL;
PFNGLXQUERYEXTENSIONSSTRING __glewXQueryExtensionsString=NULL;
PFNGLXGETCLIENTSTRING __glewXGetClientString=NULL;
PFNGLXQUERYSERVERSTRING __glewXQueryServerString=NULL;
PFNGLXSWAPBUFFERS __glewXSwapBuffers=NULL;
#endif//GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay = NULL;
PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig = NULL;
@@ -13164,7 +13217,7 @@ static GLboolean _glewInit_GLX_SUN_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT)
/* ------------------------------------------------------------------------ */
GLboolean glxewGetExtension (const char* name)
{
{
const GLubyte* start;
const GLubyte* end;
@@ -13476,6 +13529,34 @@ extern GLenum GLEWAPIENTRY wglewContextInit (void);
extern GLenum GLEWAPIENTRY glxewContextInit (void);
#endif /* _WIN32 */
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
GLboolean GLEWAPIENTRY glewXInit(void)
{
GLboolean r = GL_FALSE;
r = ((glXGetProcAddressARB = (PFNGLXGETPROCADDRESSARBPROC)dlglXGetProcAddressARB((const GLubyte*)"glXGetProcAddressARB")) == NULL) || r;
r = ((glXQueryExtension = (PFNGLXQUERYEXTENSION)dlglXGetProcAddressARB((const GLubyte*)"glXQueryExtension")) == NULL) || r;
r = ((glXQueryVersion = (PFNGLXQUERYVERSION)dlglXGetProcAddressARB((const GLubyte*)"glXQueryVersion")) == NULL) || r;
r = ((glXGetConfig = (PFNGLXGETCONFIG)dlglXGetProcAddressARB((const GLubyte*)"glXGetConfig")) == NULL) || r;
r = ((glXChooseVisual = (PFNGLXCHOOSEVISUAL)dlglXGetProcAddressARB((const GLubyte*)"glXChooseVisual")) == NULL) || r;
r = ((glXCreateContext = (PFNGLXCREATECONTEXT)dlglXGetProcAddressARB((const GLubyte*)"glXCreateContext")) == NULL) || r;
r = ((glXDestroyContext = (PFNGLXDESTROYCONTEXT)dlglXGetProcAddressARB((const GLubyte*)"glXDestroyContext")) == NULL) || r;
r = ((glXDestroyContext = (PFNGLXDESTROYCONTEXT)dlglXGetProcAddressARB((const GLubyte*)"glXDestroyContext")) == NULL) || r;
r = ((glXIsDirect = (PFNGLXISDIRECT)dlglXGetProcAddressARB((const GLubyte*)"glXIsDirect")) == NULL) || r;
r = ((glXMakeCurrent = (PFNGLXMAKECURRENT)dlglXGetProcAddressARB((const GLubyte*)"glXMakeCurrent")) == NULL) || r;
r = ((glXQueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRING)dlglXGetProcAddressARB((const GLubyte*)"glXQueryExtensionsString")) == NULL) || r;
r = ((glXGetClientString = (PFNGLXGETCLIENTSTRING)dlglXGetProcAddressARB((const GLubyte*)"glXGetClientString")) == NULL) || r;
r = ((glXQueryServerString = (PFNGLXQUERYSERVERSTRING)dlglXGetProcAddressARB((const GLubyte*)"glXQueryServerString")) == NULL) || r;
r = ((glXSwapBuffers = (PFNGLXSWAPBUFFERS)dlglXGetProcAddressARB((const GLubyte*)"glXSwapBuffers")) == NULL) || r;
//glxewContextInit();
_glewInit_GLX_VERSION_1_3();
if (r==0)
{
printf("glewXInit dynamically loaded using dlopen/dlsym OK\n");
}
return r;
}
#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#ifdef GLEW_INIT_OPENGL11_FUNCTIONS
@@ -14160,6 +14241,10 @@ GLboolean GLEWAPIENTRY glewOpenGL11Init(void)
r = ((glVertexPointer = (PFNGLVERTEXPOINTERPROC)glewGetProcAddress(fqn_from_convention(glew_convention, "glVertexPointer"))) == NULL) || r;
r = ((glViewport = (PFNGLVIEWPORTPROC)glewGetProcAddress(fqn_from_convention(glew_convention, "glViewport"))) == NULL) || r;
if (r==0)
{
printf("glewOpenGL11Init dynamically loaded using dlopen/dlsym OK\n");
}
return r;
}
#endif //GLEW_INIT_OPENGL11_FUNCTIONS