mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-24 14:55:07 +00:00
eglewInit takes EGLDisplay parameter, will do eglIntialize internally, for now
This commit is contained in:
parent
710b313d5e
commit
3be106a263
@ -27,6 +27,12 @@
|
|||||||
#include <KHR/khrplatform.h>
|
#include <KHR/khrplatform.h>
|
||||||
#include <EGL/eglplatform.h>
|
#include <EGL/eglplatform.h>
|
||||||
|
|
||||||
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int32_t EGLint;
|
typedef int32_t EGLint;
|
||||||
|
|
||||||
typedef unsigned int EGLBoolean;
|
typedef unsigned int EGLBoolean;
|
||||||
@ -79,8 +85,3 @@ struct EGLClientPixmapHI;
|
|||||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
|
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
|
||||||
|
|
||||||
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname);
|
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
GLEWAPI GLenum GLEWAPIENTRY eglewInit ();
|
GLEWAPI GLenum GLEWAPIENTRY eglewInit (EGLDisplay display);
|
||||||
GLEWAPI GLboolean GLEWAPIENTRY eglewIsSupported (const char *name);
|
GLEWAPI GLboolean GLEWAPIENTRY eglewIsSupported (const char *name);
|
||||||
|
|
||||||
#define EGLEW_GET_VAR(x) (*(const GLboolean*)&x)
|
#define EGLEW_GET_VAR(x) (*(const GLboolean*)&x)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
GLboolean eglewGetExtension (const char* name)
|
GLboolean eglewGetExtension (const char* name)
|
||||||
{
|
{
|
||||||
const GLubyte* start;
|
const GLubyte* start;
|
||||||
const GLubyte* end;
|
const GLubyte* end;
|
||||||
|
|
||||||
@ -11,34 +11,25 @@ GLboolean eglewGetExtension (const char* name)
|
|||||||
return _glewSearchExtension(name, start, end);
|
return _glewSearchExtension(name, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum eglewInit ()
|
GLenum eglewInit (EGLDisplay display)
|
||||||
{
|
{
|
||||||
GLuint dot;
|
EGLint major, minor;
|
||||||
GLint major, minor;
|
|
||||||
const GLubyte* version;
|
|
||||||
const GLubyte* extStart;
|
const GLubyte* extStart;
|
||||||
const GLubyte* extEnd;
|
const GLubyte* extEnd;
|
||||||
PFNEGLGETDISPLAYPROC getDisplay = NULL;
|
PFNEGLINITIALIZEPROC initialize = NULL;
|
||||||
PFNEGLQUERYSTRINGPROC queryString = NULL;
|
PFNEGLQUERYSTRINGPROC queryString = NULL;
|
||||||
|
|
||||||
/* Load necessary entry points */
|
/* Load necessary entry points */
|
||||||
getDisplay = (PFNEGLGETDISPLAYPROC) glewGetProcAddress("eglGetDisplay");
|
initialize = (PFNEGLINITIALIZEPROC) glewGetProcAddress("eglInitialize");
|
||||||
queryString = (PFNEGLQUERYSTRINGPROC) glewGetProcAddress("eglQueryString");
|
queryString = (PFNEGLQUERYSTRINGPROC) glewGetProcAddress("eglQueryString");
|
||||||
if (!getDisplay || !queryString)
|
if (!initialize || !queryString)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* query EGK version */
|
/* query EGK version */
|
||||||
major = 0;
|
if (initialize(display, &major, &minor) != EGL_TRUE)
|
||||||
minor = 0;
|
return 1;
|
||||||
version = (const GLubyte*) queryString(getDisplay(EGL_DEFAULT_DISPLAY), EGL_VERSION);
|
|
||||||
dot = _glewStrCLen(version, '.');
|
|
||||||
if (dot != 0)
|
|
||||||
{
|
|
||||||
major = version[dot-1]-'0';
|
|
||||||
minor = version[dot+1]-'0';
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLEW_VERSION_1_5 = ( major > 1 ) || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;
|
EGLEW_VERSION_1_5 = ( major > 1 ) || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;
|
||||||
EGLEW_VERSION_1_4 = EGLEW_VERSION_1_5 == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;
|
EGLEW_VERSION_1_4 = EGLEW_VERSION_1_5 == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;
|
||||||
EGLEW_VERSION_1_3 = EGLEW_VERSION_1_4 == GL_TRUE || ( major == 1 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
|
EGLEW_VERSION_1_3 = EGLEW_VERSION_1_4 == GL_TRUE || ( major == 1 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
|
||||||
EGLEW_VERSION_1_2 = EGLEW_VERSION_1_3 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
|
EGLEW_VERSION_1_2 = EGLEW_VERSION_1_3 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
|
||||||
@ -46,7 +37,7 @@ GLenum eglewInit ()
|
|||||||
EGLEW_VERSION_1_0 = EGLEW_VERSION_1_1 == GL_TRUE || ( major == 1 && minor >= 0 ) ? GL_TRUE : GL_FALSE;
|
EGLEW_VERSION_1_0 = EGLEW_VERSION_1_1 == GL_TRUE || ( major == 1 && minor >= 0 ) ? GL_TRUE : GL_FALSE;
|
||||||
|
|
||||||
/* query EGL extension string */
|
/* query EGL extension string */
|
||||||
extStart = (const GLubyte*) queryString(getDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS);
|
extStart = (const GLubyte*) queryString(display, EGL_EXTENSIONS);
|
||||||
if (extStart == 0)
|
if (extStart == 0)
|
||||||
extStart = (const GLubyte *)"";
|
extStart = (const GLubyte *)"";
|
||||||
extEnd = extStart + _glewStrLen(extStart);
|
extEnd = extStart + _glewStrLen(extStart);
|
||||||
|
@ -35,10 +35,14 @@ GLboolean glewExperimental = GL_FALSE;
|
|||||||
GLenum GLEWAPIENTRY glewInit (void)
|
GLenum GLEWAPIENTRY glewInit (void)
|
||||||
{
|
{
|
||||||
GLenum r;
|
GLenum r;
|
||||||
|
#if defined(GLEW_EGL)
|
||||||
|
PFNEGLGETCURRENTDISPLAYPROC getCurrentDisplay = NULL;
|
||||||
|
#endif
|
||||||
r = glewContextInit();
|
r = glewContextInit();
|
||||||
if ( r != 0 ) return r;
|
if ( r != 0 ) return r;
|
||||||
#if defined(GLEW_EGL)
|
#if defined(GLEW_EGL)
|
||||||
return eglewInit();
|
getCurrentDisplay = (PFNEGLGETCURRENTDISPLAYPROC) glewGetProcAddress("eglGetCurrentDisplay");
|
||||||
|
return eglewInit(getCurrentDisplay());
|
||||||
#elif defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
|
#elif defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
|
||||||
return r;
|
return r;
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
|
@ -159,47 +159,110 @@ EGLContext ctx;
|
|||||||
|
|
||||||
GLboolean glewCreateContext (struct createParams *params)
|
GLboolean glewCreateContext (struct createParams *params)
|
||||||
{
|
{
|
||||||
|
EGLDeviceEXT devices[1];
|
||||||
|
EGLint numDevices;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
EGLint majorVersion, minorVersion;
|
EGLint majorVersion, minorVersion;
|
||||||
const EGLint attr[] = {
|
static const EGLint configAttribs[] = {
|
||||||
EGL_BUFFER_SIZE, 32,
|
EGL_RED_SIZE, 1,
|
||||||
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_CONFORMANT, EGL_OPENGL_BIT,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||||
EGL_NONE
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||||
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
static const EGLint contextAttribs[] = {
|
||||||
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
static const EGLint pBufferAttribs[] = {
|
||||||
|
EGL_WIDTH, 128,
|
||||||
|
EGL_HEIGHT, 128,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLint numConfig;
|
EGLint numConfig;
|
||||||
|
EGLint error;
|
||||||
|
|
||||||
PFNEGLGETDISPLAYPROC getDisplay = NULL;
|
PFNEGLQUERYDEVICESEXTPROC queryDevices = NULL;
|
||||||
PFNEGLINITIALIZEPROC initialize = NULL;
|
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay = NULL;
|
||||||
PFNEGLBINDAPIPROC bindAPI = NULL;
|
PFNEGLGETERRORPROC getError = NULL;
|
||||||
PFNEGLCHOOSECONFIGPROC chooseConfig = NULL;
|
PFNEGLGETDISPLAYPROC getDisplay = NULL;
|
||||||
PFNEGLCREATEWINDOWSURFACEPROC createWindowSurface = NULL;
|
PFNEGLINITIALIZEPROC initialize = NULL;
|
||||||
PFNEGLCREATECONTEXTPROC createContext = NULL;
|
PFNEGLBINDAPIPROC bindAPI = NULL;
|
||||||
PFNEGLMAKECURRENTPROC makeCurrent = NULL;
|
PFNEGLCHOOSECONFIGPROC chooseConfig = NULL;
|
||||||
|
PFNEGLCREATEWINDOWSURFACEPROC createWindowSurface = NULL;
|
||||||
|
PFNEGLCREATECONTEXTPROC createContext = NULL;
|
||||||
|
PFNEGLMAKECURRENTPROC makeCurrent = NULL;
|
||||||
|
PFNEGLCREATEPBUFFERSURFACEPROC createPbufferSurface = NULL;
|
||||||
|
|
||||||
/* Load necessary entry points */
|
/* Load necessary entry points */
|
||||||
getDisplay = (PFNEGLGETDISPLAYPROC) eglGetProcAddress("eglGetDisplay");
|
queryDevices = (PFNEGLQUERYDEVICESEXTPROC) eglGetProcAddress("eglQueryDevicesEXT");
|
||||||
initialize = (PFNEGLINITIALIZEPROC) eglGetProcAddress("eglInitialize");
|
getPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC) eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
bindAPI = (PFNEGLBINDAPIPROC) eglGetProcAddress("eglBindAPI");
|
getError = (PFNEGLGETERRORPROC) eglGetProcAddress("eglGetError");
|
||||||
chooseConfig = (PFNEGLCHOOSECONFIGPROC) eglGetProcAddress("eglChooseConfig");
|
getDisplay = (PFNEGLGETDISPLAYPROC) eglGetProcAddress("eglGetDisplay");
|
||||||
createWindowSurface = (PFNEGLCREATEWINDOWSURFACEPROC) eglGetProcAddress("eglCreateWindowSurface");
|
initialize = (PFNEGLINITIALIZEPROC) eglGetProcAddress("eglInitialize");
|
||||||
createContext = (PFNEGLCREATECONTEXTPROC) eglGetProcAddress("eglCreateContext");
|
bindAPI = (PFNEGLBINDAPIPROC) eglGetProcAddress("eglBindAPI");
|
||||||
makeCurrent = (PFNEGLMAKECURRENTPROC) eglGetProcAddress("eglMakeCurrent");
|
chooseConfig = (PFNEGLCHOOSECONFIGPROC) eglGetProcAddress("eglChooseConfig");
|
||||||
if (!getDisplay || !initialize || !bindAPI || !chooseConfig || !createWindowSurface || !createContext || !makeCurrent)
|
createWindowSurface = (PFNEGLCREATEWINDOWSURFACEPROC) eglGetProcAddress("eglCreateWindowSurface");
|
||||||
|
createPbufferSurface = (PFNEGLCREATEPBUFFERSURFACEPROC) eglGetProcAddress("eglCreatePbufferSurface");
|
||||||
|
createContext = (PFNEGLCREATECONTEXTPROC) eglGetProcAddress("eglCreateContext");
|
||||||
|
makeCurrent = (PFNEGLMAKECURRENTPROC) eglGetProcAddress("eglMakeCurrent");
|
||||||
|
if (!getError || !getDisplay || !initialize || !bindAPI || !chooseConfig || !createWindowSurface || !createContext || !makeCurrent)
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
display = getDisplay((EGLNativeDisplayType) 0);
|
display = EGL_NO_DISPLAY;
|
||||||
if (!initialize(display, &majorVersion, &minorVersion))
|
if (queryDevices && getPlatformDisplay)
|
||||||
return GL_TRUE;
|
{
|
||||||
bindAPI(EGL_OPENGL_API);
|
queryDevices(1, devices, &numDevices);
|
||||||
if (!chooseConfig(display, attr, &config, 1, &numConfig) || (numConfig != 1))
|
if (numDevices==1)
|
||||||
return GL_TRUE;
|
{
|
||||||
surface = createWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL);
|
display = getPlatformDisplay(EGL_PLATFORM_DEVICE_EXT, devices[0], 0);
|
||||||
ctx = createContext(display, config, NULL, NULL);
|
}
|
||||||
if (NULL == ctx) return GL_TRUE;
|
}
|
||||||
makeCurrent(display, surface, surface, ctx);
|
if (display==EGL_NO_DISPLAY)
|
||||||
|
{
|
||||||
|
display = getDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
}
|
||||||
|
if (display == EGL_NO_DISPLAY)
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
eglewInit(display);
|
||||||
|
|
||||||
|
if (bindAPI(EGL_OPENGL_API) != EGL_TRUE)
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
if (chooseConfig(display, configAttribs, &config, 1, &numConfig) != EGL_TRUE || (numConfig != 1))
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
ctx = createContext(display, config, EGL_NO_CONTEXT, contextAttribs);
|
||||||
|
if (NULL == ctx)
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
surface = EGL_NO_SURFACE;
|
||||||
|
/* Create a p-buffer surface if possible */
|
||||||
|
if (createPbufferSurface)
|
||||||
|
{
|
||||||
|
surface = createPbufferSurface(display, config, pBufferAttribs);
|
||||||
|
}
|
||||||
|
/* Create a generic surface without a native window, if necessary */
|
||||||
|
if (surface==EGL_NO_SURFACE)
|
||||||
|
{
|
||||||
|
surface = createWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL);
|
||||||
|
}
|
||||||
|
if (surface == EGL_NO_SURFACE)
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
if (makeCurrent(display, surface, surface, ctx) != EGL_TRUE)
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
error = getError();
|
||||||
|
if (error!=EGL_SUCCESS)
|
||||||
|
{
|
||||||
|
printf("eglGetError: %d\n", error);
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user