mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-24 14:55:07 +00:00
GLEW_EGL mode for loading functions via eglGetProcAddress
This commit is contained in:
parent
9ef6bfb7a6
commit
bd38cd7ba3
@ -214,7 +214,7 @@ $(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)" >> $@
|
||||||
echo -e "\n#if !defined(GLEW_MX)" >> $@
|
echo -e "\n#if !defined(GLEW_MX)" >> $@
|
||||||
$(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) >> $@
|
||||||
@ -223,7 +223,7 @@ $(S.DEST)/glew.c: $(EXT)/.dummy
|
|||||||
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 "\n#if !defined(GLEW_MX)" >> $@;
|
echo -e "\n#if !defined(GLEW_MX)" >> $@;
|
||||||
@ -263,12 +263,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)
|
||||||
|
@ -9,7 +9,8 @@ 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,7 +26,8 @@ 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)
|
||||||
@ -68,7 +70,8 @@ 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)
|
||||||
@ -79,7 +82,8 @@ int main (int argc, char** argv)
|
|||||||
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;
|
||||||
|
@ -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