find gl symbols runtime - some gl's support the feature but havent
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 21 Nov 2009 10:51:51 +0000 (10:51 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 21 Nov 2009 10:51:51 +0000 (10:51 +0000)
standardised symbols! (bad gl! bad!)

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@43857 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/modules/engines/gl_common/Makefile.am
src/modules/engines/gl_common/evas_gl_common.h
src/modules/engines/gl_common/evas_gl_context.c
src/modules/engines/gl_common/evas_gl_private.h
src/modules/engines/gl_common/evas_gl_texture.c
src/modules/engines/gl_x11/evas_engine.h

index 41f78e5..fc4ec02 100644 (file)
@@ -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 = \
index e155ede..d0f0bd4 100644 (file)
 
 #ifdef BUILD_ENGINE_GL_QUARTZ
 # include <OpenGL/gl.h>
+# include <OpenGL/glext.h>
 #else
 # if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
 #  if defined(GLES_VARIETY_S3C6410)
 #   include <GLES2/gl2.h>
-//// this changed. this was the old style. above the new style
-//#   include <GLES/gl.h>
 #  elif defined(GLES_VARIETY_SGX)
 #   include <GLES2/gl2.h>
+#   include <GLES2/gl2ext.h>
 #  endif
 # else
 #  include <GL/gl.h>
+#  include <GL/glext.h>
 # 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);
+
 
 
 
index ae470c8..aa51cc0 100644 (file)
@@ -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);
 }
 
index 7fd3af4..a7d6378 100644 (file)
@@ -2,4 +2,6 @@
 #define _EVAS_GL_PRIVATE_H
 #include "evas_gl_common.h"
 
+#include <dlfcn.h>      /* dlopen,dlclose,etc */
+
 #endif
index de27fb3..61a9dbf 100644 (file)
@@ -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);
 }
 
index 579a063..734c0ab 100644 (file)
@@ -24,6 +24,7 @@
 #   define SUPPORT_X11 1
 #   include <EGL/egl.h>
 #   include <GLES2/gl2.h>
+#   include <GLES2/gl2ext.h>
 #   include <X11/Xlib.h>
 #   include <X11/Xatom.h>
 #   include <X11/Xutil.h>
@@ -36,6 +37,7 @@
 #  include <X11/Xutil.h>
 #  include <X11/extensions/Xrender.h>
 #  include <GL/gl.h>
+#  include <GL/glext.h>
 #  include <GL/glx.h>
 # endif
 #endif