mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-28 08:41:55 +00:00
GLEW_EGL mode for loading functions via eglGetProcAddress
This commit is contained in:
parent
fe41bc3bdd
commit
2cea9e2719
@ -200,14 +200,14 @@ $(S.DEST)/glew.c: $(EXT)/.dummy
|
||||
$(BIN)/make_list.pl $(GL_EXT_SPEC) >> $@
|
||||
$(BIN)/make_list2.pl $(GL_EXT_SPEC) >> $@
|
||||
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_var.pl WGL $(WGL_EXT_SPEC) >> $@
|
||||
$(BIN)/make_init.pl WGL $(WGL_EXT_SPEC) >> $@
|
||||
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(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_EXT_SPEC) >> $@
|
||||
echo -e "\nGLboolean __GLXEW_VERSION_1_0 = GL_FALSE;" >> $@
|
||||
@ -245,12 +245,14 @@ $(S.DEST)/glewinfo.c: $(EXT)/.dummy
|
||||
cat $(SRC)/glewinfo_head.c >> $@
|
||||
$(BIN)/make_info.pl $(GL_CORE_SPEC) >> $@
|
||||
$(BIN)/make_info.pl $(GL_EXT_SPEC) >> $@
|
||||
echo -e "#if !defined(GLEW_EGL)\n" >> $@
|
||||
echo -e "#ifdef _WIN32\n" >> $@
|
||||
$(BIN)/make_info.pl $(WGL_EXT_SPEC) >> $@
|
||||
echo -e "#else /* _UNIX */\n" >> $@
|
||||
$(BIN)/make_info.pl $(GLX_CORE_SPEC) >> $@
|
||||
$(BIN)/make_info.pl $(GLX_EXT_SPEC) >> $@
|
||||
echo -e "#endif /* _WIN32 */\n" >> $@
|
||||
echo -e "#endif /* !defined(GLEW_EGL) */\n" >> $@
|
||||
|
||||
cat $(SRC)/glewinfo_gl.c >> $@
|
||||
$(BIN)/make_info_list.pl $(GL_CORE_SPEC) >> $@
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <GL/glew.h>
|
||||
|
||||
#if defined(GLEW_OSMESA)
|
||||
#if defined(GLEW_EGL)
|
||||
#elif defined(GLEW_OSMESA)
|
||||
# define GLAPI extern
|
||||
# include <GL/osmesa.h>
|
||||
#elif defined(_WIN32)
|
||||
@ -13,7 +14,9 @@
|
||||
#include <stdlib.h> /* For bsearch */
|
||||
#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
|
||||
libRegal.so glGetProcAddressREGAL for looking up
|
||||
@ -113,7 +116,9 @@ void* NSGLGetProcAddress (const GLubyte *name)
|
||||
/*
|
||||
* 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)
|
||||
#elif defined(GLEW_OSMESA)
|
||||
# define glewGetProcAddress(name) OSMesaGetProcAddress((const char *)name)
|
||||
|
@ -37,7 +37,7 @@ GLenum GLEWAPIENTRY glewInit (void)
|
||||
GLenum r;
|
||||
r = glewContextInit();
|
||||
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;
|
||||
#elif defined(_WIN32)
|
||||
return wglewInit();
|
||||
|
@ -4,7 +4,7 @@
|
||||
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)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(GLEW_OSMESA)
|
||||
#if defined(_WIN32) && !defined(GLEW_EGL) && !defined(GLEW_OSMESA)
|
||||
|
||||
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 ()
|
||||
{
|
||||
|
@ -2,7 +2,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#if defined(GLEW_OSMESA)
|
||||
#if defined(GLEW_EGL)
|
||||
#include <EGL/egl.h>
|
||||
#elif defined(GLEW_OSMESA)
|
||||
#define GLAPI extern
|
||||
#include <GL/osmesa.h>
|
||||
#elif defined(_WIN32)
|
||||
@ -25,7 +27,8 @@ static FILE* f;
|
||||
|
||||
struct createParams
|
||||
{
|
||||
#if defined(GLEW_OSMESA)
|
||||
#if defined(GLEW_EGL)
|
||||
#elif defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
int pixelformat;
|
||||
#elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX)
|
||||
|
@ -9,7 +9,8 @@ int main (int argc, char** argv)
|
||||
GLuint err;
|
||||
struct createParams params =
|
||||
{
|
||||
#if defined(GLEW_OSMESA)
|
||||
#if defined(GLEW_EGL)
|
||||
#elif defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
-1, /* pixelformat */
|
||||
#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))
|
||||
{
|
||||
fprintf(stderr, "Usage: glewinfo "
|
||||
#if defined(GLEW_OSMESA)
|
||||
#if defined(GLEW_EGL)
|
||||
#elif defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
"[-pf <pixelformat>] "
|
||||
#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, "---------------------------\n\n");
|
||||
fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION));
|
||||
#if defined(GLEW_OSMESA)
|
||||
#if defined(GLEW_EGL)
|
||||
#elif defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
fprintf(f, "Reporting capabilities of pixelformat %d\n", params.pixelformat);
|
||||
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||
@ -79,7 +82,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(GLEW_OSMESA)
|
||||
#if defined(GLEW_EGL)
|
||||
#elif defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
wglewInfo();
|
||||
#else
|
||||
@ -118,7 +122,8 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params)
|
||||
else return GL_TRUE;
|
||||
++p;
|
||||
}
|
||||
#if defined(GLEW_OSMESA)
|
||||
#if defined(GLEW_EGL)
|
||||
#elif defined(GLEW_OSMESA)
|
||||
#elif defined(_WIN32)
|
||||
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;
|
||||
|
||||
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 ()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user