//-------------------------------------------------------------//
static void
-_normal_gl_api_get(Evas_GL_API *funcs)
+_normal_gles2_api_get(Evas_GL_API *funcs)
{
funcs->version = EVAS_GL_API_VERSION;
ORD(glReleaseShaderCompiler);
#undef ORD
-
- evgl_api_ext_get(funcs);
}
static void
static void
-_debug_gl_api_get(Evas_GL_API *funcs)
+_debug_gles2_api_get(Evas_GL_API *funcs)
{
funcs->version = EVAS_GL_API_VERSION;
ORD(glBindFramebuffer);
ORD(glBindRenderbuffer);
#undef ORD
-
- evgl_api_ext_get(funcs);
}
void
-_evgl_api_get(Evas_GL_API *funcs, int debug)
+_evgl_api_gles2_get(Evas_GL_API *funcs, Eina_Bool debug)
{
if (debug)
- _debug_gl_api_get(funcs);
+ _debug_gles2_api_get(funcs);
else
- _normal_gl_api_get(funcs);
+ _normal_gles2_api_get(funcs);
if (evgl_engine->direct_scissor_off)
- _direct_scissor_off_api_get(funcs);
+ _direct_scissor_off_api_get(funcs);
}
static void
ORD(glReleaseShaderCompiler);
#undef ORD
-
- evgl_api_gles3_ext_get(funcs);
}
static void
ORD(glVertexAttribIPointer);
ORD(glWaitSync);
#undef ORD
-
- evgl_api_gles3_ext_get(funcs);
}
static Eina_Bool
-_evgl_api_init(void)
+_evgl_gles3_api_init(void)
{
static Eina_Bool _initialized = EINA_FALSE;
if (_initialized) return EINA_TRUE;
{
return EINA_FALSE;
}
-/* TODO
- if (!_evgl_api_gles3_ext_init())
- WRN("Could not initialize OpenGL ES 1 extensions yet.");
-*/
+
_initialized = EINA_TRUE;
return EINA_TRUE;
}
-Eina_Bool
+void
_evgl_api_gles3_get(Evas_GL_API *funcs, Eina_Bool debug)
{
- if(!_evgl_api_init())
- return EINA_FALSE;
+ if (!_evgl_gles3_api_init())
+ return;
if (debug)
_debug_gles3_api_get(funcs);
if (evgl_engine->direct_scissor_off)
_direct_scissor_off_api_get(funcs);
- return EINA_TRUE;
+ return;
}
Evas_GL_API *
// 5: GLESv3 and GLESv2 initialized,
// 7: GLESv3 + GLESv2 + GLESv1 all initialized.
static int _evgl_api_ext_status = 0;
+#define EVASGL_API_GLES2_EXT_INITIALIZED 0x1
+#define EVASGL_API_GLES1_EXT_INITIALIZED 0x2
+#define EVASGL_API_GLES3_EXT_INITIALIZED 0x4
+
Eina_Bool
-evgl_api_ext_init(void *getproc, const char *glueexts)
+_evgl_api_gles2_ext_init(void *getproc, const char *glueexts)
{
const char *glexts;
fp_getproc gp = (fp_getproc)getproc;
eina_strbuf_free(sb);
eina_strbuf_free(sboff);
- _evgl_api_ext_status = 1;
+ _evgl_api_ext_status |= EVASGL_API_GLES2_EXT_INITIALIZED;
return EINA_TRUE;
}
void
-evgl_api_ext_get(Evas_GL_API *gl_funcs)
+evgl_api_gles2_ext_get(Evas_GL_API *gl_funcs, void *getproc, const char *glueexts)
{
- if (_evgl_api_ext_status < 1)
+ if (!(_evgl_api_ext_status & EVASGL_API_GLES2_EXT_INITIALIZED))
{
- ERR("EVGL extension is not yet initialized.");
- return;
+ DBG("Initializing GLESv2 extensions...");
+ if (!_evgl_api_gles2_ext_init(getproc, glueexts))
+ {
+ ERR("GLESv2 extensions initialization failed");
+ return;
+ }
}
-
#define ORD(f) EVAS_API_OVERRIDE(f, gl_funcs, gl_ext_sym_)
/////////////////////////////////////////////////////////////////////////////////////////////////////
}
Eina_Bool
-_evgl_api_gles1_ext_init(void)
+_evgl_api_gles1_ext_init(void *getproc, const char *glueexts)
{
- // Return if GLESv1 ext is already intiialised
- if (_evgl_api_ext_status & 0x2)
- return EINA_TRUE;
-
-#ifdef GL_GLES
+ const char *glexts;
+ fp_getproc gp = (fp_getproc)getproc;
int _curext_supported = 0;
Evas_GL_API *gles1_funcs;
- const char *gles1_exts, *eglexts;
+ Eina_Strbuf *sb = eina_strbuf_new();
+
+#ifdef GL_GLES
EVGL_Resource *rsc;
EGLint context_version;
EGLDisplay dpy = EGLDISPLAY_GET();
- Eina_Strbuf *sb = eina_strbuf_new();
/* glGetString returns the information for the currently bound context
- * So, update gles1_exts only if GLES1 context is currently bound.
+ * So, update glexts only if GLES1 context is currently bound.
* Check here if GLESv1 is current
*/
if (!(rsc=_evgl_tls_resource_get()))
if ((dpy == EGL_NO_DISPLAY) || !rsc->current_ctx)
{
- DBG("Unable to initialize GLES1 extensions. Engine not initialised");
+ DBG("Unable to initialize GLES1 extensions. Engine not initialized");
return EINA_FALSE;
}
DBG("GLESv1 context not bound");
return EINA_FALSE;
}
+#endif
gles1_funcs = _evgl_api_gles1_internal_get();
if (!gles1_funcs || !gles1_funcs->glGetString)
return EINA_FALSE;
}
- gles1_exts = (const char *) gles1_funcs->glGetString(GL_EXTENSIONS);
- if (!gles1_exts)
+ glexts = (const char *) gles1_funcs->glGetString(GL_EXTENSIONS);
+ if (!glexts)
{
ERR("GLESv1:glGetString(GL_EXTENSIONS) returned NULL!");
return EINA_FALSE;
}
- eglexts = eglQueryString(dpy, EGL_EXTENSIONS);
- if (!eglexts)
- {
- ERR("eglQueryString(EGL_EXTENSIONS) returned NULL!");
- eglexts = "";
- }
-
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Scanning supported extensions, sets the variables
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Preparing all the magic macros
#define GETPROCADDR(sym) \
- ((__typeof__((*drvfunc))) (eglGetProcAddress(sym)))
+ (((!(*drvfunc)) && (gp)) ? (__typeof__((*drvfunc)))gp(sym) : (__typeof__((*drvfunc)))dlsym(RTLD_DEFAULT, sym))
#define _EVASGL_EXT_BEGIN(name) \
{ \
}
#define _EVASGL_EXT_CHECK_SUPPORT(name) \
- ((strstr(gles1_exts, name) != NULL) || (strstr(eglexts, name) != NULL))
+ ((strstr(glexts, name) != NULL) || (strstr(glueexts, name) != NULL))
#define _EVASGL_EXT_DISCARD_SUPPORT() \
*ext_support = 0;
DBG("GLES1: List of supported extensions:\n%s", _gles1_ext_string);
// GLESv1 version has been initialized!
- _evgl_api_ext_status |= 0x2;
+ _evgl_api_ext_status |= EVASGL_API_GLES1_EXT_INITIALIZED;
return EINA_TRUE;
-#else
- ERR("GLESv1 support is not implemented for GLX");
- return EINA_FALSE;
-#endif
}
void
-evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs)
+evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs, void *getproc, const char *glueexts)
{
- if (_evgl_api_ext_status < 1)
- {
- ERR("EVGL extension is not yet initialized.");
- return;
- }
-
- if (!(_evgl_api_ext_status & 0x2))
+ if (!(_evgl_api_ext_status & EVASGL_API_GLES1_EXT_INITIALIZED))
{
DBG("Initializing GLESv1 extensions...");
- if (!_evgl_api_gles1_ext_init())
+ if (!_evgl_api_gles1_ext_init(getproc, glueexts))
{
ERR("GLESv1 extensions initialization failed");
return;
}
Eina_Bool
-_evgl_api_gles3_ext_init(void)
+_evgl_api_gles3_ext_init(void *getproc, const char *glueexts)
{
- if (_evgl_api_ext_status & 0x4)
- return EINA_TRUE;
-
-#ifdef GL_GLES
- Eina_Strbuf *sb = eina_strbuf_new();
+ const char *glexts;
+ fp_getproc gp = (fp_getproc)getproc;
int _curext_supported = 0;
Evas_GL_API *gles3_funcs;
- const char *gles3_exts;
+ Eina_Strbuf *sb = eina_strbuf_new();
+
+#ifdef GL_GLES
EVGL_Resource *rsc;
EGLint context_version;
EGLDisplay dpy = EGLDISPLAY_GET();
if ((dpy == EGL_NO_DISPLAY) || !rsc->current_ctx)
{
- DBG("Unable to initialize GLES3 extensions. Engine not initialised");
+ DBG("Unable to initialize GLES3 extensions. Engine not initialized");
return EINA_FALSE;
}
DBG("GLESv3 context not bound");
return EINA_FALSE;
}
+#endif
gles3_funcs = _evgl_api_gles3_internal_get();
if (!gles3_funcs || !gles3_funcs->glGetString)
return EINA_FALSE;
}
- gles3_exts = (const char *) gles3_funcs->glGetString(GL_EXTENSIONS);
- if (!gles3_exts)
+ glexts = (const char *) gles3_funcs->glGetString(GL_EXTENSIONS);
+ if (!glexts)
{
ERR("GLESv3:glGetString(GL_EXTENSIONS) returned NULL!");
return EINA_FALSE;
// Preparing all the magic macros
#define GETPROCADDR(sym) \
- ((__typeof__((*drvfunc))) (eglGetProcAddress(sym)))
+ (((!(*drvfunc)) && (gp)) ? (__typeof__((*drvfunc)))gp(sym) : (__typeof__((*drvfunc)))dlsym(RTLD_DEFAULT, sym))
#define _EVASGL_EXT_BEGIN(name) \
{ \
}
#define _EVASGL_EXT_CHECK_SUPPORT(name) \
- (strstr(gles3_exts, name) != NULL)
+ ((strstr(glexts, name) != NULL) || (strstr(glueexts, name) != NULL))
#define _EVASGL_EXT_DISCARD_SUPPORT() \
*ext_support = 0;
DBG("GLES3: List of supported extensions:\n%s", _gles3_ext_string);
// GLESv3 version has been initialized!
- _evgl_api_ext_status |= 0x4;
+ _evgl_api_ext_status |= EVASGL_API_GLES3_EXT_INITIALIZED;
return EINA_TRUE;
-
-#else
- ERR("GLES3 is not supported with GLX (yet)!");
- return EINA_FALSE;
-#endif
}
void
-evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs)
+evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs, void *getproc, const char *glueexts)
{
- if (_evgl_api_ext_status < 1)
- {
- ERR("EVGL extension is not yet initialized.");
- return;
- }
-
- if (!(_evgl_api_ext_status & 0x4))
+ if (!(_evgl_api_ext_status & EVASGL_API_GLES3_EXT_INITIALIZED))
{
DBG("Initializing GLESv3 extensions...");
- if (!_evgl_api_gles3_ext_init())
+ if (!_evgl_api_gles3_ext_init(getproc, glueexts))
{
ERR("GLESv3 extensions initialization failed");
return;
#define EXTENSION_SUPPORT_GLES1(name) (_gles1_ext_support_##name == 1)
#define EXTENSION_SUPPORT_GLES3(name) (_gles3_ext_support_##name == 1)
-extern Eina_Bool evgl_api_ext_init(void *getproc, const char *glueexts);
-extern void evgl_api_ext_get(Evas_GL_API *gl_funcs);
-extern void evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs);
-extern void evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs);
+extern void evgl_api_gles2_ext_get(Evas_GL_API *gl_funcs, void *getproc, const char *glueexts);
+extern void evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs, void *getproc, const char *glueexts);
+extern void evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs, void *getproc, const char *glueexts);
extern const char *evgl_api_ext_string_get(Eina_Bool official, int version);
#endif //_EVAS_GL_API_EXT_H
_EVASGL_EXT_BEGIN(framebuffer_object)
_EVASGL_EXT_DRVNAME(GL_OES_framebuffer_object)
+ _EVASGL_EXT_DRVNAME(GL_ARB_framebuffer_object)
_EVASGL_EXT_FUNCTION_BEGIN(GLboolean, glIsRenderbufferOES, (GLuint renderbuffer))
_EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR("glIsRenderbuffer")
}
_evgl_load_gles1_apis(_gles1_handle, &_gles1_api);
- if (!_evgl_api_gles1_ext_init())
- WRN("Could not initialize OpenGL ES 1 extensions yet.");
_initialized = EINA_TRUE;
return EINA_TRUE;
ORD(glVertexPointer);
ORD(glViewport);
#undef ORD
-
- evgl_api_gles1_ext_get(funcs);
}
static void
ORD(glVertexPointer);
ORD(glViewport);
#undef ORD
-
- evgl_api_gles1_ext_get(funcs);
}
void
// Extended struct size based on the 314 functions found in gl31.h
#define EVAS_GL_API_STRUCT_SIZE (sizeof(Evas_GL_API) + 300 * sizeof(void*))
-static Evas_GL_API *gl_funcs = NULL;
static Evas_GL_API *gles1_funcs = NULL;
+static Evas_GL_API *gles2_funcs = NULL;
static Evas_GL_API *gles3_funcs = NULL;
EVGL_Engine *evgl_engine = NULL;
evgl_engine->safe_extensions = eina_hash_string_small_new(NULL);
- // Initialize Extensions
- if (efunc->proc_address_get && efunc->ext_string_get)
- {
- if (!evgl_api_ext_init(efunc->proc_address_get, efunc->ext_string_get(eng_data)))
- {
- ERR("Extensions failed to load. This shouldn't happen, Evas GL load fails.");
- goto error;
- }
- }
- else
- ERR("Proc address get function not available. Extensions not initialized.");
-
- if (efunc->ext_string_get)
- DBG("GLUE Extension String: %s", efunc->ext_string_get(eng_data));
- DBG("GL Extension String: %s", glGetString(GL_EXTENSIONS));
-
// Surface Caps
if (!_surface_cap_init(eng_data))
{
// Maint Thread ID (get tid not available in eina thread yet)
evgl_engine->main_tid = 0;
- // Clear Function Pointers
- if (!gl_funcs) gl_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
-
return evgl_engine;
error:
// to use fbo & egl image passing to evas
if (!ctx->extension_checked)
{
- if (!evgl_api_get(ctx->version))
+ if (!evgl_api_get(eng_data, ctx->version))
{
ERR("Unable to get the list of GL APIs for version %d", ctx->version);
evas_gl_common_error_set(eng_data, EVAS_GL_NOT_INITIALIZED);
else
{
Eina_Bool use_extension = EINA_FALSE;
+#ifdef GL_GLES
if ((ctx->version == EVAS_GL_GLES_1_X) && (gles1_funcs))
use_extension = EINA_TRUE;
+#endif
// Normal FBO Rendering
// Create FBO if it hasn't been created
}
Evas_GL_API *
-evgl_api_get(Evas_GL_Context_Version version)
+evgl_api_get(void *eng_data, Evas_GL_Context_Version version)
{
if (version == EVAS_GL_GLES_2_X)
{
- _evgl_api_get(gl_funcs, evgl_engine->api_debug_mode);
- return gl_funcs;
+ if (!gles2_funcs) gles2_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
+
+ _evgl_api_gles2_get(gles2_funcs, evgl_engine->api_debug_mode);
+ evgl_api_gles2_ext_get(gles2_funcs, evgl_engine->funcs->proc_address_get, evgl_engine->funcs->ext_string_get(eng_data));
+
+ return gles2_funcs;
}
else if (version == EVAS_GL_GLES_1_X)
{
if (!gles1_funcs) gles1_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
_evgl_api_gles1_get(gles1_funcs, evgl_engine->api_debug_mode);
+ evgl_api_gles1_ext_get(gles1_funcs, evgl_engine->funcs->proc_address_get, evgl_engine->funcs->ext_string_get(eng_data));
+
return gles1_funcs;
}
else if (version == EVAS_GL_GLES_3_X)
{
- // Allocate gles3 funcs here, as this is called only if GLES_3 is supported
if (!gles3_funcs) gles3_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
- if (!_evgl_api_gles3_get(gles3_funcs, evgl_engine->api_debug_mode))
- {
- free(gles3_funcs);
- gles3_funcs = NULL;
- }
+ _evgl_api_gles3_get(gles3_funcs, evgl_engine->api_debug_mode);
+ evgl_api_gles3_ext_get(gles3_funcs, evgl_engine->funcs->proc_address_get, evgl_engine->funcs->ext_string_get(eng_data));
+
return gles3_funcs;
}
else return NULL;
const char *evgl_string_query(int name);
int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns);
-Evas_GL_API *evgl_api_get(Evas_GL_Context_Version version);
+Evas_GL_API *evgl_api_get(void *eng_data, Evas_GL_Context_Version version);
void evgl_safe_extension_add(const char *name, void *funcptr);
Eina_Bool evgl_safe_extension_get(const char *name, void **pfuncptr);
extern EVGL_Engine *evgl_engine;
// Internally used functions
-extern void _evgl_api_get(Evas_GL_API *api, int debug);
+extern void _evgl_api_gles2_get(Evas_GL_API *api, Eina_Bool debug);
extern void _evgl_api_gles1_get(Evas_GL_API *api, Eina_Bool debug);
-extern Eina_Bool _evgl_api_gles3_get(Evas_GL_API *api, Eina_Bool debug);
+extern void _evgl_api_gles3_get(Evas_GL_API *api, Eina_Bool debug);
extern EVGL_Resource *_evgl_tls_resource_get(void);
extern EVGL_Resource *_evgl_tls_resource_create(void *data);
extern void _evgl_tls_resource_destroy(void *data);
extern int _evgl_not_in_pixel_get(void);
extern int _evgl_direct_enabled(void);
extern EVGLNative_Context _evgl_native_context_get(Evas_GL_Context *ctx);
-Eina_Bool _evgl_api_gles1_ext_init(void);
+Eina_Bool _evgl_api_gles2_ext_init(void *getproc, const char *glueexts);
+Eina_Bool _evgl_api_gles1_ext_init(void *getproc, const char *glueexts);
+Eina_Bool _evgl_api_gles3_ext_init(void *getproc, const char *glueexts);
Evas_GL_API* _evgl_api_gles1_internal_get(void);
Evas_GL_API* _evgl_api_gles3_internal_get(void);
ERR("Version not supported!");
return NULL;
}
- ret = evgl_api_get(version);
+ ret = evgl_api_get(data, version);
//Disable GLES3 support if symbols not present
if ((!ret) && (version == EVAS_GL_GLES_3_X))
(GLXContext)share_ctx,
1);
}
- else if ((version == EVAS_GL_GLES_1_X) || (version == EVAS_GL_GLES_3_X))
- {
- context = glXCreateContext(eng_get_ob(re)->info->info.display,
- eng_get_ob(re)->visualinfo,
- NULL,
- 1);
- }
else
{
context = glXCreateContext(eng_get_ob(re)->info->info.display,