mirror of
https://github.com/Perlmint/glew-cmake.git
synced 2024-11-26 16:41:57 +00:00
For EGL purpose avoid using linked glGetString, load it via eglGetProcAddress instead.
This commit is contained in:
parent
4d9010864e
commit
23438663d6
@ -5,7 +5,7 @@ GLboolean eglewGetExtension (const char* name)
|
|||||||
const GLubyte* start;
|
const GLubyte* start;
|
||||||
const GLubyte* end;
|
const GLubyte* end;
|
||||||
|
|
||||||
start = (const GLubyte*) eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS);
|
start = (const GLubyte*) eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS);
|
||||||
if (0 == start) return GL_FALSE;
|
if (0 == start) return GL_FALSE;
|
||||||
end = start + _glewStrLen(start);
|
end = start + _glewStrLen(start);
|
||||||
return _glewSearchExtension(name, start, end);
|
return _glewSearchExtension(name, start, end);
|
||||||
|
@ -71,14 +71,22 @@ GLboolean GLEWAPIENTRY glewGetExtension (const char* name)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGPROC) (GLenum name);
|
||||||
|
typedef void (GLAPIENTRY * PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
|
||||||
|
|
||||||
static GLenum GLEWAPIENTRY glewContextInit ()
|
static GLenum GLEWAPIENTRY glewContextInit ()
|
||||||
{
|
{
|
||||||
|
PFNGLGETSTRINGPROC getString;
|
||||||
const GLubyte* s;
|
const GLubyte* s;
|
||||||
GLuint dot;
|
GLuint dot;
|
||||||
GLint major, minor;
|
GLint major, minor;
|
||||||
|
|
||||||
/* query opengl version */
|
/* query opengl version */
|
||||||
s = glGetString(GL_VERSION);
|
getString = (PFNGLGETSTRINGPROC) glewGetProcAddress((const GLubyte*)"glGetString");
|
||||||
|
if (!getString)
|
||||||
|
return GLEW_ERROR_NO_GL_VERSION;
|
||||||
|
|
||||||
|
s = getString(GL_VERSION);
|
||||||
dot = _glewStrCLen(s, '.');
|
dot = _glewStrCLen(s, '.');
|
||||||
if (dot == 0)
|
if (dot == 0)
|
||||||
return GLEW_ERROR_NO_GL_VERSION;
|
return GLEW_ERROR_NO_GL_VERSION;
|
||||||
@ -123,11 +131,14 @@ static GLenum GLEWAPIENTRY glewContextInit ()
|
|||||||
{
|
{
|
||||||
GLint n = 0;
|
GLint n = 0;
|
||||||
GLint i;
|
GLint i;
|
||||||
|
PFNGLGETINTEGERVPROC getIntegerv;
|
||||||
PFNGLGETSTRINGIPROC getStringi;
|
PFNGLGETSTRINGIPROC getStringi;
|
||||||
const char *ext;
|
const char *ext;
|
||||||
GLboolean *enable;
|
GLboolean *enable;
|
||||||
|
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
getIntegerv = (PFNGLGETINTEGERVPROC) glewGetProcAddress((const GLubyte*)"glGetIntegerv");
|
||||||
|
if (getIntegerv)
|
||||||
|
getIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||||
|
|
||||||
/* glGetStringi is OpenGL 3.0 */
|
/* glGetStringi is OpenGL 3.0 */
|
||||||
getStringi = (PFNGLGETSTRINGIPROC) glewGetProcAddress((const GLubyte*)"glGetStringi");
|
getStringi = (PFNGLGETSTRINGIPROC) glewGetProcAddress((const GLubyte*)"glGetStringi");
|
||||||
@ -156,7 +167,7 @@ static GLenum GLEWAPIENTRY glewContextInit ()
|
|||||||
char ext[128];
|
char ext[128];
|
||||||
GLboolean *enable;
|
GLboolean *enable;
|
||||||
|
|
||||||
extensions = (const char *) glGetString(GL_EXTENSIONS);
|
extensions = (const char *) getString(GL_EXTENSIONS);
|
||||||
|
|
||||||
if (extensions)
|
if (extensions)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,11 @@ int main (int argc, char** argv)
|
|||||||
0 /* flags */
|
0 /* flags */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(GLEW_EGL)
|
||||||
|
typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGPROC) (GLenum name);
|
||||||
|
PFNGLGETSTRINGPROC getString;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (glewParseArgs(argc-1, argv+1, ¶ms))
|
if (glewParseArgs(argc-1, argv+1, ¶ms))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: glewinfo "
|
fprintf(stderr, "Usage: glewinfo "
|
||||||
@ -55,6 +60,17 @@ int main (int argc, char** argv)
|
|||||||
glewDestroyContext();
|
glewDestroyContext();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(GLEW_EGL)
|
||||||
|
getString = (PFNGLGETSTRINGPROC) eglGetProcAddress("glGetString");
|
||||||
|
if (!getString)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: eglGetProcAddress failed to fetch glGetString\n");
|
||||||
|
glewDestroyContext();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
if (fopen_s(&f, "glewinfo.txt", "w") != 0)
|
if (fopen_s(&f, "glewinfo.txt", "w") != 0)
|
||||||
@ -78,9 +94,15 @@ int main (int argc, char** argv)
|
|||||||
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
|
||||||
|
#if defined(GLEW_EGL)
|
||||||
|
fprintf(f, "Running on a %s from %s\n",
|
||||||
|
getString(GL_RENDERER), getString(GL_VENDOR));
|
||||||
|
fprintf(f, "OpenGL version %s is supported\n", getString(GL_VERSION));
|
||||||
|
#else
|
||||||
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));
|
||||||
|
#endif
|
||||||
glewInfo();
|
glewInfo();
|
||||||
#if defined(GLEW_OSMESA)
|
#if defined(GLEW_OSMESA)
|
||||||
#elif defined(GLEW_EGL)
|
#elif defined(GLEW_EGL)
|
||||||
|
Loading…
Reference in New Issue
Block a user