mirror of
https://github.com/Perlmint/glew-cmake.git
synced 2024-11-22 22:55:06 +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* end;
|
||||
|
||||
start = (const GLubyte*) eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS);
|
||||
start = (const GLubyte*) eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS);
|
||||
if (0 == start) return GL_FALSE;
|
||||
end = start + _glewStrLen(start);
|
||||
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 ()
|
||||
{
|
||||
PFNGLGETSTRINGPROC getString;
|
||||
const GLubyte* s;
|
||||
GLuint dot;
|
||||
GLint major, minor;
|
||||
|
||||
/* 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, '.');
|
||||
if (dot == 0)
|
||||
return GLEW_ERROR_NO_GL_VERSION;
|
||||
@ -123,11 +131,14 @@ static GLenum GLEWAPIENTRY glewContextInit ()
|
||||
{
|
||||
GLint n = 0;
|
||||
GLint i;
|
||||
PFNGLGETINTEGERVPROC getIntegerv;
|
||||
PFNGLGETSTRINGIPROC getStringi;
|
||||
const char *ext;
|
||||
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 */
|
||||
getStringi = (PFNGLGETSTRINGIPROC) glewGetProcAddress((const GLubyte*)"glGetStringi");
|
||||
@ -156,7 +167,7 @@ static GLenum GLEWAPIENTRY glewContextInit ()
|
||||
char ext[128];
|
||||
GLboolean *enable;
|
||||
|
||||
extensions = (const char *) glGetString(GL_EXTENSIONS);
|
||||
extensions = (const char *) getString(GL_EXTENSIONS);
|
||||
|
||||
if (extensions)
|
||||
{
|
||||
|
@ -23,6 +23,11 @@ int main (int argc, char** argv)
|
||||
0 /* flags */
|
||||
};
|
||||
|
||||
#if defined(GLEW_EGL)
|
||||
typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGPROC) (GLenum name);
|
||||
PFNGLGETSTRINGPROC getString;
|
||||
#endif
|
||||
|
||||
if (glewParseArgs(argc-1, argv+1, ¶ms))
|
||||
{
|
||||
fprintf(stderr, "Usage: glewinfo "
|
||||
@ -55,6 +60,17 @@ int main (int argc, char** argv)
|
||||
glewDestroyContext();
|
||||
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(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
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",
|
||||
params.display == NULL ? getenv("DISPLAY") : params.display, params.visual);
|
||||
#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",
|
||||
glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
||||
fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
|
||||
#endif
|
||||
glewInfo();
|
||||
#if defined(GLEW_OSMESA)
|
||||
#elif defined(GLEW_EGL)
|
||||
|
Loading…
Reference in New Issue
Block a user