mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-25 15:25:07 +00:00
GLEW_EGL mode for loading functions via eglGetProcAddress
This commit is contained in:
parent
4ee89ccb39
commit
f4abb657b3
@ -200,14 +200,14 @@ $(S.DEST)/glew.c: $(EXT)/.dummy
|
|||||||
$(BIN)/make_list.pl $(GL_EXT_SPEC) >> $@
|
$(BIN)/make_list.pl $(GL_EXT_SPEC) >> $@
|
||||||
$(BIN)/make_list2.pl $(GL_EXT_SPEC) >> $@
|
$(BIN)/make_list2.pl $(GL_EXT_SPEC) >> $@
|
||||||
echo -e "\n return GLEW_OK;\n}\n" >> $@
|
echo -e "\n return GLEW_OK;\n}\n" >> $@
|
||||||
echo -e "\n#if defined(_WIN32) && ! defined(GLEW_OSMESA)" >> $@
|
echo -e "\n#if defined(_WIN32) && !defined(GLEW_EGL) && !defined(GLEW_OSMESA)" >> $@
|
||||||
$(BIN)/make_def_fun.pl WGL $(WGL_EXT_SPEC) >> $@
|
$(BIN)/make_def_fun.pl WGL $(WGL_EXT_SPEC) >> $@
|
||||||
$(BIN)/make_def_var.pl WGL $(WGL_EXT_SPEC) >> $@
|
$(BIN)/make_def_var.pl WGL $(WGL_EXT_SPEC) >> $@
|
||||||
$(BIN)/make_init.pl WGL $(WGL_EXT_SPEC) >> $@
|
$(BIN)/make_init.pl WGL $(WGL_EXT_SPEC) >> $@
|
||||||
cat $(SRC)/glew_init_wgl.c >> $@
|
cat $(SRC)/glew_init_wgl.c >> $@
|
||||||
$(BIN)/make_list.pl $(WGL_EXT_SPEC) >> $@
|
$(BIN)/make_list.pl $(WGL_EXT_SPEC) >> $@
|
||||||
echo -e "\n return GLEW_OK;\n}" >> $@;
|
echo -e "\n return GLEW_OK;\n}" >> $@;
|
||||||
echo -e "\n#elif !defined(GLEW_OSMESA) && !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))" >> $@
|
echo -e "\n#elif !defined(GLEW_EGL) && !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_CORE_SPEC) >> $@
|
||||||
$(BIN)/make_def_fun.pl GLX $(GLX_EXT_SPEC) >> $@
|
$(BIN)/make_def_fun.pl GLX $(GLX_EXT_SPEC) >> $@
|
||||||
echo -e "\nGLboolean __GLXEW_VERSION_1_0 = GL_FALSE;" >> $@
|
echo -e "\nGLboolean __GLXEW_VERSION_1_0 = GL_FALSE;" >> $@
|
||||||
@ -245,12 +245,14 @@ $(S.DEST)/glewinfo.c: $(EXT)/.dummy
|
|||||||
cat $(SRC)/glewinfo_head.c >> $@
|
cat $(SRC)/glewinfo_head.c >> $@
|
||||||
$(BIN)/make_info.pl $(GL_CORE_SPEC) >> $@
|
$(BIN)/make_info.pl $(GL_CORE_SPEC) >> $@
|
||||||
$(BIN)/make_info.pl $(GL_EXT_SPEC) >> $@
|
$(BIN)/make_info.pl $(GL_EXT_SPEC) >> $@
|
||||||
|
echo -e "#if !defined(GLEW_EGL)\n" >> $@
|
||||||
echo -e "#ifdef _WIN32\n" >> $@
|
echo -e "#ifdef _WIN32\n" >> $@
|
||||||
$(BIN)/make_info.pl $(WGL_EXT_SPEC) >> $@
|
$(BIN)/make_info.pl $(WGL_EXT_SPEC) >> $@
|
||||||
echo -e "#else /* _UNIX */\n" >> $@
|
echo -e "#else /* _UNIX */\n" >> $@
|
||||||
$(BIN)/make_info.pl $(GLX_CORE_SPEC) >> $@
|
$(BIN)/make_info.pl $(GLX_CORE_SPEC) >> $@
|
||||||
$(BIN)/make_info.pl $(GLX_EXT_SPEC) >> $@
|
$(BIN)/make_info.pl $(GLX_EXT_SPEC) >> $@
|
||||||
echo -e "#endif /* _WIN32 */\n" >> $@
|
echo -e "#endif /* _WIN32 */\n" >> $@
|
||||||
|
echo -e "#endif /* !defined(GLEW_EGL) */\n" >> $@
|
||||||
|
|
||||||
cat $(SRC)/glewinfo_gl.c >> $@
|
cat $(SRC)/glewinfo_gl.c >> $@
|
||||||
$(BIN)/make_info_list.pl $(GL_CORE_SPEC) >> $@
|
$(BIN)/make_info_list.pl $(GL_CORE_SPEC) >> $@
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
# define GLAPI extern
|
# define GLAPI extern
|
||||||
# include <GL/osmesa.h>
|
# include <GL/osmesa.h>
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
@ -13,7 +14,9 @@
|
|||||||
#include <stdlib.h> /* For bsearch */
|
#include <stdlib.h> /* For bsearch */
|
||||||
#include <string.h> /* For memset */
|
#include <string.h> /* For memset */
|
||||||
|
|
||||||
#if defined(GLEW_REGAL)
|
#if defined(GLEW_EGL)
|
||||||
|
extern void * eglGetProcAddress (const char *procname);
|
||||||
|
#elif defined(GLEW_REGAL)
|
||||||
|
|
||||||
/* In GLEW_REGAL mode we call direcly into the linked
|
/* In GLEW_REGAL mode we call direcly into the linked
|
||||||
libRegal.so glGetProcAddressREGAL for looking up
|
libRegal.so glGetProcAddressREGAL for looking up
|
||||||
@ -113,7 +116,9 @@ void* NSGLGetProcAddress (const GLubyte *name)
|
|||||||
/*
|
/*
|
||||||
* Define glewGetProcAddress.
|
* Define glewGetProcAddress.
|
||||||
*/
|
*/
|
||||||
#if defined(GLEW_REGAL)
|
#if defined(GLEW_EGL)
|
||||||
|
# define glewGetProcAddress(name) eglGetProcAddress((const char *)name)
|
||||||
|
#elif defined(GLEW_REGAL)
|
||||||
# define glewGetProcAddress(name) regalGetProcAddress((const GLchar *)name)
|
# define glewGetProcAddress(name) regalGetProcAddress((const GLchar *)name)
|
||||||
#elif defined(GLEW_OSMESA)
|
#elif defined(GLEW_OSMESA)
|
||||||
# define glewGetProcAddress(name) OSMesaGetProcAddress((const char *)name)
|
# define glewGetProcAddress(name) OSMesaGetProcAddress((const char *)name)
|
||||||
|
@ -37,7 +37,7 @@ GLenum GLEWAPIENTRY glewInit (void)
|
|||||||
GLenum r;
|
GLenum r;
|
||||||
r = glewContextInit();
|
r = glewContextInit();
|
||||||
if ( r != 0 ) return r;
|
if ( r != 0 ) return r;
|
||||||
#if defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
|
#if defined(GLEW_EGL) || defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
|
||||||
return r;
|
return r;
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
return wglewInit();
|
return wglewInit();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif !defined(GLEW_OSMESA) && !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
#elif !defined(GLEW_EGL) && !defined(GLEW_OSMESA) && !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||||
|
|
||||||
GLboolean glxewIsSupported (const char* name)
|
GLboolean glxewIsSupported (const char* name)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(GLEW_OSMESA)
|
#if defined(_WIN32) && !defined(GLEW_EGL) && !defined(GLEW_OSMESA)
|
||||||
|
|
||||||
GLboolean GLEWAPIENTRY wglewIsSupported (const char* name)
|
GLboolean GLEWAPIENTRY wglewIsSupported (const char* name)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif !defined(GLEW_OSMESA) /* _UNIX */
|
#elif !defined(GLEW_EGL) && !defined(GLEW_OSMESA) /* _UNIX */
|
||||||
|
|
||||||
static void glxewInfo ()
|
static void glxewInfo ()
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
#define GLAPI extern
|
#define GLAPI extern
|
||||||
#include <GL/osmesa.h>
|
#include <GL/osmesa.h>
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
@ -25,7 +27,8 @@ static FILE* f;
|
|||||||
|
|
||||||
struct createParams
|
struct createParams
|
||||||
{
|
{
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
int pixelformat;
|
int pixelformat;
|
||||||
#elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX)
|
#elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX)
|
||||||
|
@ -7,9 +7,10 @@
|
|||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
GLuint err;
|
GLuint err;
|
||||||
struct createParams params =
|
struct createParams params =
|
||||||
{
|
{
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
-1, /* pixelformat */
|
-1, /* pixelformat */
|
||||||
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||||
@ -25,17 +26,18 @@ int main (int argc, char** argv)
|
|||||||
if (glewParseArgs(argc-1, argv+1, ¶ms))
|
if (glewParseArgs(argc-1, argv+1, ¶ms))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: glewinfo "
|
fprintf(stderr, "Usage: glewinfo "
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
"[-pf <pixelformat>] "
|
"[-pf <pixelformat>] "
|
||||||
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||||
"[-display <display>] "
|
"[-display <display>] "
|
||||||
"[-visual <visual id>] "
|
"[-visual <visual id>] "
|
||||||
#endif
|
#endif
|
||||||
"[-version <OpenGL version>] "
|
"[-version <OpenGL version>] "
|
||||||
"[-profile core|compatibility] "
|
"[-profile core|compatibility] "
|
||||||
"[-flag debug|forward]"
|
"[-flag debug|forward]"
|
||||||
"\n");
|
"\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,18 +70,20 @@ int main (int argc, char** argv)
|
|||||||
fprintf(f, " GLEW Extension Info\n");
|
fprintf(f, " GLEW Extension Info\n");
|
||||||
fprintf(f, "---------------------------\n\n");
|
fprintf(f, "---------------------------\n\n");
|
||||||
fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION));
|
fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION));
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
fprintf(f, "Reporting capabilities of pixelformat %d\n", params.pixelformat);
|
fprintf(f, "Reporting capabilities of pixelformat %d\n", params.pixelformat);
|
||||||
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||||
fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n",
|
fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n",
|
||||||
params.display == NULL ? getenv("DISPLAY") : params.display, params.visual);
|
params.display == NULL ? getenv("DISPLAY") : params.display, params.visual);
|
||||||
#endif
|
#endif
|
||||||
fprintf(f, "Running on a %s from %s\n",
|
fprintf(f, "Running on a %s from %s\n",
|
||||||
glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
||||||
fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
|
fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
|
||||||
glewInfo();
|
glewInfo();
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
wglewInfo();
|
wglewInfo();
|
||||||
#else
|
#else
|
||||||
@ -118,7 +122,8 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params)
|
|||||||
else return GL_TRUE;
|
else return GL_TRUE;
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
else if (!strcmp(argv[p], "-pf") || !strcmp(argv[p], "-pixelformat"))
|
else if (!strcmp(argv[p], "-pf") || !strcmp(argv[p], "-pixelformat"))
|
||||||
{
|
{
|
||||||
@ -145,7 +150,44 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_EGL)
|
||||||
|
EGLDisplay display;
|
||||||
|
EGLContext ctx;
|
||||||
|
|
||||||
|
/* See: http://stackoverflow.com/questions/12662227/opengl-es2-0-offscreen-context-for-fbo-rendering */
|
||||||
|
|
||||||
|
GLboolean glewCreateContext (struct createParams *params)
|
||||||
|
{
|
||||||
|
EGLSurface surface;
|
||||||
|
EGLint majorVersion, minorVersion;
|
||||||
|
const EGLint attr[] = {
|
||||||
|
EGL_BUFFER_SIZE, 32,
|
||||||
|
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
||||||
|
EGL_CONFORMANT, EGL_OPENGL_BIT,
|
||||||
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
EGLConfig config;
|
||||||
|
EGLint numConfig;
|
||||||
|
display = eglGetDisplay((EGLNativeDisplayType) 0);
|
||||||
|
if (!eglInitialize(display, &majorVersion, &minorVersion))
|
||||||
|
return GL_TRUE;
|
||||||
|
eglBindAPI(EGL_OPENGL_API);
|
||||||
|
if (!eglChooseConfig(display, attr, &config, 1, &numConfig) || (numConfig != 1))
|
||||||
|
return GL_TRUE;
|
||||||
|
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL);
|
||||||
|
ctx = eglCreateContext(display, config, NULL, NULL);
|
||||||
|
if (NULL == ctx) return GL_TRUE;
|
||||||
|
eglMakeCurrent(display, surface, surface, ctx);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void glewDestroyContext ()
|
||||||
|
{
|
||||||
|
if (NULL != ctx) eglDestroyContext(display, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(GLEW_OSMESA)
|
||||||
OSMesaContext ctx;
|
OSMesaContext ctx;
|
||||||
|
|
||||||
static const GLint osmFormat = GL_UNSIGNED_BYTE;
|
static const GLint osmFormat = GL_UNSIGNED_BYTE;
|
||||||
@ -190,7 +232,7 @@ GLboolean glewCreateContext (struct createParams* params)
|
|||||||
wc.lpszClassName = "GLEW";
|
wc.lpszClassName = "GLEW";
|
||||||
if (0 == RegisterClass(&wc)) return GL_TRUE;
|
if (0 == RegisterClass(&wc)) return GL_TRUE;
|
||||||
/* create window */
|
/* create window */
|
||||||
wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
|
CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
|
||||||
if (NULL == wnd) return GL_TRUE;
|
if (NULL == wnd) return GL_TRUE;
|
||||||
/* get the device context */
|
/* get the device context */
|
||||||
@ -378,8 +420,8 @@ GLboolean glewCreateContext (struct createParams *params)
|
|||||||
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
|
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
|
||||||
swa.border_pixel = 0;
|
swa.border_pixel = 0;
|
||||||
swa.colormap = cmap;
|
swa.colormap = cmap;
|
||||||
wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen),
|
wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen),
|
||||||
0, 0, 1, 1, 0, vi->depth, InputOutput, vi->visual,
|
0, 0, 1, 1, 0, vi->depth, InputOutput, vi->visual,
|
||||||
CWBorderPixel | CWColormap, &swa);
|
CWBorderPixel | CWColormap, &swa);
|
||||||
/* make context current */
|
/* make context current */
|
||||||
if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE;
|
if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(GLEW_OSMESA)
|
#if defined(_WIN32) && !defined(GLEW_EGL) && !defined(GLEW_OSMESA)
|
||||||
|
|
||||||
static void wglewInfo ()
|
static void wglewInfo ()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user