From: raster Date: Sat, 21 Nov 2009 10:51:51 +0000 (+0000) Subject: find gl symbols runtime - some gl's support the feature but havent X-Git-Tag: accepted/2.0/20130306.225542~242^2~2172 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=656cb26cb4d5cb372897b7965c196ba62b629655;p=profile%2Fivi%2Fevas.git find gl symbols runtime - some gl's support the feature but havent standardised symbols! (bad gl! bad!) git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@43857 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/modules/engines/gl_common/Makefile.am b/src/modules/engines/gl_common/Makefile.am index 41f78e5..fc4ec02 100644 --- a/src/modules/engines/gl_common/Makefile.am +++ b/src/modules/engines/gl_common/Makefile.am @@ -48,7 +48,7 @@ evas_gl_font.c #evas_gl_polygon.c \ # -libevas_engine_gl_common_la_LIBADD = @EINA_LIBS@ @evas_engine_gl_common_libs@ +libevas_engine_gl_common_la_LIBADD = @EINA_LIBS@ @evas_engine_gl_common_libs@ @dlopen_libs@ endif EXTRA_DIST = \ diff --git a/src/modules/engines/gl_common/evas_gl_common.h b/src/modules/engines/gl_common/evas_gl_common.h index e155ede..d0f0bd4 100644 --- a/src/modules/engines/gl_common/evas_gl_common.h +++ b/src/modules/engines/gl_common/evas_gl_common.h @@ -21,17 +21,18 @@ #ifdef BUILD_ENGINE_GL_QUARTZ # include +# include #else # if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) # if defined(GLES_VARIETY_S3C6410) # include -//// this changed. this was the old style. above the new style -//# include # elif defined(GLES_VARIETY_SGX) # include +# include # endif # else # include +# include # endif #endif @@ -293,6 +294,11 @@ void evas_gl_font_texture_free(Evas_GL_Texture *ft); void evas_gl_font_texture_draw(Evas_GL_Context *gc, void *surface, RGBA_Draw_Context *dc, RGBA_Font_Glyph *fg, int x, int y); +void (*glsym_glGenFramebuffers) (GLsizei a, GLuint *b); +void (*glsym_glBindFramebuffer) (GLenum a, GLuint b); +void (*glsym_glFramebufferTexture2D) (GLenum a, GLenum b, GLenum c, GLuint d, GLint e); +void (*glsym_glDeleteFramebuffers) (GLsizei a, const GLuint *b); + diff --git a/src/modules/engines/gl_common/evas_gl_context.c b/src/modules/engines/gl_common/evas_gl_context.c index ae470c8..aa51cc0 100644 --- a/src/modules/engines/gl_common/evas_gl_context.c +++ b/src/modules/engines/gl_common/evas_gl_context.c @@ -1,5 +1,44 @@ #include "evas_gl_private.h" - + +static int sym_done = 0; + +void (*glsym_glGenFramebuffers) (GLsizei a, GLuint *b) = NULL; +void (*glsym_glBindFramebuffer) (GLenum a, GLuint b) = NULL; +void (*glsym_glFramebufferTexture2D) (GLenum a, GLenum b, GLenum c, GLuint d, GLint e) = NULL; +void (*glsym_glDeleteFramebuffers) (GLsizei a, const GLuint *b) = NULL; + +static void +sym_missing(void) +{ + printf("EVAS ERROR - GL symbols missing!\n"); +} + +static void +gl_symbols(void) +{ + if (sym_done) return; + sym_done = 1; + +#define FINDSYM(dst, sym) if (!dst) dst = dlsym(RTLD_DEFAULT, sym) +#define FALLBAK(dst) if (!dst) dst = (void *)sym_missing; + + FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffers"); + FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffersEXT"); + FALLBAK(glsym_glGenFramebuffers); + + FINDSYM(glsym_glBindFramebuffer, "glBindFramebuffer"); + FINDSYM(glsym_glBindFramebuffer, "glBindFramebufferEXT"); + FALLBAK(glsym_glBindFramebuffer); + + FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2D"); + FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2DEXT"); + FALLBAK(glsym_glFramebufferTexture2D); + + FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffers"); + FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffersEXT"); + FALLBAK(glsym_glDeleteFramebuffers); +} + static void shader_array_flush(Evas_GL_Context *gc); static Evas_GL_Context *_evas_gl_common_context = NULL; @@ -118,6 +157,7 @@ evas_gl_common_context_new(void) { Evas_GL_Context *gc; + gl_symbols(); #if 1 if (_evas_gl_common_context) { @@ -315,9 +355,9 @@ evas_gl_common_context_target_surface_set(Evas_GL_Context *gc, # endif #endif if (gc->shader.surface == gc->def_surface) - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0); else - glBindFramebuffer(GL_FRAMEBUFFER, surface->tex->pt->fb); + glsym_glBindFramebuffer(GL_FRAMEBUFFER, surface->tex->pt->fb); _evas_gl_common_viewport_set(gc); } diff --git a/src/modules/engines/gl_common/evas_gl_private.h b/src/modules/engines/gl_common/evas_gl_private.h index 7fd3af4..a7d6378 100644 --- a/src/modules/engines/gl_common/evas_gl_private.h +++ b/src/modules/engines/gl_common/evas_gl_private.h @@ -2,4 +2,6 @@ #define _EVAS_GL_PRIVATE_H #include "evas_gl_common.h" +#include /* dlopen,dlclose,etc */ + #endif diff --git a/src/modules/engines/gl_common/evas_gl_texture.c b/src/modules/engines/gl_common/evas_gl_texture.c index de27fb3..61a9dbf 100644 --- a/src/modules/engines/gl_common/evas_gl_texture.c +++ b/src/modules/engines/gl_common/evas_gl_texture.c @@ -290,10 +290,12 @@ _pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); _tex_2d(pt->intformat, w, h, pt->format, pt->dataformat); - glGenFramebuffers(1, &(pt->fb)); - glBindFramebuffer(GL_FRAMEBUFFER, pt->fb); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pt->texture, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + + glsym_glGenFramebuffers(1, &(pt->fb)); + glsym_glBindFramebuffer(GL_FRAMEBUFFER, pt->fb); + glsym_glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pt->texture, 0); + glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex); return pt; } @@ -389,7 +391,7 @@ pt_unref(Evas_GL_Texture_Pool *pt) pt->gc->shared->tex.atlas [pt->slot][pt->fslot] = eina_list_remove(pt->gc->shared->tex.atlas[pt->slot][pt->fslot], pt); glDeleteTextures(1, &(pt->texture)); - if (pt->fb) glDeleteFramebuffers(1, &(pt->fb)); + if (pt->fb) glsym_glDeleteFramebuffers(1, &(pt->fb)); free(pt); } diff --git a/src/modules/engines/gl_x11/evas_engine.h b/src/modules/engines/gl_x11/evas_engine.h index 579a063..734c0ab 100644 --- a/src/modules/engines/gl_x11/evas_engine.h +++ b/src/modules/engines/gl_x11/evas_engine.h @@ -24,6 +24,7 @@ # define SUPPORT_X11 1 # include # include +# include # include # include # include @@ -36,6 +37,7 @@ # include # include # include +# include # include # endif #endif