Applying Fastpath
authorPark SangHee <sh15.park@samsung.com>
Thu, 9 Feb 2012 06:29:56 +0000 (15:29 +0900)
committerPark SangHee <sh15.park@samsung.com>
Thu, 9 Feb 2012 07:15:25 +0000 (16:15 +0900)
12 files changed:
m4/evas_check_engine.m4
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_core.c [new file with mode: 0644]
src/modules/engines/gl_common/evas_gl_core.h [new file with mode: 0644]
src/modules/engines/gl_common/evas_gl_line.c
src/modules/engines/gl_common/evas_gl_shader.c
src/modules/engines/gl_common/evas_gl_texture.c
src/modules/engines/gl_x11/evas_engine.c
src/modules/engines/gl_x11/evas_engine.h
src/modules/engines/gl_x11/evas_x_main.c

index e88022b..67db8fa 100644 (file)
@@ -141,8 +141,8 @@ if test "x${have_dep}" = "xyes" ; then
          x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext -lXrender"
       fi
    evas_engine_[]$1[]_cflags="-I/usr/include ${x_cflags}"
-   evas_engine_[]$1[]_libs="${x_libs} -lGL $gl_pt_lib"
-   evas_engine_gl_common_libs="-lGL $gl_pt_lib"
+   evas_engine_[]$1[]_libs="${x_libs} $gl_pt_lib"
+   evas_engine_gl_common_libs="$gl_pt_lib"
    fi
 else
    if test "x$2" = "xyes" ; then
@@ -171,8 +171,8 @@ else
          PKG_CHECK_MODULES([GL_EET], [eet >= 1.5.0], [have_dep="yes"], [have_dep="no"])
          if test "x${have_dep}" = "xyes" ; then
             evas_engine_[]$1[]_cflags="${x_cflags}"
-            evas_engine_[]$1[]_libs="${x_libs} -lGLESv2 -lEGL -lm $gl_pt_lib"
-            evas_engine_gl_common_libs="-lGLESv2 -lm $gl_pt_lib"
+            evas_engine_[]$1[]_libs="${x_libs} -lm $gl_pt_lib"
+            evas_engine_gl_common_libs="-lm $gl_pt_lib"
             have_dep="yes"
             gl_flavor_gles="no"
             AC_DEFINE(GLES_VARIETY_SGX, 1, [Imagination SGX GLES2 support])
@@ -316,8 +316,8 @@ if test "x${have_dep}" = "xyes" ; then
          x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext -lXrender"
       fi
    evas_engine_[]$1[]_cflags="-I/usr/include ${XCB_GL_CFLAGS} ${x_cflags}"
-   evas_engine_[]$1[]_libs="${XCB_GL_LIBS} ${x_libs} -lGL $gl_pt_lib"
-   evas_engine_gl_common_libs="-lGL $gl_pt_lib"
+   evas_engine_[]$1[]_libs="${XCB_GL_LIBS} ${x_libs} $gl_pt_lib"
+   evas_engine_gl_common_libs="$gl_pt_lib"
    fi
 else
    if test "x$2" = "xyes" ; then
@@ -341,8 +341,8 @@ else
          PKG_CHECK_MODULES([GL_EET], [eet >= 1.5.0], [have_dep="yes"], [have_dep="no"])
          if test "x${have_dep}" = "xyes" ; then
             evas_engine_[]$1[]_cflags="${XCB_GL_CFLAGS} ${x_cflags}"
-            evas_engine_[]$1[]_libs="${XCB_GL_LIBS} ${x_libs} -lGLESv2 -lEGL -lm $gl_pt_lib"
-            evas_engine_gl_common_libs="-lGLESv2 -lm $gl_pt_lib"
+            evas_engine_[]$1[]_libs="${XCB_GL_LIBS} ${x_libs} -lm $gl_pt_lib"
+            evas_engine_gl_common_libs="-lm $gl_pt_lib"
             have_dep="yes"
             gl_flavor_gles="no"
             AC_DEFINE(GLES_VARIETY_SGX, 1, [Imagination SGX GLES2 support])
index 15acc02..6b419df 100644 (file)
@@ -14,6 +14,8 @@ if BUILD_ENGINE_GL_COMMON
 
 noinst_LTLIBRARIES = libevas_engine_gl_common.la
 libevas_engine_gl_common_la_SOURCES  = \
+evas_gl_core.h \
+evas_gl_core.c \
 evas_gl_private.h \
 evas_gl_common.h \
 evas_gl_context.c \
index 051fb3b..bcf69ea 100644 (file)
@@ -12,6 +12,7 @@
 #include <sys/time.h>
 #include <unistd.h>
 #include <Eet.h>
+#include "evas_gl_core.h"
 
 #define GL_GLEXT_PROTOTYPES
 
 # else
 #  if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
 #   if defined(GLES_VARIETY_S3C6410)
-#    include <GLES2/gl2.h>
+//#    include <GLES2/gl2.h>
 #   elif defined(GLES_VARIETY_SGX)
-#    include <GLES2/gl2.h>
-#    include <GLES2/gl2ext.h>
+//#    include <GLES2/gl2.h>
+//#    include <GLES2/gl2ext.h>
 #   endif
 #  else
-#   include <GL/gl.h>
-#   include <GL/glext.h>
+//#   include <GL/gl.h>
+//#   include <GL/glext.h>
 #  endif
 # endif
 #endif
@@ -624,29 +625,13 @@ Filtered_Image   *evas_gl_common_image_filtered_save(Evas_GL_Image *im, Evas_GL_
 void              evas_gl_common_image_filtered_free(Evas_GL_Image *im, Filtered_Image *);
 #endif
 
-extern void (*glsym_glGenFramebuffers)      (GLsizei a, GLuint *b);
-extern void (*glsym_glBindFramebuffer)      (GLenum a, GLuint b);
-extern void (*glsym_glFramebufferTexture2D) (GLenum a, GLenum b, GLenum c, GLuint d, GLint e);
-extern void (*glsym_glDeleteFramebuffers)   (GLsizei a, const GLuint *b);
-extern void (*glsym_glGetProgramBinary)     (GLuint a, GLsizei b, GLsizei *c, GLenum *d, void *e);
-extern void (*glsym_glProgramBinary)        (GLuint a, GLenum b, const void *c, GLint d);
-extern void (*glsym_glProgramParameteri)    (GLuint a, GLuint b, GLint d);
-
-#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-extern void          *(*secsym_eglCreateImage)               (void *a, void *b, GLenum c, void *d, const int *e);
-extern unsigned int   (*secsym_eglDestroyImage)              (void *a, void *b);
-extern void           (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b);
-extern void          *(*secsym_eglMapImageSEC)               (void *a, void *b);
-extern unsigned int   (*secsym_eglUnmapImageSEC)             (void *a, void *b);
-extern unsigned int   (*secsym_eglGetImageAttribSEC)         (void *a, void *b, int c, int *d);
-#endif
 
 //#define GL_ERRORS 1
 
 #ifdef GL_ERRORS
 # define GLERR(fn, fl, ln, op) \
    { \
-      int __gl_err = glGetError(); \
+      int __gl_err = glsym_glGetError(); \
       if (__gl_err != GL_NO_ERROR) glerr(__gl_err, fl, fn, ln, op); \
    }
 #else
index 62e72bd..26b9897 100644 (file)
 static int sym_done = 0;
 int _evas_engine_GL_common_log_dom = -1;
 
-typedef void    (*glsym_func_void) ();
-
-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;
-void (*glsym_glGetProgramBinary)     (GLuint a, GLsizei b, GLsizei *c, GLenum *d, void *e) = NULL;
-void (*glsym_glProgramBinary)        (GLuint a, GLenum b, const void *c, GLint d) = NULL;
-void (*glsym_glProgramParameteri)    (GLuint a, GLuint b, GLint d) = NULL;
-
-#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-// just used for finding symbols :)
-typedef void (*_eng_fn) (void);
-
-typedef _eng_fn       (*secsym_func_eng_fn) ();
-typedef unsigned int  (*secsym_func_uint) ();
-typedef void         *(*secsym_func_void_ptr) ();
-
-static _eng_fn  (*secsym_eglGetProcAddress)          (const char *a) = NULL;
-
-void          *(*secsym_eglCreateImage)               (void *a, void *b, GLenum c, void *d, const int *e) = NULL;
-unsigned int   (*secsym_eglDestroyImage)              (void *a, void *b) = NULL;
-void           (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
-void          *(*secsym_eglMapImageSEC)               (void *a, void *b) = NULL;
-unsigned int   (*secsym_eglUnmapImageSEC)             (void *a, void *b) = NULL;
-unsigned int   (*secsym_eglGetImageAttribSEC)         (void *a, void *b, int c, int *d) = NULL;
-#endif
-
 static int dbgflushnum = -1;
 
-static void
-sym_missing(void)
-{
-   ERR("GL symbols missing!");
-}
-
-static void
-gl_symbols(void)
-{
-   if (sym_done) return;
-   sym_done = 1;
-
-   /* FIXME: If using the SDL engine, we should use SDL_GL_GetProcAddress
-    * instead of dlsym
-    * if (!dst) dst = (typ)SDL_GL_GetProcAddress(sym)
-    */
-#define FINDSYM(dst, sym, typ) if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
-#define FALLBAK(dst, typ) if (!dst) dst = (typ)sym_missing;
-
-   FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffers", glsym_func_void);
-   FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffersEXT", glsym_func_void);
-   FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffersARB", glsym_func_void);
-   FALLBAK(glsym_glGenFramebuffers, glsym_func_void);
-
-   FINDSYM(glsym_glBindFramebuffer, "glBindFramebuffer", glsym_func_void);
-   FINDSYM(glsym_glBindFramebuffer, "glBindFramebufferEXT", glsym_func_void);
-   FINDSYM(glsym_glBindFramebuffer, "glBindFramebufferARB", glsym_func_void);
-   FALLBAK(glsym_glBindFramebuffer, glsym_func_void);
-
-   FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2D", glsym_func_void);
-   FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2DEXT", glsym_func_void);
-   FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2DARB", glsym_func_void);
-   FALLBAK(glsym_glFramebufferTexture2D, glsym_func_void);
-
-   FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffers", glsym_func_void);
-   FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffersEXT", glsym_func_void);
-   FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffersARB", glsym_func_void);
-   FALLBAK(glsym_glDeleteFramebuffers, glsym_func_void);
-
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinary", glsym_func_void);
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryEXT", glsym_func_void);
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryARB", glsym_func_void);
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryOES", glsym_func_void);
-
-   FINDSYM(glsym_glProgramBinary, "glProgramBinary", glsym_func_void);
-   FINDSYM(glsym_glProgramBinary, "glProgramBinaryEXT", glsym_func_void);
-   FINDSYM(glsym_glProgramBinary, "glProgramBinaryARB", glsym_func_void);
-
-   FINDSYM(glsym_glProgramParameteri, "glProgramParameteri", glsym_func_void);
-   FINDSYM(glsym_glProgramParameteri, "glProgramParameteriEXT", glsym_func_void);
-   FINDSYM(glsym_glProgramParameteri, "glProgramParameteriARB", glsym_func_void);
-
-#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-#undef FINDSYM
-#define FINDSYM(dst, sym, typ) \
-   if ((!dst) && (secsym_eglGetProcAddress)) dst = (typ)secsym_eglGetProcAddress(sym); \
-   if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
-// yes - gl core looking for egl stuff. i know it's odd. a reverse-layer thing
-// but it will work as the egl/glx layer calls gl core common stuff and thus
-// these symbols will work. making the glx/egl + x11 layer do this kind-of is
-// wrong as this is not x11 (output) layer specific like the native surface
-// stuff. this is generic zero-copy textures for gl
-
-   FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddress", secsym_func_eng_fn);
-   FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressEXT", secsym_func_eng_fn);
-   FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressARB", secsym_func_eng_fn);
-   FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressKHR", secsym_func_eng_fn);
-
-   FINDSYM(secsym_eglCreateImage, "eglCreateImage", secsym_func_void_ptr);
-   FINDSYM(secsym_eglCreateImage, "eglCreateImageEXT", secsym_func_void_ptr);
-   FINDSYM(secsym_eglCreateImage, "eglCreateImageARB", secsym_func_void_ptr);
-   FINDSYM(secsym_eglCreateImage, "eglCreateImageKHR", secsym_func_void_ptr);
-
-   FINDSYM(secsym_eglDestroyImage, "eglDestroyImage", secsym_func_uint);
-   FINDSYM(secsym_eglDestroyImage, "eglDestroyImageEXT", secsym_func_uint);
-   FINDSYM(secsym_eglDestroyImage, "eglDestroyImageARB", secsym_func_uint);
-   FINDSYM(secsym_eglDestroyImage, "eglDestroyImageKHR", secsym_func_uint);
-
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinary", glsym_func_void);
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryEXT", glsym_func_void);
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryARB", glsym_func_void);
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryOES", glsym_func_void);
-   FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryKHR", glsym_func_void);
-
-   FINDSYM(glsym_glProgramBinary, "glProgramBinary", glsym_func_void);
-   FINDSYM(glsym_glProgramBinary, "glProgramBinaryEXT", glsym_func_void);
-   FINDSYM(glsym_glProgramBinary, "glProgramBinaryARB", glsym_func_void);
-   FINDSYM(glsym_glProgramBinary, "glProgramBinaryOES", glsym_func_void);
-   FINDSYM(glsym_glProgramBinary, "glProgramBinaryKHR", glsym_func_void);
-
-   FINDSYM(glsym_glProgramParameteri, "glProgramParameteri", glsym_func_void);
-   FINDSYM(glsym_glProgramParameteri, "glProgramParameteriEXT", glsym_func_void);
-   FINDSYM(glsym_glProgramParameteri, "glProgramParameteriARB", glsym_func_void);
-   FINDSYM(glsym_glProgramParameteri, "glProgramParameteriOES", glsym_func_void);
-   FINDSYM(glsym_glProgramParameteri, "glProgramParameteriKHR", glsym_func_void);
-
-   FINDSYM(secsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", glsym_func_void);
-
-   FINDSYM(secsym_eglMapImageSEC, "eglMapImageSEC", secsym_func_void_ptr);
-
-   FINDSYM(secsym_eglUnmapImageSEC, "eglUnmapImageSEC", secsym_func_uint);
-
-   FINDSYM(secsym_eglGetImageAttribSEC, "eglGetImageAttribSEC", secsym_func_uint);
-#endif
-}
-
 static void shader_array_flush(Evas_Engine_GL_Context *gc);
 
 static Evas_Engine_GL_Context *_evas_gl_common_context = NULL;
@@ -249,11 +115,11 @@ _evas_gl_common_version_check()
    int minor;
 
   /*
-   * glGetString returns a string describing the current GL connection.
+   * glsym_glGetString returns a string describing the current GL connection.
    * GL_VERSION is used to get the version of the connection
    */
 
-   version = (char *)glGetString(GL_VERSION);
+   version = (char *)glsym_glGetString(GL_VERSION);
 
   /*
    * OpengL ES
@@ -300,7 +166,7 @@ _evas_gl_common_version_check()
    * version number and the vendor-specific information.
    */
 
-   /* glGetString() returns a static string, and we are going to */
+   /* glsym_glGetString() returns a static string, and we are going to */
    /* modify it, so we get a copy first */
    version = strdup(version);
    if (!version)
@@ -371,9 +237,9 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
    if (foc == 0)
      {
         if ((rot == 0) || (rot == 180))
-           glViewport(0, 0, w, h);
+           glsym_glViewport(0, 0, w, h);
         else
-           glViewport(0, 0, h, w);
+           glsym_glViewport(0, 0, h, w);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
         // std matrix
         if (m == 1)
@@ -436,9 +302,9 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
         if (m == -1) ay = vy * 2;
 
         if ((rot == 0) || (rot == 180))
-           glViewport(-2 * vx, -2 * vy, vw, vh);
+           glsym_glViewport(-2 * vx, -2 * vy, vw, vh);
         else
-           glViewport(-2 * vy, -2 * vx, vh, vw);
+           glsym_glViewport(-2 * vy, -2 * vx, vh, vw);
         if (m == 1)
            matrix_ortho(proj, 0, vw, 0, vh,
                         -1000000.0, 1000000.0,
@@ -455,15 +321,15 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
 
    for (i = 0; i < SHADER_LAST; ++i)
      {
-        glUseProgram(gc->shared->shader[i].prog);
+        glsym_glUseProgram(gc->shared->shader[i].prog);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader[i].prog, "mvp"), 1, GL_FALSE, proj);
+        glsym_glUniformMatrix4fv(glsym_glGetUniformLocation(gc->shared->shader[i].prog, "mvp"), 1, GL_FALSE, proj);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
      }
 
    if (gc->state.current.cur_prog == PRG_INVALID)
-      glUseProgram(gc->shared->shader[0].prog);
-   else glUseProgram(gc->state.current.cur_prog);
+      glsym_glUseProgram(gc->shared->shader[0].prog);
+   else glsym_glUseProgram(gc->state.current.cur_prog);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 }
 
@@ -486,8 +352,6 @@ evas_gl_common_context_new(void)
    gc = calloc(1, sizeof(Evas_Engine_GL_Context));
    if (!gc) return NULL;
 
-   gl_symbols();
-
    gc->references = 1;
 
    _evas_gl_common_context = gc;
@@ -500,7 +364,7 @@ evas_gl_common_context_new(void)
         const GLubyte *ext;
 
         shared = calloc(1, sizeof(Evas_GL_Shared));
-        ext = glGetString(GL_EXTENSIONS);
+        ext = glsym_glGetString(GL_EXTENSIONS);
         if (ext)
           {
              if (getenv("EVAS_GL_INFO"))
@@ -518,8 +382,8 @@ evas_gl_common_context_new(void)
                shared->info.bin_program = 1;
 #ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
              if ((strstr((char *)ext, "GL_EXT_texture_filter_anisotropic")))
-               glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
-                           &(shared->info.anisotropic));
+                glsym_glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
+                                  &(shared->info.anisotropic));
 #endif
 #ifdef GL_BGRA
              if ((strstr((char *)ext, "GL_EXT_bgra")) ||
@@ -536,24 +400,24 @@ evas_gl_common_context_new(void)
                {
                   // test for all needed symbols - be "conservative" and
                   // need all of it
-                  if ((secsym_eglCreateImage) &&
-                      (secsym_eglDestroyImage) &&
-                      (secsym_glEGLImageTargetTexture2DOES) &&
-                      (secsym_eglMapImageSEC) &&
-                      (secsym_eglUnmapImageSEC) &&
-                      (secsym_eglGetImageAttribSEC))
+                  if ((glsym_eglCreateImage) &&
+                      (glsym_eglDestroyImage) &&
+                      (glsym_glEGLImageTargetTexture2DOES) &&
+                      (glsym_eglMapImageSEC) &&
+                      (glsym_eglUnmapImageSEC) &&
+                      (glsym_eglGetImageAttribSEC))
                      shared->info.sec_image_map = 1;
                }
 #endif
           }
-        glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,
-                      &(shared->info.max_texture_units));
-        glGetIntegerv(GL_MAX_TEXTURE_SIZE,
-                      &(shared->info.max_texture_size));
+        glsym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,
+                            &(shared->info.max_texture_units));
+        glsym_glGetIntegerv(GL_MAX_TEXTURE_SIZE,
+                            &(shared->info.max_texture_size));
         shared->info.max_vertex_elements = 6 * 100000;
 #ifdef GL_MAX_ELEMENTS_VERTICES
-/* only applies to glDrawRangeElements. don't really need to get it.
-        glGetIntegerv(GL_MAX_ELEMENTS_VERTICES,
+/* only applies to glsym_glDrawRangeElements. don't really need to get it.
+        glsym_glGetIntegerv(GL_MAX_ELEMENTS_VERTICES,
                       &(shared->info.max_vertex_elements));
  */
 #endif
@@ -573,7 +437,7 @@ evas_gl_common_context_new(void)
         shared->info.tune.atlas.slot_size            = DEF_ATLAS_SLOT;
 
         // per gpu hacks. based on impirical measurement of some known gpu's
-        s = (const char *)glGetString(GL_RENDERER);
+        s = (const char *)glsym_glGetString(GL_RENDERER);
         if (s)
           {
              if      (strstr(s, "PowerVR SGX 540"))
@@ -646,47 +510,47 @@ evas_gl_common_context_new(void)
                    (int)shared->info.tune.atlas.slot_size
                   );
 
-        glDisable(GL_DEPTH_TEST);
+        glsym_glDisable(GL_DEPTH_TEST);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glEnable(GL_DITHER);
+        glsym_glEnable(GL_DITHER);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glDisable(GL_BLEND);
+        glsym_glDisable(GL_BLEND);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+        glsym_glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
         // no dest alpha
-//        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // dest alpha
-//        glBlendFunc(GL_SRC_ALPHA, GL_ONE); // ???
-        glDepthMask(GL_FALSE);
+//        glsym_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // dest alpha
+//        glsym_glBlendFunc(GL_SRC_ALPHA, GL_ONE); // ???
+        glsym_glDepthMask(GL_FALSE);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+        glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+        glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+        glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
         if (shared->info.anisotropic > 0.0)
           {
-             glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0);
+             glsym_glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
           }
 #endif
 
-        glEnableVertexAttribArray(SHAD_VERTEX);
+        glsym_glEnableVertexAttribArray(SHAD_VERTEX);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glEnableVertexAttribArray(SHAD_COLOR);
+        glsym_glEnableVertexAttribArray(SHAD_COLOR);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
        if (!evas_gl_common_shader_program_init(shared)) goto error;
 
 #define SHADER_TEXTURE_ADD(Shared, Shader, Name)                        \
-        glUseProgram(Shared->shader[SHADER_##Shader].prog);             \
+        glsym_glUseProgram(Shared->shader[SHADER_##Shader].prog);             \
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");                    \
-        glUniform1i(glGetUniformLocation(Shared->shader[SHADER_##Shader].prog, #Name), Shared->shader[SHADER_##Shader].tex_count++); \
+        glsym_glUniform1i(glsym_glGetUniformLocation(Shared->shader[SHADER_##Shader].prog, #Name), Shared->shader[SHADER_##Shader].tex_count++); \
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
         SHADER_TEXTURE_ADD(shared, YUV, tex);
@@ -713,8 +577,8 @@ evas_gl_common_context_new(void)
         SHADER_TEXTURE_ADD(shared, IMG_MASK, texm);
 
         if (gc->state.current.cur_prog == PRG_INVALID)
-           glUseProgram(gc->shared->shader[0].prog);
-        else glUseProgram(gc->state.current.cur_prog);
+           glsym_glUseProgram(gc->shared->shader[0].prog);
+        else glsym_glUseProgram(gc->state.current.cur_prog);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
         evas_gl_common_shader_program_init_done();
@@ -723,8 +587,8 @@ evas_gl_common_context_new(void)
         //
         // in code:
         // GLuint texes[8];
-        // GLint loc = glGetUniformLocation(prog, "tex");
-        // glUniform1iv(loc, 8, texes);
+        // GLint loc = glsym_glGetUniformLocation(prog, "tex");
+        // glsym_glUniform1iv(loc, 8, texes);
 
         shared->native_pm_hash  = eina_hash_int32_new(NULL);
         shared->native_tex_hash = eina_hash_int32_new(NULL);
@@ -863,53 +727,53 @@ evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc)
      }
    gc->change.size = 1;
 
-   glDisable(GL_SCISSOR_TEST);
+   glsym_glDisable(GL_SCISSOR_TEST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glScissor(0, 0, 0, 0);
+   glsym_glScissor(0, 0, 0, 0);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-   glDisable(GL_DEPTH_TEST);
+   glsym_glDisable(GL_DEPTH_TEST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glEnable(GL_DITHER);
+   glsym_glEnable(GL_DITHER);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glDisable(GL_BLEND);
+   glsym_glDisable(GL_BLEND);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+   glsym_glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    // no dest alpha
-//   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // dest alpha
-//   glBlendFunc(GL_SRC_ALPHA, GL_ONE); // ???
-   glDepthMask(GL_FALSE);
+//   glsym_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // dest alpha
+//   glsym_glBlendFunc(GL_SRC_ALPHA, GL_ONE); // ???
+   glsym_glDepthMask(GL_FALSE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
    if (shared->info.anisotropic > 0.0)
      {
-        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0);
+        glsym_glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
      }
 #endif
 
-   glEnableVertexAttribArray(SHAD_VERTEX);
+   glsym_glEnableVertexAttribArray(SHAD_VERTEX);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glEnableVertexAttribArray(SHAD_COLOR);
+   glsym_glEnableVertexAttribArray(SHAD_COLOR);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    if (gc->state.current.cur_prog == PRG_INVALID)
-      glUseProgram(gc->shared->shader[0].prog);
-   else glUseProgram(gc->state.current.cur_prog);
+      glsym_glUseProgram(gc->shared->shader[0].prog);
+   else glsym_glUseProgram(gc->state.current.cur_prog);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-   glActiveTexture(GL_TEXTURE0);
+   glsym_glActiveTexture(GL_TEXTURE0);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
+   glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
    _evas_gl_common_viewport_set(gc);
@@ -2314,19 +2178,19 @@ scissor_rot(Evas_Engine_GL_Context *gc __UNUSED__,
    switch (rot)
      {
       case 0: // UP this way: ^
-        glScissor(cx, cy, cw, ch);
+        glsym_glScissor(cx, cy, cw, ch);
         break;
       case 90: // UP this way: <
-        glScissor(gh - (cy + ch), cx, ch, cw);
+        glsym_glScissor(gh - (cy + ch), cx, ch, cw);
         break;
       case 180: // UP this way: v
-        glScissor(gw - (cx + cw), gh - (cy + ch), cw, ch);
+        glsym_glScissor(gw - (cx + cw), gh - (cy + ch), cw, ch);
         break;
       case 270: // UP this way: >
-        glScissor(cy, gw - (cx + cw), ch, cw);
+        glsym_glScissor(cy, gw - (cx + cw), ch, cw);
         break;
       default: // assume up is up
-        glScissor(cx, cy, cw, ch);
+        glsym_glScissor(cx, cy, cw, ch);
         break;
      }
 }
@@ -2355,7 +2219,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
         GLERR(__FUNCTION__, __FILE__, __LINE__, "<flush err>");
         if (gc->pipe[i].shader.cur_prog != gc->state.current.cur_prog)
           {
-             glUseProgram(gc->pipe[i].shader.cur_prog);
+             glsym_glUseProgram(gc->pipe[i].shader.cur_prog);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
           }
 
@@ -2364,18 +2228,18 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
 #if 0
              if (gc->pipe[i].shader.cur_tex)
                {
-                  glEnable(GL_TEXTURE_2D);
+                  glsym_glEnable(GL_TEXTURE_2D);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
              else
                {
-                  glDisable(GL_TEXTURE_2D);
+                  glsym_glDisable(GL_TEXTURE_2D);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
 #endif
-             glActiveTexture(GL_TEXTURE0);
+             glsym_glActiveTexture(GL_TEXTURE0);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-             glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_tex);
+             glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_tex);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
           }
         if (gc->pipe[i].array.im)
@@ -2383,7 +2247,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
              if (gc->pipe[i].array.im->tex->pt->dyn.img)
                {
-                  secsym_glEGLImageTargetTexture2DOES
+                  glsym_glEGLImageTargetTexture2DOES
                      (GL_TEXTURE_2D, gc->pipe[i].array.im->tex->pt->dyn.img);
                }
              else
@@ -2402,12 +2266,12 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
              switch (gc->pipe[i].shader.render_op)
                {
                case EVAS_RENDER_BLEND: /**< default op: d = d*(1-sa) + s */
-                  glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+                  glsym_glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                   break;
                case EVAS_RENDER_COPY: /**< d = s */
                   gc->pipe[i].shader.blend = 0;
-                  glBlendFunc(GL_ONE, GL_ONE);
+                  glsym_glBlendFunc(GL_ONE, GL_ONE);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                   break;
                   // FIXME: fix blend funcs below!
@@ -2422,7 +2286,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
                case EVAS_RENDER_MASK: /**< d = d*sa */
                case EVAS_RENDER_MUL: /**< d = d*s */
                default:
-                  glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+                  glsym_glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                   break;
                }
@@ -2431,12 +2295,12 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
           {
              if (gc->pipe[i].shader.blend)
                {
-                  glEnable(GL_BLEND);
+                  glsym_glEnable(GL_BLEND);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
              else
                {
-                  glDisable(GL_BLEND);
+                  glsym_glDisable(GL_BLEND);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
           }
@@ -2448,17 +2312,17 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
 #ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
                   if (shared->info.anisotropic > 0.0)
                     {
-                       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, shared->info.anisotropic);
+                       glsym_glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, shared->info.anisotropic);
                        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                     }
 #endif
-                  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+                  glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+                  glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+                  glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+                  glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
              else
@@ -2466,17 +2330,17 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
 #ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
                   if (shared->info.anisotropic > 0.0)
                     {
-                       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0);
+                       glsym_glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0);
                        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                     }
 #endif
-                  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+                  glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+                  glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+                  glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+                  glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
           }
@@ -2487,7 +2351,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
                {
                   cy = gh - gc->pipe[i].shader.cy - gc->pipe[i].shader.ch;
                   if (fbo) cy = gc->pipe[i].shader.cy;
-                  glEnable(GL_SCISSOR_TEST);
+                  glsym_glEnable(GL_SCISSOR_TEST);
                   if (!fbo)
                      scissor_rot(gc, gc->rot, gw, gh,
                                  gc->pipe[i].shader.cx,
@@ -2495,14 +2359,14 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
                                  gc->pipe[i].shader.cw,
                                  gc->pipe[i].shader.ch);
                   else
-                     glScissor(gc->pipe[i].shader.cx, cy,
+                     glsym_glScissor(gc->pipe[i].shader.cx, cy,
                                gc->pipe[i].shader.cw, gc->pipe[i].shader.ch);
                   setclip = 1;
                }
              else
                {
-                  glDisable(GL_SCISSOR_TEST);
-                  glScissor(0, 0, 0, 0);
+                  glsym_glDisable(GL_SCISSOR_TEST);
+                  glsym_glScissor(0, 0, 0, 0);
                }
           }
         if ((gc->pipe[i].shader.clip) && (!setclip))
@@ -2521,112 +2385,112 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
                                  gc->pipe[i].shader.cw,
                                  gc->pipe[i].shader.ch);
                   else
-                     glScissor(gc->pipe[i].shader.cx, cy,
+                     glsym_glScissor(gc->pipe[i].shader.cx, cy,
                                gc->pipe[i].shader.cw, gc->pipe[i].shader.ch);
                }
           }
 
-        glVertexAttribPointer(SHAD_VERTEX, 3, GL_SHORT, GL_FALSE, 0, gc->pipe[i].array.vertex);
+        glsym_glVertexAttribPointer(SHAD_VERTEX, 3, GL_SHORT, GL_FALSE, 0, gc->pipe[i].array.vertex);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glVertexAttribPointer(SHAD_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, gc->pipe[i].array.color);
+        glsym_glVertexAttribPointer(SHAD_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, gc->pipe[i].array.color);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
         if (gc->pipe[i].array.use_texuv)
           {
-             glEnableVertexAttribArray(SHAD_TEXUV);
+             glsym_glEnableVertexAttribArray(SHAD_TEXUV);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-             glVertexAttribPointer(SHAD_TEXUV, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv);
+             glsym_glVertexAttribPointer(SHAD_TEXUV, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
           }
         else
           {
-             glDisableVertexAttribArray(SHAD_TEXUV);
+             glsym_glDisableVertexAttribArray(SHAD_TEXUV);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
           }
 
         if (gc->pipe[i].array.line)
           {
-             glDisableVertexAttribArray(SHAD_TEXUV);
+             glsym_glDisableVertexAttribArray(SHAD_TEXUV);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-             glDisableVertexAttribArray(SHAD_TEXUV2);
+             glsym_glDisableVertexAttribArray(SHAD_TEXUV2);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-             glDisableVertexAttribArray(SHAD_TEXUV3);
+             glsym_glDisableVertexAttribArray(SHAD_TEXUV3);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-             glDrawArrays(GL_LINES, 0, gc->pipe[i].array.num);
+             glsym_glDrawArrays(GL_LINES, 0, gc->pipe[i].array.num);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
           }
         else
           {
             if (gc->pipe[i].array.use_texm)
               {
-                 glEnableVertexAttribArray(SHAD_TEXM);
+                 glsym_glEnableVertexAttribArray(SHAD_TEXM);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glVertexAttribPointer(SHAD_TEXM, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texm);
+                  glsym_glVertexAttribPointer(SHAD_TEXM, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texm);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glActiveTexture(GL_TEXTURE1);
+                  glsym_glActiveTexture(GL_TEXTURE1);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texm);
+                  glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texm);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glActiveTexture(GL_TEXTURE0);
+                  glsym_glActiveTexture(GL_TEXTURE0);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
               }
             else
               {
-                  glDisableVertexAttribArray(SHAD_TEXM);
+                  glsym_glDisableVertexAttribArray(SHAD_TEXM);
               }
              if ((gc->pipe[i].array.use_texuv2) && (gc->pipe[i].array.use_texuv3))
                {
-                  glEnableVertexAttribArray(SHAD_TEXUV2);
+                  glsym_glEnableVertexAttribArray(SHAD_TEXUV2);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glEnableVertexAttribArray(SHAD_TEXUV3);
+                  glsym_glEnableVertexAttribArray(SHAD_TEXUV3);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glVertexAttribPointer(SHAD_TEXUV2, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv2);
+                  glsym_glVertexAttribPointer(SHAD_TEXUV2, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv2);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glVertexAttribPointer(SHAD_TEXUV3, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv3);
+                  glsym_glVertexAttribPointer(SHAD_TEXUV3, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv3);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-                  glActiveTexture(GL_TEXTURE1);
+                  glsym_glActiveTexture(GL_TEXTURE1);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu);
+                  glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
                   if (gc->pipe[i].shader.cur_texu_dyn)
-                   secsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu_dyn);
+                   glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu_dyn);
 #endif
                   
-                  glActiveTexture(GL_TEXTURE2);
+                  glsym_glActiveTexture(GL_TEXTURE2);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texv);
+                  glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texv);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
                  if (gc->pipe[i].shader.cur_texv_dyn)
-                   secsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texv_dyn);
+                   glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texv_dyn);
 #endif
-                  glActiveTexture(GL_TEXTURE0);
+                  glsym_glActiveTexture(GL_TEXTURE0);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
              else if (gc->pipe[i].array.use_texuv2)
                {
-                  glEnableVertexAttribArray(SHAD_TEXUV2);
+                  glsym_glEnableVertexAttribArray(SHAD_TEXUV2);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glVertexAttribPointer(SHAD_TEXUV2, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv2);
+                  glsym_glVertexAttribPointer(SHAD_TEXUV2, 2, GL_FLOAT, GL_FALSE, 0, gc->pipe[i].array.texuv2);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-                  glActiveTexture(GL_TEXTURE1);
+                  glsym_glActiveTexture(GL_TEXTURE1);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu);
+                  glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
                  if (gc->pipe[i].shader.cur_texu_dyn)
-                   secsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu_dyn);
+                   glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu_dyn);
 #endif
-                  glActiveTexture(GL_TEXTURE0);
+                  glsym_glActiveTexture(GL_TEXTURE0);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
              else
                {
-                  glDisableVertexAttribArray(SHAD_TEXUV2);
+                  glsym_glDisableVertexAttribArray(SHAD_TEXUV2);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-                  glDisableVertexAttribArray(SHAD_TEXUV3);
+                  glsym_glDisableVertexAttribArray(SHAD_TEXUV3);
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                }
              if (dbgflushnum)
@@ -2644,7 +2508,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
                          types[gc->pipe[i].region.type]
                         );
                }
-             glDrawArrays(GL_TRIANGLES, 0, gc->pipe[i].array.num);
+             glsym_glDrawArrays(GL_TRIANGLES, 0, gc->pipe[i].array.num);
              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
           }
         if (gc->pipe[i].array.im)
@@ -2703,6 +2567,8 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
 Eina_Bool
 evas_gl_common_module_open(void)
 {
+   if (!init_gl()) return EINA_FALSE;
+
    if (_evas_engine_GL_common_log_dom < 0)
      _evas_engine_GL_common_log_dom = eina_log_domain_register
        ("evas-gl_common", EVAS_DEFAULT_LOG_COLOR);
@@ -2717,6 +2583,8 @@ evas_gl_common_module_open(void)
 void
 evas_gl_common_module_close(void)
 {
+   free_gl();
+
    if (_evas_engine_GL_common_log_dom < 0) return;
    eina_log_domain_unregister(_evas_engine_GL_common_log_dom);
    _evas_engine_GL_common_log_dom = -1;
diff --git a/src/modules/engines/gl_common/evas_gl_core.c b/src/modules/engines/gl_common/evas_gl_core.c
new file mode 100644 (file)
index 0000000..ae63605
--- /dev/null
@@ -0,0 +1,5561 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+#include "evas_gl_core.h"
+
+
+#define FLAG_BIT_0      0x01
+#define FLAG_BIT_1      0x02
+#define FLAG_BIT_2      0x04
+#define FLAG_BIT_3      0x08
+#define FLAG_BIT_4      0x10
+#define FLAG_BIT_5      0x20
+#define FLAG_BIT_6      0x40
+#define FLAG_BIT_7      0x80
+
+//------------------------------------------------------//
+typedef _eng_fn                (*glsym_func_eng_fn) ();
+typedef void                   (*glsym_func_void) ();
+typedef XID                    (*glsym_func_xid) ();
+typedef XVisualInfo           *(*glsym_func_xvisinfo_ptr) ();
+typedef Bool                   (*glsym_func_bool) ();
+typedef unsigned int           (*glsym_func_uint) ();
+typedef int                    (*glsym_func_int) ();
+typedef unsigned char          (*glsym_func_uchar) ();
+typedef unsigned char         *(*glsym_func_uchar_ptr) ();
+typedef const unsigned char   *(*glsym_func_const_uchar_ptr) ();
+typedef char const            *(*glsym_func_char_const_ptr) ();
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+typedef EGLDisplay             (*glsym_func_egldpy) ();
+typedef EGLContext             (*glsym_func_eglctx) ();
+typedef EGLSurface             (*glsym_func_eglsfc) ();
+typedef EGLBoolean             (*glsym_func_eglbool) ();
+#else
+typedef GLXContext             (*glsym_func_glxctx) ();
+typedef GLXDrawable            (*glsym_func_glxdraw) ();
+typedef GLXFBConfig           *(*glsym_func_glxfbcfg_ptr) ();
+#endif
+//------------------------------------------------------//
+
+static void                *gl_lib_handle;
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+static void                *egl_lib_handle;
+static EGLDisplay           global_dpy         = EGL_DEFAULT_DISPLAY;
+static EGLSurface           current_surf       = EGL_NO_SURFACE;
+static EGLContext           global_ctx         = NULL;
+#else
+static Display             *global_dpy         = NULL;
+static GLXDrawable          current_surf       = None;
+static GLXContext           global_ctx         = NULL;
+#endif
+static int                  global_ctx_initted = 0;
+static EvasGlueContext      current_ctx        = NULL;
+static EvasGlueContext      real_current_ctx   = NULL;
+static int                  ctx_ref_count      = 0;
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+
+//------------------------------------------------------//
+// EGL APIs... Only ones that are being used.
+//--------//
+_eng_fn      (*GL(eglGetProcAddress))            (const char *procname) = NULL;
+
+//--------//
+// Standard EGL APIs
+EGLint       (*GL(eglGetError))                  (void) = NULL;
+EGLDisplay   (*GL(eglGetDisplay))                (EGLNativeDisplayType display_id) = NULL;
+EGLBoolean   (*GL(eglInitialize))                (EGLDisplay dpy, EGLint* major, EGLint* minor) = NULL;
+EGLBoolean   (*GL(eglTerminate))                 (EGLDisplay dpy) = NULL;
+EGLBoolean   (*GL(eglChooseConfig))              (EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) = NULL;
+EGLSurface   (*GL(eglCreateWindowSurface)  )     (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) = NULL;
+EGLSurface   (*GL(eglCreatePixmapSurface)  )     (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) = NULL;
+EGLBoolean   (*GL(eglDestroySurface))            (EGLDisplay dpy, EGLSurface surface) = NULL;
+EGLBoolean   (*GL(eglBindAPI))                   (EGLenum api) = NULL;
+EGLBoolean   (*GL(eglWaitClient))                (void) = NULL;
+EGLBoolean   (*GL(eglSurfaceAttrib))             (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) = NULL;
+void         (*GL(eglBindTexImage))              (EGLDisplay dpy, EGLSurface surface, EGLint buffer) = NULL;
+EGLBoolean   (*GL(eglReleaseTexImage))           (EGLDisplay dpy, EGLSurface surface, EGLint buffer) = NULL;
+EGLBoolean   (*GL(eglSwapInterval))              (EGLDisplay dpy, EGLint interval) = NULL;
+EGLContext   (*GL(eglCreateContext))             (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) = NULL;
+EGLBoolean   (*GL(eglDestroyContext))            (EGLDisplay dpy, EGLContext ctx) = NULL;
+EGLBoolean   (*GL(eglMakeCurrent))               (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) = NULL;
+EGLContext   (*GL(eglGetCurrentContext))         (void) = NULL;
+EGLSurface   (*GL(eglGetCurrentSurface))         (EGLint readdraw) = NULL;
+EGLDisplay   (*GL(eglGetCurrentDisplay))         (void) = NULL;
+EGLBoolean   (*GL(eglWaitGL))                    (void) = NULL;
+EGLBoolean   (*GL(eglWaitNative))                (EGLint engine) = NULL;
+EGLBoolean   (*GL(eglSwapBuffers))               (EGLDisplay dpy, EGLSurface surface) = NULL;
+EGLBoolean   (*GL(eglCopyBuffers))               (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) = NULL;
+char const  *(*GL(eglQueryString))               (EGLDisplay dpy, EGLint name) = NULL;
+
+// Extensions
+void         *(*GL(eglCreateImage))               (void *a, void *b, GLenum c, void *d, const int *e) = NULL;
+unsigned int  (*GL(eglDestroyImage))              (void *a, void *b) = NULL;
+void          (*GL(glEGLImageTargetTexture2DOES)) (int a, void *b) = NULL;
+void          (*GL(glEGLImageTargetRenderbufferStorageOES)) (int a, void *b) = NULL;
+void         *(*GL(eglMapImageSEC))               (void *a, void *b) = NULL;
+unsigned int  (*GL(eglUnmapImageSEC))             (void *a, void *b) = NULL;
+unsigned int  (*GL(eglGetImageAttribSEC))         (void *a, void *b, int c, int *d) = NULL;
+
+
+//--------//
+
+//------------------------------------------------------//
+// Internal EGL APIs... Only ones that are being used.
+//--------//
+static _eng_fn      (*_sym_eglGetProcAddress)            (const char* procname) = NULL;
+// Standard EGL funtions
+static EGLint       (*_sym_eglGetError)                  (void) = NULL;
+static EGLDisplay   (*_sym_eglGetDisplay)                (EGLNativeDisplayType display_id) = NULL;
+static EGLBoolean   (*_sym_eglInitialize)                (EGLDisplay dpy, EGLint* major, EGLint* minor) = NULL;
+static EGLBoolean   (*_sym_eglTerminate)                 (EGLDisplay dpy) = NULL;
+static EGLBoolean   (*_sym_eglChooseConfig)              (EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) = NULL;
+static EGLSurface   (*_sym_eglCreateWindowSurface  )     (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) = NULL;
+static EGLSurface   (*_sym_eglCreatePixmapSurface  )     (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) = NULL;
+static EGLBoolean   (*_sym_eglDestroySurface)            (EGLDisplay dpy, EGLSurface surface) = NULL;
+static EGLBoolean   (*_sym_eglBindAPI)                   (EGLenum api) = NULL;
+static EGLBoolean   (*_sym_eglWaitClient)                (void) = NULL;
+static EGLBoolean   (*_sym_eglSurfaceAttrib)             (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) = NULL;
+static void         (*_sym_eglBindTexImage)              (EGLDisplay dpy, EGLSurface surface, EGLint buffer) = NULL;
+static EGLBoolean   (*_sym_eglReleaseTexImage)           (EGLDisplay dpy, EGLSurface surface, EGLint buffer) = NULL;
+static EGLBoolean   (*_sym_eglSwapInterval)              (EGLDisplay dpy, EGLint interval) = NULL;
+static EGLContext   (*_sym_eglCreateContext)             (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) = NULL;
+static EGLBoolean   (*_sym_eglDestroyContext)            (EGLDisplay dpy, EGLContext ctx) = NULL;
+static EGLBoolean   (*_sym_eglMakeCurrent)               (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) = NULL;
+static EGLContext   (*_sym_eglGetCurrentContext)         (void) = NULL;
+static EGLSurface   (*_sym_eglGetCurrentSurface)         (EGLint readdraw) = NULL;
+static EGLDisplay   (*_sym_eglGetCurrentDisplay)         (void) = NULL;
+static EGLBoolean   (*_sym_eglWaitGL)                    (void) = NULL;
+static EGLBoolean   (*_sym_eglWaitNative)                (EGLint engine) = NULL;
+static EGLBoolean   (*_sym_eglSwapBuffers)               (EGLDisplay dpy, EGLSurface surface) = NULL;
+static EGLBoolean   (*_sym_eglCopyBuffers)               (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) = NULL;
+static char const  *(*_sym_eglQueryString)               (EGLDisplay dpy, EGLint name) = NULL;
+
+// Extensions
+static void         *(*_sym_eglCreateImage)               (void *a, void *b, GLenum c, void *d, const int *e) = NULL;
+static unsigned int  (*_sym_eglDestroyImage)              (void *a, void *b) = NULL;
+static void          (*_sym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
+static void          (*_sym_glEGLImageTargetRenderbufferStorageOES) (int a, void *b) = NULL;
+static void         *(*_sym_eglMapImageSEC)               (void *a, void *b) = NULL;
+static unsigned int  (*_sym_eglUnmapImageSEC)             (void *a, void *b) = NULL;
+static unsigned int  (*_sym_eglGetImageAttribSEC)         (void *a, void *b, int c, int *d) = NULL;
+
+
+#else
+//------------------------------------------------------//
+// GLX APIs... Only ones that are being used.
+//--------//
+_eng_fn      (*GL(glXGetProcAddress))            (const char* procName) = NULL;
+
+// Standard glX functions
+XVisualInfo* (*GL(glXChooseVisual))              (Display* dpy, int screen, int* attribList) = NULL;
+GLXContext   (*GL(glXCreateContext))             (Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct) = NULL;
+void         (*GL(glXDestroyContext))            (Display* dpy, GLXContext ctx) = NULL;
+GLXContext   (*GL(glXGetCurrentContext))         (void) = NULL;
+GLXDrawable  (*GL(glXGetCurrentDrawable))        (void) = NULL;
+Bool         (*GL(glXMakeCurrent))               (Display* dpy, GLXDrawable draw, GLXContext ctx) = NULL;
+void         (*GL(glXSwapBuffers))               (Display* dpy, GLXDrawable draw) = NULL;
+void         (*GL(glXWaitX))                     (void) = NULL;
+void         (*GL(glXWaitGL))                    (void) = NULL;
+Bool         (*GL(glXQueryExtension))            (Display* dpy, int* errorb, int *event) = NULL;
+const char  *(*GL(glXQueryExtensionsString))     (Display *dpy, int screen) = NULL;
+
+//--------//
+GLXFBConfig* (*GL(glXChooseFBConfig))            (Display* dpy, int screen, const int* attribList, int* nitems) = NULL;
+GLXFBConfig* (*GL(glXGetFBConfigs))              (Display* dpy, int screen, int* nelements) = NULL;
+int          (*GL(glXGetFBConfigAttrib))         (Display* dpy, GLXFBConfig config, int attribute, int* value) = NULL;
+XVisualInfo* (*GL(glXGetVisualFromFBConfig))     (Display* dpy, GLXFBConfig config) = NULL;
+void         (*GL(glXDestroyWindow))             (Display* dpy, GLXWindow window) = NULL;
+Bool         (*GL(glXMakeContextCurrent))        (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) = NULL;
+//--------//
+
+void         (*GL(glXBindTexImage))              (Display* dpy, GLXDrawable draw, int buffer, int* attribList) = NULL;
+void         (*GL(glXReleaseTexImage))           (Display* dpy, GLXDrawable draw, int buffer) = NULL;
+int          (*GL(glXGetVideoSync))              (unsigned int* count) = NULL;
+int          (*GL(glXWaitVideoSync))             (int divisor, int remainder, unsigned int *count) = NULL;
+XID          (*GL(glXCreatePixmap))              (Display* dpy, void* config, Pixmap pixmap, const int* attribList) = NULL;
+void         (*GL(glXDestroyPixmap))             (Display* dpy, XID pixmap) = NULL;
+void         (*GL(glXQueryDrawable))             (Display* dpy, XID draw, int attribute, unsigned int* value) = NULL;
+int          (*GL(glXSwapIntervalSGI))           (int interval) = NULL;
+void         (*GL(glXSwapIntervalEXT))           (Display* dpy, GLXDrawable draw, int interval) = NULL;
+
+//------------------//
+
+
+//------------------------------------------------------//
+// Internal GLX APIs... Only ones that are being used.
+//--------//
+static _eng_fn      (*_sym_glXGetProcAddress)            (const char* procName) = NULL;
+
+// Standard glX functions
+static XVisualInfo* (*_sym_glXChooseVisual)              (Display* dpy, int screen, int* attribList) = NULL;
+static GLXContext   (*_sym_glXCreateContext)             (Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct) = NULL;
+static void         (*_sym_glXDestroyContext)            (Display* dpy, GLXContext ctx) = NULL;
+static GLXContext   (*_sym_glXGetCurrentContext)         (void) = NULL;
+static GLXDrawable  (*_sym_glXGetCurrentDrawable)        (void) = NULL;
+static Bool         (*_sym_glXMakeCurrent)               (Display* dpy, GLXDrawable draw, GLXContext ctx) = NULL;
+static void         (*_sym_glXSwapBuffers)               (Display* dpy, GLXDrawable draw) = NULL;
+static void         (*_sym_glXWaitX)                     (void) = NULL;
+static void         (*_sym_glXWaitGL)                    (void) = NULL;
+static Bool         (*_sym_glXQueryExtension)            (Display* dpy, int* errorb, int* event) = NULL;
+static const char  *(*_sym_glXQueryExtensionsString)     (Display* dpy, int screen);
+
+//--------//
+static GLXFBConfig* (*_sym_glXChooseFBConfig)            (Display* dpy, int screen, const int* attribList, int* nitems) = NULL;
+static GLXFBConfig* (*_sym_glXGetFBConfigs)              (Display* dpy, int screen, int* nelements) = NULL;
+static int          (*_sym_glXGetFBConfigAttrib)         (Display* dpy, GLXFBConfig config, int attribute, int* value) = NULL;
+static XVisualInfo* (*_sym_glXGetVisualFromFBConfig)     (Display* dpy, GLXFBConfig config) = NULL;
+static void         (*_sym_glXDestroyWindow)             (Display* dpy, GLXWindow window) = NULL;
+static Bool         (*_sym_glXMakeContextCurrent)        (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) = NULL;
+//--------//
+
+static void         (*_sym_glXBindTexImage)              (Display* dpy, GLXDrawable draw, int buffer, int* attribList) = NULL;
+static void         (*_sym_glXReleaseTexImage)           (Display* dpy, GLXDrawable draw, int buffer) = NULL;
+static int          (*_sym_glXGetVideoSync)              (unsigned int* count) = NULL;
+static int          (*_sym_glXWaitVideoSync)             (int divisor, int remainder, unsigned int* count) = NULL;
+static XID          (*_sym_glXCreatePixmap)              (Display* dpy, void* config, Pixmap pixmap, const int* attribList) = NULL;
+static void         (*_sym_glXDestroyPixmap)             (Display* dpy, XID pixmap) = NULL;
+static void         (*_sym_glXQueryDrawable)             (Display* dpy, XID draw, int attribute, unsigned int* value) = NULL;
+static int          (*_sym_glXSwapIntervalSGI)           (int interval) = NULL;
+static void         (*_sym_glXSwapIntervalEXT)           (Display* dpy, GLXDrawable draw, int interval) = NULL;
+
+//------------------//
+#endif
+
+//------------------------------------------------------//
+
+
+/* version 1: */
+void         (*GL(glActiveTexture)) (GLenum texture) = NULL;
+void         (*GL(glAttachShader)) (GLuint program, GLuint shader) = NULL;
+void         (*GL(glBindAttribLocation)) (GLuint program, GLuint index, const char* name) = NULL;
+void         (*GL(glBindBuffer)) (GLenum target, GLuint buffer) = NULL;
+void         (*GL(glBindFramebuffer)) (GLenum target, GLuint framebuffer) = NULL;
+void         (*GL(glBindRenderbuffer)) (GLenum target, GLuint renderbuffer) = NULL;
+void         (*GL(glBindTexture)) (GLenum target, GLuint texture) = NULL;
+void         (*GL(glBlendColor)) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
+void         (*GL(glBlendEquation)) ( GLenum mode ) = NULL;
+void         (*GL(glBlendEquationSeparate)) (GLenum modeRGB, GLenum modeAlpha) = NULL;
+void         (*GL(glBlendFunc)) (GLenum sfactor, GLenum dfactor) = NULL;
+void         (*GL(glBlendFuncSeparate)) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) = NULL;
+void         (*GL(glBufferData)) (GLenum target, GLsizeiptr size, const void* data, GLenum usage) = NULL;
+void         (*GL(glBufferSubData)) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) = NULL;
+GLenum       (*GL(glCheckFramebufferStatus)) (GLenum target) = NULL;
+void         (*GL(glClear)) (GLbitfield mask) = NULL;
+void         (*GL(glClearColor)) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
+void         (*GL(glClearDepthf)) (GLclampf depth) = NULL;
+void         (*GL(glClearStencil)) (GLint s) = NULL;
+void         (*GL(glColorMask)) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = NULL;
+void         (*GL(glCompileShader)) (GLuint shader) = NULL;
+void         (*GL(glCompressedTexImage2D)) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) = NULL;
+void         (*GL(glCompressedTexSubImage2D)) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) = NULL;
+void         (*GL(glCopyTexImage2D)) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = NULL;
+void         (*GL(glCopyTexSubImage2D)) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
+GLuint       (*GL(glCreateProgram)) (void) = NULL;
+GLuint       (*GL(glCreateShader)) (GLenum type) = NULL;
+void         (*GL(glCullFace)) (GLenum mode) = NULL;
+void         (*GL(glDeleteBuffers)) (GLsizei n, const GLuint* buffers) = NULL;
+void         (*GL(glDeleteFramebuffers)) (GLsizei n, const GLuint* framebuffers) = NULL;
+void         (*GL(glDeleteProgram)) (GLuint program) = NULL;
+void         (*GL(glDeleteRenderbuffers)) (GLsizei n, const GLuint* renderbuffers) = NULL;
+void         (*GL(glDeleteShader)) (GLuint shader) = NULL;
+void         (*GL(glDeleteTextures)) (GLsizei n, const GLuint* textures) = NULL;
+void         (*GL(glDepthFunc)) (GLenum func) = NULL;
+void         (*GL(glDepthMask)) (GLboolean flag) = NULL;
+void         (*GL(glDepthRangef)) (GLclampf zNear, GLclampf zFar) = NULL;
+void         (*GL(glDetachShader)) (GLuint program, GLuint shader) = NULL;
+void         (*GL(glDisable)) (GLenum cap) = NULL;
+void         (*GL(glDisableVertexAttribArray)) (GLuint index) = NULL;
+void         (*GL(glDrawArrays)) (GLenum mode, GLint first, GLsizei count) = NULL;
+void         (*GL(glDrawElements)) (GLenum mode, GLsizei count, GLenum type, const void* indices) = NULL;
+void         (*GL(glEnable)) (GLenum cap) = NULL;
+void         (*GL(glEnableVertexAttribArray)) (GLuint index) = NULL;
+void         (*GL(glFinish)) (void) = NULL;
+void         (*GL(glFlush)) (void) = NULL;
+void         (*GL(glFramebufferRenderbuffer)) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL;
+void         (*GL(glFramebufferTexture2D)) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
+void         (*GL(glFrontFace)) (GLenum mode) = NULL;
+void         (*GL(glGenBuffers)) (GLsizei n, GLuint* buffers) = NULL;
+void         (*GL(glGenerateMipmap)) (GLenum target) = NULL;
+void         (*GL(glGenFramebuffers)) (GLsizei n, GLuint* framebuffers) = NULL;
+void         (*GL(glGenRenderbuffers)) (GLsizei n, GLuint* renderbuffers) = NULL;
+void         (*GL(glGenTextures)) (GLsizei n, GLuint* textures) = NULL;
+void         (*GL(glGetActiveAttrib)) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
+void         (*GL(glGetActiveUniform)) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
+void         (*GL(glGetAttachedShaders)) (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) = NULL;
+int          (*GL(glGetAttribLocation)) (GLuint program, const char* name) = NULL;
+void         (*GL(glGetBooleanv)) (GLenum pname, GLboolean* params) = NULL;
+void         (*GL(glGetBufferParameteriv)) (GLenum target, GLenum pname, GLint* params) = NULL;
+GLenum       (*GL(glGetError)) (void) = NULL;
+void         (*GL(glGetFloatv)) (GLenum pname, GLfloat* params) = NULL;
+void         (*GL(glGetFramebufferAttachmentParameteriv)) (GLenum target, GLenum attachment, GLenum pname, GLint* params) = NULL;
+void         (*GL(glGetIntegerv)) (GLenum pname, GLint* params) = NULL;
+void         (*GL(glGetProgramiv)) (GLuint program, GLenum pname, GLint* params) = NULL;
+void         (*GL(glGetProgramInfoLog)) (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
+void         (*GL(glGetRenderbufferParameteriv)) (GLenum target, GLenum pname, GLint* params) = NULL;
+void         (*GL(glGetShaderiv)) (GLuint shader, GLenum pname, GLint* params) = NULL;
+void         (*GL(glGetShaderInfoLog)) (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
+void         (*GL(glGetShaderPrecisionFormat)) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) = NULL;
+void         (*GL(glGetShaderSource)) (GLuint shader, GLsizei bufsize, GLsizei* length, char* source) = NULL;
+const GLubyte *(*GL(glGetString)) (GLenum name) = NULL;
+void         (*GL(glGetTexParameterfv)) (GLenum target, GLenum pname, GLfloat* params) = NULL;
+void         (*GL(glGetTexParameteriv)) (GLenum target, GLenum pname, GLint* params) = NULL;
+void         (*GL(glGetUniformfv)) (GLuint program, GLint location, GLfloat* params) = NULL;
+void         (*GL(glGetUniformiv)) (GLuint program, GLint location, GLint* params) = NULL;
+int          (*GL(glGetUniformLocation)) (GLuint program, const char* name) = NULL;
+void         (*GL(glGetVertexAttribfv)) (GLuint index, GLenum pname, GLfloat* params) = NULL;
+void         (*GL(glGetVertexAttribiv)) (GLuint index, GLenum pname, GLint* params) = NULL;
+void         (*GL(glGetVertexAttribPointerv)) (GLuint index, GLenum pname, void** pointer) = NULL;
+void         (*GL(glHint)) (GLenum target, GLenum mode) = NULL;
+GLboolean    (*GL(glIsBuffer)) (GLuint buffer) = NULL;
+GLboolean    (*GL(glIsEnabled)) (GLenum cap) = NULL;
+GLboolean    (*GL(glIsFramebuffer)) (GLuint framebuffer) = NULL;
+GLboolean    (*GL(glIsProgram)) (GLuint program) = NULL;
+GLboolean    (*GL(glIsRenderbuffer)) (GLuint renderbuffer) = NULL;
+GLboolean    (*GL(glIsShader)) (GLuint shader) = NULL;
+GLboolean    (*GL(glIsTexture)) (GLuint texture) = NULL;
+void         (*GL(glLineWidth)) (GLfloat width) = NULL;
+void         (*GL(glLinkProgram)) (GLuint program) = NULL;
+void         (*GL(glPixelStorei)) (GLenum pname, GLint param) = NULL;
+void         (*GL(glPolygonOffset)) (GLfloat factor, GLfloat units) = NULL;
+void         (*GL(glReadPixels)) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) = NULL;
+void         (*GL(glReleaseShaderCompiler)) (void) = NULL;
+void         (*GL(glRenderbufferStorage)) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
+void         (*GL(glSampleCoverage)) (GLclampf value, GLboolean invert) = NULL;
+void         (*GL(glScissor)) (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
+void         (*GL(glShaderBinary)) (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) = NULL;
+void         (*GL(glShaderSource)) (GLuint shader, GLsizei count, const char** string, const GLint* length) = NULL;
+void         (*GL(glStencilFunc)) (GLenum func, GLint ref, GLuint mask) = NULL;
+void         (*GL(glStencilFuncSeparate)) (GLenum face, GLenum func, GLint ref, GLuint mask) = NULL;
+void         (*GL(glStencilMask)) (GLuint mask) = NULL;
+void         (*GL(glStencilMaskSeparate)) (GLenum face, GLuint mask) = NULL;
+void         (*GL(glStencilOp)) (GLenum fail, GLenum zfail, GLenum zpass) = NULL;
+void         (*GL(glStencilOpSeparate)) (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) = NULL;
+void         (*GL(glTexImage2D)) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) = NULL;
+void         (*GL(glTexParameterf)) (GLenum target, GLenum pname, GLfloat param) = NULL;
+void         (*GL(glTexParameterfv)) (GLenum target, GLenum pname, const GLfloat* params) = NULL;
+void         (*GL(glTexParameteri)) (GLenum target, GLenum pname, GLint param) = NULL;
+void         (*GL(glTexParameteriv)) (GLenum target, GLenum pname, const GLint* params) = NULL;
+void         (*GL(glTexSubImage2D)) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) = NULL;
+void         (*GL(glUniform1f)) (GLint location, GLfloat x) = NULL;
+void         (*GL(glUniform1fv)) (GLint location, GLsizei count, const GLfloat* v) = NULL;
+void         (*GL(glUniform1i)) (GLint location, GLint x) = NULL;
+void         (*GL(glUniform1iv)) (GLint location, GLsizei count, const GLint* v) = NULL;
+void         (*GL(glUniform2f)) (GLint location, GLfloat x, GLfloat y) = NULL;
+void         (*GL(glUniform2fv)) (GLint location, GLsizei count, const GLfloat* v) = NULL;
+void         (*GL(glUniform2i)) (GLint location, GLint x, GLint y) = NULL;
+void         (*GL(glUniform2iv)) (GLint location, GLsizei count, const GLint* v) = NULL;
+void         (*GL(glUniform3f)) (GLint location, GLfloat x, GLfloat y, GLfloat z) = NULL;
+void         (*GL(glUniform3fv)) (GLint location, GLsizei count, const GLfloat* v) = NULL;
+void         (*GL(glUniform3i)) (GLint location, GLint x, GLint y, GLint z) = NULL;
+void         (*GL(glUniform3iv)) (GLint location, GLsizei count, const GLint* v) = NULL;
+void         (*GL(glUniform4f)) (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
+void         (*GL(glUniform4fv)) (GLint location, GLsizei count, const GLfloat* v) = NULL;
+void         (*GL(glUniform4i)) (GLint location, GLint x, GLint y, GLint z, GLint w) = NULL;
+void         (*GL(glUniform4iv)) (GLint location, GLsizei count, const GLint* v) = NULL;
+void         (*GL(glUniformMatrix2fv)) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
+void         (*GL(glUniformMatrix3fv)) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
+void         (*GL(glUniformMatrix4fv)) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
+void         (*GL(glUseProgram)) (GLuint program) = NULL;
+void         (*GL(glValidateProgram)) (GLuint program) = NULL;
+void         (*GL(glVertexAttrib1f)) (GLuint indx, GLfloat x) = NULL;
+void         (*GL(glVertexAttrib1fv)) (GLuint indx, const GLfloat* values) = NULL;
+void         (*GL(glVertexAttrib2f)) (GLuint indx, GLfloat x, GLfloat y) = NULL;
+void         (*GL(glVertexAttrib2fv)) (GLuint indx, const GLfloat* values) = NULL;
+void         (*GL(glVertexAttrib3f)) (GLuint indx, GLfloat x, GLfloat y, GLfloat z) = NULL;
+void         (*GL(glVertexAttrib3fv)) (GLuint indx, const GLfloat* values) = NULL;
+void         (*GL(glVertexAttrib4f)) (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
+void         (*GL(glVertexAttrib4fv)) (GLuint indx, const GLfloat* values) = NULL;
+void         (*GL(glVertexAttribPointer)) (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) = NULL;
+void         (*GL(glViewport)) (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
+
+/* Extensions */
+void         (*GL(glGetProgramBinary)) (GLuint program, GLsizei bufsize, GLsizei *length, GLenum *binaryFormat, void *binary) = NULL;
+void         (*GL(glProgramBinary)) (GLuint program, GLenum binaryFormat, const void *binary, GLint length) = NULL;
+void         (*GL(glProgramParameteri)) (GLuint a, GLuint b, GLint d) = NULL;
+
+
+//------------------------------------------------------//
+// GLES 2.0 APIs...
+static void       (*_sym_glActiveTexture)                       (GLenum texture) = NULL;
+static void       (*_sym_glAttachShader)                        (GLuint program, GLuint shader) = NULL;
+static void       (*_sym_glBindAttribLocation)                  (GLuint program, GLuint index, const char* name) = NULL;
+static void       (*_sym_glBindBuffer)                          (GLenum target, GLuint buffer) = NULL;
+static void       (*_sym_glBindFramebuffer)                     (GLenum target, GLuint framebuffer) = NULL;
+static void       (*_sym_glBindRenderbuffer)                    (GLenum target, GLuint renderbuffer) = NULL;
+static void       (*_sym_glBindTexture)                         (GLenum target, GLuint texture) = NULL;
+static void       (*_sym_glBlendColor)                          (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
+static void       (*_sym_glBlendEquation)                       (GLenum mode) = NULL;
+static void       (*_sym_glBlendEquationSeparate)               (GLenum modeRGB, GLenum modeAlpha) = NULL;
+static void       (*_sym_glBlendFunc)                           (GLenum sfactor, GLenum dfactor) = NULL;
+static void       (*_sym_glBlendFuncSeparate)                   (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) = NULL;
+static void       (*_sym_glBufferData)                          (GLenum target, GLsizeiptr size, const void* data, GLenum usage) = NULL;
+static void       (*_sym_glBufferSubData)                       (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) = NULL;
+static GLenum     (*_sym_glCheckFramebufferStatus)              (GLenum target) = NULL;
+static void       (*_sym_glClear)                               (GLbitfield mask) = NULL;
+static void       (*_sym_glClearColor)                          (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
+static void       (*_sym_glClearDepthf)                         (GLclampf depth) = NULL;
+static void       (*_sym_glClearStencil)                        (GLint s) = NULL;
+static void       (*_sym_glColorMask)                           (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = NULL;
+static void       (*_sym_glCompileShader)                       (GLuint shader) = NULL;
+static void       (*_sym_glCompressedTexImage2D)                (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) = NULL;
+static void       (*_sym_glCompressedTexSubImage2D)             (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) = NULL;
+static void       (*_sym_glCopyTexImage2D)                      (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = NULL;
+static void       (*_sym_glCopyTexSubImage2D)                   (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
+static GLuint     (*_sym_glCreateProgram)                       (void) = NULL;
+static GLuint     (*_sym_glCreateShader)                        (GLenum type) = NULL;
+static void       (*_sym_glCullFace)                            (GLenum mode) = NULL;
+static void       (*_sym_glDeleteBuffers)                       (GLsizei n, const GLuint* buffers) = NULL;
+static void       (*_sym_glDeleteFramebuffers)                  (GLsizei n, const GLuint* framebuffers) = NULL;
+static void       (*_sym_glDeleteProgram)                       (GLuint program) = NULL;
+static void       (*_sym_glDeleteRenderbuffers)                 (GLsizei n, const GLuint* renderbuffers) = NULL;
+static void       (*_sym_glDeleteShader)                        (GLuint shader) = NULL;
+static void       (*_sym_glDeleteTextures)                      (GLsizei n, const GLuint* textures) = NULL;
+static void       (*_sym_glDepthFunc)                           (GLenum func) = NULL;
+static void       (*_sym_glDepthMask)                           (GLboolean flag) = NULL;
+static void       (*_sym_glDepthRangef)                         (GLclampf zNear, GLclampf zFar) = NULL;
+static void       (*_sym_glDetachShader)                        (GLuint program, GLuint shader) = NULL;
+static void       (*_sym_glDisable)                             (GLenum cap) = NULL;
+static void       (*_sym_glDisableVertexAttribArray)            (GLuint index) = NULL;
+static void       (*_sym_glDrawArrays)                          (GLenum mode, GLint first, GLsizei count) = NULL;
+static void       (*_sym_glDrawElements)                        (GLenum mode, GLsizei count, GLenum type, const void* indices) = NULL;
+static void       (*_sym_glEnable)                              (GLenum cap) = NULL;
+static void       (*_sym_glEnableVertexAttribArray)             (GLuint index) = NULL;
+static void       (*_sym_glFinish)                              (void) = NULL;
+static void       (*_sym_glFlush)                               (void) = NULL;
+static void       (*_sym_glFramebufferRenderbuffer)             (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL;
+static void       (*_sym_glFramebufferTexture2D)                (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
+static void       (*_sym_glFrontFace)                           (GLenum mode) = NULL;
+static void       (*_sym_glGenBuffers)                          (GLsizei n, GLuint* buffers) = NULL;
+static void       (*_sym_glGenerateMipmap)                      (GLenum target) = NULL;
+static void       (*_sym_glGenFramebuffers)                     (GLsizei n, GLuint* framebuffers) = NULL;
+static void       (*_sym_glGenRenderbuffers)                    (GLsizei n, GLuint* renderbuffers) = NULL;
+static void       (*_sym_glGenTextures)                         (GLsizei n, GLuint* textures) = NULL;
+static void       (*_sym_glGetActiveAttrib)                     (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
+static void       (*_sym_glGetActiveUniform)                    (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
+static void       (*_sym_glGetAttachedShaders)                  (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) = NULL;
+static int        (*_sym_glGetAttribLocation)                   (GLuint program, const char* name) = NULL;
+static void       (*_sym_glGetBooleanv)                         (GLenum pname, GLboolean* params) = NULL;
+static void       (*_sym_glGetBufferParameteriv)                (GLenum target, GLenum pname, GLint* params) = NULL;
+static GLenum     (*_sym_glGetError)                            (void) = NULL;
+static void       (*_sym_glGetFloatv)                           (GLenum pname, GLfloat* params) = NULL;
+static void       (*_sym_glGetFramebufferAttachmentParameteriv) (GLenum target, GLenum attachment, GLenum pname, GLint* params) = NULL;
+static void       (*_sym_glGetIntegerv)                         (GLenum pname, GLint* params) = NULL;
+static void       (*_sym_glGetProgramiv)                        (GLuint program, GLenum pname, GLint* params) = NULL;
+static void       (*_sym_glGetProgramInfoLog)                   (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
+static void       (*_sym_glGetRenderbufferParameteriv)          (GLenum target, GLenum pname, GLint* params) = NULL;
+static void       (*_sym_glGetShaderiv)                         (GLuint shader, GLenum pname, GLint* params) = NULL;
+static void       (*_sym_glGetShaderInfoLog)                    (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
+static void       (*_sym_glGetShaderPrecisionFormat)            (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) = NULL;
+static void       (*_sym_glGetShaderSource)                     (GLuint shader, GLsizei bufsize, GLsizei* length, char* source) = NULL;
+static const GLubyte *(*_sym_glGetString)                           (GLenum name) = NULL;
+static void       (*_sym_glGetTexParameterfv)                   (GLenum target, GLenum pname, GLfloat* params) = NULL;
+static void       (*_sym_glGetTexParameteriv)                   (GLenum target, GLenum pname, GLint* params) = NULL;
+static void       (*_sym_glGetUniformfv)                        (GLuint program, GLint location, GLfloat* params) = NULL;
+static void       (*_sym_glGetUniformiv)                        (GLuint program, GLint location, GLint* params) = NULL;
+static int        (*_sym_glGetUniformLocation)                  (GLuint program, const char* name) = NULL;
+static void       (*_sym_glGetVertexAttribfv)                   (GLuint index, GLenum pname, GLfloat* params) = NULL;
+static void       (*_sym_glGetVertexAttribiv)                   (GLuint index, GLenum pname, GLint* params) = NULL;
+static void       (*_sym_glGetVertexAttribPointerv)             (GLuint index, GLenum pname, void** pointer) = NULL;
+static void       (*_sym_glHint)                                (GLenum target, GLenum mode) = NULL;
+static GLboolean  (*_sym_glIsBuffer)                            (GLuint buffer) = NULL;
+static GLboolean  (*_sym_glIsEnabled)                           (GLenum cap) = NULL;
+static GLboolean  (*_sym_glIsFramebuffer)                       (GLuint framebuffer) = NULL;
+static GLboolean  (*_sym_glIsProgram)                           (GLuint program) = NULL;
+static GLboolean  (*_sym_glIsRenderbuffer)                      (GLuint renderbuffer) = NULL;
+static GLboolean  (*_sym_glIsShader)                            (GLuint shader) = NULL;
+static GLboolean  (*_sym_glIsTexture)                           (GLuint texture) = NULL;
+static void       (*_sym_glLineWidth)                           (GLfloat width) = NULL;
+static void       (*_sym_glLinkProgram)                         (GLuint program) = NULL;
+static void       (*_sym_glPixelStorei)                         (GLenum pname, GLint param) = NULL;
+static void       (*_sym_glPolygonOffset)                       (GLfloat factor, GLfloat units) = NULL;
+static void       (*_sym_glReadPixels)                          (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) = NULL;
+static void       (*_sym_glReleaseShaderCompiler)               (void) = NULL;
+static void       (*_sym_glRenderbufferStorage)                 (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
+static void       (*_sym_glSampleCoverage)                      (GLclampf value, GLboolean invert) = NULL;
+static void       (*_sym_glScissor)                             (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
+static void       (*_sym_glShaderBinary)                        (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) = NULL;
+static void       (*_sym_glShaderSource)                        (GLuint shader, GLsizei count, const char** string, const GLint* length) = NULL;
+static void       (*_sym_glStencilFunc)                         (GLenum func, GLint ref, GLuint mask) = NULL;
+static void       (*_sym_glStencilFuncSeparate)                 (GLenum face, GLenum func, GLint ref, GLuint mask) = NULL;
+static void       (*_sym_glStencilMask)                         (GLuint mask) = NULL;
+static void       (*_sym_glStencilMaskSeparate)                 (GLenum face, GLuint mask) = NULL;
+static void       (*_sym_glStencilOp)                           (GLenum fail, GLenum zfail, GLenum zpass) = NULL;
+static void       (*_sym_glStencilOpSeparate)                   (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) = NULL;
+static void       (*_sym_glTexImage2D)                          (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) = NULL;
+static void       (*_sym_glTexParameterf)                       (GLenum target, GLenum pname, GLfloat param) = NULL;
+static void       (*_sym_glTexParameterfv)                      (GLenum target, GLenum pname, const GLfloat* params) = NULL;
+static void       (*_sym_glTexParameteri)                       (GLenum target, GLenum pname, GLint param) = NULL;
+static void       (*_sym_glTexParameteriv)                      (GLenum target, GLenum pname, const GLint* params) = NULL;
+static void       (*_sym_glTexSubImage2D)                       (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) = NULL;
+static void       (*_sym_glUniform1f)                           (GLint location, GLfloat x) = NULL;
+static void       (*_sym_glUniform1fv)                          (GLint location, GLsizei count, const GLfloat* v) = NULL;
+static void       (*_sym_glUniform1i)                           (GLint location, GLint x) = NULL;
+static void       (*_sym_glUniform1iv)                          (GLint location, GLsizei count, const GLint* v) = NULL;
+static void       (*_sym_glUniform2f)                           (GLint location, GLfloat x, GLfloat y) = NULL;
+static void       (*_sym_glUniform2fv)                          (GLint location, GLsizei count, const GLfloat* v) = NULL;
+static void       (*_sym_glUniform2i)                           (GLint location, GLint x, GLint y) = NULL;
+static void       (*_sym_glUniform2iv)                          (GLint location, GLsizei count, const GLint* v) = NULL;
+static void       (*_sym_glUniform3f)                           (GLint location, GLfloat x, GLfloat y, GLfloat z) = NULL;
+static void       (*_sym_glUniform3fv)                          (GLint location, GLsizei count, const GLfloat* v) = NULL;
+static void       (*_sym_glUniform3i)                           (GLint location, GLint x, GLint y, GLint z) = NULL;
+static void       (*_sym_glUniform3iv)                          (GLint location, GLsizei count, const GLint* v) = NULL;
+static void       (*_sym_glUniform4f)                           (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
+static void       (*_sym_glUniform4fv)                          (GLint location, GLsizei count, const GLfloat* v) = NULL;
+static void       (*_sym_glUniform4i)                           (GLint location, GLint x, GLint y, GLint z, GLint w) = NULL;
+static void       (*_sym_glUniform4iv)                          (GLint location, GLsizei count, const GLint* v) = NULL;
+static void       (*_sym_glUniformMatrix2fv)                    (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
+static void       (*_sym_glUniformMatrix3fv)                    (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
+static void       (*_sym_glUniformMatrix4fv)                    (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
+static void       (*_sym_glUseProgram)                          (GLuint program) = NULL;
+static void       (*_sym_glValidateProgram)                     (GLuint program) = NULL;
+static void       (*_sym_glVertexAttrib1f)                      (GLuint indx, GLfloat x) = NULL;
+static void       (*_sym_glVertexAttrib1fv)                     (GLuint indx, const GLfloat* values) = NULL;
+static void       (*_sym_glVertexAttrib2f)                      (GLuint indx, GLfloat x, GLfloat y) = NULL;
+static void       (*_sym_glVertexAttrib2fv)                     (GLuint indx, const GLfloat* values) = NULL;
+static void       (*_sym_glVertexAttrib3f)                      (GLuint indx, GLfloat x, GLfloat y, GLfloat z) = NULL;
+static void       (*_sym_glVertexAttrib3fv)                     (GLuint indx, const GLfloat* values) = NULL;
+static void       (*_sym_glVertexAttrib4f)                      (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
+static void       (*_sym_glVertexAttrib4fv)                     (GLuint indx, const GLfloat* values) = NULL;
+static void       (*_sym_glVertexAttribPointer)                 (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) = NULL;
+static void       (*_sym_glViewport)                            (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
+
+// GLES Extensions...
+static void       (*_sym_glGetProgramBinary)                    (GLuint a, GLsizei b, GLsizei* c, GLenum* d, void* e) = NULL;
+static void       (*_sym_glProgramBinary)                       (GLuint a, GLenum b, const void* c, GLint d) = NULL;
+static void       (*_sym_glProgramParameteri)                   (GLuint a, GLuint b, GLint d) = NULL;
+
+
+//------------------------------------------------------//
+// For internal fastpath
+static int
+init_context_states(EvasGlueContext ctx)
+{
+   int i;
+
+   if (!ctx)
+     {
+        ERR("Context NULL\n");
+        return 0;
+     }
+
+   // Set Magic and other inits
+   ctx->magic      = MAGIC_GLFAST;
+   ctx->first_time = 1;
+
+   //-------------------//
+   ctx->num_tex_units                          = MAX_TEXTURE_UNITS;
+   ctx->num_vertex_attribs                     = MAX_VERTEX_ATTRIBS;
+
+   //----------------------------------------//
+   // GL States
+   // Bind Functions
+   // glBind {Buffer, Framebuffer, Renderbuffer, Texture}
+   ctx->gl_array_buffer_binding                = 0;
+   ctx->gl_element_array_buffer_binding        = 0;
+   ctx->gl_framebuffer_binding                 = 0;
+   ctx->gl_renderbuffer_binding                = 0;
+
+   // Enable States
+   // glEnable()
+   ctx->gl_blend                               = GL_FALSE;
+   ctx->gl_cull_face                           = GL_FALSE;
+   ctx->gl_cull_face_mode                      = GL_FALSE;
+   ctx->gl_depth_test                          = GL_FALSE;
+   ctx->gl_dither                              = GL_TRUE;
+   ctx->gl_polygon_offset_fill                 = GL_FALSE;
+   ctx->gl_sample_alpha_to_coverage            = GL_FALSE;
+   ctx->gl_sample_coverage                     = GL_FALSE;
+   ctx->gl_scissor_test                        = GL_FALSE;
+   ctx->gl_stencil_test                        = GL_FALSE;
+
+   // Viewport - Set it to 0
+   ctx->gl_viewport[0]                         = 0;       // (0,0,w,h)
+   ctx->gl_viewport[1]                         = 0;       // (0,0,w,h)
+   ctx->gl_viewport[2]                         = 0;       // (0,0,w,h)
+   ctx->gl_viewport[3]                         = 0;       // (0,0,w,h)
+
+   // Program (Shaders)
+   ctx->gl_current_program                     = 0;
+
+   // Texture
+   //   ctx->tex_state[MAX_TEXTURE_UNITS]
+   ctx->gl_active_texture                      = GL_TEXTURE0;
+   ctx->gl_generate_mipmap_hint                = GL_DONT_CARE;
+   ctx->gl_texture_binding_2d                  = 0;
+   ctx->gl_texture_binding_cube_map            = 0;
+
+
+   // Clear Color
+   ctx->gl_color_clear_value[0]                = 0;
+   ctx->gl_color_clear_value[1]                = 0;
+   ctx->gl_color_clear_value[2]                = 0;
+   ctx->gl_color_clear_value[3]                = 0;
+   ctx->gl_color_writemask[0]                  = GL_TRUE;
+   ctx->gl_color_writemask[1]                  = GL_TRUE;
+   ctx->gl_color_writemask[2]                  = GL_TRUE;
+   ctx->gl_color_writemask[3]                  = GL_TRUE;
+
+   // Depth
+   ctx->gl_depth_range[0]                      = 0;
+   ctx->gl_depth_range[1]                      = 1;
+   ctx->gl_depth_clear_value                   = 1;
+   ctx->gl_depth_func                          = GL_LESS;
+   ctx->gl_depth_writemask                     = GL_TRUE;
+
+   // Blending
+   ctx->gl_blend_color[0]                      = 0;
+   ctx->gl_blend_color[1]                      = 0;
+   ctx->gl_blend_color[2]                      = 0;
+   ctx->gl_blend_color[3]                      = 0;
+   ctx->gl_blend_src_rgb                       = GL_ONE;
+   ctx->gl_blend_src_alpha                     = GL_ONE;
+   ctx->gl_blend_dst_rgb                       = GL_ZERO;
+   ctx->gl_blend_dst_alpha                     = GL_ZERO;
+   ctx->gl_blend_equation_rgb                  = GL_FUNC_ADD;
+   ctx->gl_blend_equation_alpha                = GL_FUNC_ADD;
+
+   // Stencil
+   ctx->gl_stencil_fail                        = GL_KEEP;
+   ctx->gl_stencil_func                        = GL_ALWAYS;
+   ctx->gl_stencil_pass_depth_fail             = GL_KEEP;
+   ctx->gl_stencil_pass_depth_pass             = GL_KEEP;
+   ctx->gl_stencil_ref                         = 0;
+   ctx->gl_stencil_value_mask                  = 0xffffffff;
+   ctx->gl_stencil_writemask                   = 0xffffffff;
+
+   ctx->gl_stencil_back_fail                   = GL_KEEP;
+   ctx->gl_stencil_back_func                   = GL_ALWAYS;
+   ctx->gl_stencil_back_depth_fail             = GL_KEEP;
+   ctx->gl_stencil_back_depth_pass             = GL_KEEP;
+   ctx->gl_stencil_back_ref                    = 0;
+   ctx->gl_stencil_back_value_mask             = 0xffffffff;
+   ctx->gl_stencil_back_writemask              = 0xffffffff;
+   ctx->gl_stencil_clear_value                 = 0;
+
+   // Misc.
+   ctx->gl_front_face                          = GL_CCW;
+   ctx->gl_line_width                          = 1;
+   ctx->gl_polygon_offset_factor               = 0;
+   ctx->gl_polygon_offset_units                = 0;
+
+   ctx->gl_sample_coverage_value               = 1.0;
+   ctx->gl_sample_coverage_invert              = GL_FALSE;
+   ctx->gl_scissor_box[0]                      = 0;
+   ctx->gl_scissor_box[1]                      = 0;
+   ctx->gl_scissor_box[2]                      = 0;      // Supposed to be w
+   ctx->gl_scissor_box[3]                      = 0;      // Supposed to be h
+
+   ctx->gl_pack_alignment                      = 4;
+   ctx->gl_unpack_alignment                    = 4;
+
+
+   // Vertex Attrib Array
+   for (i = 0; i < MAX_VERTEX_ATTRIBS; i++)
+     {
+        ctx->vertex_array[i].modified          = GL_FALSE;
+        ctx->vertex_array[i].enabled           = GL_FALSE;
+        ctx->vertex_array[i].size              = 0;
+        ctx->vertex_array[i].type              = GL_FLOAT;
+        ctx->vertex_array[i].normalized        = GL_FALSE;
+        ctx->vertex_array[i].stride            = GL_FALSE;
+        ctx->vertex_array[i].pointer           = NULL;
+     }
+
+   ctx->gl_current_vertex_attrib[0]            = 0;
+   ctx->gl_current_vertex_attrib[1]            = 0;
+   ctx->gl_current_vertex_attrib[2]            = 0;
+   ctx->gl_current_vertex_attrib[3]            = 1;
+
+   return 1;
+}
+
+static void
+make_context_current(EvasGlueContext oldctx, EvasGlueContext newctx)
+{
+   unsigned char flag = 0;
+   int i = 0;
+
+   // Return if they're the same
+   if (oldctx==newctx) return;
+
+#define STATE_COMPARE(state) \
+   if ((oldctx->state) != (newctx->state))
+#define STATES_COMPARE(state_ptr, bytes) \
+   if ((memcmp((oldctx->state_ptr), (newctx->state_ptr), (bytes))) != 0)
+
+   _sym_glFlush();
+
+   //------------------//
+   // _bind_flag
+   flag = oldctx->_bind_flag | newctx->_bind_flag;
+   if (flag)
+     {
+        STATE_COMPARE(gl_array_buffer_binding)
+          {
+             _sym_glBindBuffer(GL_ARRAY_BUFFER, newctx->gl_array_buffer_binding);
+          }
+        STATE_COMPARE(gl_element_array_buffer_binding)
+          {
+             _sym_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, newctx->gl_element_array_buffer_binding);
+          }
+        STATE_COMPARE(gl_framebuffer_binding)
+          {
+             _sym_glBindFramebuffer(GL_FRAMEBUFFER, newctx->gl_framebuffer_binding);
+          }
+        STATE_COMPARE(gl_renderbuffer_binding)
+          {
+             _sym_glBindRenderbuffer(GL_RENDERBUFFER, newctx->gl_renderbuffer_binding);
+          }
+     }
+
+   //------------------//
+   // Enable States
+   // _enable_flag1
+   flag = oldctx->_enable_flag1 | newctx->_enable_flag1;
+   if (flag)
+     {
+        STATE_COMPARE(gl_blend)
+          {
+             if (newctx->gl_blend)
+                _sym_glEnable(GL_BLEND);
+             else
+                _sym_glDisable(GL_BLEND);
+          }
+        STATE_COMPARE(gl_cull_face)
+          {
+             if (newctx->gl_cull_face)
+                _sym_glEnable(GL_CULL_FACE);
+             else
+                _sym_glDisable(GL_CULL_FACE);
+          }
+        STATE_COMPARE(gl_depth_test)
+          {
+             if (newctx->gl_depth_test)
+                _sym_glEnable(GL_DEPTH_TEST);
+             else
+                _sym_glDisable(GL_DEPTH_TEST);
+          }
+        STATE_COMPARE(gl_dither)
+          {
+             if (newctx->gl_dither)
+                _sym_glEnable(GL_DITHER);
+             else
+                _sym_glDisable(GL_DITHER);
+          }
+     }
+
+   // _enable_flag2
+   flag = oldctx->_enable_flag2 | newctx->_enable_flag2;
+   if (flag)
+     {
+        STATE_COMPARE(gl_polygon_offset_fill)
+          {
+             if (newctx->gl_polygon_offset_fill)
+                _sym_glEnable(GL_POLYGON_OFFSET_FILL);
+             else
+                _sym_glDisable(GL_POLYGON_OFFSET_FILL);
+          }
+        STATE_COMPARE(gl_sample_alpha_to_coverage)
+          {
+             if (newctx->gl_sample_alpha_to_coverage)
+                _sym_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+             else
+                _sym_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+          }
+        STATE_COMPARE(gl_sample_coverage)
+          {
+             if (newctx->gl_sample_coverage)
+                _sym_glEnable(GL_SAMPLE_COVERAGE);
+             else
+                _sym_glDisable(GL_SAMPLE_COVERAGE);
+          }
+        STATE_COMPARE(gl_scissor_test)
+          {
+             if (newctx->gl_scissor_test)
+                _sym_glEnable(GL_SCISSOR_TEST);
+             else
+                _sym_glDisable(GL_SCISSOR_TEST);
+          }
+        STATE_COMPARE(gl_stencil_test)
+          {
+             if (newctx->gl_stencil_test)
+                _sym_glEnable(GL_STENCIL_TEST);
+             else
+                _sym_glDisable(GL_STENCIL_TEST);
+          }
+     }
+
+   //------------------//
+   // _clear_flag1
+   flag = oldctx->_clear_flag1 | newctx->_clear_flag1;
+   if (flag)
+     {
+        // Viewport.
+        STATES_COMPARE(gl_viewport, 4*sizeof(GLint))
+          {
+             _sym_glViewport(newctx->gl_viewport[0],
+                             newctx->gl_viewport[1],
+                             newctx->gl_viewport[2],
+                             newctx->gl_viewport[3]);
+          }
+        STATE_COMPARE(gl_current_program)
+          {
+             _sym_glUseProgram(newctx->gl_current_program);
+          }
+        STATES_COMPARE(gl_color_clear_value, 4*sizeof(GLclampf))
+          {
+             _sym_glClearColor(newctx->gl_color_clear_value[0],
+                               newctx->gl_color_clear_value[1],
+                               newctx->gl_color_clear_value[2],
+                               newctx->gl_color_clear_value[3]);
+          }
+     }
+
+
+   // _clear_flag2
+   flag = oldctx->_clear_flag2 | newctx->_clear_flag2;
+   if (flag)
+     {
+        STATES_COMPARE(gl_color_writemask, 4*sizeof(GLboolean))
+          {
+             _sym_glColorMask(newctx->gl_color_writemask[0],
+                              newctx->gl_color_writemask[1],
+                              newctx->gl_color_writemask[2],
+                              newctx->gl_color_writemask[3]);
+          }
+        STATES_COMPARE(gl_depth_range, 2*sizeof(GLclampf))
+          {
+             _sym_glDepthRangef(newctx->gl_depth_range[0],
+                                newctx->gl_depth_range[1]);
+          }
+        STATE_COMPARE(gl_depth_clear_value)
+          {
+             _sym_glClearDepthf(newctx->gl_depth_clear_value);
+          }
+        STATE_COMPARE(gl_depth_func)
+          {
+             _sym_glDepthFunc(newctx->gl_depth_func);
+          }
+        STATE_COMPARE(gl_depth_writemask)
+          {
+             _sym_glDepthMask(newctx->gl_depth_writemask);
+          }
+        STATE_COMPARE(gl_cull_face_mode)
+          {
+             _sym_glCullFace(oldctx->gl_cull_face_mode);
+          }
+
+     }
+   //------------------//
+   // Texture here...
+   flag = oldctx->_tex_flag1 | newctx->_tex_flag1;
+   if (flag)
+     {
+
+        for (i = 0; i < oldctx->num_tex_units; i++)
+          {
+             STATE_COMPARE(tex_state[i].tex_id)
+               {
+                  _sym_glActiveTexture(GL_TEXTURE0+i);
+                  _sym_glBindTexture(newctx->tex_state[i].tex_unit, newctx->tex_state[i].tex_id);
+               }
+          }
+
+        // Restore active texture
+        _sym_glActiveTexture(newctx->gl_active_texture);
+
+        STATE_COMPARE(gl_generate_mipmap_hint)
+          {
+             _sym_glHint(GL_GENERATE_MIPMAP_HINT, newctx->gl_generate_mipmap_hint);
+          }
+        /*
+        STATE_COMPARE(gl_texture_binding_2d)
+          {
+             _sym_glBindTexture(GL_TEXTURE_2D, newctx->gl_texture_binding_2d);
+          }
+        STATE_COMPARE(gl_texture_binding_cube_map)
+          {
+             _sym_glBindTexture(GL_TEXTURE_CUBE_MAP, newctx->gl_texture_binding_cube_map);
+          }
+          */
+     }
+
+
+   //------------------//
+   flag = oldctx->_blend_flag | newctx->_blend_flag;
+   if (flag)
+     {
+        STATES_COMPARE(gl_blend_color, 4*sizeof(GLclampf))
+          {
+             _sym_glBlendColor(newctx->gl_blend_color[0],
+                               newctx->gl_blend_color[1],
+                               newctx->gl_blend_color[2],
+                               newctx->gl_blend_color[3]);
+          }
+        if ((oldctx->gl_blend_src_rgb != newctx->gl_blend_src_rgb) ||
+            (oldctx->gl_blend_dst_rgb != newctx->gl_blend_dst_rgb) ||
+            (oldctx->gl_blend_src_alpha != newctx->gl_blend_src_alpha) ||
+            (oldctx->gl_blend_dst_alpha != newctx->gl_blend_dst_alpha))
+          {
+             _sym_glBlendFuncSeparate(newctx->gl_blend_src_rgb,
+                                      newctx->gl_blend_dst_rgb,
+                                      newctx->gl_blend_src_alpha,
+                                      newctx->gl_blend_dst_alpha);
+          }
+        if ((oldctx->gl_blend_equation_rgb != newctx->gl_blend_equation_rgb) ||
+            (oldctx->gl_blend_equation_alpha != newctx->gl_blend_equation_alpha))
+          {
+             _sym_glBlendEquationSeparate(newctx->gl_blend_equation_rgb, newctx->gl_blend_equation_alpha);
+          }
+
+     }
+
+   //------------------//
+   // _stencil_flag1
+   flag = oldctx->_stencil_flag1 | newctx->_stencil_flag1;
+   if (flag)
+     {
+        if ((oldctx->gl_stencil_func != newctx->gl_stencil_func) ||
+            (oldctx->gl_stencil_ref  != newctx->gl_stencil_ref)  ||
+            (oldctx->gl_stencil_value_mask != newctx->gl_stencil_value_mask))
+          {
+             _sym_glStencilFuncSeparate(GL_FRONT,
+                                        newctx->gl_stencil_func,
+                                        newctx->gl_stencil_ref,
+                                        newctx->gl_stencil_value_mask);
+          }
+        if ((oldctx->gl_stencil_fail != newctx->gl_stencil_fail) ||
+            (oldctx->gl_stencil_pass_depth_fail != newctx->gl_stencil_pass_depth_fail) ||
+            (oldctx->gl_stencil_pass_depth_pass != newctx->gl_stencil_pass_depth_pass))
+          {
+             _sym_glStencilOpSeparate(GL_FRONT,
+                                      newctx->gl_stencil_fail,
+                                      newctx->gl_stencil_pass_depth_fail,
+                                      newctx->gl_stencil_pass_depth_pass);
+          }
+        STATE_COMPARE(gl_stencil_writemask)
+          {
+             _sym_glStencilMaskSeparate(GL_FRONT, newctx->gl_stencil_writemask);
+          }
+     }
+
+
+   // _stencil_flag1
+   flag = oldctx->_stencil_flag2 | newctx->_stencil_flag2;
+   if (flag)
+     {
+        if ((oldctx->gl_stencil_back_func != newctx->gl_stencil_back_func) ||
+            (oldctx->gl_stencil_back_ref  != newctx->gl_stencil_back_ref)  ||
+            (oldctx->gl_stencil_back_depth_pass != newctx->gl_stencil_back_depth_pass))
+          {
+             _sym_glStencilFuncSeparate(GL_BACK,
+                                        newctx->gl_stencil_back_func,
+                                        newctx->gl_stencil_back_ref,
+                                        newctx->gl_stencil_back_value_mask);
+          }
+        if ((oldctx->gl_stencil_back_fail != newctx->gl_stencil_back_fail) ||
+            (oldctx->gl_stencil_back_depth_fail != newctx->gl_stencil_back_depth_fail) ||
+            (oldctx->gl_stencil_back_depth_pass != newctx->gl_stencil_back_depth_pass))
+          {
+             _sym_glStencilOpSeparate(GL_BACK,
+                                      newctx->gl_stencil_back_fail,
+                                      newctx->gl_stencil_back_depth_fail,
+                                      newctx->gl_stencil_back_depth_pass);
+          }
+        STATE_COMPARE(gl_stencil_back_writemask)
+          {
+             _sym_glStencilMaskSeparate(GL_BACK, newctx->gl_stencil_back_writemask);
+          }
+        STATE_COMPARE(gl_stencil_clear_value)
+          {
+             _sym_glClearStencil(newctx->gl_stencil_clear_value);
+          }
+     }
+
+   //------------------//
+   // _misc_flag1
+   flag = oldctx->_misc_flag1 | newctx->_misc_flag1;
+   if (flag)
+     {
+        STATE_COMPARE(gl_front_face)
+          {
+             _sym_glFrontFace(newctx->gl_front_face);
+          }
+        STATE_COMPARE(gl_line_width)
+          {
+             _sym_glLineWidth(newctx->gl_line_width);
+          }
+        if ((oldctx->gl_polygon_offset_factor != newctx->gl_polygon_offset_factor) ||
+            (oldctx->gl_polygon_offset_units  != newctx->gl_polygon_offset_units))
+          {
+             _sym_glPolygonOffset(newctx->gl_polygon_offset_factor,
+                                  newctx->gl_polygon_offset_units);
+          }
+        if ((oldctx->gl_sample_coverage_value  != newctx->gl_sample_coverage_value) ||
+            (oldctx->gl_sample_coverage_invert != newctx->gl_sample_coverage_invert))
+          {
+             _sym_glSampleCoverage(newctx->gl_sample_coverage_value,
+                                   newctx->gl_sample_coverage_invert);
+          }
+     }
+
+   // _misc_flag2
+   flag = oldctx->_misc_flag2 | newctx->_misc_flag2;
+   if (flag)
+     {
+        STATES_COMPARE(gl_scissor_box, 4*sizeof(GLint))
+          {
+             _sym_glScissor(newctx->gl_scissor_box[0],
+                            newctx->gl_scissor_box[1],
+                            newctx->gl_scissor_box[2],
+                            newctx->gl_scissor_box[3]);
+          }
+        STATE_COMPARE(gl_pack_alignment)
+          {
+             _sym_glPixelStorei(GL_PACK_ALIGNMENT, newctx->gl_pack_alignment);
+          }
+        STATE_COMPARE(gl_unpack_alignment)
+          {
+             _sym_glPixelStorei(GL_UNPACK_ALIGNMENT, newctx->gl_unpack_alignment);
+          }
+     }
+
+   // _varray_flag
+   flag = oldctx->_varray_flag | newctx->_varray_flag;
+   if (flag)
+     {
+        for (i = 0; i < MAX_VERTEX_ATTRIBS; i++)
+          {
+             // If both untouched, don't bother
+             if ((oldctx->vertex_array[i].modified == GL_FALSE) &&
+                 (newctx->vertex_array[i].modified == GL_FALSE))
+                continue;
+             _sym_glVertexAttribPointer(i,
+                                        newctx->vertex_array[i].size,
+                                        newctx->vertex_array[i].type,
+                                        newctx->vertex_array[i].normalized,
+                                        newctx->vertex_array[i].stride,
+                                        newctx->vertex_array[i].pointer);
+
+             if (newctx->vertex_array[i].enabled == GL_TRUE)
+                _sym_glEnableVertexAttribArray(i);
+             else
+                _sym_glDisableVertexAttribArray(i);
+          }
+     }
+#undef STATE_COMPARE
+#undef STATES_COMPARE
+}
+//----------------------------------------------------------------//
+//                                                                //
+//                      Wrapped Glue Functions                    //
+//                                                                //
+//----------------------------------------------------------------//
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+
+//----------------------------------------------------------------//
+//                      Wrapped EGL Functions                     //
+//----------------------------------------------------------------//
+static _eng_fn
+evgl_eglGetProcAddress(const char* procname)
+{
+   return _sym_eglGetProcAddress(procname);
+}
+
+static EGLint
+evgl_eglGetError(void)
+{
+   return _sym_eglGetError();
+}
+
+static EGLDisplay
+evgl_eglGetDisplay(EGLNativeDisplayType display_id)
+{
+   return _sym_eglGetDisplay(display_id);
+}
+
+static EGLBoolean
+evgl_eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
+{
+   return _sym_eglInitialize(dpy, major, minor);
+}
+
+static EGLBoolean
+evgl_eglTerminate(EGLDisplay dpy)
+{
+   return _sym_eglTerminate(dpy);
+}
+
+static EGLBoolean
+evgl_eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config)
+{
+   return _sym_eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
+}
+
+static EGLSurface
+evgl_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list)
+{
+   return _sym_eglCreateWindowSurface(dpy, config, win, attrib_list);
+}
+
+static EGLSurface
+evgl_eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list)
+{
+   return _sym_eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
+}
+
+static EGLBoolean
+evgl_eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+{
+   return _sym_eglDestroySurface(dpy, surface);
+}
+
+static EGLBoolean
+evgl_eglBindAPI(EGLenum api)
+{
+   return _sym_eglBindAPI(api);
+}
+
+static EGLBoolean
+evgl_eglWaitClient(void)
+{
+   return _sym_eglWaitClient();
+}
+
+static EGLBoolean
+evgl_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+{
+   return _sym_eglSurfaceAttrib(dpy, surface, attribute, value);
+}
+
+static void
+evgl_eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+   _sym_eglBindTexImage(dpy, surface, buffer);
+}
+
+static EGLBoolean
+evgl_eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+   return _sym_eglReleaseTexImage(dpy, surface, buffer);
+}
+
+static EGLBoolean
+evgl_eglSwapInterval(EGLDisplay dpy, EGLint interval)
+{
+   return _sym_eglSwapInterval(dpy, interval);
+}
+
+static EGLContext
+evgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
+{
+   return _sym_eglCreateContext(dpy, config, share_context, attrib_list);
+}
+
+static EGLBoolean
+evgl_eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+   return _sym_eglDestroyContext(dpy, ctx);
+}
+
+static EGLBoolean
+evgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+   /*
+   if (_sym_eglMakeCurrent(dpy, draw, read, ctx))
+     {
+        current_egl_context = ctx;
+        current_surf = draw;
+        return EGL_TRUE;
+     }
+   else return EGL_FALSE;
+   */
+   return _sym_eglMakeCurrent(dpy, draw, read, ctx);
+}
+
+static EGLContext
+evgl_eglGetCurrentContext(void)
+{
+   //return current_egl_context;
+   return _sym_eglGetCurrentContext();
+}
+
+static EGLSurface
+evgl_eglGetCurrentSurface(EGLint readdraw)
+{
+   return _sym_eglGetCurrentSurface(readdraw);
+}
+
+static EGLDisplay
+evgl_eglGetCurrentDisplay(void)
+{
+   return _sym_eglGetCurrentDisplay();
+}
+
+static EGLBoolean
+evgl_eglWaitGL(void)
+{
+   return _sym_eglWaitGL();
+}
+
+static EGLBoolean
+evgl_eglWaitNative(EGLint engine)
+{
+   return _sym_eglWaitNative(engine);
+}
+
+static EGLBoolean
+evgl_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
+{
+   return _sym_eglSwapBuffers(dpy, surface);
+}
+
+static EGLBoolean
+evgl_eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+{
+   return _sym_eglCopyBuffers(dpy, surface, target);
+}
+
+static char const *
+evgl_eglQueryString(EGLDisplay dpy, EGLint name)
+{
+   return _sym_eglQueryString(dpy, name);
+}
+
+static void
+evgl_eglCreateImage (void *a, void *b, GLenum c, void *d, const int *e)
+{
+   _sym_eglCreateImage(a, b, c, d, e);
+}
+
+static unsigned int
+evgl_eglDestroyImage (void *a, void *b)
+{
+   return _sym_eglDestroyImage(a, b);
+}
+
+static void
+evgl_glEGLImageTargetTexture2DOES (int a, void *b)
+{
+   _sym_glEGLImageTargetTexture2DOES(a, b);
+}
+
+static void
+evgl_glEGLImageTargetRenderbufferStorageOES (int a, void *b)
+{
+   _sym_glEGLImageTargetRenderbufferStorageOES(a, b);
+}
+
+static void *
+evgl_eglMapImageSEC (void *a, void *b)
+{
+   _sym_eglMapImageSEC(a, b);
+}
+
+static unsigned int
+evgl_eglUnmapImageSEC (void *a, void *b)
+{
+   return _sym_eglUnmapImageSEC(a, b);
+}
+
+static unsigned int
+evgl_eglGetImageAttribSEC (void *a, void *b, int c, int *d)
+{
+   return _sym_eglGetImageAttribSEC(a, b, c, d);
+}
+//----------------------------------------------------------------//
+//                   Fastpath EGL Functions                       //
+//    The functions have prefix 'fpgl_' for (fastpath gl)         //
+//----------------------------------------------------------------//
+static EGLContext
+fpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
+{
+   EvasGlueContext ctx;
+
+   // Create a global context if it hasn't been created
+   if (!global_ctx)
+     {
+        global_dpy = dpy;
+        // Create a global context if it hasn't been created yet
+        global_ctx = _sym_eglCreateContext(dpy, config, NULL, attrib_list);
+
+        if (!global_ctx)
+          {
+             ERR("Failed creating a glX global context for FastPath.\n");
+             return 0;
+          }
+     }
+
+
+   // Allocate a new context
+   ctx = calloc(1, sizeof(struct _EvasGlueContext));
+   if (!ctx)
+     {
+        ERR("Error creating a new EvasGlueContext.\n");
+        return NULL;
+     }
+
+   // Initialize context states
+   if (!init_context_states(ctx))
+     {
+        ERR("Error intialing intial context\n");
+        free(ctx);
+        return NULL;
+     }
+
+   ctx_ref_count++;
+
+   return (EGLContext)ctx;
+}
+
+static EGLBoolean
+fpgl_eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+   EvasGlueContext ectx = (EvasGlueContext)ctx;
+
+   if (ctx!=NULL)
+     {
+        if (ectx->magic != MAGIC_GLFAST)
+          {
+             ERR("Magic Check Failed!!!\n");
+             return EGL_FALSE;
+          }
+
+        if (ectx == current_ctx)
+          {
+             DBG("Destroying current context... %d\n", ctx_ref_count);
+             real_current_ctx = current_ctx;
+             current_ctx = NULL;
+          }
+
+        if (ectx)
+           free(ectx);
+
+        if (!(--ctx_ref_count))
+          {
+             DBG("Destroying the global context...\n");
+             _sym_eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+             _sym_eglDestroyContext(dpy, global_ctx);
+             global_ctx = NULL;
+             current_ctx = NULL;
+             real_current_ctx = NULL;
+          }
+
+        return EGL_TRUE;
+     }
+   else
+     {
+        ERR("Invalid Context.\n");
+        return EGL_FALSE;
+     }
+
+}
+
+static EGLBoolean
+fpgl_eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+{
+   // Do a Make Current NULL  (This is to unreference the currently bound surface)
+   if (!_sym_eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT))
+     {
+        ERR("Error making context current with the drawable.\n");
+        return EGL_FALSE;
+     }
+
+   if (current_ctx)
+      real_current_ctx = current_ctx;
+
+   current_ctx = NULL;
+   current_surf = EGL_NO_SURFACE;
+
+   return _sym_eglDestroySurface(dpy, surface);
+}
+
+
+static EGLBoolean
+fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+   EvasGlueContext ectx = (EvasGlueContext)ctx;
+
+   // Check if the values are null
+   if ((draw == EGL_NO_SURFACE) || (ctx == NULL))
+     {
+        if (current_ctx)
+          {
+             real_current_ctx = current_ctx;
+          }
+
+        /*
+        if (!_sym_eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT))
+          {
+             ERR("Error making context current with the drawable.\n");
+             return EGL_FALSE;
+          }
+          */
+
+        current_ctx = NULL;
+        current_surf = EGL_NO_SURFACE;
+
+        return EGL_TRUE;
+     }
+
+   // Check if the object is correct
+   if (ectx->magic != MAGIC_GLFAST)
+     {
+        ERR("Magic Check Failed!!!\n");
+        return EGL_FALSE;
+     }
+
+
+   // If it's a first time or drawable changed, do a make current
+   if (!global_ctx_initted)
+     {
+        if (!_sym_eglMakeCurrent(dpy, draw, read, global_ctx))
+          {
+             ERR("Error making context current with the drawable.\n");
+             return False;
+          }
+
+        current_ctx      = ectx;
+        current_surf     = draw;
+        real_current_ctx = current_ctx;
+
+        global_ctx_initted = 1;
+     }
+
+
+   if (!current_ctx) current_ctx = real_current_ctx;
+
+   // If drawable changed, do a make current
+   if (current_surf != draw)
+     {
+        if (!_sym_eglMakeCurrent(dpy, draw, read, global_ctx))
+          {
+             ERR("Error making context current with the drawable.\n");
+             return False;
+          }
+        current_surf = draw;
+     }
+
+   // If it's first time...
+   if (ectx->first_time == 1)
+     {
+        // FIXME!!!:
+        // Actually, i need to query the drawable size...
+        // Do some initializations that required make_current
+        _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &ectx->num_tex_units);
+        _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &ectx->num_vertex_attribs);
+        _sym_glGetIntegerv(GL_VIEWPORT, ectx->gl_viewport);
+        _sym_glGetIntegerv(GL_SCISSOR_BOX, ectx->gl_scissor_box);
+        DBG("----Num Tex Units: %d, Num Vertex Attribs: %d \n", ectx->num_tex_units, ectx->num_vertex_attribs);
+
+        ectx->first_time = 0;
+     }
+
+   // if context is same, return
+   if ( (current_ctx == ectx) && (current_surf == draw) )
+     {
+        return EGL_TRUE;
+     }
+
+   make_context_current(current_ctx, ectx);
+
+   current_ctx = ectx;
+   current_surf = draw;
+
+   return EGL_TRUE;
+}
+
+static EGLContext
+fpgl_eglGetCurrentContext(void)
+{
+   return (EGLContext)current_ctx;
+   //return _sym_eglGetCurrentContext();
+}
+
+static EGLSurface
+fpgl_eglGetCurrentSurface(EGLint readdraw)
+{
+   return current_surf;
+   //return _sym_eglGetCurrentSurface(readdraw);
+}
+
+// FIXME!!!!
+static void
+fvgl_glEGLImageTargetTexture2DOES (int a, void *b)
+{
+   _sym_glEGLImageTargetTexture2DOES(a, b);
+}
+
+// FIXME!!!!
+static void
+fvgl_glEGLImageTargetRenderbufferStorageOES (int a, void *b)
+{
+   _sym_glEGLImageTargetRenderbufferStorageOES(a, b);
+}
+
+
+#else
+
+//----------------------------------------------------------------//
+//                      Wrapped GLX Functions                     //
+//----------------------------------------------------------------//
+static _eng_fn
+evgl_glXGetProcAddress(const char* procName)
+{
+   return _sym_glXGetProcAddress(procName);
+}
+
+static XVisualInfo*
+evgl_glXChooseVisual(Display* dpy, int screen, int* attribList)
+{
+   return _sym_glXChooseVisual(dpy, screen, attribList);
+}
+
+static GLXContext
+evgl_glXCreateContext(Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct)
+{
+   return _sym_glXCreateContext(dpy, vis, shareList, direct);
+}
+
+static void
+evgl_glXDestroyContext(Display* dpy, GLXContext ctx)
+{
+   _sym_glXDestroyContext(dpy, ctx);
+}
+
+static GLXContext
+evgl_glXGetCurrentContext(void)
+{
+   return _sym_glXGetCurrentContext();
+}
+
+static GLXDrawable
+evgl_glXGetCurrentDrawable(void)
+{
+   return _sym_glXGetCurrentDrawable();
+}
+
+
+static Bool
+evgl_glXMakeCurrent(Display* dpy, GLXDrawable draw, GLXContext ctx)
+{
+   return _sym_glXMakeCurrent(dpy, draw, ctx);
+}
+
+static void
+evgl_glXSwapBuffers(Display* dpy, GLXDrawable draw)
+{
+   _sym_glXSwapBuffers(dpy, draw);
+}
+
+static void
+evgl_glXWaitX(void)
+{
+   _sym_glXWaitX();
+}
+
+static void
+evgl_glXWaitGL(void)
+{
+   _sym_glXWaitGL();
+}
+
+static Bool
+evgl_glXQueryExtension(Display* dpy, int* errorb, int* event)
+{
+   return _sym_glXQueryExtension(dpy, errorb, event);
+}
+
+static const char *
+evgl_glXQueryExtensionsString(Display *dpy, int screen)
+{
+   return _sym_glXQueryExtensionsString(dpy, screen);
+}
+
+static GLXFBConfig*
+evgl_glXChooseFBConfig(Display* dpy, int screen, const int* attribList, int* nitems)
+{
+   return _sym_glXChooseFBConfig(dpy, screen, attribList, nitems);
+}
+
+static GLXFBConfig*
+evgl_glXGetFBConfigs(Display* dpy, int screen, int* nelements)
+{
+   return _sym_glXGetFBConfigs(dpy, screen, nelements);
+}
+
+//!!!!! FIXME Called too many times
+static int
+evgl_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig config, int attribute, int* value)
+{
+   return _sym_glXGetFBConfigAttrib(dpy, config, attribute, value);
+}
+
+//!!!!! FIXME Called too many times
+static XVisualInfo*
+evgl_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig config)
+{
+   return _sym_glXGetVisualFromFBConfig(dpy, config);
+}
+
+static void
+evgl_glXDestroyWindow(Display* dpy, GLXWindow window)
+{
+   _sym_glXDestroyWindow(dpy, window);
+}
+
+static Bool
+evgl_glXMakeContextCurrent(Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+{
+   return _sym_glXMakeContextCurrent(dpy, draw, read, ctx);
+}
+
+static void
+evgl_glXBindTexImage(Display* dpy, GLXDrawable draw, int buffer, int* attribList)
+{
+   _sym_glXBindTexImage(dpy, draw, buffer, attribList);
+}
+
+static void
+evgl_glXReleaseTexImage(Display* dpy, GLXDrawable draw, int buffer)
+{
+   _sym_glXReleaseTexImage(dpy, draw, buffer);
+}
+
+static int
+evgl_glXGetVideoSync(unsigned int* count)
+{
+   return _sym_glXGetVideoSync(count);
+}
+
+static int
+evgl_glXWaitVideoSync(int divisor, int remainder, unsigned int* count)
+{
+   return _sym_glXWaitVideoSync(divisor, remainder, count);
+}
+
+static XID
+evgl_glXCreatePixmap(Display* dpy, void* config, Pixmap pixmap, const int* attribList)
+{
+   return _sym_glXCreatePixmap(dpy, config, pixmap, attribList);
+}
+
+static void
+evgl_glXDestroyPixmap(Display* dpy, XID pixmap)
+{
+   _sym_glXDestroyPixmap(dpy, pixmap);
+}
+
+static void
+evgl_glXQueryDrawable(Display* dpy, XID draw, int attribute, unsigned int* value)
+{
+   _sym_glXQueryDrawable(dpy, draw, attribute, value);
+}
+
+static int
+evgl_glXSwapIntervalSGI(int interval)
+{
+   return _sym_glXSwapIntervalSGI(interval);
+}
+
+static void
+evgl_glXSwapIntervalEXT(Display* dpy, GLXDrawable draw, int interval)
+{
+   _sym_glXSwapIntervalEXT(dpy, draw, interval);
+}
+
+
+//----------------------------------------------------------------//
+//                   Fastpath GLX Functions                       //
+//       The functions have prefix 'fpgl_' for (fastpath gl)      //
+//----------------------------------------------------------------//
+static GLXContext
+fpgl_glXCreateContext(Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct)
+{
+   EvasGlueContext ctx;
+
+   // Create a global context if it hasn't been created
+   if (!global_ctx)
+     {
+        global_dpy = dpy;
+        // Create a global context if it hasn't been created yet
+        global_ctx = _sym_glXCreateContext(dpy, vis, NULL, 1);
+        if (!global_ctx)
+          {
+             ERR("Failed creating a glX global context for FastPath.\n");
+             return 0;
+          }
+        ctx_ref_count++;
+     }
+
+   // Allocate a new context
+   ctx = calloc(1, sizeof(struct _EvasGlueContext));
+   if (!ctx)
+     {
+        ERR("Error creating a new EvasGlueContext.\n");
+        return NULL;
+     }
+
+   if (!init_context_states(ctx))
+     {
+        ERR("Error intialing intial context\n");
+        free(ctx);
+        return NULL;
+     }
+
+   ctx_ref_count++;
+
+   return (GLXContext)ctx;
+
+}
+
+static void
+fpgl_glXDestroyContext(Display* dpy, GLXContext ctx)
+{
+   EvasGlueContext ectx = (EvasGlueContext)ctx;
+
+   if (ctx!=NULL)
+     {
+        if (ectx->magic != MAGIC_GLFAST)
+          {
+             ERR("Magic Check Failed!!!\n");
+             return;
+          }
+
+        if (ectx == current_ctx)
+          {
+             DBG("Destroying current context... %d\n", ctx_ref_count);
+             real_current_ctx = current_ctx;
+             current_ctx = NULL;
+          }
+
+        if (ectx)
+           free(ectx);
+
+        if (!(--ctx_ref_count))
+          {
+             DBG("Destroying the global context...\n");
+             _sym_glXDestroyContext(dpy, global_ctx);
+             global_ctx = NULL;
+             current_ctx = NULL;
+             real_current_ctx = NULL;
+          }
+     }
+}
+
+
+static GLXContext
+fpgl_glXGetCurrentContext(void)
+{
+   return (GLXContext)current_ctx;
+}
+
+static GLXDrawable
+fpgl_glXGetCurrentDrawable(void)
+{
+   //return _sym_glXGetCurrentDrawable();
+   return (GLXDrawable)current_surf;
+}
+
+
+static Bool
+fpgl_glXMakeCurrent(Display* dpy, GLXDrawable draw, GLXContext ctx)
+{
+   EvasGlueContext ectx = (EvasGlueContext)ctx;
+
+   // Check if the values are null
+   if ((draw == None) || (ctx == NULL))
+     {
+        if (current_ctx)
+           real_current_ctx = current_ctx;
+
+        /*
+        if (!_sym_glXMakeCurrent(dpy, None, NULL))
+          {
+             ERR("Error making context current with the drawable.\n");
+             return False;
+          }
+          */
+
+        current_ctx = NULL;
+        current_surf = None;
+
+        return 1;
+     }
+
+   // Check if the object is correct
+   if (ectx->magic != MAGIC_GLFAST)
+     {
+        ERR("Magic Check Failed!!!\n");
+        return 0;
+     }
+
+
+   // If it's the first time
+   if (!global_ctx_initted)
+     {
+        if (!_sym_glXMakeCurrent(dpy, draw, global_ctx))
+          {
+             ERR("Error making context current with the drawable.\n");
+             return False;
+          }
+
+        current_ctx  = ectx;
+        current_surf = draw;
+
+        real_current_ctx = current_ctx;
+
+        global_ctx_initted = 1;
+     }
+
+
+   if (!current_ctx) current_ctx = real_current_ctx;
+
+   // If drawable changed, do a make current
+   if (current_surf != draw)
+     {
+        if (!_sym_glXMakeCurrent(dpy, draw, global_ctx))
+          {
+             ERR("Error making context current with the drawable.\n");
+             return False;
+          }
+        current_surf = draw;
+     }
+
+   // If it's first time...
+   if (ectx->first_time == 1)
+     {
+        // FIXME!!!:
+        // Actually, i need to query the drawable size...
+        // Do some initializations that required make_current
+        _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &ectx->num_tex_units);
+        _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &ectx->num_vertex_attribs);
+        _sym_glGetIntegerv(GL_VIEWPORT, ectx->gl_viewport);
+        _sym_glGetIntegerv(GL_SCISSOR_BOX, ectx->gl_scissor_box);
+        DBG("----Num Tex Units: %d, Num Vertex Attribs: %d \n", ectx->num_tex_units, ectx->num_vertex_attribs);
+
+        ectx->first_time = 0;
+     }
+
+   // if context is same, return
+   if ( (current_ctx == ectx) && (current_surf == draw) )
+     {
+        return True;
+     }
+
+   make_context_current(current_ctx, ectx);
+
+   current_ctx = ectx;
+   current_surf = draw;
+
+   return True;
+}
+
+static Bool
+fpgl_glXMakeContextCurrent(Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+{
+   ERR("NOT IMPLEMENTED YET!!! GLX Function Wrapped. Not fastpathed yet...\n");
+   return _sym_glXMakeContextCurrent(dpy, draw, read, ctx);
+}
+
+
+#endif // (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+
+
+
+//----------------------------------------------------------------//
+//                                                                //
+//                      Wrapped GL Functions                      //
+//                                                                //
+//----------------------------------------------------------------//
+
+static void
+evgl_glActiveTexture(GLenum texture)
+{
+   _sym_glActiveTexture(texture);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glAttachShader(GLuint program, GLuint shader)
+{
+   _sym_glAttachShader(program, shader);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBindAttribLocation(GLuint program, GLuint index, const char* name)
+{
+   _sym_glBindAttribLocation(program, index, name);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBindBuffer(GLenum target, GLuint buffer)
+{
+   _sym_glBindBuffer(target, buffer);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
+{
+   _sym_glBindFramebuffer(target, framebuffer);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+   _sym_glBindRenderbuffer(target, renderbuffer);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBindTexture(GLenum target, GLuint texture)
+{
+   _sym_glBindTexture(target, texture);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+   _sym_glBlendColor(red, green, blue, alpha);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBlendEquation(GLenum mode)
+{
+   _sym_glBlendEquation(mode);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+   _sym_glBlendEquationSeparate(modeRGB, modeAlpha);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+   _sym_glBlendFunc(sfactor, dfactor);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+   _sym_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
+{
+   _sym_glBufferData(target, size, data, usage);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
+{
+   _sym_glBufferSubData(target, offset, size, data);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static GLenum
+evgl_glCheckFramebufferStatus(GLenum target)
+{
+   GLenum result;
+
+   result = _sym_glCheckFramebufferStatus(target);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return result;
+}
+
+static void
+evgl_glClear(GLbitfield mask)
+{
+   _sym_glClear(mask);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+   _sym_glClearColor(red, green, blue, alpha);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glClearDepthf(GLclampf depth)
+{
+   _sym_glClearDepthf(depth);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glClearStencil(GLint s)
+{
+   _sym_glClearStencil(s);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+   _sym_glColorMask(red, green, blue, alpha);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glCompileShader(GLuint shader)
+{
+   _sym_glCompileShader(shader);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
+{
+   _sym_glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
+{
+   _sym_glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+   _sym_glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   _sym_glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static GLuint
+evgl_glCreateProgram(void)
+{
+   GLuint program;
+
+   program = _sym_glCreateProgram();
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return program;
+}
+
+static GLuint
+evgl_glCreateShader(GLenum type)
+{
+   GLuint shader;
+
+   shader = _sym_glCreateShader(type);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return shader;
+}
+
+static void
+evgl_glCullFace(GLenum mode)
+{
+   _sym_glCullFace(mode);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDeleteBuffers(GLsizei n, const GLuint* buffers)
+{
+   _sym_glDeleteBuffers(n, buffers);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+{
+   _sym_glDeleteFramebuffers(n, framebuffers);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDeleteProgram(GLuint program)
+{
+   _sym_glDeleteProgram(program);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+{
+   _sym_glDeleteRenderbuffers(n, renderbuffers);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDeleteShader(GLuint shader)
+{
+   _sym_glDeleteShader(shader);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDeleteTextures(GLsizei n, const GLuint* textures)
+{
+   _sym_glDeleteTextures(n, textures);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDepthFunc(GLenum func)
+{
+   _sym_glDepthFunc(func);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDepthMask(GLboolean flag)
+{
+   _sym_glDepthMask(flag);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
+{
+   _sym_glDepthRangef(zNear, zFar);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDetachShader(GLuint program, GLuint shader)
+{
+   _sym_glDetachShader(program, shader);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDisable(GLenum cap)
+{
+   _sym_glDisable(cap);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDisableVertexAttribArray(GLuint index)
+{
+   _sym_glDisableVertexAttribArray(index);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+   _sym_glDrawArrays(mode, first, count);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
+{
+   _sym_glDrawElements(mode, count, type, indices);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glEnable(GLenum cap)
+{
+   _sym_glEnable(cap);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glEnableVertexAttribArray(GLuint index)
+{
+   _sym_glEnableVertexAttribArray(index);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glFinish(void)
+{
+   _sym_glFinish();
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glFlush(void)
+{
+   _sym_glFlush();
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+   _sym_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+   _sym_glFramebufferTexture2D(target, attachment, textarget, texture, level);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glFrontFace(GLenum mode)
+{
+   _sym_glFrontFace(mode);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+{
+   _sym_glGetVertexAttribfv(index, pname, params);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+{
+   _sym_glGetVertexAttribiv(index, pname, params);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
+{
+   _sym_glGetVertexAttribPointerv(index, pname, pointer);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+}
+
+static void
+evgl_glHint(GLenum target, GLenum mode)
+{
+   _sym_glHint(target, mode);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   if (target == GL_GENERATE_MIPMAP_HINT)
+     {
+        current_ctx->_tex_flag1 |= FLAG_BIT_2;
+        current_ctx->gl_generate_mipmap_hint = mode;
+     }
+}
+
+static void
+evgl_glGenBuffers(GLsizei n, GLuint* buffers)
+{
+   _sym_glGenBuffers(n, buffers);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGenerateMipmap(GLenum target)
+{
+   _sym_glGenerateMipmap(target);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGenFramebuffers(GLsizei n, GLuint* framebuffers)
+{
+   _sym_glGenFramebuffers(n, framebuffers);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+{
+   _sym_glGenRenderbuffers(n, renderbuffers);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGenTextures(GLsizei n, GLuint* textures)
+{
+   _sym_glGenTextures(n, textures);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+{
+   _sym_glGetActiveAttrib(program, index, bufsize, length, size, type, name);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+{
+   _sym_glGetActiveUniform(program, index, bufsize, length, size, type, name);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+{
+   _sym_glGetAttachedShaders(program, maxcount, count, shaders);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static int
+evgl_glGetAttribLocation(GLuint program, const char* name)
+{
+   int location;
+
+   location = _sym_glGetAttribLocation(program, name);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return location;
+}
+
+static void
+evgl_glGetBooleanv(GLenum pname, GLboolean* params)
+{
+   _sym_glGetBooleanv(pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+   _sym_glGetBufferParameteriv(target, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static GLenum
+evgl_glGetError(void)
+{
+   return _sym_glGetError();
+}
+
+static void
+evgl_glGetFloatv(GLenum pname, GLfloat* params)
+{
+   _sym_glGetFloatv(pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+   _sym_glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetIntegerv(GLenum pname, GLint* params)
+{
+   _sym_glGetIntegerv(pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetProgramiv(GLuint program, GLenum pname, GLint* params)
+{
+   _sym_glGetProgramiv(program, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
+{
+   _sym_glGetProgramInfoLog(program, bufsize, length, infolog);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+   _sym_glGetRenderbufferParameteriv(target, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
+{
+   _sym_glGetShaderiv(shader, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
+{
+   _sym_glGetShaderInfoLog(shader, bufsize, length, infolog);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+{
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+   _sym_glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+#else
+   if (range)
+     {
+        range[0] = -126; // floor(log2(FLT_MIN))
+        range[1] = 127; // floor(log2(FLT_MAX))
+     }
+   if (precision)
+     {
+        precision[0] = 24; // floor(-log2((1.0/16777218.0)));
+     }
+   return;
+   shadertype = precisiontype = 0;
+#endif
+
+}
+
+static void
+evgl_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
+{
+   _sym_glGetShaderSource(shader, bufsize, length, source);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static const GLubyte *
+evgl_glGetString(GLenum name)
+{
+   const GLubyte *str;
+
+   str =_sym_glGetString(name);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return str;
+}
+
+static void
+evgl_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
+{
+   _sym_glGetTexParameterfv(target, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+   _sym_glGetTexParameteriv(target, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetUniformfv(GLuint program, GLint location, GLfloat* params)
+{
+   _sym_glGetUniformfv(program, location, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glGetUniformiv(GLuint program, GLint location, GLint* params)
+{
+   _sym_glGetUniformiv(program, location, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+static int
+evgl_glGetUniformLocation(GLuint program, const char* name)
+{
+   int location;
+
+   location = _sym_glGetUniformLocation(program, name);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return location;
+}
+
+static GLboolean
+evgl_glIsBuffer(GLuint buffer)
+{
+   GLboolean result;
+
+   result =  _sym_glIsBuffer(buffer);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return result;
+}
+
+static GLboolean
+evgl_glIsEnabled(GLenum cap)
+{
+   GLboolean result;
+
+   result =  _sym_glIsEnabled(cap);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return result;
+}
+
+static GLboolean
+evgl_glIsFramebuffer(GLuint framebuffer)
+{
+   GLboolean result;
+
+   result = _sym_glIsFramebuffer(framebuffer);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return result;
+}
+
+static GLboolean
+evgl_glIsProgram(GLuint program)
+{
+   GLboolean result;
+
+   result =  _sym_glIsProgram(program);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return result;
+}
+
+static GLboolean
+evgl_glIsRenderbuffer(GLuint renderbuffer)
+{
+   GLboolean result;
+
+   result =  _sym_glIsRenderbuffer(renderbuffer);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return result;
+}
+
+static GLboolean
+evgl_glIsShader(GLuint shader)
+{
+   GLboolean result;
+
+   result =  _sym_glIsShader(shader);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return result;
+}
+
+static GLboolean
+evgl_glIsTexture(GLuint texture)
+{
+   GLboolean result;
+
+   result = _sym_glIsTexture(texture);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   return result;
+}
+
+static void
+evgl_glLineWidth(GLfloat width)
+{
+   _sym_glLineWidth(width);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glLinkProgram(GLuint program)
+{
+   _sym_glLinkProgram(program);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glPixelStorei(GLenum pname, GLint param)
+{
+   _sym_glPixelStorei(pname, param);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glPolygonOffset(GLfloat factor, GLfloat units)
+{
+   _sym_glPolygonOffset(factor, units);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
+{
+   _sym_glReadPixels(x, y, width, height, format, type, pixels);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glReleaseShaderCompiler(void)
+{
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+   _sym_glReleaseShaderCompiler();
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+#else
+   //FIXME!!! need something here?
+
+#endif
+}
+
+static void
+evgl_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+   _sym_glRenderbufferStorage(target, internalformat, width, height);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glSampleCoverage(GLclampf value, GLboolean invert)
+{
+   _sym_glSampleCoverage(value, invert);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   _sym_glScissor(x, y, width, height);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
+{
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+   _sym_glShaderBinary(n, shaders, binaryformat, binary, length);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+#else
+// FIXME: need to dlsym/getprocaddress for this
+   return;
+/*
+   n = binaryformat = length = 0;
+   shaders = binary = 0;
+*/
+#endif
+}
+
+static void
+evgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
+{
+   _sym_glShaderSource(shader, count, string, length);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+   _sym_glStencilFunc(func, ref, mask);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+   _sym_glStencilFuncSeparate(face, func, ref, mask);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glStencilMask(GLuint mask)
+{
+   _sym_glStencilMask(mask);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glStencilMaskSeparate(GLenum face, GLuint mask)
+{
+   _sym_glStencilMaskSeparate(face, mask);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+   _sym_glStencilOp(fail, zfail, zpass);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+   _sym_glStencilOpSeparate(face, fail, zfail, zpass);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
+{
+   _sym_glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glTexParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+   _sym_glTexParameterf(target, pname, param);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
+{
+   _sym_glTexParameterfv(target, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glTexParameteri(GLenum target, GLenum pname, GLint param)
+{
+   _sym_glTexParameteri(target, pname, param);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
+{
+   _sym_glTexParameteriv(target, pname, params);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
+{
+   _sym_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform1f(GLint location, GLfloat x)
+{
+   _sym_glUniform1f(location, x);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
+{
+   _sym_glUniform1fv(location, count, v);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform1i(GLint location, GLint x)
+{
+   _sym_glUniform1i(location, x);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform1iv(GLint location, GLsizei count, const GLint* v)
+{
+   _sym_glUniform1iv(location, count, v);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform2f(GLint location, GLfloat x, GLfloat y)
+{
+   _sym_glUniform2f(location, x, y);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
+{
+   _sym_glUniform2fv(location, count, v);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform2i(GLint location, GLint x, GLint y)
+{
+   _sym_glUniform2i(location, x, y);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform2iv(GLint location, GLsizei count, const GLint* v)
+{
+   _sym_glUniform2iv(location, count, v);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+   _sym_glUniform3f(location, x, y, z);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
+{
+   _sym_glUniform3fv(location, count, v);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform3i(GLint location, GLint x, GLint y, GLint z)
+{
+   _sym_glUniform3i(location, x, y, z);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform3iv(GLint location, GLsizei count, const GLint* v)
+{
+   _sym_glUniform3iv(location, count, v);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+   _sym_glUniform4f(location, x, y, z, w);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
+{
+   _sym_glUniform4fv(location, count, v);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+   _sym_glUniform4i(location, x, y, z, w);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniform4iv(GLint location, GLsizei count, const GLint* v)
+{
+   _sym_glUniform4iv(location, count, v);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+   _sym_glUniformMatrix2fv(location, count, transpose, value);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+   _sym_glUniformMatrix3fv(location, count, transpose, value);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+   _sym_glUniformMatrix4fv(location, count, transpose, value);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glUseProgram(GLuint program)
+{
+   _sym_glUseProgram(program);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glValidateProgram(GLuint program)
+{
+   _sym_glValidateProgram(program);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttrib1f(GLuint indx, GLfloat x)
+{
+   _sym_glVertexAttrib1f(indx, x);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttrib1fv(GLuint indx, const GLfloat* values)
+{
+   _sym_glVertexAttrib1fv(indx, values);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
+{
+   _sym_glVertexAttrib2f(indx, x, y);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttrib2fv(GLuint indx, const GLfloat* values)
+{
+   _sym_glVertexAttrib2fv(indx, values);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+{
+   _sym_glVertexAttrib3f(indx, x, y, z);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttrib3fv(GLuint indx, const GLfloat* values)
+{
+   _sym_glVertexAttrib3fv(indx, values);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+   _sym_glVertexAttrib4f(indx, x, y, z, w);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttrib4fv(GLuint indx, const GLfloat* values)
+{
+   _sym_glVertexAttrib4fv(indx, values);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
+{
+   _sym_glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   _sym_glViewport(x, y, width, height);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+
+// GLES Extensions...
+static void
+evgl_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary)
+{
+   _sym_glGetProgramBinary(program, bufsize, length, binaryFormat, binary);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+evgl_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length)
+{
+   _sym_glProgramBinary(program, binaryFormat, binary, length);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+
+static void
+evgl_glProgramParameteri(GLuint program, GLuint pname, GLint value)
+{
+   _sym_glProgramParameteri(program, pname, value);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+//----------------------------------------------------------------//
+//                                                                //
+//                      Fastpath GL Functions                     //
+// The functions have prefix 'fpgl_' for (fastpath gl)            //
+//                                                                //
+//----------------------------------------------------------------//
+
+#define CURR_STATE_COMPARE(curr_state, state ) \
+   if ((current_ctx->curr_state) != (state))
+
+
+static void
+fpgl_glActiveTexture(GLenum texture)
+{
+   CURR_STATE_COMPARE(gl_active_texture, texture)
+     {
+        _sym_glActiveTexture(texture);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_tex_flag1 |= FLAG_BIT_1;
+        current_ctx->gl_active_texture = texture;
+     }
+}
+
+static void
+fpgl_glBindBuffer(GLenum target, GLuint buffer)
+{
+   if (target == GL_ARRAY_BUFFER)
+     {
+        CURR_STATE_COMPARE(gl_array_buffer_binding, buffer)
+          {
+             _sym_glBindBuffer(target, buffer);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             if (buffer == 0)
+                current_ctx->_bind_flag &= (~FLAG_BIT_0);
+             else
+                current_ctx->_bind_flag |= FLAG_BIT_0;
+             current_ctx->gl_array_buffer_binding = buffer;
+          }
+     }
+   else if (target == GL_ELEMENT_ARRAY_BUFFER)
+     {
+        CURR_STATE_COMPARE(gl_element_array_buffer_binding, buffer)
+          {
+             _sym_glBindBuffer(target, buffer);
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             if (buffer == 0)
+                current_ctx->_bind_flag &= (~FLAG_BIT_1);
+             else
+                current_ctx->_bind_flag |= FLAG_BIT_1;
+             current_ctx->gl_element_array_buffer_binding = buffer;
+          }
+     }
+   else
+     {
+        // For error recording
+        _sym_glBindBuffer(target, buffer);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
+}
+
+static void
+fpgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
+{
+   if (target == GL_FRAMEBUFFER)
+     {
+        CURR_STATE_COMPARE(gl_framebuffer_binding, framebuffer)
+          {
+             _sym_glBindFramebuffer(target, framebuffer);
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             if (framebuffer == 0)
+                current_ctx->_bind_flag &= (~FLAG_BIT_2);
+             else
+                current_ctx->_bind_flag |= FLAG_BIT_2;
+             current_ctx->gl_framebuffer_binding = framebuffer;
+          }
+     }
+   else
+     {
+        // For error recording
+        _sym_glBindFramebuffer(target, framebuffer);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+     }
+}
+
+static void
+fpgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+   if (target == GL_RENDERBUFFER)
+     {
+        CURR_STATE_COMPARE(gl_renderbuffer_binding, renderbuffer)
+          {
+             _sym_glBindRenderbuffer(target, renderbuffer);
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             if (renderbuffer == 0)
+                current_ctx->_bind_flag &= (~FLAG_BIT_3);
+             else
+                current_ctx->_bind_flag |= FLAG_BIT_3;
+             current_ctx->gl_renderbuffer_binding = renderbuffer;
+          }
+     }
+   else
+     {
+        // For error recording
+        _sym_glBindRenderbuffer(target, renderbuffer);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
+}
+
+static void
+fpgl_glBindTexture(GLenum target, GLuint texture)
+{
+   int tex_idx;
+
+   if (target == GL_TEXTURE_2D)
+     {
+        CURR_STATE_COMPARE(gl_texture_binding_2d, texture)
+          {
+             _sym_glEnable(GL_TEXTURE_2D);
+             _sym_glBindTexture(target, texture);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             if (texture == 0)
+                current_ctx->_tex_flag1 &= (~FLAG_BIT_3);
+             else
+                current_ctx->_tex_flag1 |= FLAG_BIT_3;
+             current_ctx->gl_texture_binding_2d = texture;
+
+             tex_idx = current_ctx->gl_active_texture - GL_TEXTURE0;
+             current_ctx->tex_state[tex_idx].tex_unit = GL_TEXTURE_2D;
+             current_ctx->tex_state[tex_idx].tex_id = texture;
+          }
+     }
+   else if (target == GL_TEXTURE_CUBE_MAP)
+     {
+        CURR_STATE_COMPARE(gl_texture_binding_cube_map, texture)
+          {
+             _sym_glEnable(GL_TEXTURE_CUBE_MAP);
+             _sym_glBindTexture(target, texture);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             if (texture == 0)
+                current_ctx->_tex_flag1 &= (~FLAG_BIT_4);
+             else
+                current_ctx->_tex_flag1 |= FLAG_BIT_4;
+             current_ctx->gl_texture_binding_cube_map = texture;
+
+             tex_idx = current_ctx->gl_active_texture - GL_TEXTURE0;
+             current_ctx->tex_state[tex_idx].tex_unit = GL_TEXTURE_CUBE_MAP;
+             current_ctx->tex_state[tex_idx].tex_id = texture;
+          }
+     }
+}
+
+static void
+fpgl_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+   if ((current_ctx->gl_blend_color[0] != red) ||
+       (current_ctx->gl_blend_color[1] != green) ||
+       (current_ctx->gl_blend_color[2] != blue) ||
+       (current_ctx->gl_blend_color[3] != alpha))
+     {
+        _sym_glBlendColor(red, green, blue, alpha);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_blend_flag |= FLAG_BIT_0;
+        current_ctx->gl_blend_color[0] = red;
+        current_ctx->gl_blend_color[1] = green;
+        current_ctx->gl_blend_color[2] = blue;
+        current_ctx->gl_blend_color[3] = alpha;
+     }
+}
+
+//!!! Optimze?
+static void
+fpgl_glBlendEquation(GLenum mode)
+{
+   _sym_glBlendEquation(mode);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_blend_flag |= (FLAG_BIT_5 | FLAG_BIT_6);
+   _sym_glGetIntegerv(GL_BLEND_EQUATION_RGB,   (GLint*)&(current_ctx->gl_blend_equation_rgb));
+   _sym_glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&(current_ctx->gl_blend_equation_alpha));
+}
+
+static void
+fpgl_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+   if ((current_ctx->gl_blend_equation_rgb != modeRGB) ||
+       (current_ctx->gl_blend_equation_alpha != modeAlpha))
+     {
+        _sym_glBlendEquationSeparate(modeRGB, modeAlpha);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_blend_flag |= (FLAG_BIT_5 | FLAG_BIT_6);
+        current_ctx->gl_blend_equation_rgb    = modeRGB;
+        current_ctx->gl_blend_equation_alpha  = modeAlpha;
+     }
+}
+
+//!!! Optimze?
+static void
+fpgl_glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+   _sym_glBlendFunc(sfactor, dfactor);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_blend_flag |= (FLAG_BIT_1 | FLAG_BIT_2 | FLAG_BIT_3 | FLAG_BIT_4);
+   _sym_glGetIntegerv(GL_BLEND_SRC_RGB,   (GLint*)&(current_ctx->gl_blend_src_rgb));
+   _sym_glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&(current_ctx->gl_blend_src_alpha));
+   _sym_glGetIntegerv(GL_BLEND_DST_RGB,   (GLint*)&(current_ctx->gl_blend_dst_rgb));
+   _sym_glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&(current_ctx->gl_blend_dst_alpha));
+}
+
+static void
+fpgl_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+   if ((current_ctx->gl_blend_src_rgb != srcRGB) ||
+       (current_ctx->gl_blend_dst_rgb != dstRGB) ||
+       (current_ctx->gl_blend_src_alpha != srcAlpha) ||
+       (current_ctx->gl_blend_dst_alpha != dstAlpha))
+     {
+        _sym_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_blend_flag |= (FLAG_BIT_1 | FLAG_BIT_2 | FLAG_BIT_3 | FLAG_BIT_4);
+        current_ctx->gl_blend_src_rgb   = srcRGB;
+        current_ctx->gl_blend_dst_rgb   = dstRGB;
+        current_ctx->gl_blend_src_alpha = srcAlpha;
+        current_ctx->gl_blend_dst_alpha = dstAlpha;
+     }
+}
+
+static void
+fpgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+   if ((current_ctx->gl_color_clear_value[0] != red) ||
+       (current_ctx->gl_color_clear_value[1] != green) ||
+       (current_ctx->gl_color_clear_value[2] != blue) ||
+       (current_ctx->gl_color_clear_value[3] != alpha))
+     {
+        _sym_glClearColor(red, green, blue, alpha);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag1 |= (FLAG_BIT_2);
+        current_ctx->gl_color_clear_value[0] = red;
+        current_ctx->gl_color_clear_value[1] = green;
+        current_ctx->gl_color_clear_value[2] = blue;
+        current_ctx->gl_color_clear_value[3] = alpha;
+     }
+}
+
+static void
+fpgl_glClearDepthf(GLclampf depth)
+{
+   CURR_STATE_COMPARE(gl_depth_clear_value, depth)
+     {
+        _sym_glClearDepthf(depth);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag2 |= FLAG_BIT_2;
+        current_ctx->gl_depth_clear_value = depth;
+     }
+}
+
+static void
+fpgl_glClearStencil(GLint s)
+{
+   CURR_STATE_COMPARE(gl_stencil_clear_value, s)
+     {
+        _sym_glClearStencil(s);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_stencil_flag2 |= FLAG_BIT_7;
+        current_ctx->gl_stencil_clear_value = s;
+     }
+}
+
+static void
+fpgl_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+   if ((current_ctx->gl_color_writemask[0] != red) ||
+       (current_ctx->gl_color_writemask[1] != green) ||
+       (current_ctx->gl_color_writemask[2] != blue) ||
+       (current_ctx->gl_color_writemask[3] != alpha))
+     {
+        _sym_glColorMask(red, green, blue, alpha);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag2 |= FLAG_BIT_0;
+        current_ctx->gl_color_writemask[0] = red;
+        current_ctx->gl_color_writemask[1] = green;
+        current_ctx->gl_color_writemask[2] = blue;
+        current_ctx->gl_color_writemask[3] = alpha;
+     }
+}
+
+static void
+fpgl_glCullFace(GLenum mode)
+{
+   CURR_STATE_COMPARE(gl_cull_face_mode, mode)
+     {
+        _sym_glCullFace(mode);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag2 |= FLAG_BIT_5;
+        current_ctx->gl_cull_face_mode = mode;
+     }
+}
+
+static void
+fpgl_glDepthFunc(GLenum func)
+{
+   CURR_STATE_COMPARE(gl_depth_func, func)
+     {
+        _sym_glDepthFunc(func);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag2 |= FLAG_BIT_3;
+        current_ctx->gl_depth_func = func;
+     }
+}
+
+static void
+fpgl_glDepthMask(GLboolean flag)
+{
+   CURR_STATE_COMPARE(gl_depth_writemask, flag)
+     {
+        _sym_glDepthMask(flag);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag2 |= FLAG_BIT_4;
+        current_ctx->gl_depth_writemask = flag;
+     }
+}
+
+static void
+fpgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
+{
+   if ((current_ctx->gl_depth_range[0] != zNear) ||
+       (current_ctx->gl_depth_range[1] != zFar))
+     {
+        _sym_glDepthRangef(zNear, zFar);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag2 |= FLAG_BIT_1;
+        current_ctx->gl_depth_range[0] = zNear;
+        current_ctx->gl_depth_range[1] = zFar;
+     }
+}
+
+static void
+fpgl_glDisable(GLenum cap)
+{
+   switch(cap)
+     {
+      case GL_BLEND:
+         CURR_STATE_COMPARE(gl_blend, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag1 &= (~FLAG_BIT_0);
+              current_ctx->gl_blend = GL_FALSE;
+           }
+         break;
+      case GL_CULL_FACE:
+         CURR_STATE_COMPARE(gl_cull_face, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag1 &= (~FLAG_BIT_1);
+              current_ctx->gl_cull_face = GL_FALSE;
+           }
+         break;
+      case GL_DEPTH_TEST:
+         CURR_STATE_COMPARE(gl_depth_test, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag1 &= (~FLAG_BIT_2);
+              current_ctx->gl_depth_test = GL_FALSE;
+           }
+         break;
+      case GL_DITHER:
+         CURR_STATE_COMPARE(gl_dither, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag1 &= (~FLAG_BIT_3);
+              current_ctx->gl_dither = GL_FALSE;
+           }
+         break;
+      case GL_POLYGON_OFFSET_FILL:
+         CURR_STATE_COMPARE(gl_polygon_offset_fill, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag2 &= (~FLAG_BIT_0);
+              current_ctx->gl_polygon_offset_fill = GL_FALSE;
+           }
+         break;
+      case GL_SAMPLE_ALPHA_TO_COVERAGE:
+         CURR_STATE_COMPARE(gl_sample_alpha_to_coverage, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag2 &= (~FLAG_BIT_1);
+              current_ctx->gl_sample_alpha_to_coverage = GL_FALSE;
+           }
+         break;
+      case GL_SAMPLE_COVERAGE:
+         CURR_STATE_COMPARE(gl_sample_coverage, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag2 &= (~FLAG_BIT_2);
+              current_ctx->gl_sample_coverage = GL_FALSE;
+           }
+         break;
+      case GL_SCISSOR_TEST:
+         CURR_STATE_COMPARE(gl_scissor_test, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag2 &= (~FLAG_BIT_3);
+              current_ctx->gl_scissor_test = GL_FALSE;
+           }
+         break;
+      case GL_STENCIL_TEST:
+         CURR_STATE_COMPARE(gl_stencil_test, GL_FALSE)
+           {
+              _sym_glDisable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+              current_ctx->_enable_flag2 &= (~FLAG_BIT_4);
+              current_ctx->gl_stencil_test = GL_FALSE;
+           }
+         break;
+     }
+}
+
+static void
+fpgl_glDisableVertexAttribArray(GLuint index)
+{
+   _sym_glDisableVertexAttribArray(index);
+}
+
+static void
+fpgl_glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+   _sym_glDrawArrays(mode, first, count);
+}
+
+static void
+fpgl_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
+{
+   _sym_glDrawElements(mode, count, type, indices);
+}
+
+static void
+fpgl_glEnable(GLenum cap)
+{
+   switch(cap)
+     {
+      case GL_BLEND:
+         CURR_STATE_COMPARE(gl_blend, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+              current_ctx->_enable_flag1 |= FLAG_BIT_0;
+              current_ctx->gl_blend = GL_TRUE;
+           }
+         break;
+      case GL_CULL_FACE:
+         CURR_STATE_COMPARE(gl_cull_face, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+
+              current_ctx->_enable_flag1 |= FLAG_BIT_1;
+              current_ctx->gl_cull_face = GL_TRUE;
+           }
+         break;
+      case GL_DEPTH_TEST:
+         CURR_STATE_COMPARE(gl_depth_test, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+
+              current_ctx->_enable_flag1 |= FLAG_BIT_2;
+              current_ctx->gl_depth_test = GL_TRUE;
+           }
+         break;
+      case GL_DITHER:
+         CURR_STATE_COMPARE(gl_dither, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+
+              current_ctx->_enable_flag1 |= FLAG_BIT_3;
+              current_ctx->gl_dither = GL_TRUE;
+           }
+         break;
+      case GL_POLYGON_OFFSET_FILL:
+         CURR_STATE_COMPARE(gl_polygon_offset_fill, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+
+              current_ctx->_enable_flag2 |= FLAG_BIT_0;
+              current_ctx->gl_polygon_offset_fill = GL_TRUE;
+           }
+         break;
+      case GL_SAMPLE_ALPHA_TO_COVERAGE:
+         CURR_STATE_COMPARE(gl_sample_alpha_to_coverage, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+
+              current_ctx->_enable_flag2 |= FLAG_BIT_1;
+              current_ctx->gl_sample_alpha_to_coverage = GL_TRUE;
+           }
+         break;
+      case GL_SAMPLE_COVERAGE:
+         CURR_STATE_COMPARE(gl_sample_coverage, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+
+              current_ctx->_enable_flag2 |= FLAG_BIT_2;
+              current_ctx->gl_sample_coverage = GL_TRUE;
+           }
+         break;
+      case GL_SCISSOR_TEST:
+         CURR_STATE_COMPARE(gl_scissor_test, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+
+              current_ctx->_enable_flag2 |= FLAG_BIT_3;
+              current_ctx->gl_scissor_test = GL_TRUE;
+           }
+         break;
+      case GL_STENCIL_TEST:
+         CURR_STATE_COMPARE(gl_stencil_test, GL_TRUE)
+           {
+              _sym_glEnable(cap);
+              GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+
+              current_ctx->_enable_flag2 |= FLAG_BIT_4;
+              current_ctx->gl_stencil_test = GL_TRUE;
+           }
+         break;
+     }
+}
+
+// Optimze?
+static void
+fpgl_glEnableVertexAttribArray(GLuint index)
+{
+   _sym_glEnableVertexAttribArray(index);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_varray_flag |= FLAG_BIT_0;
+   current_ctx->vertex_array[index].enabled    = GL_TRUE;
+   current_ctx->vertex_array[index].modified   = GL_TRUE;
+
+}
+
+static void
+fpgl_glFrontFace(GLenum mode)
+{
+   CURR_STATE_COMPARE(gl_front_face, mode)
+     {
+        _sym_glFrontFace(mode);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_misc_flag1 |= FLAG_BIT_0;
+        current_ctx->gl_front_face = mode;
+     }
+}
+
+static void
+fpgl_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+{
+   _sym_glGetVertexAttribfv(index, pname, params);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+fpgl_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+{
+   _sym_glGetVertexAttribiv(index, pname, params);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+}
+
+static void
+fpgl_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
+{
+   _sym_glGetVertexAttribPointerv(index, pname, pointer);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+}
+
+// Fix Maybe?
+static void
+fpgl_glHint(GLenum target, GLenum mode)
+{
+   if (target == GL_GENERATE_MIPMAP_HINT)
+     {
+        CURR_STATE_COMPARE(gl_generate_mipmap_hint, mode)
+          {
+             _sym_glHint(target, mode);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_tex_flag1 |= FLAG_BIT_2;
+             current_ctx->gl_generate_mipmap_hint = mode;
+          }
+     }
+   else
+     {
+        // For GL Error to be picked up
+        _sym_glHint(target, mode);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
+}
+
+static void
+fpgl_glLineWidth(GLfloat width)
+{
+   CURR_STATE_COMPARE(gl_line_width, width)
+     {
+        _sym_glLineWidth(width);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_misc_flag1 |= FLAG_BIT_1;
+        current_ctx->gl_line_width = width;
+     }
+}
+
+static void
+fpgl_glPixelStorei(GLenum pname, GLint param)
+{
+   if (pname == GL_PACK_ALIGNMENT)
+     {
+        CURR_STATE_COMPARE(gl_pack_alignment, param)
+          {
+             _sym_glPixelStorei(pname, param);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_misc_flag2 |= FLAG_BIT_1;
+             current_ctx->gl_pack_alignment = param;
+          }
+     }
+   else if (pname == GL_UNPACK_ALIGNMENT)
+     {
+        CURR_STATE_COMPARE(gl_unpack_alignment, param)
+          {
+             _sym_glPixelStorei(pname, param);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_misc_flag2 |= FLAG_BIT_2;
+             current_ctx->gl_unpack_alignment = param;
+          }
+     }
+   else
+     {
+        // For GL Error to be picked up
+        _sym_glPixelStorei(pname, param);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
+}
+
+static void
+fpgl_glPolygonOffset(GLfloat factor, GLfloat units)
+{
+   if ((current_ctx->gl_polygon_offset_factor != factor) ||
+       (current_ctx->gl_polygon_offset_units != units))
+     {
+        _sym_glPolygonOffset(factor, units);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_misc_flag1 |= (FLAG_BIT_2 | FLAG_BIT_3);
+        current_ctx->gl_polygon_offset_factor = factor;
+        current_ctx->gl_polygon_offset_units  = units;
+     }
+}
+
+static void
+fpgl_glSampleCoverage(GLclampf value, GLboolean invert)
+{
+   if ((current_ctx->gl_sample_coverage_value != value) ||
+       (current_ctx->gl_sample_coverage_invert != invert))
+     {
+        _sym_glSampleCoverage(value, invert);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_misc_flag1 |= (FLAG_BIT_4 | FLAG_BIT_5);
+        current_ctx->gl_sample_coverage_value  = value;
+        current_ctx->gl_sample_coverage_invert = invert;
+     }
+}
+
+static void
+fpgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   if ((current_ctx->gl_scissor_box[0] != x) ||
+       (current_ctx->gl_scissor_box[1] != y) ||
+       (current_ctx->gl_scissor_box[2] != width) ||
+       (current_ctx->gl_scissor_box[3] != height))
+     {
+        _sym_glScissor(x, y, width, height);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_misc_flag2 |= FLAG_BIT_0;
+        current_ctx->gl_scissor_box[0] = x;
+        current_ctx->gl_scissor_box[1] = y;
+        current_ctx->gl_scissor_box[2] = width;
+        current_ctx->gl_scissor_box[3] = height;
+     }
+}
+
+static void
+fpgl_glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+   if ((current_ctx->gl_stencil_func != func) ||
+       (current_ctx->gl_stencil_ref != ref) ||
+       (current_ctx->gl_stencil_value_mask != mask) ||
+       (current_ctx->gl_stencil_back_func != func) ||
+       (current_ctx->gl_stencil_back_ref != ref) ||
+       (current_ctx->gl_stencil_back_value_mask != mask))
+     {
+        _sym_glStencilFunc(func, ref, mask);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_stencil_flag1 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
+        current_ctx->gl_stencil_func             = func;
+        current_ctx->gl_stencil_ref              = ref;
+        current_ctx->gl_stencil_value_mask       = mask;
+
+        current_ctx->_stencil_flag2 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
+        current_ctx->gl_stencil_back_func        = func;
+        current_ctx->gl_stencil_back_ref         = ref;
+        current_ctx->gl_stencil_back_value_mask  = mask;
+     }
+}
+
+static void
+fpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+   if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
+     {
+        if ((current_ctx->gl_stencil_func != func) ||
+            (current_ctx->gl_stencil_ref != ref) ||
+            (current_ctx->gl_stencil_value_mask != mask))
+          {
+             _sym_glStencilFuncSeparate(face, func, ref, mask);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_stencil_flag1 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
+
+             current_ctx->gl_stencil_func             = func;
+             current_ctx->gl_stencil_ref              = ref;
+             current_ctx->gl_stencil_value_mask       = mask;
+          }
+     }
+   else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
+     {
+        if ((current_ctx->gl_stencil_back_func != func) ||
+            (current_ctx->gl_stencil_back_ref != ref) ||
+            (current_ctx->gl_stencil_back_value_mask != mask))
+          {
+             _sym_glStencilFuncSeparate(face, func, ref, mask);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_stencil_flag2 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
+
+             current_ctx->gl_stencil_back_func        = func;
+             current_ctx->gl_stencil_back_ref         = ref;
+             current_ctx->gl_stencil_back_value_mask  = mask;
+          }
+     }
+   else
+     {
+        // Have GL pick up the error
+        _sym_glStencilFuncSeparate(face, func, ref, mask);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
+}
+
+static void
+fpgl_glStencilMask(GLuint mask)
+{
+   if ((current_ctx->gl_stencil_writemask != mask) ||
+       (current_ctx->gl_stencil_back_writemask != mask))
+     {
+        _sym_glStencilMask(mask);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_stencil_flag1 |= (FLAG_BIT_6);
+        current_ctx->_stencil_flag2 |= (FLAG_BIT_6);
+
+        current_ctx->gl_stencil_writemask        = mask;
+        current_ctx->gl_stencil_back_writemask   = mask;
+     }
+}
+
+static void
+fpgl_glStencilMaskSeparate(GLenum face, GLuint mask)
+{
+   if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
+     {
+        if (current_ctx->gl_stencil_writemask != mask)
+          {
+             _sym_glStencilMaskSeparate(face, mask);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_stencil_flag1 |= (FLAG_BIT_6);
+             current_ctx->gl_stencil_writemask = mask;
+          }
+     }
+   else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
+     {
+        if (current_ctx->gl_stencil_back_writemask != mask)
+          {
+             _sym_glStencilMaskSeparate(face, mask);
+
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_stencil_flag2 |= (FLAG_BIT_6);
+             current_ctx->gl_stencil_back_writemask   = mask;
+          }
+     }
+   else
+     {
+        // Have GL pick up the error
+        _sym_glStencilMaskSeparate(face, mask);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
+}
+
+static void
+fpgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+   if ((current_ctx->gl_stencil_fail != fail) ||
+       (current_ctx->gl_stencil_pass_depth_fail != zfail) ||
+       (current_ctx->gl_stencil_pass_depth_pass != zpass) ||
+       (current_ctx->gl_stencil_back_fail != fail) ||
+       (current_ctx->gl_stencil_back_depth_fail != zfail) ||
+       (current_ctx->gl_stencil_back_depth_pass != zpass))
+     {
+        _sym_glStencilOp(fail, zfail, zpass);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_stencil_flag1 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
+        current_ctx->gl_stencil_fail              = fail;
+        current_ctx->gl_stencil_pass_depth_fail   = zfail;
+        current_ctx->gl_stencil_pass_depth_pass   = zpass;
+
+        current_ctx->_stencil_flag2 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
+        current_ctx->gl_stencil_back_fail         = fail;
+        current_ctx->gl_stencil_back_depth_fail   = zfail;
+        current_ctx->gl_stencil_back_depth_pass   = zpass;
+     }
+}
+
+static void
+fpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+
+   if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
+     {
+        if ((current_ctx->gl_stencil_fail != fail) ||
+            (current_ctx->gl_stencil_pass_depth_fail != zfail) ||
+            (current_ctx->gl_stencil_pass_depth_pass != zpass))
+          {
+             _sym_glStencilOpSeparate(face, fail, zfail, zpass);
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_stencil_flag1 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
+             current_ctx->gl_stencil_fail              = fail;
+             current_ctx->gl_stencil_pass_depth_fail   = zfail;
+             current_ctx->gl_stencil_pass_depth_pass   = zpass;
+          }
+     }
+   else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
+     {
+        if ((current_ctx->gl_stencil_back_fail != fail) ||
+            (current_ctx->gl_stencil_back_depth_fail != zfail) ||
+            (current_ctx->gl_stencil_back_depth_pass != zpass))
+          {
+             _sym_glStencilOpSeparate(face, fail, zfail, zpass);
+             GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+             current_ctx->_stencil_flag2 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
+             current_ctx->gl_stencil_back_fail         = fail;
+             current_ctx->gl_stencil_back_depth_fail   = zfail;
+             current_ctx->gl_stencil_back_depth_pass   = zpass;
+          }
+     }
+   else
+     {
+        // For picking up error purpose
+        _sym_glStencilOpSeparate(face, fail, zfail, zpass);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
+}
+
+static void
+fpgl_glUseProgram(GLuint program)
+{
+   CURR_STATE_COMPARE(gl_current_program, program)
+     {
+        _sym_glUseProgram(program);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag1 |= FLAG_BIT_1;
+        current_ctx->gl_current_program = program;
+     }
+}
+
+// Optmize?
+static void
+fpgl_glVertexAttrib1f(GLuint indx, GLfloat x)
+{
+   _sym_glVertexAttrib1f(indx, x);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_vattrib_flag |= FLAG_BIT_0;
+   current_ctx->vertex_attrib[indx].modified = GL_TRUE;
+   current_ctx->vertex_attrib[indx].value[0] = x;
+   current_ctx->vertex_attrib[indx].value[1] = 0;
+   current_ctx->vertex_attrib[indx].value[2] = 0;
+   current_ctx->vertex_attrib[indx].value[3] = 1;
+}
+
+// Optmize?
+static void
+fpgl_glVertexAttrib1fv(GLuint indx, const GLfloat* values)
+{
+   _sym_glVertexAttrib1fv(indx, values);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_vattrib_flag |= FLAG_BIT_0;
+   current_ctx->vertex_attrib[indx].modified = GL_TRUE;
+   current_ctx->vertex_attrib[indx].value[0] = values[0];
+   current_ctx->vertex_attrib[indx].value[1] = 0;
+   current_ctx->vertex_attrib[indx].value[2] = 0;
+   current_ctx->vertex_attrib[indx].value[3] = 1;
+}
+
+// Optmize?
+static void
+fpgl_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
+{
+   _sym_glVertexAttrib2f(indx, x, y);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_vattrib_flag |= FLAG_BIT_0;
+   current_ctx->vertex_attrib[indx].modified = GL_TRUE;
+   current_ctx->vertex_attrib[indx].value[0] = x;
+   current_ctx->vertex_attrib[indx].value[1] = y;
+   current_ctx->vertex_attrib[indx].value[2] = 0;
+   current_ctx->vertex_attrib[indx].value[3] = 1;
+}
+
+// Optmize?
+static void
+fpgl_glVertexAttrib2fv(GLuint indx, const GLfloat* values)
+{
+   _sym_glVertexAttrib2fv(indx, values);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_vattrib_flag |= FLAG_BIT_0;
+   current_ctx->vertex_attrib[indx].modified = GL_TRUE;
+   current_ctx->vertex_attrib[indx].value[0] = values[0];
+   current_ctx->vertex_attrib[indx].value[1] = values[1];
+   current_ctx->vertex_attrib[indx].value[2] = 0;
+   current_ctx->vertex_attrib[indx].value[3] = 1;
+}
+
+// Optmize?
+static void
+fpgl_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+{
+   _sym_glVertexAttrib3f(indx, x, y, z);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_vattrib_flag |= FLAG_BIT_0;
+   current_ctx->vertex_attrib[indx].modified = GL_TRUE;
+   current_ctx->vertex_attrib[indx].value[0] = x;
+   current_ctx->vertex_attrib[indx].value[1] = y;
+   current_ctx->vertex_attrib[indx].value[2] = z;
+   current_ctx->vertex_attrib[indx].value[3] = 1;
+}
+
+// Optmize?
+static void
+fpgl_glVertexAttrib3fv(GLuint indx, const GLfloat* values)
+{
+   _sym_glVertexAttrib3fv(indx, values);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_vattrib_flag |= FLAG_BIT_0;
+   current_ctx->vertex_attrib[indx].modified = GL_TRUE;
+   current_ctx->vertex_attrib[indx].value[0] = values[0];
+   current_ctx->vertex_attrib[indx].value[1] = values[1];
+   current_ctx->vertex_attrib[indx].value[2] = values[2];
+   current_ctx->vertex_attrib[indx].value[3] = 1;
+}
+
+// Optmize?
+static void
+fpgl_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+   _sym_glVertexAttrib4f(indx, x, y, z, w);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_vattrib_flag |= FLAG_BIT_0;
+   current_ctx->vertex_attrib[indx].modified = GL_TRUE;
+   current_ctx->vertex_attrib[indx].value[0] = x;
+   current_ctx->vertex_attrib[indx].value[1] = y;
+   current_ctx->vertex_attrib[indx].value[2] = z;
+   current_ctx->vertex_attrib[indx].value[3] = w;
+}
+
+// Optmize?
+static void
+fpgl_glVertexAttrib4fv(GLuint indx, const GLfloat* values)
+{
+   _sym_glVertexAttrib4fv(indx, values);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_vattrib_flag |= FLAG_BIT_0;
+   current_ctx->vertex_attrib[indx].modified = GL_TRUE;
+   current_ctx->vertex_attrib[indx].value[0] = values[0];
+   current_ctx->vertex_attrib[indx].value[1] = values[1];
+   current_ctx->vertex_attrib[indx].value[2] = values[2];
+   current_ctx->vertex_attrib[indx].value[3] = values[3];
+}
+
+
+// Optmize?
+static void
+fpgl_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
+{
+   _sym_glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
+
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   current_ctx->_varray_flag |= FLAG_BIT_0;
+
+   current_ctx->vertex_array[indx].modified   = GL_TRUE;
+   current_ctx->vertex_array[indx].size       = size;
+   current_ctx->vertex_array[indx].type       = type;
+   current_ctx->vertex_array[indx].normalized = normalized;
+   current_ctx->vertex_array[indx].stride     = stride;
+   current_ctx->vertex_array[indx].pointer    = ptr;
+}
+
+static void
+fpgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   if ((current_ctx->gl_viewport[0] != x) ||
+       (current_ctx->gl_viewport[1] != y) ||
+       (current_ctx->gl_viewport[2] != width) ||
+       (current_ctx->gl_viewport[3] != height))
+     {
+        _sym_glViewport(x, y, width, height);
+
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+        current_ctx->_clear_flag1 |= FLAG_BIT_0;
+        current_ctx->gl_viewport[0] = x;
+        current_ctx->gl_viewport[1] = y;
+        current_ctx->gl_viewport[2] = width;
+        current_ctx->gl_viewport[3] = height;
+     }
+}
+
+
+//----------------------------------------------------------------//
+//                                                                //
+//                      Load Symbols                              //
+//                                                                //
+//----------------------------------------------------------------//
+static void
+sym_missing(void)
+{
+   ERR("GL symbols missing!\n");
+}
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+//------------------------------------------------------//
+// EGL
+static int
+glue_sym_init(void)
+{
+   //------------------------------------------------//
+   // Use gl_lib_handle for finding both GL and GLX symbols
+#define FINDSYM(dst, sym, typ) \
+   if ((!dst) && (_sym_eglGetProcAddress)) dst = (typeof(dst))_sym_eglGetProcAddress(sym); \
+   if (!dst) dst = (typeof(dst))dlsym(egl_lib_handle, sym); \
+   if (!dst) DBG("Error loading %s\n", sym);
+#define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
+
+   FINDSYM(_sym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn);
+
+   FINDSYM(_sym_eglGetError, "eglGetError", glsym_func_int);
+   FINDSYM(_sym_eglGetDisplay, "eglGetDisplay", glsym_func_egldpy);
+   FINDSYM(_sym_eglInitialize, "eglInitialize", glsym_func_bool);
+   FINDSYM(_sym_eglTerminate, "eglTerminate", glsym_func_bool);
+   FINDSYM(_sym_eglChooseConfig, "eglChooseConfig", glsym_func_bool);
+   FINDSYM(_sym_eglCreateWindowSurface, "eglCreateWindowSurface", glsym_func_eglsfc);
+   FINDSYM(_sym_eglCreatePixmapSurface, "eglCreatePixmapSurface", glsym_func_eglsfc);
+   FINDSYM(_sym_eglDestroySurface, "eglDestroySurface", glsym_func_bool);
+   FINDSYM(_sym_eglBindAPI, "eglBindAPI", glsym_func_bool);
+   FINDSYM(_sym_eglWaitClient, "eglWaitClient", glsym_func_bool);
+   FINDSYM(_sym_eglSurfaceAttrib, "eglSurfaceAttrib", glsym_func_bool);
+   FINDSYM(_sym_eglBindTexImage, "eglBindTexImage", glsym_func_void);
+   FINDSYM(_sym_eglReleaseTexImage, "eglReleaseTexImage", glsym_func_bool);
+   FINDSYM(_sym_eglSwapInterval, "eglSwapInterval", glsym_func_bool);
+   FINDSYM(_sym_eglCreateContext, "eglCreateContext", glsym_func_eglctx);
+   FINDSYM(_sym_eglDestroyContext, "eglDestroyContext", glsym_func_bool);
+   FINDSYM(_sym_eglMakeCurrent, "eglMakeCurrent", glsym_func_bool);
+   FINDSYM(_sym_eglGetCurrentContext, "eglGetCurrentContext", glsym_func_eglctx);
+   FINDSYM(_sym_eglGetCurrentSurface, "eglGetCurrentSurface", glsym_func_eglsfc);
+   FINDSYM(_sym_eglGetCurrentDisplay, "eglGetCurrentDisplay", glsym_func_egldpy);
+   FINDSYM(_sym_eglWaitGL, "eglWaitGL", glsym_func_bool);
+   FINDSYM(_sym_eglWaitNative, "eglWaitNative", glsym_func_bool);
+   FINDSYM(_sym_eglSwapBuffers, "eglSwapBuffers", glsym_func_bool);
+   FINDSYM(_sym_eglCopyBuffers, "eglCopyBuffers", glsym_func_bool);
+   FINDSYM(_sym_eglQueryString, "eglQueryString", glsym_func_char_const_ptr);
+   //FINDSYM(_sym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn);
+
+   //----------------//
+   FINDSYM(_sym_eglGetProcAddress, "eglGetProcAddressEXT", glsym_func_eng_fn);
+   FINDSYM(_sym_eglGetProcAddress, "eglGetProcAddressARB", glsym_func_eng_fn);
+   FINDSYM(_sym_eglGetProcAddress, "eglGetProcAddressKHR", glsym_func_eng_fn);
+
+   FINDSYM(_sym_eglCreateImage, "eglCreateImage", glsym_func_void_ptr);
+   FINDSYM(_sym_eglCreateImage, "eglCreateImageEXT", glsym_func_void_ptr);
+   FINDSYM(_sym_eglCreateImage, "eglCreateImageARB", glsym_func_void_ptr);
+   FINDSYM(_sym_eglCreateImage, "eglCreateImageKHR", glsym_func_void_ptr);
+
+   FINDSYM(_sym_eglDestroyImage, "eglDestroyImage", glsym_func_uint);
+   FINDSYM(_sym_eglDestroyImage, "eglDestroyImageEXT", glsym_func_uint);
+   FINDSYM(_sym_eglDestroyImage, "eglDestroyImageARB", glsym_func_uint);
+   FINDSYM(_sym_eglDestroyImage, "eglDestroyImageKHR", glsym_func_uint);
+
+   FINDSYM(_sym_eglMapImageSEC, "eglMapImageSEC", glsym_func_void_ptr);
+
+   FINDSYM(_sym_eglUnmapImageSEC, "eglUnmapImageSEC", glsym_func_uint);
+
+   FINDSYM(_sym_eglGetImageAttribSEC, "eglGetImageAttribSEC", glsym_func_uint);
+
+   FINDSYM(_sym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", glsym_func_void);
+   FINDSYM(_sym_glEGLImageTargetRenderbufferStorageOES, "glEGLImageTargetRenderbufferStorageOES", glsym_func_void);
+
+#undef FINDSYM
+#undef FALLBAK
+
+   return 1;
+}
+
+
+#else
+//------------------------------------------------------//
+// GLX
+static int
+glue_sym_init(void)
+{
+   //------------------------------------------------//
+   // Use gl_lib_handle for finding both GL and GLX symbols
+#define FINDSYM(dst, sym, typ) \
+   if ((!dst) && (_sym_glXGetProcAddress)) dst = (typeof(dst))_sym_glXGetProcAddress(sym); \
+   if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
+   if (!dst) DBG("Error loading %s\n", sym);
+#define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
+
+   //------------------------------------------------------//
+   // GLX APIs... Only ones that are being used.
+   FINDSYM(_sym_glXGetProcAddress, "glXGetProcAddress", glsym_func_eng_fn);
+   FINDSYM(_sym_glXGetProcAddress, "glXGetProcAddressEXT", glsym_func_eng_fn);
+   FINDSYM(_sym_glXGetProcAddress, "glXGetProcAddressARB", glsym_func_eng_fn);
+
+   // Standard Functions
+   FINDSYM(_sym_glXChooseVisual, "glXChooseVisual", glsym_func_xvisinfo_ptr);
+   FINDSYM(_sym_glXCreateContext, "glXCreateContext", glsym_func_glxctx);
+   FINDSYM(_sym_glXDestroyContext, "glXDestroyContext", glsym_func_void);
+   FINDSYM(_sym_glXGetCurrentContext, "glXGetCurrentContext", glsym_func_glxctx);
+   FINDSYM(_sym_glXGetCurrentDrawable, "glXGetCurrentDrawable", glsym_func_glxdraw);
+   FINDSYM(_sym_glXMakeCurrent, "glXMakeCurrent", glsym_func_bool);
+   FINDSYM(_sym_glXSwapBuffers, "glXSwapBuffers", glsym_func_void);
+   FINDSYM(_sym_glXWaitX, "glXWaitX", glsym_func_void);
+   FINDSYM(_sym_glXWaitGL, "glXWaitGL", glsym_func_void);
+   FINDSYM(_sym_glXQueryExtension, "glXQueryExtension", glsym_func_bool);
+   FINDSYM(_sym_glXQueryExtensionsString, "glXQueryExtensionsString", glsym_func_const_char_ptr);
+
+   // 1.3 and later
+   FINDSYM(_sym_glXChooseFBConfig, "glXChooseFBConfig", glsym_func_glxfbcfg_ptr);
+   FINDSYM(_sym_glXGetFBConfigs, "glXGetFBConfigs", glsym_func_glxfbcfg_ptr);
+   FINDSYM(_sym_glXGetFBConfigAttrib, "glXGetFBConfigAttrib", glsym_func_int);
+   FINDSYM(_sym_glXGetVisualFromFBConfig, "glXGetVisualFromFBConfig", glsym_func_xvisinfo_ptr);
+   FINDSYM(_sym_glXDestroyWindow, "glXDestroyWindow", glsym_func_void);
+   FINDSYM(_sym_glXMakeContextCurrent, "glXMakeContextCurrent", glsym_func_bool);
+
+
+   // Extension functions
+   FINDSYM(_sym_glXBindTexImage, "glXBindTexImage", glsym_func_void);
+   FINDSYM(_sym_glXBindTexImage, "glXBindTexImageEXT", glsym_func_void);
+   FINDSYM(_sym_glXBindTexImage, "glXBindTexImageARB", glsym_func_void);
+
+   FINDSYM(_sym_glXReleaseTexImage, "glXReleaseTexImage", glsym_func_void);
+   FINDSYM(_sym_glXReleaseTexImage, "glXReleaseTexImageEXT", glsym_func_void);
+   FINDSYM(_sym_glXReleaseTexImage, "glXReleaseTexImageARB", glsym_func_void);
+
+   FINDSYM(_sym_glXGetVideoSync, "glXGetVideoSyncSGI", glsym_func_int);
+
+   FINDSYM(_sym_glXWaitVideoSync, "glXWaitVideoSyncSGI", glsym_func_int);
+
+   FINDSYM(_sym_glXCreatePixmap, "glXCreatePixmap", glsym_func_xid);
+   FINDSYM(_sym_glXCreatePixmap, "glXCreatePixmapEXT", glsym_func_xid);
+   FINDSYM(_sym_glXCreatePixmap, "glXCreatePixmapARB", glsym_func_xid);
+
+   FINDSYM(_sym_glXDestroyPixmap, "glXDestroyPixmap", glsym_func_void);
+   FINDSYM(_sym_glXDestroyPixmap, "glXDestroyPixmapEXT", glsym_func_void);
+   FINDSYM(_sym_glXDestroyPixmap, "glXDestroyPixmapARB", glsym_func_void);
+
+   FINDSYM(_sym_glXQueryDrawable, "glXQueryDrawable", glsym_func_void);
+   FINDSYM(_sym_glXQueryDrawable, "glXQueryDrawableEXT", glsym_func_void);
+   FINDSYM(_sym_glXQueryDrawable, "glXQueryDrawableARB", glsym_func_void);
+
+   FINDSYM(_sym_glXSwapIntervalSGI, "glXSwapIntervalMESA", glsym_func_int);
+   FINDSYM(_sym_glXSwapIntervalSGI, "glXSwapIntervalSGI", glsym_func_int);
+
+   //----------//
+   FINDSYM(_sym_glXSwapIntervalEXT, "glXSwapIntervalEXT", glsym_func_void);
+
+
+#undef FINDSYM
+#undef FALLBAK
+
+   return 1;
+}
+
+#endif
+
+static int
+gl_sym_init(void)
+{
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+
+   //------------------------------------------------//
+   // Use eglGetProcAddress
+#  define FINDSYM(dst, sym, typ) \
+   if ((!dst) && (_sym_eglGetProcAddress)) dst = (typeof(dst))_sym_eglGetProcAddress(sym); \
+   if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
+   if (!dst) DBG("Error loading %s\n", sym);
+#  define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
+
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinary", glsym_func_void);
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinaryEXT", glsym_func_void);
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinaryARB", glsym_func_void);
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinaryOES", glsym_func_void);
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinaryKHR", glsym_func_void);
+
+   FINDSYM(_sym_glProgramBinary, "glProgramBinary", glsym_func_void);
+   FINDSYM(_sym_glProgramBinary, "glProgramBinaryEXT", glsym_func_void);
+   FINDSYM(_sym_glProgramBinary, "glProgramBinaryARB", glsym_func_void);
+   FINDSYM(_sym_glProgramBinary, "glProgramBinaryOES", glsym_func_void);
+   FINDSYM(_sym_glProgramBinary, "glProgramBinaryKHR", glsym_func_void);
+
+   FINDSYM(_sym_glProgramParameteri, "glProgramParameteri", glsym_func_void);
+   FINDSYM(_sym_glProgramParameteri, "glProgramParameteriEXT", glsym_func_void);
+   FINDSYM(_sym_glProgramParameteri, "glProgramParameteriARB", glsym_func_void);
+   FINDSYM(_sym_glProgramParameteri, "glProgramParameteriOES", glsym_func_void);
+   FINDSYM(_sym_glProgramParameteri, "glProgramParameteriKHR", glsym_func_void);
+
+#else
+
+   //------------------------------------------------//
+   // Use gl_lib_handle for finding both GL and GLX symbols
+   // Try eglGetProcAddress
+#  define FINDSYM(dst, sym, typ) \
+   if ((!dst) && (_sym_glXGetProcAddress)) dst = (typeof(dst))_sym_glXGetProcAddress(sym); \
+   if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
+   if (!dst) DBG("Error loading %s\n", sym);
+#  define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
+
+
+   //----------//
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinary", glsym_func_void);
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinaryEXT", glsym_func_void);
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinaryARB", glsym_func_void);
+   FINDSYM(_sym_glGetProgramBinary, "glGetProgramBinaryOES", glsym_func_void);
+
+   FINDSYM(_sym_glProgramBinary, "glProgramBinary", glsym_func_void);
+   FINDSYM(_sym_glProgramBinary, "glProgramBinaryEXT", glsym_func_void);
+   FINDSYM(_sym_glProgramBinary, "glProgramBinaryARB", glsym_func_void);
+
+   FINDSYM(_sym_glProgramParameteri, "glProgramParameteri", glsym_func_void);
+   FINDSYM(_sym_glProgramParameteri, "glProgramParameteriEXT", glsym_func_void);
+   FINDSYM(_sym_glProgramParameteri, "glProgramParameteriARB", glsym_func_void);
+
+#endif
+
+   //------------------------------------------------------//
+   // GLES 2.0 APIs...
+   FINDSYM(_sym_glActiveTexture, "glActiveTexture", glsym_func_void);
+   FALLBAK(_sym_glActiveTexture, glsym_func_void);
+
+   FINDSYM(_sym_glAttachShader, "glAttachShader", glsym_func_void);
+   FALLBAK(_sym_glAttachShader, glsym_func_void);
+
+   FINDSYM(_sym_glBindAttribLocation, "glBindAttribLocation", glsym_func_void);
+   FALLBAK(_sym_glBindAttribLocation, glsym_func_void);
+
+   FINDSYM(_sym_glBindBuffer, "glBindBuffer", glsym_func_void);
+   FALLBAK(_sym_glBindBuffer, glsym_func_void);
+
+   FINDSYM(_sym_glBindFramebuffer, "glBindFramebuffer", glsym_func_void);
+   FALLBAK(_sym_glBindFramebuffer, glsym_func_void);
+
+   FINDSYM(_sym_glBindRenderbuffer, "glBindRenderbuffer", glsym_func_void);
+   FALLBAK(_sym_glBindRenderbuffer, glsym_func_void);
+
+   FINDSYM(_sym_glBindTexture, "glBindTexture", glsym_func_void);
+   FALLBAK(_sym_glBindTexture, glsym_func_void);
+
+   FINDSYM(_sym_glBlendColor, "glBlendColor", glsym_func_void);
+   FALLBAK(_sym_glBlendColor, glsym_func_void);
+
+   FINDSYM(_sym_glBlendEquation, "glBlendEquation", glsym_func_void);
+   FALLBAK(_sym_glBlendEquation, glsym_func_void);
+
+   FINDSYM(_sym_glBlendEquationSeparate, "glBlendEquationSeparate", glsym_func_void);
+   FALLBAK(_sym_glBlendEquationSeparate, glsym_func_void);
+
+   FINDSYM(_sym_glBlendFunc, "glBlendFunc", glsym_func_void);
+   FALLBAK(_sym_glBlendFunc, glsym_func_void);
+
+   FINDSYM(_sym_glBlendFuncSeparate, "glBlendFuncSeparate", glsym_func_void);
+   FALLBAK(_sym_glBlendFuncSeparate, glsym_func_void);
+
+   FINDSYM(_sym_glBufferData, "glBufferData", glsym_func_void);
+   FALLBAK(_sym_glBufferData, glsym_func_void);
+
+   FINDSYM(_sym_glBufferSubData, "glBufferSubData", glsym_func_void);
+   FALLBAK(_sym_glBufferSubData, glsym_func_void);
+
+   FINDSYM(_sym_glCheckFramebufferStatus, "glCheckFramebufferStatus", glsym_func_uint);
+   FALLBAK(_sym_glCheckFramebufferStatus, glsym_func_uint);
+
+   FINDSYM(_sym_glClear, "glClear", glsym_func_void);
+   FALLBAK(_sym_glClear, glsym_func_void);
+
+   FINDSYM(_sym_glClearColor, "glClearColor", glsym_func_void);
+   FALLBAK(_sym_glClearColor, glsym_func_void);
+
+   FINDSYM(_sym_glClearDepthf, "glClearDepthf", glsym_func_void);
+   FINDSYM(_sym_glClearDepthf, "glClearDepth", glsym_func_void);
+   FALLBAK(_sym_glClearDepthf, glsym_func_void);
+
+   FINDSYM(_sym_glClearStencil, "glClearStencil", glsym_func_void);
+   FALLBAK(_sym_glClearStencil, glsym_func_void);
+
+   FINDSYM(_sym_glColorMask, "glColorMask", glsym_func_void);
+   FALLBAK(_sym_glColorMask, glsym_func_void);
+
+   FINDSYM(_sym_glCompileShader, "glCompileShader", glsym_func_void);
+   FALLBAK(_sym_glCompileShader, glsym_func_void);
+
+   FINDSYM(_sym_glCompressedTexImage2D, "glCompressedTexImage2D", glsym_func_void);
+   FALLBAK(_sym_glCompressedTexImage2D, glsym_func_void);
+
+   FINDSYM(_sym_glCompressedTexSubImage2D, "glCompressedTexSubImage2D", glsym_func_void);
+   FALLBAK(_sym_glCompressedTexSubImage2D, glsym_func_void);
+
+   FINDSYM(_sym_glCopyTexImage2D, "glCopyTexImage2D", glsym_func_void);
+   FALLBAK(_sym_glCopyTexImage2D, glsym_func_void);
+
+   FINDSYM(_sym_glCopyTexSubImage2D, "glCopyTexSubImage2D", glsym_func_void);
+   FALLBAK(_sym_glCopyTexSubImage2D, glsym_func_void);
+
+   FINDSYM(_sym_glCreateProgram, "glCreateProgram", glsym_func_uint);
+   FALLBAK(_sym_glCreateProgram, glsym_func_uint);
+
+   FINDSYM(_sym_glCreateShader, "glCreateShader", glsym_func_uint);
+   FALLBAK(_sym_glCreateShader, glsym_func_uint);
+
+   FINDSYM(_sym_glCullFace, "glCullFace", glsym_func_void);
+   FALLBAK(_sym_glCullFace, glsym_func_void);
+
+   FINDSYM(_sym_glDeleteBuffers, "glDeleteBuffers", glsym_func_void);
+   FALLBAK(_sym_glDeleteBuffers, glsym_func_void);
+
+   FINDSYM(_sym_glDeleteFramebuffers, "glDeleteFramebuffers", glsym_func_void);
+   FALLBAK(_sym_glDeleteFramebuffers, glsym_func_void);
+
+   FINDSYM(_sym_glDeleteProgram, "glDeleteProgram", glsym_func_void);
+   FALLBAK(_sym_glDeleteProgram, glsym_func_void);
+
+   FINDSYM(_sym_glDeleteRenderbuffers, "glDeleteRenderbuffers", glsym_func_void);
+   FALLBAK(_sym_glDeleteRenderbuffers, glsym_func_void);
+
+   FINDSYM(_sym_glDeleteShader, "glDeleteShader", glsym_func_void);
+   FALLBAK(_sym_glDeleteShader, glsym_func_void);
+
+   FINDSYM(_sym_glDeleteTextures, "glDeleteTextures", glsym_func_void);
+   FALLBAK(_sym_glDeleteTextures, glsym_func_void);
+
+   FINDSYM(_sym_glDepthFunc, "glDepthFunc", glsym_func_void);
+   FALLBAK(_sym_glDepthFunc, glsym_func_void);
+
+   FINDSYM(_sym_glDepthMask, "glDepthMask", glsym_func_void);
+   FALLBAK(_sym_glDepthMask, glsym_func_void);
+
+   FINDSYM(_sym_glDepthRangef, "glDepthRangef", glsym_func_void);
+   FINDSYM(_sym_glDepthRangef, "glDepthRange", glsym_func_void);
+   FALLBAK(_sym_glDepthRangef, glsym_func_void);
+
+   FINDSYM(_sym_glDetachShader, "glDetachShader", glsym_func_void);
+   FALLBAK(_sym_glDetachShader, glsym_func_void);
+
+   FINDSYM(_sym_glDisable, "glDisable", glsym_func_void);
+   FALLBAK(_sym_glDisable, glsym_func_void);
+
+   FINDSYM(_sym_glDisableVertexAttribArray, "glDisableVertexAttribArray", glsym_func_void);
+   FALLBAK(_sym_glDisableVertexAttribArray, glsym_func_void);
+
+   FINDSYM(_sym_glDrawArrays, "glDrawArrays", glsym_func_void);
+   FALLBAK(_sym_glDrawArrays, glsym_func_void);
+
+   FINDSYM(_sym_glDrawElements, "glDrawElements", glsym_func_void);
+   FALLBAK(_sym_glDrawElements, glsym_func_void);
+
+   FINDSYM(_sym_glEnable, "glEnable", glsym_func_void);
+   FALLBAK(_sym_glEnable, glsym_func_void);
+
+   FINDSYM(_sym_glEnableVertexAttribArray, "glEnableVertexAttribArray", glsym_func_void);
+   FALLBAK(_sym_glEnableVertexAttribArray, glsym_func_void);
+
+   FINDSYM(_sym_glFinish, "glFinish", glsym_func_void);
+   FALLBAK(_sym_glFinish, glsym_func_void);
+
+   FINDSYM(_sym_glFlush, "glFlush", glsym_func_void);
+   FALLBAK(_sym_glFlush, glsym_func_void);
+
+   FINDSYM(_sym_glFramebufferRenderbuffer, "glFramebufferRenderbuffer", glsym_func_void);
+   FALLBAK(_sym_glFramebufferRenderbuffer, glsym_func_void);
+
+   FINDSYM(_sym_glFramebufferTexture2D, "glFramebufferTexture2D", glsym_func_void);
+   FALLBAK(_sym_glFramebufferTexture2D, glsym_func_void);
+
+   FINDSYM(_sym_glFrontFace, "glFrontFace", glsym_func_void);
+   FALLBAK(_sym_glFrontFace, glsym_func_void);
+
+   FINDSYM(_sym_glGenBuffers, "glGenBuffers", glsym_func_void);
+   FALLBAK(_sym_glGenBuffers, glsym_func_void);
+
+   FINDSYM(_sym_glGenerateMipmap, "glGenerateMipmap", glsym_func_void);
+   FALLBAK(_sym_glGenerateMipmap, glsym_func_void);
+
+   FINDSYM(_sym_glGenFramebuffers, "glGenFramebuffers", glsym_func_void);
+   FALLBAK(_sym_glGenFramebuffers, glsym_func_void);
+
+   FINDSYM(_sym_glGenRenderbuffers, "glGenRenderbuffers", glsym_func_void);
+   FALLBAK(_sym_glGenRenderbuffers, glsym_func_void);
+
+   FINDSYM(_sym_glGenTextures, "glGenTextures", glsym_func_void);
+   FALLBAK(_sym_glGenTextures, glsym_func_void);
+
+   FINDSYM(_sym_glGetActiveAttrib, "glGetActiveAttrib", glsym_func_void);
+   FALLBAK(_sym_glGetActiveAttrib, glsym_func_void);
+
+   FINDSYM(_sym_glGetActiveUniform, "glGetActiveUniform", glsym_func_void);
+   FALLBAK(_sym_glGetActiveUniform, glsym_func_void);
+
+   FINDSYM(_sym_glGetAttachedShaders, "glGetAttachedShaders", glsym_func_void);
+   FALLBAK(_sym_glGetAttachedShaders, glsym_func_void);
+
+   FINDSYM(_sym_glGetAttribLocation, "glGetAttribLocation", glsym_func_int);
+   FALLBAK(_sym_glGetAttribLocation, glsym_func_int);
+
+   FINDSYM(_sym_glGetBooleanv, "glGetBooleanv", glsym_func_void);
+   FALLBAK(_sym_glGetBooleanv, glsym_func_void);
+
+   FINDSYM(_sym_glGetBufferParameteriv, "glGetBufferParameteriv", glsym_func_void);
+   FALLBAK(_sym_glGetBufferParameteriv, glsym_func_void);
+
+   FINDSYM(_sym_glGetError, "glGetError", glsym_func_uint);
+   FALLBAK(_sym_glGetError, glsym_func_uint);
+
+   FINDSYM(_sym_glGetFloatv, "glGetFloatv", glsym_func_void);
+   FALLBAK(_sym_glGetFloatv, glsym_func_void);
+
+   FINDSYM(_sym_glGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv", glsym_func_void);
+   FALLBAK(_sym_glGetFramebufferAttachmentParameteriv, glsym_func_void);
+
+   FINDSYM(_sym_glGetIntegerv, "glGetIntegerv", glsym_func_void);
+   FALLBAK(_sym_glGetIntegerv, glsym_func_void);
+
+   FINDSYM(_sym_glGetProgramiv, "glGetProgramiv", glsym_func_void);
+   FALLBAK(_sym_glGetProgramiv, glsym_func_void);
+
+   FINDSYM(_sym_glGetProgramInfoLog, "glGetProgramInfoLog", glsym_func_void);
+   FALLBAK(_sym_glGetProgramInfoLog, glsym_func_void);
+
+   FINDSYM(_sym_glGetRenderbufferParameteriv, "glGetRenderbufferParameteriv", glsym_func_void);
+   FALLBAK(_sym_glGetRenderbufferParameteriv, glsym_func_void);
+
+   FINDSYM(_sym_glGetShaderiv, "glGetShaderiv", glsym_func_void);
+   FALLBAK(_sym_glGetShaderiv, glsym_func_void);
+
+   FINDSYM(_sym_glGetShaderInfoLog, "glGetShaderInfoLog", glsym_func_void);
+   FALLBAK(_sym_glGetShaderInfoLog, glsym_func_void);
+
+   FINDSYM(_sym_glGetShaderPrecisionFormat, "glGetShaderPrecisionFormat", glsym_func_void);
+   FALLBAK(_sym_glGetShaderPrecisionFormat, glsym_func_void);
+
+   FINDSYM(_sym_glGetShaderSource, "glGetShaderSource", glsym_func_void);
+   FALLBAK(_sym_glGetShaderSource, glsym_func_void);
+
+   FINDSYM(_sym_glGetString, "glGetString", glsym_func_uchar_ptr);
+   FALLBAK(_sym_glGetString, glsym_func_const_uchar_ptr);
+
+   FINDSYM(_sym_glGetTexParameterfv, "glGetTexParameterfv", glsym_func_void);
+   FALLBAK(_sym_glGetTexParameterfv, glsym_func_void);
+
+   FINDSYM(_sym_glGetTexParameteriv, "glGetTexParameteriv", glsym_func_void);
+   FALLBAK(_sym_glGetTexParameteriv, glsym_func_void);
+
+   FINDSYM(_sym_glGetUniformfv, "glGetUniformfv", glsym_func_void);
+   FALLBAK(_sym_glGetUniformfv, glsym_func_void);
+
+   FINDSYM(_sym_glGetUniformiv, "glGetUniformiv", glsym_func_void);
+   FALLBAK(_sym_glGetUniformiv, glsym_func_void);
+
+   FINDSYM(_sym_glGetUniformLocation, "glGetUniformLocation", glsym_func_int);
+   FALLBAK(_sym_glGetUniformLocation, glsym_func_int);
+
+   FINDSYM(_sym_glGetVertexAttribfv, "glGetVertexAttribfv", glsym_func_void);
+   FALLBAK(_sym_glGetVertexAttribfv, glsym_func_void);
+
+   FINDSYM(_sym_glGetVertexAttribiv, "glGetVertexAttribiv", glsym_func_void);
+   FALLBAK(_sym_glGetVertexAttribiv, glsym_func_void);
+
+   FINDSYM(_sym_glGetVertexAttribPointerv, "glGetVertexAttribPointerv", glsym_func_void);
+   FALLBAK(_sym_glGetVertexAttribPointerv, glsym_func_void);
+
+   FINDSYM(_sym_glHint, "glHint", glsym_func_void);
+   FALLBAK(_sym_glHint, glsym_func_void);
+
+   FINDSYM(_sym_glIsBuffer, "glIsBuffer", glsym_func_uchar);
+   FALLBAK(_sym_glIsBuffer, glsym_func_uchar);
+
+   FINDSYM(_sym_glIsEnabled, "glIsEnabled", glsym_func_uchar);
+   FALLBAK(_sym_glIsEnabled, glsym_func_uchar);
+
+   FINDSYM(_sym_glIsFramebuffer, "glIsFramebuffer", glsym_func_uchar);
+   FALLBAK(_sym_glIsFramebuffer, glsym_func_uchar);
+
+   FINDSYM(_sym_glIsProgram, "glIsProgram", glsym_func_uchar);
+   FALLBAK(_sym_glIsProgram, glsym_func_uchar);
+
+   FINDSYM(_sym_glIsRenderbuffer, "glIsRenderbuffer", glsym_func_uchar);
+   FALLBAK(_sym_glIsRenderbuffer, glsym_func_uchar);
+
+   FINDSYM(_sym_glIsShader, "glIsShader", glsym_func_uchar);
+   FALLBAK(_sym_glIsShader, glsym_func_uchar);
+
+   FINDSYM(_sym_glIsTexture, "glIsTexture", glsym_func_uchar);
+   FALLBAK(_sym_glIsTexture, glsym_func_uchar);
+
+   FINDSYM(_sym_glLineWidth, "glLineWidth", glsym_func_void);
+   FALLBAK(_sym_glLineWidth, glsym_func_void);
+
+   FINDSYM(_sym_glLinkProgram, "glLinkProgram", glsym_func_void);
+   FALLBAK(_sym_glLinkProgram, glsym_func_void);
+
+   FINDSYM(_sym_glPixelStorei, "glPixelStorei", glsym_func_void);
+   FALLBAK(_sym_glPixelStorei, glsym_func_void);
+
+   FINDSYM(_sym_glPolygonOffset, "glPolygonOffset", glsym_func_void);
+   FALLBAK(_sym_glPolygonOffset, glsym_func_void);
+
+   FINDSYM(_sym_glReadPixels, "glReadPixels", glsym_func_void);
+   FALLBAK(_sym_glReadPixels, glsym_func_void);
+
+   FINDSYM(_sym_glReleaseShaderCompiler, "glReleaseShaderCompiler", glsym_func_void);
+   FALLBAK(_sym_glReleaseShaderCompiler, glsym_func_void);
+
+   FINDSYM(_sym_glRenderbufferStorage, "glRenderbufferStorage", glsym_func_void);
+   FALLBAK(_sym_glRenderbufferStorage, glsym_func_void);
+
+   FINDSYM(_sym_glSampleCoverage, "glSampleCoverage", glsym_func_void);
+   FALLBAK(_sym_glSampleCoverage, glsym_func_void);
+
+   FINDSYM(_sym_glScissor, "glScissor", glsym_func_void);
+   FALLBAK(_sym_glScissor, glsym_func_void);
+
+   FINDSYM(_sym_glShaderBinary, "glShaderBinary", glsym_func_void);
+   FALLBAK(_sym_glShaderBinary, glsym_func_void);
+
+   FINDSYM(_sym_glShaderSource, "glShaderSource", glsym_func_void);
+   FALLBAK(_sym_glShaderSource, glsym_func_void);
+
+   FINDSYM(_sym_glStencilFunc, "glStencilFunc", glsym_func_void);
+   FALLBAK(_sym_glStencilFunc, glsym_func_void);
+
+   FINDSYM(_sym_glStencilFuncSeparate, "glStencilFuncSeparate", glsym_func_void);
+   FALLBAK(_sym_glStencilFuncSeparate, glsym_func_void);
+
+   FINDSYM(_sym_glStencilMask, "glStencilMask", glsym_func_void);
+   FALLBAK(_sym_glStencilMask, glsym_func_void);
+
+   FINDSYM(_sym_glStencilMaskSeparate, "glStencilMaskSeparate", glsym_func_void);
+   FALLBAK(_sym_glStencilMaskSeparate, glsym_func_void);
+
+   FINDSYM(_sym_glStencilOp, "glStencilOp", glsym_func_void);
+   FALLBAK(_sym_glStencilOp, glsym_func_void);
+
+   FINDSYM(_sym_glStencilOpSeparate, "glStencilOpSeparate", glsym_func_void);
+   FALLBAK(_sym_glStencilOpSeparate, glsym_func_void);
+
+   FINDSYM(_sym_glTexImage2D, "glTexImage2D", glsym_func_void);
+   FALLBAK(_sym_glTexImage2D, glsym_func_void);
+
+   FINDSYM(_sym_glTexParameterf, "glTexParameterf", glsym_func_void);
+   FALLBAK(_sym_glTexParameterf, glsym_func_void);
+
+   FINDSYM(_sym_glTexParameterfv, "glTexParameterfv", glsym_func_void);
+   FALLBAK(_sym_glTexParameterfv, glsym_func_void);
+
+   FINDSYM(_sym_glTexParameteri, "glTexParameteri", glsym_func_void);
+   FALLBAK(_sym_glTexParameteri, glsym_func_void);
+
+   FINDSYM(_sym_glTexParameteriv, "glTexParameteriv", glsym_func_void);
+   FALLBAK(_sym_glTexParameteriv, glsym_func_void);
+
+   FINDSYM(_sym_glTexSubImage2D, "glTexSubImage2D", glsym_func_void);
+   FALLBAK(_sym_glTexSubImage2D, glsym_func_void);
+
+   FINDSYM(_sym_glUniform1f, "glUniform1f", glsym_func_void);
+   FALLBAK(_sym_glUniform1f, glsym_func_void);
+
+   FINDSYM(_sym_glUniform1fv, "glUniform1fv", glsym_func_void);
+   FALLBAK(_sym_glUniform1fv, glsym_func_void);
+
+   FINDSYM(_sym_glUniform1i, "glUniform1i", glsym_func_void);
+   FALLBAK(_sym_glUniform1i, glsym_func_void);
+
+   FINDSYM(_sym_glUniform1iv, "glUniform1iv", glsym_func_void);
+   FALLBAK(_sym_glUniform1iv, glsym_func_void);
+
+   FINDSYM(_sym_glUniform2f, "glUniform2f", glsym_func_void);
+   FALLBAK(_sym_glUniform2f, glsym_func_void);
+
+   FINDSYM(_sym_glUniform2fv, "glUniform2fv", glsym_func_void);
+   FALLBAK(_sym_glUniform2fv, glsym_func_void);
+
+   FINDSYM(_sym_glUniform2i, "glUniform2i", glsym_func_void);
+   FALLBAK(_sym_glUniform2i, glsym_func_void);
+
+   FINDSYM(_sym_glUniform2iv, "glUniform2iv", glsym_func_void);
+   FALLBAK(_sym_glUniform2iv, glsym_func_void);
+
+   FINDSYM(_sym_glUniform3f, "glUniform3f", glsym_func_void);
+   FALLBAK(_sym_glUniform3f, glsym_func_void);
+
+   FINDSYM(_sym_glUniform3fv, "glUniform3fv", glsym_func_void);
+   FALLBAK(_sym_glUniform3fv, glsym_func_void);
+
+   FINDSYM(_sym_glUniform3i, "glUniform3i", glsym_func_void);
+   FALLBAK(_sym_glUniform3i, glsym_func_void);
+
+   FINDSYM(_sym_glUniform3iv, "glUniform3iv", glsym_func_void);
+   FALLBAK(_sym_glUniform3iv, glsym_func_void);
+
+   FINDSYM(_sym_glUniform4f, "glUniform4f", glsym_func_void);
+   FALLBAK(_sym_glUniform4f, glsym_func_void);
+
+   FINDSYM(_sym_glUniform4fv, "glUniform4fv", glsym_func_void);
+   FALLBAK(_sym_glUniform4fv, glsym_func_void);
+
+   FINDSYM(_sym_glUniform4i, "glUniform4i", glsym_func_void);
+   FALLBAK(_sym_glUniform4i, glsym_func_void);
+
+   FINDSYM(_sym_glUniform4iv, "glUniform4iv", glsym_func_void);
+   FALLBAK(_sym_glUniform4iv, glsym_func_void);
+
+   FINDSYM(_sym_glUniformMatrix2fv, "glUniformMatrix2fv", glsym_func_void);
+   FALLBAK(_sym_glUniformMatrix2fv, glsym_func_void);
+
+   FINDSYM(_sym_glUniformMatrix3fv, "glUniformMatrix3fv", glsym_func_void);
+   FALLBAK(_sym_glUniformMatrix3fv, glsym_func_void);
+
+   FINDSYM(_sym_glUniformMatrix4fv, "glUniformMatrix4fv", glsym_func_void);
+   FALLBAK(_sym_glUniformMatrix4fv, glsym_func_void);
+
+   FINDSYM(_sym_glUseProgram, "glUseProgram", glsym_func_void);
+   FALLBAK(_sym_glUseProgram, glsym_func_void);
+
+   FINDSYM(_sym_glValidateProgram, "glValidateProgram", glsym_func_void);
+   FALLBAK(_sym_glValidateProgram, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttrib1f, "glVertexAttrib1f", glsym_func_void);
+   FALLBAK(_sym_glVertexAttrib1f, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttrib1fv, "glVertexAttrib1fv", glsym_func_void);
+   FALLBAK(_sym_glVertexAttrib1fv, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttrib2f, "glVertexAttrib2f", glsym_func_void);
+   FALLBAK(_sym_glVertexAttrib2f, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttrib2fv, "glVertexAttrib2fv", glsym_func_void);
+   FALLBAK(_sym_glVertexAttrib2fv, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttrib3f, "glVertexAttrib3f", glsym_func_void);
+   FALLBAK(_sym_glVertexAttrib3f, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttrib3fv, "glVertexAttrib3fv", glsym_func_void);
+   FALLBAK(_sym_glVertexAttrib3fv, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttrib4f, "glVertexAttrib4f", glsym_func_void);
+   FALLBAK(_sym_glVertexAttrib4f, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttrib4fv, "glVertexAttrib4fv", glsym_func_void);
+   FALLBAK(_sym_glVertexAttrib4fv, glsym_func_void);
+
+   FINDSYM(_sym_glVertexAttribPointer, "glVertexAttribPointer", glsym_func_void);
+   FALLBAK(_sym_glVertexAttribPointer, glsym_func_void);
+
+   FINDSYM(_sym_glViewport, "glViewport", glsym_func_void);
+   FALLBAK(_sym_glViewport, glsym_func_void);
+
+#undef FINDSYM
+#undef FALLBAK
+
+   return 1;
+}
+
+static int
+gl_lib_init(void)
+{
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+   //------------------------------------------------//
+   // Open EGL Library as EGL is separate
+   egl_lib_handle = dlopen("libEGL.so.1", RTLD_NOW|RTLD_GLOBAL);
+   if (!egl_lib_handle)
+      egl_lib_handle = dlopen("libEGL.so", RTLD_NOW|RTLD_GLOBAL);
+   if (!egl_lib_handle)
+     {
+        ERR("%s\n", dlerror());
+        return 0;
+     }
+
+   // use gl_lib handle for GL symbols
+   gl_lib_handle = dlopen("libGLESv2.so.1", RTLD_NOW);
+   if (!gl_lib_handle)
+      gl_lib_handle = dlopen("libGLESv2.so", RTLD_NOW);
+   if (!gl_lib_handle)
+     {
+        ERR("%s\n", dlerror());
+        return 0;
+     }
+   //------------------------------------------------//
+
+#else // GLX
+
+
+   // use gl_lib handle for both GLX and GL symbols
+   //gl_lib_handle = dlopen("/usr/lib/libGL.so", RTLD_NOW);
+   gl_lib_handle = dlopen("libGL.so.1", RTLD_NOW);
+   if (!gl_lib_handle)
+      gl_lib_handle = dlopen("libGL.so", RTLD_NOW);
+   if (!gl_lib_handle)
+     {
+        ERR("%s\n", dlerror());
+        return 0;
+     }
+
+   //------------------------------------------------//
+
+#endif // defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+
+   if (!glue_sym_init()) return 0;
+   if (!gl_sym_init()) return 0;
+
+   return 1;
+}
+
+
+//----------------------------------------------------------------//
+//                      Override Functions                        //
+//----------------------------------------------------------------//
+#define EVASGLUE_API_OVERRIDE(func, api_pre, prefix) \
+   api_pre##func = prefix##func
+
+#define EVASGL_API_OVERRIDE(func, api, prefix) \
+     (api)->func = prefix##func
+
+static void
+override_glue_normal_path()
+{
+#ifdef EVAS_GL_NAME_MANGLE
+#  define N_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, _sym_) // GL Normal Path
+#  define W_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, evgl_) // GL Wrapped Path
+#else
+#  define N_ORD(f) EVASGLUE_API_OVERRIDE(f,, _sym_) // GL Normal Path
+#  define W_ORD(f) EVASGLUE_API_OVERRIDE(f,, evgl_) // GL Wrapped Path
+#endif
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+   N_ORD(eglGetProcAddress);
+   N_ORD(eglGetError);
+   N_ORD(eglGetDisplay);
+   N_ORD(eglInitialize);
+   N_ORD(eglTerminate);
+   N_ORD(eglChooseConfig);
+   N_ORD(eglCreateWindowSurface);
+   N_ORD(eglCreatePixmapSurface);
+   N_ORD(eglDestroySurface);
+   N_ORD(eglBindAPI);
+   N_ORD(eglWaitClient);
+   N_ORD(eglSurfaceAttrib);
+   N_ORD(eglBindTexImage);
+   N_ORD(eglReleaseTexImage);
+   N_ORD(eglSwapInterval);
+   N_ORD(eglCreateContext);
+   N_ORD(eglDestroyContext);
+   N_ORD(eglGetCurrentContext);
+   N_ORD(eglGetCurrentSurface);
+   N_ORD(eglGetCurrentDisplay);
+   N_ORD(eglWaitGL);
+   N_ORD(eglWaitNative);
+   N_ORD(eglSwapBuffers);
+   N_ORD(eglCopyBuffers);
+   N_ORD(eglQueryString);
+
+   // Extensions
+   N_ORD(eglCreateImage);
+   N_ORD(eglDestroyImage);
+   N_ORD(eglMapImageSEC);
+   N_ORD(eglUnmapImageSEC);
+   N_ORD(eglGetImageAttribSEC);
+   N_ORD(glEGLImageTargetTexture2DOES);
+   N_ORD(glEGLImageTargetRenderbufferStorageOES);
+
+   // Wrapped functions for evasgl specific purpose
+   W_ORD(eglMakeCurrent);
+#else
+   N_ORD(glXGetProcAddress);
+   N_ORD(glXChooseVisual);
+   N_ORD(glXCreateContext);
+   N_ORD(glXDestroyContext);
+   N_ORD(glXGetCurrentContext);
+   N_ORD(glXGetCurrentDrawable);
+   N_ORD(glXSwapBuffers);
+   N_ORD(glXWaitX);
+   N_ORD(glXWaitGL);
+   N_ORD(glXQueryExtension);
+   N_ORD(glXQueryExtensionsString);
+   N_ORD(glXChooseFBConfig);
+   N_ORD(glXGetFBConfigs);
+   N_ORD(glXGetFBConfigAttrib);
+   N_ORD(glXGetVisualFromFBConfig);
+   N_ORD(glXDestroyWindow);
+   N_ORD(glXMakeContextCurrent);
+   N_ORD(glXBindTexImage);
+   N_ORD(glXReleaseTexImage);
+   N_ORD(glXGetVideoSync);
+   N_ORD(glXWaitVideoSync);
+   N_ORD(glXCreatePixmap);
+   N_ORD(glXDestroyPixmap);
+   N_ORD(glXQueryDrawable);
+   N_ORD(glXSwapIntervalSGI);
+   N_ORD(glXSwapIntervalEXT);
+
+   // Wrapped functions for evasgl specific purpose
+   W_ORD(glXMakeCurrent);
+#endif
+
+#undef N_ORD
+#undef W_ORD
+}
+
+
+static void
+override_glue_wrapped_path()
+{
+
+#ifdef EVAS_GL_NAME_MANGLE
+#  define W_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, evgl_) // GL Wrapped Path
+#else
+#  define W_ORD(f) EVASGLUE_API_OVERRIDE(f,, evgl_) // GL Wrapped Path
+#endif
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+   W_ORD(eglGetProcAddress);
+   W_ORD(eglGetError);
+   W_ORD(eglGetDisplay);
+   W_ORD(eglInitialize);
+   W_ORD(eglTerminate);
+   W_ORD(eglChooseConfig);
+   W_ORD(eglCreateWindowSurface);
+   W_ORD(eglCreatePixmapSurface);
+   W_ORD(eglDestroySurface);
+   W_ORD(eglBindAPI);
+   W_ORD(eglWaitClient);
+   W_ORD(eglSurfaceAttrib);
+   W_ORD(eglBindTexImage);
+   W_ORD(eglReleaseTexImage);
+   W_ORD(eglSwapInterval);
+   W_ORD(eglCreateContext);
+   W_ORD(eglDestroyContext);
+   W_ORD(eglGetCurrentContext);
+   W_ORD(eglGetCurrentSurface);
+   W_ORD(eglGetCurrentDisplay);
+   W_ORD(eglWaitGL);
+   W_ORD(eglWaitNative);
+   W_ORD(eglSwapBuffers);
+   W_ORD(eglCopyBuffers);
+   W_ORD(eglQueryString);
+
+   // Extensions
+   W_ORD(eglCreateImage);
+   W_ORD(eglDestroyImage);
+   W_ORD(eglMapImageSEC);
+   W_ORD(eglUnmapImageSEC);
+   W_ORD(eglGetImageAttribSEC);
+   W_ORD(glEGLImageTargetTexture2DOES);
+   W_ORD(glEGLImageTargetRenderbufferStorageOES);
+
+   // Wrapped functions for evasgl specific purpose
+   W_ORD(eglMakeCurrent);
+#else
+   W_ORD(glXGetProcAddress);
+   W_ORD(glXChooseVisual);
+   W_ORD(glXCreateContext);
+   W_ORD(glXDestroyContext);
+   W_ORD(glXGetCurrentContext);
+   W_ORD(glXGetCurrentDrawable);
+   W_ORD(glXSwapBuffers);
+   W_ORD(glXWaitX);
+   W_ORD(glXWaitGL);
+   W_ORD(glXQueryExtension);
+   W_ORD(glXQueryExtensionsString);
+   W_ORD(glXChooseFBConfig);
+   W_ORD(glXGetFBConfigs);
+   W_ORD(glXGetFBConfigAttrib);
+   W_ORD(glXGetVisualFromFBConfig);
+   W_ORD(glXDestroyWindow);
+   W_ORD(glXMakeContextCurrent);
+   W_ORD(glXBindTexImage);
+   W_ORD(glXReleaseTexImage);
+   W_ORD(glXGetVideoSync);
+   W_ORD(glXWaitVideoSync);
+   W_ORD(glXCreatePixmap);
+   W_ORD(glXDestroyPixmap);
+   W_ORD(glXQueryDrawable);
+   W_ORD(glXSwapIntervalSGI);
+   W_ORD(glXSwapIntervalEXT);
+
+   // Wrapped functions for evasgl specific purpose
+   W_ORD(glXMakeCurrent);
+#endif
+
+#undef W_ORD
+}
+
+static void
+override_glue_fast_path()
+{
+   // Inherit from wrapped path
+   override_glue_wrapped_path();
+
+#ifdef EVAS_GL_NAME_MANGLE
+#  define F_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, fpgl_) // GL Fast Path
+#else
+#  define F_ORD(f) EVASGLUE_API_OVERRIDE(f,, fpgl_) // GL Fast Path
+#endif
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+   // Fastpath-ed Functions
+   F_ORD(eglCreateContext);
+   F_ORD(eglDestroyContext);
+   F_ORD(eglDestroySurface);
+   F_ORD(eglMakeCurrent);
+   F_ORD(eglGetCurrentContext);
+   F_ORD(eglGetCurrentSurface);
+
+#else
+   // Fastpath-ed Functions
+   F_ORD(glXCreateContext);
+   F_ORD(glXDestroyContext);
+   F_ORD(glXMakeCurrent);
+   F_ORD(glXGetCurrentContext);
+   F_ORD(glXGetCurrentDrawable);
+
+   F_ORD(glXMakeContextCurrent);
+#endif
+
+#undef F_ORD
+}
+
+static void
+override_gl_normal_path()
+{
+#ifdef EVAS_GL_NAME_MANGLE
+#  define N_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, _sym_) // GL Normal Path
+#  define W_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, evgl_) // GL Wrapped Path
+#else
+#  define N_ORD(f) EVASGLUE_API_OVERRIDE(f,, _sym_) // GL Normal Path
+#  define W_ORD(f) EVASGLUE_API_OVERRIDE(f,, evgl_) // GL Wrapped Path
+#endif
+   N_ORD(glAttachShader);
+   N_ORD(glBindAttribLocation);
+   N_ORD(glBufferData);
+   N_ORD(glBufferSubData);
+   N_ORD(glCheckFramebufferStatus);
+   N_ORD(glClear);
+   N_ORD(glCompileShader);
+   N_ORD(glCompressedTexImage2D);
+   N_ORD(glCompressedTexSubImage2D);
+   N_ORD(glCopyTexImage2D);
+   N_ORD(glCopyTexSubImage2D);
+   N_ORD(glCreateProgram);
+   N_ORD(glCreateShader);
+   N_ORD(glDeleteBuffers);
+   N_ORD(glDeleteFramebuffers);
+   N_ORD(glDeleteProgram);
+   N_ORD(glDeleteRenderbuffers);
+   N_ORD(glDeleteShader);
+   N_ORD(glDeleteTextures);
+   N_ORD(glFinish);
+   N_ORD(glFlush);
+   N_ORD(glFramebufferRenderbuffer);
+   N_ORD(glFramebufferTexture2D);
+   N_ORD(glGenBuffers);
+   N_ORD(glGenerateMipmap);
+   N_ORD(glGenFramebuffers);
+   N_ORD(glGenRenderbuffers);
+   N_ORD(glGenTextures);
+   N_ORD(glGetActiveAttrib);
+   N_ORD(glGetActiveUniform);
+   N_ORD(glGetAttachedShaders);
+   N_ORD(glGetAttribLocation);
+   N_ORD(glGetBooleanv);
+   N_ORD(glGetBufferParameteriv);
+   N_ORD(glGetError);
+   N_ORD(glGetFloatv);
+   N_ORD(glGetFramebufferAttachmentParameteriv);
+   N_ORD(glGetIntegerv);
+   N_ORD(glGetProgramiv);
+   N_ORD(glGetProgramInfoLog);
+   N_ORD(glGetRenderbufferParameteriv);
+   N_ORD(glGetShaderiv);
+   N_ORD(glGetShaderInfoLog);
+   N_ORD(glGetShaderSource);
+   N_ORD(glGetString);
+   N_ORD(glGetTexParameterfv);
+   N_ORD(glGetTexParameteriv);
+   N_ORD(glGetUniformfv);
+   N_ORD(glGetUniformiv);
+   N_ORD(glGetUniformLocation);
+   N_ORD(glIsBuffer);
+   N_ORD(glIsEnabled);
+   N_ORD(glIsFramebuffer);
+   N_ORD(glIsProgram);
+   N_ORD(glIsRenderbuffer);
+   N_ORD(glIsShader);
+   N_ORD(glIsTexture);
+   N_ORD(glLineWidth);
+   N_ORD(glLinkProgram);
+   N_ORD(glReadPixels);
+   N_ORD(glRenderbufferStorage);
+   N_ORD(glShaderSource);
+   N_ORD(glTexImage2D);
+   N_ORD(glTexParameterf);
+   N_ORD(glTexParameterfv);
+   N_ORD(glTexParameteri);
+   N_ORD(glTexParameteriv);
+   N_ORD(glTexSubImage2D);
+   N_ORD(glUniform1f);
+   N_ORD(glUniform1fv);
+   N_ORD(glUniform1i);
+   N_ORD(glUniform1iv);
+   N_ORD(glUniform2f);
+   N_ORD(glUniform2fv);
+   N_ORD(glUniform2i);
+   N_ORD(glUniform2iv);
+   N_ORD(glUniform3f);
+   N_ORD(glUniform3fv);
+   N_ORD(glUniform3i);
+   N_ORD(glUniform3iv);
+   N_ORD(glUniform4f);
+   N_ORD(glUniform4fv);
+   N_ORD(glUniform4i);
+   N_ORD(glUniform4iv);
+   N_ORD(glUniformMatrix2fv);
+   N_ORD(glUniformMatrix3fv);
+   N_ORD(glUniformMatrix4fv);
+   N_ORD(glValidateProgram);
+
+   N_ORD(glActiveTexture);
+   N_ORD(glBindBuffer);
+   N_ORD(glBindTexture);
+   N_ORD(glBlendColor);
+   N_ORD(glBlendEquation);
+   N_ORD(glBlendEquationSeparate);
+   N_ORD(glBlendFunc);
+   N_ORD(glBlendFuncSeparate);
+   N_ORD(glClearColor);
+   N_ORD(glClearDepthf);
+   N_ORD(glClearStencil);
+   N_ORD(glColorMask);
+   N_ORD(glCullFace);
+   N_ORD(glDepthFunc);
+   N_ORD(glDepthMask);
+   N_ORD(glDepthRangef);
+   N_ORD(glDetachShader);
+   N_ORD(glDisable);
+   N_ORD(glDisableVertexAttribArray);
+   N_ORD(glDrawArrays);
+   N_ORD(glDrawElements);
+   N_ORD(glEnable);
+   N_ORD(glEnableVertexAttribArray);
+   N_ORD(glFrontFace);
+   N_ORD(glGetVertexAttribfv);
+   N_ORD(glGetVertexAttribiv);
+   N_ORD(glGetVertexAttribPointerv);
+   N_ORD(glHint);
+   N_ORD(glPixelStorei);
+   N_ORD(glPolygonOffset);
+   N_ORD(glSampleCoverage);
+   N_ORD(glScissor);
+   N_ORD(glStencilFunc);
+   N_ORD(glStencilFuncSeparate);
+   N_ORD(glStencilMask);
+   N_ORD(glStencilMaskSeparate);
+   N_ORD(glStencilOp);
+   N_ORD(glStencilOpSeparate);
+   N_ORD(glUseProgram);
+   N_ORD(glVertexAttrib1f);
+   N_ORD(glVertexAttrib1fv);
+   N_ORD(glVertexAttrib2f);
+   N_ORD(glVertexAttrib2fv);
+   N_ORD(glVertexAttrib3f);
+   N_ORD(glVertexAttrib3fv);
+   N_ORD(glVertexAttrib4f);
+   N_ORD(glVertexAttrib4fv);
+   N_ORD(glVertexAttribPointer);
+   N_ORD(glViewport);
+
+   // Extensions
+   N_ORD(glGetProgramBinary);
+   N_ORD(glProgramBinary);
+   N_ORD(glProgramParameteri);
+
+   //----------------------------------------------------//
+   // Functions that need to be overriden for evasgl use
+   W_ORD(glBindFramebuffer);
+   W_ORD(glBindRenderbuffer);
+
+   // GLES2.0 API compat on top of desktop gl
+   W_ORD(glGetShaderPrecisionFormat);
+   W_ORD(glReleaseShaderCompiler);
+   W_ORD(glShaderBinary);
+
+#undef N_ORD
+#undef W_ORD
+}
+
+static void
+override_gl_wrapped_path()
+{
+
+#ifdef EVAS_GL_NAME_MANGLE
+#  define N_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, _sym_) // GL Normal Path
+#  define W_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, evgl_) // GL Wrapped Path
+#else
+#  define N_ORD(f) EVASGLUE_API_OVERRIDE(f,, _sym_) // GL Normal Path
+#  define W_ORD(f) EVASGLUE_API_OVERRIDE(f,, evgl_) // GL Wrapped Path
+#endif
+
+   W_ORD(glAttachShader);
+   W_ORD(glBindAttribLocation);
+   W_ORD(glBufferData);
+   W_ORD(glBufferSubData);
+   W_ORD(glCheckFramebufferStatus);
+   W_ORD(glClear);
+   W_ORD(glCompileShader);
+   W_ORD(glCompressedTexImage2D);
+   W_ORD(glCompressedTexSubImage2D);
+   W_ORD(glCopyTexImage2D);
+   W_ORD(glCopyTexSubImage2D);
+   W_ORD(glCreateProgram);
+   W_ORD(glCreateShader);
+   W_ORD(glDeleteBuffers);
+   W_ORD(glDeleteFramebuffers);
+   W_ORD(glDeleteProgram);
+   W_ORD(glDeleteRenderbuffers);
+   W_ORD(glDeleteShader);
+   W_ORD(glDeleteTextures);
+   W_ORD(glFinish);
+   W_ORD(glFlush);
+   W_ORD(glFramebufferRenderbuffer);
+   W_ORD(glFramebufferTexture2D);
+   W_ORD(glGenBuffers);
+   W_ORD(glGenerateMipmap);
+   W_ORD(glGenFramebuffers);
+   W_ORD(glGenRenderbuffers);
+   W_ORD(glGenTextures);
+   W_ORD(glGetActiveAttrib);
+   W_ORD(glGetActiveUniform);
+   W_ORD(glGetAttachedShaders);
+   W_ORD(glGetAttribLocation);
+   W_ORD(glGetBooleanv);
+   W_ORD(glGetBufferParameteriv);
+   W_ORD(glGetError);
+   W_ORD(glGetFloatv);
+   W_ORD(glGetFramebufferAttachmentParameteriv);
+   W_ORD(glGetIntegerv);
+   W_ORD(glGetProgramiv);
+   W_ORD(glGetProgramInfoLog);
+   W_ORD(glGetRenderbufferParameteriv);
+   W_ORD(glGetShaderiv);
+   W_ORD(glGetShaderInfoLog);
+   W_ORD(glGetShaderSource);
+   W_ORD(glGetString);
+   W_ORD(glGetTexParameterfv);
+   W_ORD(glGetTexParameteriv);
+   W_ORD(glGetUniformfv);
+   W_ORD(glGetUniformiv);
+   W_ORD(glGetUniformLocation);
+   W_ORD(glIsBuffer);
+   W_ORD(glIsEnabled);
+   W_ORD(glIsFramebuffer);
+   W_ORD(glIsProgram);
+   W_ORD(glIsRenderbuffer);
+   W_ORD(glIsShader);
+   W_ORD(glIsTexture);
+   W_ORD(glLineWidth);
+   W_ORD(glLinkProgram);
+   W_ORD(glReadPixels);
+   W_ORD(glRenderbufferStorage);
+   W_ORD(glShaderSource);
+   W_ORD(glTexImage2D);
+   W_ORD(glTexParameterf);
+   W_ORD(glTexParameterfv);
+   W_ORD(glTexParameteri);
+   W_ORD(glTexParameteriv);
+   W_ORD(glTexSubImage2D);
+   W_ORD(glUniform1f);
+   W_ORD(glUniform1fv);
+   W_ORD(glUniform1i);
+   W_ORD(glUniform1iv);
+   W_ORD(glUniform2f);
+   W_ORD(glUniform2fv);
+   W_ORD(glUniform2i);
+   W_ORD(glUniform2iv);
+   W_ORD(glUniform3f);
+   W_ORD(glUniform3fv);
+   W_ORD(glUniform3i);
+   W_ORD(glUniform3iv);
+   W_ORD(glUniform4f);
+   W_ORD(glUniform4fv);
+   W_ORD(glUniform4i);
+   W_ORD(glUniform4iv);
+   W_ORD(glUniformMatrix2fv);
+   W_ORD(glUniformMatrix3fv);
+   W_ORD(glUniformMatrix4fv);
+   W_ORD(glValidateProgram);
+
+   W_ORD(glActiveTexture);
+   W_ORD(glBindBuffer);
+   W_ORD(glBindTexture);
+   W_ORD(glBlendColor);
+   W_ORD(glBlendEquation);
+   W_ORD(glBlendEquationSeparate);
+   W_ORD(glBlendFunc);
+   W_ORD(glBlendFuncSeparate);
+   W_ORD(glClearColor);
+   W_ORD(glClearDepthf);
+   W_ORD(glClearStencil);
+   W_ORD(glColorMask);
+   W_ORD(glCullFace);
+   W_ORD(glDepthFunc);
+   W_ORD(glDepthMask);
+   W_ORD(glDepthRangef);
+   W_ORD(glDetachShader);
+   W_ORD(glDisable);
+   W_ORD(glDisableVertexAttribArray);
+   W_ORD(glDrawArrays);
+   W_ORD(glDrawElements);
+   W_ORD(glEnable);
+   W_ORD(glEnableVertexAttribArray);
+   W_ORD(glFrontFace);
+   W_ORD(glGetVertexAttribfv);
+   W_ORD(glGetVertexAttribiv);
+   W_ORD(glGetVertexAttribPointerv);
+   W_ORD(glHint);
+   W_ORD(glPixelStorei);
+   W_ORD(glPolygonOffset);
+   W_ORD(glSampleCoverage);
+   W_ORD(glScissor);
+   W_ORD(glStencilFunc);
+   W_ORD(glStencilFuncSeparate);
+   W_ORD(glStencilMask);
+   W_ORD(glStencilMaskSeparate);
+   W_ORD(glStencilOp);
+   W_ORD(glStencilOpSeparate);
+   W_ORD(glUseProgram);
+   W_ORD(glVertexAttrib1f);
+   W_ORD(glVertexAttrib1fv);
+   W_ORD(glVertexAttrib2f);
+   W_ORD(glVertexAttrib2fv);
+   W_ORD(glVertexAttrib3f);
+   W_ORD(glVertexAttrib3fv);
+   W_ORD(glVertexAttrib4f);
+   W_ORD(glVertexAttrib4fv);
+   W_ORD(glVertexAttribPointer);
+   W_ORD(glViewport);
+
+   // Extensions
+   W_ORD(glGetProgramBinary);
+   W_ORD(glProgramBinary);
+   W_ORD(glProgramParameteri);
+
+   //----------------------------------------------------//
+   // Functions that need to be overriden for evasgl use
+   W_ORD(glBindFramebuffer);
+   W_ORD(glBindRenderbuffer);
+
+   // GLES2.0 API compat on top of desktop gl
+   W_ORD(glGetShaderPrecisionFormat);
+   W_ORD(glReleaseShaderCompiler);
+   W_ORD(glShaderBinary);
+
+#undef N_ORD
+#undef W_ORD
+}
+
+static void
+override_gl_fast_path()
+{
+   // Inherit from wrapped path
+   override_gl_wrapped_path();
+
+#ifdef EVAS_GL_NAME_MANGLE
+#  define F_ORD(f) EVASGLUE_API_OVERRIDE(f, glsym_, fpgl_) // GL Wrapped Path
+#else
+#  define F_ORD(f) EVASGLUE_API_OVERRIDE(f,, fpgl_) // GL Wrapped Path
+#endif
+
+   // Fast-Path Functions
+   F_ORD(glActiveTexture);
+   F_ORD(glBindBuffer);
+   F_ORD(glBindTexture);
+   F_ORD(glBlendColor);
+   F_ORD(glBlendEquation);
+   F_ORD(glBlendEquationSeparate);
+   F_ORD(glBlendFunc);
+   F_ORD(glBlendFuncSeparate);
+   F_ORD(glClearColor);
+   F_ORD(glClearDepthf);
+   F_ORD(glClearStencil);
+   F_ORD(glColorMask);
+   F_ORD(glCullFace);
+   F_ORD(glDepthFunc);
+   F_ORD(glDepthMask);
+   F_ORD(glDepthRangef);
+   F_ORD(glDisable);
+   F_ORD(glDisableVertexAttribArray);
+   F_ORD(glDrawArrays);
+   F_ORD(glDrawElements);
+   F_ORD(glEnable);
+   F_ORD(glEnableVertexAttribArray);
+   F_ORD(glFrontFace);
+   F_ORD(glGetVertexAttribfv);
+   F_ORD(glGetVertexAttribiv);
+   F_ORD(glGetVertexAttribPointerv);
+   F_ORD(glHint);
+   F_ORD(glLineWidth);
+   F_ORD(glPixelStorei);
+   F_ORD(glPolygonOffset);
+   F_ORD(glSampleCoverage);
+   F_ORD(glScissor);
+   F_ORD(glStencilFunc);
+   F_ORD(glStencilFuncSeparate);
+   F_ORD(glStencilMask);
+   F_ORD(glStencilMaskSeparate);
+   F_ORD(glStencilOp);
+   F_ORD(glStencilOpSeparate);
+   F_ORD(glUseProgram);
+   F_ORD(glVertexAttrib1f);
+   F_ORD(glVertexAttrib1fv);
+   F_ORD(glVertexAttrib2f);
+   F_ORD(glVertexAttrib2fv);
+   F_ORD(glVertexAttrib3f);
+   F_ORD(glVertexAttrib3fv);
+   F_ORD(glVertexAttrib4f);
+   F_ORD(glVertexAttrib4fv);
+   F_ORD(glVertexAttribPointer);
+   F_ORD(glViewport);
+
+   // Functions that need to be overriden for evasgl use
+   F_ORD(glBindFramebuffer);
+   F_ORD(glBindRenderbuffer);
+
+#undef F_ORD
+}
+
+
+static void
+override_glue_apis(Evas_GL_Opt_Flag opt)
+{
+   switch(opt)
+     {
+      case GL_NORMAL_PATH:
+         override_glue_normal_path();
+         break;
+      case GL_WRAPPED_PATH:
+         override_glue_wrapped_path();
+         break;
+      case GL_FAST_PATH:
+         override_glue_fast_path();
+         break;
+      default:
+         ERR("Invalide GL Override Option!!!\n");
+     }
+}
+
+static void
+override_gl_apis(Evas_GL_Opt_Flag opt)
+{
+   //_gl.version = EVAS_GL_API_VERSION;
+
+   switch(opt)
+     {
+      case GL_NORMAL_PATH:
+         override_gl_normal_path();
+         break;
+      case GL_WRAPPED_PATH:
+         override_gl_wrapped_path();
+         break;
+      case GL_FAST_PATH:
+         override_gl_fast_path();
+         break;
+      default:
+         ERR("Invalide GL Override Option!!!\n");
+     }
+}
+
+int
+init_gl()
+{
+   char *fp_env;
+   int fastpath_opt = 0;
+   Evas_GL_Opt_Flag api_opt = GL_NORMAL_PATH;
+
+   fprintf(stderr, "Initializing OpenGL APIs...\n");
+
+   fp_env = getenv("EVAS_GL_FASTPATH");
+
+   if (fp_env) fastpath_opt = atoi(fp_env);
+   else fastpath_opt = 0;
+
+   switch(fastpath_opt)
+     {
+      case 1:
+         api_opt = GL_FAST_PATH;
+         fprintf(stderr, "API OPT: %d Fastpath enabled...\n", fastpath_opt);
+         break;
+      case 2:
+         api_opt = GL_WRAPPED_PATH;
+         fprintf(stderr, "API OPT: %d Wrapped API path enabled...\n", fastpath_opt);
+         break;
+      default:
+         fprintf(stderr, "API OPT: %d Default API path enabled...\n", fastpath_opt);
+         api_opt = GL_NORMAL_PATH;
+         break;
+     }
+
+   if (!gl_lib_init()) return 0;
+
+   override_glue_apis(api_opt);
+   override_gl_apis(api_opt);
+
+   return 1;
+}
+
+void
+free_gl()
+{
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+   if (global_ctx)
+     {
+        ERR("Destroying global context...\n");
+        _sym_eglMakeCurrent(global_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        _sym_eglDestroyContext(global_dpy, global_ctx);
+     }
+   if (egl_lib_handle) dlclose(egl_lib_handle);
+   if (gl_lib_handle) dlclose (gl_lib_handle);
+#else
+   if (global_ctx)
+     {
+        ERR("Destroying global context...\n");
+        _sym_glXDestroyContext(global_dpy, global_ctx);
+     }
+   if (gl_lib_handle) dlclose (gl_lib_handle);
+#endif
+}
+
diff --git a/src/modules/engines/gl_common/evas_gl_core.h b/src/modules/engines/gl_common/evas_gl_core.h
new file mode 100644 (file)
index 0000000..31af73f
--- /dev/null
@@ -0,0 +1,1381 @@
+#ifndef EVAS_GL_CORE_H
+#define EVAS_GL_CORE_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#ifdef EVAS_GL_STANDALONE
+#  define ERR(...) \
+   fprintf(stderr, __VA_ARGS__);
+
+#  ifdef EVAS_GL_DEBUG
+#     define DBG(...) \
+         fprintf(stderr, __VA_ARGS__);
+#  endif
+#else
+#  include "config.h"
+#  include "evas_common.h"
+
+#  define EVAS_GL_NAME_MANGLE 1
+#endif
+
+// Name mangling used when built with Evas
+#ifdef EVAS_GL_NAME_MANGLE
+#  define GL(name) glsym_##name
+#else
+#  define GL(name) name
+#endif
+
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/*-------------------------------------------------------------------------
+ * Data type definitions
+ *-----------------------------------------------------------------------*/
+
+typedef void             GLvoid;
+typedef unsigned int     GLenum;
+typedef unsigned char    GLboolean;
+typedef unsigned int     GLbitfield;
+typedef signed char      GLbyte;       // Changed khronos_int8_t
+typedef short            GLshort;
+typedef int              GLint;
+typedef int              GLsizei;
+typedef unsigned char    GLubyte;      // Changed khronos_uint8_t
+typedef unsigned short   GLushort;
+typedef unsigned int     GLuint;
+typedef float            GLfloat;      // Changed khronos_float_t
+typedef float            GLclampf;     // Changed khronos_float_t
+typedef signed int       GLfixed;      // Changed khronos_int32_t
+
+/* GL types for handling large vertex buffer objects */
+typedef signed long int  GLintptr;     // Changed khronos_intptr_t
+typedef signed long int  GLsizeiptr;   // Changed khronos_ssize_t
+
+#if (!defined(__gl2_h_) && !defined(__gl_h_))
+# define __gl_h_
+# define __gl2_h_
+
+/* OpenGL ES core versions */
+//#define GL_ES_VERSION_2_0                 1
+
+/* ClearBufferMask */
+#define GL_DEPTH_BUFFER_BIT               0x00000100
+#define GL_STENCIL_BUFFER_BIT             0x00000400
+#define GL_COLOR_BUFFER_BIT               0x00004000
+
+/* Boolean */
+#define GL_FALSE                          0
+#define GL_TRUE                           1
+
+/* BeginMode */
+#define GL_POINTS                         0x0000
+#define GL_LINES                          0x0001
+#define GL_LINE_LOOP                      0x0002
+#define GL_LINE_STRIP                     0x0003
+#define GL_TRIANGLES                      0x0004
+#define GL_TRIANGLE_STRIP                 0x0005
+#define GL_TRIANGLE_FAN                   0x0006
+
+/* AlphaFunction (not supported in ES20) */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* BlendingFactorDest */
+#define GL_ZERO                           0
+#define GL_ONE                            1
+#define GL_SRC_COLOR                      0x0300
+#define GL_ONE_MINUS_SRC_COLOR            0x0301
+#define GL_SRC_ALPHA                      0x0302
+#define GL_ONE_MINUS_SRC_ALPHA            0x0303
+#define GL_DST_ALPHA                      0x0304
+#define GL_ONE_MINUS_DST_ALPHA            0x0305
+
+/* BlendingFactorSrc */
+/*      GL_ZERO */
+/*      GL_ONE */
+#define GL_DST_COLOR                      0x0306
+#define GL_ONE_MINUS_DST_COLOR            0x0307
+#define GL_SRC_ALPHA_SATURATE             0x0308
+/*      GL_SRC_ALPHA */
+/*      GL_ONE_MINUS_SRC_ALPHA */
+/*      GL_DST_ALPHA */
+/*      GL_ONE_MINUS_DST_ALPHA */
+
+/* BlendEquationSeparate */
+#define GL_FUNC_ADD                       0x8006
+#define GL_BLEND_EQUATION                 0x8009
+#define GL_BLEND_EQUATION_RGB             0x8009    /* same as BLEND_EQUATION */
+#define GL_BLEND_EQUATION_ALPHA           0x883D
+
+/* BlendSubtract */
+#define GL_FUNC_SUBTRACT                  0x800A
+#define GL_FUNC_REVERSE_SUBTRACT          0x800B
+
+/* Separate Blend Functions */
+#define GL_BLEND_DST_RGB                  0x80C8
+#define GL_BLEND_SRC_RGB                  0x80C9
+#define GL_BLEND_DST_ALPHA                0x80CA
+#define GL_BLEND_SRC_ALPHA                0x80CB
+#define GL_CONSTANT_COLOR                 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR       0x8002
+#define GL_CONSTANT_ALPHA                 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA       0x8004
+#define GL_BLEND_COLOR                    0x8005
+
+/* Buffer Objects */
+#define GL_ARRAY_BUFFER                   0x8892
+#define GL_ELEMENT_ARRAY_BUFFER           0x8893
+#define GL_ARRAY_BUFFER_BINDING           0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING   0x8895
+
+#define GL_STREAM_DRAW                    0x88E0
+#define GL_STATIC_DRAW                    0x88E4
+#define GL_DYNAMIC_DRAW                   0x88E8
+
+#define GL_BUFFER_SIZE                    0x8764
+#define GL_BUFFER_USAGE                   0x8765
+
+#define GL_CURRENT_VERTEX_ATTRIB          0x8626
+
+/* CullFaceMode */
+#define GL_FRONT                          0x0404
+#define GL_BACK                           0x0405
+#define GL_FRONT_AND_BACK                 0x0408
+
+/* DepthFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* EnableCap */
+#define GL_TEXTURE_2D                     0x0DE1
+#define GL_CULL_FACE                      0x0B44
+#define GL_BLEND                          0x0BE2
+#define GL_DITHER                         0x0BD0
+#define GL_STENCIL_TEST                   0x0B90
+#define GL_DEPTH_TEST                     0x0B71
+#define GL_SCISSOR_TEST                   0x0C11
+#define GL_POLYGON_OFFSET_FILL            0x8037
+#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
+#define GL_SAMPLE_COVERAGE                0x80A0
+
+/* ErrorCode */
+#define GL_NO_ERROR                       0
+#define GL_INVALID_ENUM                   0x0500
+#define GL_INVALID_VALUE                  0x0501
+#define GL_INVALID_OPERATION              0x0502
+#define GL_OUT_OF_MEMORY                  0x0505
+
+/* FrontFaceDirection */
+#define GL_CW                             0x0900
+#define GL_CCW                            0x0901
+
+/* GetPName */
+#define GL_LINE_WIDTH                     0x0B21
+#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
+#define GL_CULL_FACE_MODE                 0x0B45
+#define GL_FRONT_FACE                     0x0B46
+#define GL_DEPTH_RANGE                    0x0B70
+#define GL_DEPTH_WRITEMASK                0x0B72
+#define GL_DEPTH_CLEAR_VALUE              0x0B73
+#define GL_DEPTH_FUNC                     0x0B74
+#define GL_STENCIL_CLEAR_VALUE            0x0B91
+#define GL_STENCIL_FUNC                   0x0B92
+#define GL_STENCIL_FAIL                   0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL        0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS        0x0B96
+#define GL_STENCIL_REF                    0x0B97
+#define GL_STENCIL_VALUE_MASK             0x0B93
+#define GL_STENCIL_WRITEMASK              0x0B98
+#define GL_STENCIL_BACK_FUNC              0x8800
+#define GL_STENCIL_BACK_FAIL              0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL   0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS   0x8803
+#define GL_STENCIL_BACK_REF               0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK        0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK         0x8CA5
+#define GL_VIEWPORT                       0x0BA2
+#define GL_SCISSOR_BOX                    0x0C10
+/*      GL_SCISSOR_TEST */
+#define GL_COLOR_CLEAR_VALUE              0x0C22
+#define GL_COLOR_WRITEMASK                0x0C23
+#define GL_UNPACK_ALIGNMENT               0x0CF5
+#define GL_PACK_ALIGNMENT                 0x0D05
+#define GL_MAX_TEXTURE_SIZE               0x0D33
+#define GL_MAX_VIEWPORT_DIMS              0x0D3A
+#define GL_SUBPIXEL_BITS                  0x0D50
+#define GL_RED_BITS                       0x0D52
+#define GL_GREEN_BITS                     0x0D53
+#define GL_BLUE_BITS                      0x0D54
+#define GL_ALPHA_BITS                     0x0D55
+#define GL_DEPTH_BITS                     0x0D56
+#define GL_STENCIL_BITS                   0x0D57
+#define GL_POLYGON_OFFSET_UNITS           0x2A00
+/*      GL_POLYGON_OFFSET_FILL */
+#define GL_POLYGON_OFFSET_FACTOR          0x8038
+#define GL_TEXTURE_BINDING_2D             0x8069
+#define GL_SAMPLE_BUFFERS                 0x80A8
+#define GL_SAMPLES                        0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE          0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT         0x80AB
+
+/* GetTextureParameter */
+/*      GL_TEXTURE_MAG_FILTER */
+/*      GL_TEXTURE_MIN_FILTER */
+/*      GL_TEXTURE_WRAP_S */
+/*      GL_TEXTURE_WRAP_T */
+
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
+
+/* HintMode */
+#define GL_DONT_CARE                      0x1100
+#define GL_FASTEST                        0x1101
+#define GL_NICEST                         0x1102
+
+/* HintTarget */
+#define GL_GENERATE_MIPMAP_HINT            0x8192
+
+/* DataType */
+#define GL_BYTE                           0x1400
+#define GL_UNSIGNED_BYTE                  0x1401
+#define GL_SHORT                          0x1402
+#define GL_UNSIGNED_SHORT                 0x1403
+#define GL_INT                            0x1404
+#define GL_UNSIGNED_INT                   0x1405
+#define GL_FLOAT                          0x1406
+#define GL_FIXED                          0x140C
+
+/* PixelFormat */
+#define GL_DEPTH_COMPONENT                0x1902
+#define GL_ALPHA                          0x1906
+#define GL_RGB                            0x1907
+#define GL_RGBA                           0x1908
+#define GL_LUMINANCE                      0x1909
+#define GL_LUMINANCE_ALPHA                0x190A
+
+/* PixelType */
+/*      GL_UNSIGNED_BYTE */
+#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
+#define GL_UNSIGNED_SHORT_5_6_5           0x8363
+
+/* Shaders */
+#define GL_FRAGMENT_SHADER                  0x8B30
+#define GL_VERTEX_SHADER                    0x8B31
+#define GL_MAX_VERTEX_ATTRIBS               0x8869
+#define GL_MAX_VERTEX_UNIFORM_VECTORS       0x8DFB
+#define GL_MAX_VARYING_VECTORS              0x8DFC
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS   0x8B4C
+#define GL_MAX_TEXTURE_IMAGE_UNITS          0x8872
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS     0x8DFD
+#define GL_SHADER_TYPE                      0x8B4F
+#define GL_DELETE_STATUS                    0x8B80
+#define GL_LINK_STATUS                      0x8B82
+#define GL_VALIDATE_STATUS                  0x8B83
+#define GL_ATTACHED_SHADERS                 0x8B85
+#define GL_ACTIVE_UNIFORMS                  0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH        0x8B87
+#define GL_ACTIVE_ATTRIBUTES                0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH      0x8B8A
+#define GL_SHADING_LANGUAGE_VERSION         0x8B8C
+#define GL_CURRENT_PROGRAM                  0x8B8D
+
+/* StencilFunction */
+#define GL_NEVER                          0x0200
+#define GL_LESS                           0x0201
+#define GL_EQUAL                          0x0202
+#define GL_LEQUAL                         0x0203
+#define GL_GREATER                        0x0204
+#define GL_NOTEQUAL                       0x0205
+#define GL_GEQUAL                         0x0206
+#define GL_ALWAYS                         0x0207
+
+/* StencilOp */
+/*      GL_ZERO */
+#define GL_KEEP                           0x1E00
+#define GL_REPLACE                        0x1E01
+#define GL_INCR                           0x1E02
+#define GL_DECR                           0x1E03
+#define GL_INVERT                         0x150A
+#define GL_INCR_WRAP                      0x8507
+#define GL_DECR_WRAP                      0x8508
+
+/* StringName */
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+
+/* TextureMagFilter */
+#define GL_NEAREST                        0x2600
+#define GL_LINEAR                         0x2601
+
+/* TextureMinFilter */
+/*      GL_NEAREST */
+/*      GL_LINEAR */
+#define GL_NEAREST_MIPMAP_NEAREST         0x2700
+#define GL_LINEAR_MIPMAP_NEAREST          0x2701
+#define GL_NEAREST_MIPMAP_LINEAR          0x2702
+#define GL_LINEAR_MIPMAP_LINEAR           0x2703
+
+/* TextureParameterName */
+#define GL_TEXTURE_MAG_FILTER             0x2800
+#define GL_TEXTURE_MIN_FILTER             0x2801
+#define GL_TEXTURE_WRAP_S                 0x2802
+#define GL_TEXTURE_WRAP_T                 0x2803
+
+/* TextureTarget */
+/*      GL_TEXTURE_2D */
+#define GL_TEXTURE                        0x1702
+
+#define GL_TEXTURE_CUBE_MAP               0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP       0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X    0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X    0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y    0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y    0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z    0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z    0x851A
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE      0x851C
+
+/* TextureUnit */
+#define GL_TEXTURE0                       0x84C0
+#define GL_TEXTURE1                       0x84C1
+#define GL_TEXTURE2                       0x84C2
+#define GL_TEXTURE3                       0x84C3
+#define GL_TEXTURE4                       0x84C4
+#define GL_TEXTURE5                       0x84C5
+#define GL_TEXTURE6                       0x84C6
+#define GL_TEXTURE7                       0x84C7
+#define GL_TEXTURE8                       0x84C8
+#define GL_TEXTURE9                       0x84C9
+#define GL_TEXTURE10                      0x84CA
+#define GL_TEXTURE11                      0x84CB
+#define GL_TEXTURE12                      0x84CC
+#define GL_TEXTURE13                      0x84CD
+#define GL_TEXTURE14                      0x84CE
+#define GL_TEXTURE15                      0x84CF
+#define GL_TEXTURE16                      0x84D0
+#define GL_TEXTURE17                      0x84D1
+#define GL_TEXTURE18                      0x84D2
+#define GL_TEXTURE19                      0x84D3
+#define GL_TEXTURE20                      0x84D4
+#define GL_TEXTURE21                      0x84D5
+#define GL_TEXTURE22                      0x84D6
+#define GL_TEXTURE23                      0x84D7
+#define GL_TEXTURE24                      0x84D8
+#define GL_TEXTURE25                      0x84D9
+#define GL_TEXTURE26                      0x84DA
+#define GL_TEXTURE27                      0x84DB
+#define GL_TEXTURE28                      0x84DC
+#define GL_TEXTURE29                      0x84DD
+#define GL_TEXTURE30                      0x84DE
+#define GL_TEXTURE31                      0x84DF
+#define GL_ACTIVE_TEXTURE                 0x84E0
+
+/* TextureWrapMode */
+#define GL_REPEAT                         0x2901
+#define GL_CLAMP_TO_EDGE                  0x812F
+#define GL_MIRRORED_REPEAT                0x8370
+
+/* Uniform Types */
+#define GL_FLOAT_VEC2                     0x8B50
+#define GL_FLOAT_VEC3                     0x8B51
+#define GL_FLOAT_VEC4                     0x8B52
+#define GL_INT_VEC2                       0x8B53
+#define GL_INT_VEC3                       0x8B54
+#define GL_INT_VEC4                       0x8B55
+#define GL_BOOL                           0x8B56
+#define GL_BOOL_VEC2                      0x8B57
+#define GL_BOOL_VEC3                      0x8B58
+#define GL_BOOL_VEC4                      0x8B59
+#define GL_FLOAT_MAT2                     0x8B5A
+#define GL_FLOAT_MAT3                     0x8B5B
+#define GL_FLOAT_MAT4                     0x8B5C
+#define GL_SAMPLER_2D                     0x8B5E
+#define GL_SAMPLER_CUBE                   0x8B60
+
+/* Vertex Arrays */
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED        0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE           0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE         0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE           0x8625
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED     0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER        0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+
+/* Read Format */
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE   0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+
+/* Shader Source */
+#define GL_COMPILE_STATUS                 0x8B81
+#define GL_INFO_LOG_LENGTH                0x8B84
+#define GL_SHADER_SOURCE_LENGTH           0x8B88
+#define GL_SHADER_COMPILER                0x8DFA
+
+/* Shader Binary */
+#define GL_SHADER_BINARY_FORMATS          0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS      0x8DF9
+
+/* Shader Precision-Specified Types */
+#define GL_LOW_FLOAT                      0x8DF0
+#define GL_MEDIUM_FLOAT                   0x8DF1
+#define GL_HIGH_FLOAT                     0x8DF2
+#define GL_LOW_INT                        0x8DF3
+#define GL_MEDIUM_INT                     0x8DF4
+#define GL_HIGH_INT                       0x8DF5
+
+/* Framebuffer Object. */
+#define GL_FRAMEBUFFER                    0x8D40
+#define GL_RENDERBUFFER                   0x8D41
+
+#define GL_RGBA4                          0x8056
+#define GL_RGB5_A1                        0x8057
+#define GL_RGB565                         0x8D62
+#define GL_DEPTH_COMPONENT16              0x81A5
+#define GL_STENCIL_INDEX                  0x1901
+#define GL_STENCIL_INDEX8                 0x8D48
+
+#define GL_RENDERBUFFER_WIDTH             0x8D42
+#define GL_RENDERBUFFER_HEIGHT            0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT   0x8D44
+#define GL_RENDERBUFFER_RED_SIZE          0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE        0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE         0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE        0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE        0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE      0x8D55
+
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE           0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME           0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL         0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+
+#define GL_COLOR_ATTACHMENT0              0x8CE0
+#define GL_DEPTH_ATTACHMENT               0x8D00
+#define GL_STENCIL_ATTACHMENT             0x8D20
+
+#define GL_NONE                           0
+
+#define GL_FRAMEBUFFER_COMPLETE                      0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT         0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS         0x8CD9
+#define GL_FRAMEBUFFER_UNSUPPORTED                   0x8CDD
+
+#define GL_FRAMEBUFFER_BINDING            0x8CA6
+#define GL_RENDERBUFFER_BINDING           0x8CA7
+#define GL_MAX_RENDERBUFFER_SIZE          0x84E8
+
+#define GL_INVALID_FRAMEBUFFER_OPERATION  0x0506
+
+//---------------------------//
+// GLES extension defines
+
+/* GL_OES_get_program_binary */
+#ifndef GL_OES_get_program_binary
+#define GL_PROGRAM_BINARY_LENGTH_OES                            0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS_OES                       0x87FE
+#define GL_PROGRAM_BINARY_FORMATS_OES                           0x87FF
+#endif
+
+#ifndef GL_ARB_get_program_binary
+#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
+#define GL_PROGRAM_BINARY_LENGTH          0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS     0x87FE
+#define GL_PROGRAM_BINARY_FORMATS         0x87FF
+#endif
+
+/* GL_EXT_read_format_bgra */
+#ifndef GL_EXT_read_format_bgra
+#define GL_BGRA_EXT                                             0x80E1
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT                       0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT                       0x8366
+#endif
+
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT                           0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                       0x84FF
+#endif
+
+/* GL_EXT_texture_format_BGRA8888 */
+#ifndef GL_EXT_texture_format_BGRA8888
+#define GL_BGRA_EXT                                             0x80E1
+#endif
+
+#endif
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+//------------------------------------------------------//
+//                         EGL
+//------------------------------------------------------//
+
+/* EGL Types */
+/* EGLint is defined in eglplatform.h */
+
+//!!!! Should be in
+typedef int EGLint;     // Should properly handle 64bit machine...
+
+//!!!! X11 Dependent...
+typedef Display *EGLNativeDisplayType;
+typedef Pixmap   EGLNativePixmapType;
+typedef Window   EGLNativeWindowType;
+
+typedef unsigned int EGLBoolean;
+typedef unsigned int EGLenum;
+typedef void *EGLConfig;
+typedef void *EGLContext;
+typedef void *EGLDisplay;
+typedef void *EGLSurface;
+typedef void *EGLClientBuffer;
+
+/* EGL Versioning */
+#define EGL_VERSION_1_0                        1
+#define EGL_VERSION_1_1                        1
+#define EGL_VERSION_1_2                        1
+#define EGL_VERSION_1_3                        1
+#define EGL_VERSION_1_4                        1
+
+/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
+ * enums are assigned unique values starting at 0x3000.
+ */
+
+/* EGL aliases */
+#define EGL_FALSE                      0
+#define EGL_TRUE                       1
+
+/* Out-of-band handle values */
+#define EGL_DEFAULT_DISPLAY            ((EGLNativeDisplayType)0)
+#define EGL_NO_CONTEXT                 ((EGLContext)0)
+#define EGL_NO_DISPLAY                 ((EGLDisplay)0)
+#define EGL_NO_SURFACE                 ((EGLSurface)0)
+
+/* Out-of-band attribute value */
+#define EGL_DONT_CARE                  ((EGLint)-1)
+
+/* Errors / GetError return values */
+#define EGL_SUCCESS                    0x3000
+#define EGL_NOT_INITIALIZED            0x3001
+#define EGL_BAD_ACCESS                 0x3002
+#define EGL_BAD_ALLOC                  0x3003
+#define EGL_BAD_ATTRIBUTE              0x3004
+#define EGL_BAD_CONFIG                 0x3005
+#define EGL_BAD_CONTEXT                        0x3006
+#define EGL_BAD_CURRENT_SURFACE                0x3007
+#define EGL_BAD_DISPLAY                        0x3008
+#define EGL_BAD_MATCH                  0x3009
+#define EGL_BAD_NATIVE_PIXMAP          0x300A
+#define EGL_BAD_NATIVE_WINDOW          0x300B
+#define EGL_BAD_PARAMETER              0x300C
+#define EGL_BAD_SURFACE                        0x300D
+#define EGL_CONTEXT_LOST               0x300E  /* EGL 1.1 - IMG_power_management */
+
+/* Reserved 0x300F-0x301F for additional errors */
+
+/* Config attributes */
+#define EGL_BUFFER_SIZE                        0x3020
+#define EGL_ALPHA_SIZE                 0x3021
+#define EGL_BLUE_SIZE                  0x3022
+#define EGL_GREEN_SIZE                 0x3023
+#define EGL_RED_SIZE                   0x3024
+#define EGL_DEPTH_SIZE                 0x3025
+#define EGL_STENCIL_SIZE               0x3026
+#define EGL_CONFIG_CAVEAT              0x3027
+#define EGL_CONFIG_ID                  0x3028
+#define EGL_LEVEL                      0x3029
+#define EGL_MAX_PBUFFER_HEIGHT         0x302A
+#define EGL_MAX_PBUFFER_PIXELS         0x302B
+#define EGL_MAX_PBUFFER_WIDTH          0x302C
+#define EGL_NATIVE_RENDERABLE          0x302D
+#define EGL_NATIVE_VISUAL_ID           0x302E
+#define EGL_NATIVE_VISUAL_TYPE         0x302F
+#define EGL_PRESERVED_RESOURCES                0x3030
+#define EGL_SAMPLES                    0x3031
+#define EGL_SAMPLE_BUFFERS             0x3032
+#define EGL_SURFACE_TYPE               0x3033
+#define EGL_TRANSPARENT_TYPE           0x3034
+#define EGL_TRANSPARENT_BLUE_VALUE     0x3035
+#define EGL_TRANSPARENT_GREEN_VALUE    0x3036
+#define EGL_TRANSPARENT_RED_VALUE      0x3037
+#define EGL_NONE                       0x3038  /* Attrib list terminator */
+#define EGL_BIND_TO_TEXTURE_RGB                0x3039
+#define EGL_BIND_TO_TEXTURE_RGBA       0x303A
+#define EGL_MIN_SWAP_INTERVAL          0x303B
+#define EGL_MAX_SWAP_INTERVAL          0x303C
+#define EGL_LUMINANCE_SIZE             0x303D
+#define EGL_ALPHA_MASK_SIZE            0x303E
+#define EGL_COLOR_BUFFER_TYPE          0x303F
+#define EGL_RENDERABLE_TYPE            0x3040
+#define EGL_MATCH_NATIVE_PIXMAP                0x3041  /* Pseudo-attribute (not queryable) */
+#define EGL_CONFORMANT                 0x3042
+
+/* Reserved 0x3041-0x304F for additional config attributes */
+
+/* Config attribute values */
+#define EGL_SLOW_CONFIG                        0x3050  /* EGL_CONFIG_CAVEAT value */
+#define EGL_NON_CONFORMANT_CONFIG      0x3051  /* EGL_CONFIG_CAVEAT value */
+#define EGL_TRANSPARENT_RGB            0x3052  /* EGL_TRANSPARENT_TYPE value */
+#define EGL_RGB_BUFFER                 0x308E  /* EGL_COLOR_BUFFER_TYPE value */
+#define EGL_LUMINANCE_BUFFER           0x308F  /* EGL_COLOR_BUFFER_TYPE value */
+
+/* More config attribute values, for EGL_TEXTURE_FORMAT */
+#define EGL_NO_TEXTURE                 0x305C
+#define EGL_TEXTURE_RGB                        0x305D
+#define EGL_TEXTURE_RGBA               0x305E
+#define EGL_TEXTURE_2D                 0x305F
+
+/* Config attribute mask bits */
+#define EGL_PBUFFER_BIT                        0x0001  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_PIXMAP_BIT                 0x0002  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_WINDOW_BIT                 0x0004  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_VG_COLORSPACE_LINEAR_BIT   0x0020  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_VG_ALPHA_FORMAT_PRE_BIT    0x0040  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
+#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
+
+#define EGL_OPENGL_ES_BIT              0x0001  /* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENVG_BIT                 0x0002  /* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENGL_ES2_BIT             0x0004  /* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENGL_BIT                 0x0008  /* EGL_RENDERABLE_TYPE mask bits */
+
+/* QueryString targets */
+#define EGL_VENDOR                     0x3053
+#define EGL_VERSION                    0x3054
+#define EGL_EXTENSIONS                 0x3055
+#define EGL_CLIENT_APIS                        0x308D
+
+/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
+#define EGL_HEIGHT                     0x3056
+#define EGL_WIDTH                      0x3057
+#define EGL_LARGEST_PBUFFER            0x3058
+#define EGL_TEXTURE_FORMAT             0x3080
+#define EGL_TEXTURE_TARGET             0x3081
+#define EGL_MIPMAP_TEXTURE             0x3082
+#define EGL_MIPMAP_LEVEL               0x3083
+#define EGL_RENDER_BUFFER              0x3086
+#define EGL_VG_COLORSPACE              0x3087
+#define EGL_VG_ALPHA_FORMAT            0x3088
+#define EGL_HORIZONTAL_RESOLUTION      0x3090
+#define EGL_VERTICAL_RESOLUTION                0x3091
+#define EGL_PIXEL_ASPECT_RATIO         0x3092
+#define EGL_SWAP_BEHAVIOR              0x3093
+#define EGL_MULTISAMPLE_RESOLVE                0x3099
+
+/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
+#define EGL_BACK_BUFFER                        0x3084
+#define EGL_SINGLE_BUFFER              0x3085
+
+/* OpenVG color spaces */
+#define EGL_VG_COLORSPACE_sRGB         0x3089  /* EGL_VG_COLORSPACE value */
+#define EGL_VG_COLORSPACE_LINEAR       0x308A  /* EGL_VG_COLORSPACE value */
+
+/* OpenVG alpha formats */
+#define EGL_VG_ALPHA_FORMAT_NONPRE     0x308B  /* EGL_ALPHA_FORMAT value */
+#define EGL_VG_ALPHA_FORMAT_PRE                0x308C  /* EGL_ALPHA_FORMAT value */
+
+/* Constant scale factor by which fractional display resolutions &
+ * aspect ratio are scaled when queried as integer values.
+ */
+#define EGL_DISPLAY_SCALING            10000
+
+/* Unknown display resolution/aspect ratio */
+#define EGL_UNKNOWN                    ((EGLint)-1)
+
+/* Back buffer swap behaviors */
+#define EGL_BUFFER_PRESERVED           0x3094  /* EGL_SWAP_BEHAVIOR value */
+#define EGL_BUFFER_DESTROYED           0x3095  /* EGL_SWAP_BEHAVIOR value */
+
+/* CreatePbufferFromClientBuffer buffer types */
+#define EGL_OPENVG_IMAGE               0x3096
+
+/* QueryContext targets */
+#define EGL_CONTEXT_CLIENT_TYPE                0x3097
+
+/* CreateContext attributes */
+#define EGL_CONTEXT_CLIENT_VERSION     0x3098
+
+/* Multisample resolution behaviors */
+#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
+#define EGL_MULTISAMPLE_RESOLVE_BOX    0x309B  /* EGL_MULTISAMPLE_RESOLVE value */
+
+/* BindAPI/QueryAPI targets */
+#define EGL_OPENGL_ES_API              0x30A0
+#define EGL_OPENVG_API                 0x30A1
+#define EGL_OPENGL_API                 0x30A2
+
+/* GetCurrentSurface targets */
+#define EGL_DRAW                       0x3059
+#define EGL_READ                       0x305A
+
+/* WaitNative engines */
+#define EGL_CORE_NATIVE_ENGINE         0x305B
+
+/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
+#define EGL_COLORSPACE                 EGL_VG_COLORSPACE
+#define EGL_ALPHA_FORMAT               EGL_VG_ALPHA_FORMAT
+#define EGL_COLORSPACE_sRGB            EGL_VG_COLORSPACE_sRGB
+#define EGL_COLORSPACE_LINEAR          EGL_VG_COLORSPACE_LINEAR
+#define EGL_ALPHA_FORMAT_NONPRE                EGL_VG_ALPHA_FORMAT_NONPRE
+#define EGL_ALPHA_FORMAT_PRE           EGL_VG_ALPHA_FORMAT_PRE
+
+// KHR Extention
+#ifndef EGL_NATIVE_PIXMAP_KHR
+# define EGL_NATIVE_PIXMAP_KHR 0x30b0
+#endif
+
+#else
+
+//------------------------------------------------------//
+//                         GLX
+//------------------------------------------------------//
+
+#define GLX_VERSION_1_1                1
+#define GLX_VERSION_1_2                1
+#define GLX_VERSION_1_3                1
+#define GLX_VERSION_1_4                1
+
+#define GLX_EXTENSION_NAME   "GLX"
+
+/*
+ * Tokens for glXChooseVisual and glXGetConfig:
+ */
+#define GLX_USE_GL             1
+#define GLX_BUFFER_SIZE                2
+#define GLX_LEVEL              3
+#define GLX_RGBA               4
+#define GLX_DOUBLEBUFFER       5
+#define GLX_STEREO             6
+#define GLX_AUX_BUFFERS                7
+#define GLX_RED_SIZE           8
+#define GLX_GREEN_SIZE         9
+#define GLX_BLUE_SIZE          10
+#define GLX_ALPHA_SIZE         11
+#define GLX_DEPTH_SIZE         12
+#define GLX_STENCIL_SIZE       13
+#define GLX_ACCUM_RED_SIZE     14
+#define GLX_ACCUM_GREEN_SIZE   15
+#define GLX_ACCUM_BLUE_SIZE    16
+#define GLX_ACCUM_ALPHA_SIZE   17
+
+
+/*
+ * Error codes returned by glXGetConfig:
+ */
+#define GLX_BAD_SCREEN         1
+#define GLX_BAD_ATTRIBUTE      2
+#define GLX_NO_EXTENSION       3
+#define GLX_BAD_VISUAL         4
+#define GLX_BAD_CONTEXT                5
+#define GLX_BAD_VALUE          6
+#define GLX_BAD_ENUM           7
+
+
+/*
+ * GLX 1.1 and later:
+ */
+#define GLX_VENDOR             1
+#define GLX_VERSION            2
+#define GLX_EXTENSIONS                 3
+
+
+/*
+ * GLX 1.3 and later:
+ */
+#define GLX_CONFIG_CAVEAT              0x20
+#define GLX_DONT_CARE                  0xFFFFFFFF
+#define GLX_X_VISUAL_TYPE              0x22
+#define GLX_TRANSPARENT_TYPE           0x23
+#define GLX_TRANSPARENT_INDEX_VALUE    0x24
+#define GLX_TRANSPARENT_RED_VALUE      0x25
+#define GLX_TRANSPARENT_GREEN_VALUE    0x26
+#define GLX_TRANSPARENT_BLUE_VALUE     0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE    0x28
+#define GLX_WINDOW_BIT                 0x00000001
+#define GLX_PIXMAP_BIT                 0x00000002
+#define GLX_PBUFFER_BIT                        0x00000004
+#define GLX_AUX_BUFFERS_BIT            0x00000010
+#define GLX_FRONT_LEFT_BUFFER_BIT      0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT     0x00000002
+#define GLX_BACK_LEFT_BUFFER_BIT       0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT      0x00000008
+#define GLX_DEPTH_BUFFER_BIT           0x00000020
+#define GLX_STENCIL_BUFFER_BIT         0x00000040
+#define GLX_ACCUM_BUFFER_BIT           0x00000080
+#define GLX_NONE                       0x8000
+#define GLX_SLOW_CONFIG                        0x8001
+#define GLX_TRUE_COLOR                 0x8002
+#define GLX_DIRECT_COLOR               0x8003
+#define GLX_PSEUDO_COLOR               0x8004
+#define GLX_STATIC_COLOR               0x8005
+#define GLX_GRAY_SCALE                 0x8006
+#define GLX_STATIC_GRAY                        0x8007
+#define GLX_TRANSPARENT_RGB            0x8008
+#define GLX_TRANSPARENT_INDEX          0x8009
+#define GLX_VISUAL_ID                  0x800B
+#define GLX_SCREEN                     0x800C
+#define GLX_NON_CONFORMANT_CONFIG      0x800D
+#define GLX_DRAWABLE_TYPE              0x8010
+#define GLX_RENDER_TYPE                        0x8011
+#define GLX_X_RENDERABLE               0x8012
+#define GLX_FBCONFIG_ID                        0x8013
+#define GLX_RGBA_TYPE                  0x8014
+#define GLX_COLOR_INDEX_TYPE           0x8015
+#define GLX_MAX_PBUFFER_WIDTH          0x8016
+#define GLX_MAX_PBUFFER_HEIGHT         0x8017
+#define GLX_MAX_PBUFFER_PIXELS         0x8018
+#define GLX_PRESERVED_CONTENTS         0x801B
+#define GLX_LARGEST_PBUFFER            0x801C
+#define GLX_WIDTH                      0x801D
+#define GLX_HEIGHT                     0x801E
+#define GLX_EVENT_MASK                 0x801F
+#define GLX_DAMAGED                    0x8020
+#define GLX_SAVED                      0x8021
+#define GLX_WINDOW                     0x8022
+#define GLX_PBUFFER                    0x8023
+#define GLX_PBUFFER_HEIGHT              0x8040
+#define GLX_PBUFFER_WIDTH               0x8041
+#define GLX_RGBA_BIT                   0x00000001
+#define GLX_COLOR_INDEX_BIT            0x00000002
+#define GLX_PBUFFER_CLOBBER_MASK       0x08000000
+
+
+/*
+ * GLX 1.4 and later:
+ */
+#define GLX_SAMPLE_BUFFERS              0x186a0 /*100000*/
+#define GLX_SAMPLES                     0x186a1 /*100001*/
+
+
+
+typedef struct __GLXcontextRec *GLXContext;
+typedef XID GLXPixmap;
+typedef XID GLXDrawable;
+/* GLX 1.3 and later */
+typedef struct __GLXFBConfigRec *GLXFBConfig;
+typedef XID GLXFBConfigID;
+typedef XID GLXContextID;
+typedef XID GLXWindow;
+typedef XID GLXPbuffer;
+
+
+
+/*
+ * #?. GLX_EXT_texture_from_pixmap
+ * XXX not finished?
+ */
+#ifndef GLX_EXT_texture_from_pixmap
+#define GLX_EXT_texture_from_pixmap 1
+
+#define GLX_BIND_TO_TEXTURE_RGB_EXT        0x20D0
+#define GLX_BIND_TO_TEXTURE_RGBA_EXT       0x20D1
+#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT     0x20D2
+#define GLX_BIND_TO_TEXTURE_TARGETS_EXT    0x20D3
+#define GLX_Y_INVERTED_EXT                 0x20D4
+
+#define GLX_TEXTURE_FORMAT_EXT             0x20D5
+#define GLX_TEXTURE_TARGET_EXT             0x20D6
+#define GLX_MIPMAP_TEXTURE_EXT             0x20D7
+
+#define GLX_TEXTURE_FORMAT_NONE_EXT        0x20D8
+#define GLX_TEXTURE_FORMAT_RGB_EXT         0x20D9
+#define GLX_TEXTURE_FORMAT_RGBA_EXT        0x20DA
+
+#define GLX_TEXTURE_1D_BIT_EXT             0x00000001
+#define GLX_TEXTURE_2D_BIT_EXT             0x00000002
+#define GLX_TEXTURE_RECTANGLE_BIT_EXT      0x00000004
+
+#define GLX_TEXTURE_1D_EXT                 0x20DB
+#define GLX_TEXTURE_2D_EXT                 0x20DC
+#define GLX_TEXTURE_RECTANGLE_EXT          0x20DD
+
+#define GLX_FRONT_LEFT_EXT                 0x20DE
+#define GLX_FRONT_RIGHT_EXT                0x20DF
+#define GLX_BACK_LEFT_EXT                  0x20E0
+#define GLX_BACK_RIGHT_EXT                 0x20E1
+#define GLX_FRONT_EXT                      GLX_FRONT_LEFT_EXT
+#define GLX_BACK_EXT                       GLX_BACK_LEFT_EXT
+#define GLX_AUX0_EXT                       0x20E2
+#define GLX_AUX1_EXT                       0x20E3
+#define GLX_AUX2_EXT                       0x20E4
+#define GLX_AUX3_EXT                       0x20E5
+#define GLX_AUX4_EXT                       0x20E6
+#define GLX_AUX5_EXT                       0x20E7
+#define GLX_AUX6_EXT                       0x20E8
+#define GLX_AUX7_EXT                       0x20E9
+#define GLX_AUX8_EXT                       0x20EA
+#define GLX_AUX9_EXT                       0x20EB
+
+#endif //GLX_EXT_texture_from_pixmap
+
+#endif //EGL vs. GLX
+
+
+//------------------------------------------------------//
+
+#define MAX_TEXTURE_UNITS 32
+#define MAX_VERTEX_ATTRIBS 16
+typedef struct _EvasGlueContext     *EvasGlueContext;
+
+typedef struct _GL_Texture_State
+{
+   GLint    tex_unit;
+   GLuint   tex_id;
+} GL_Texture_State;
+
+typedef struct _GL_Vertex_Array_State
+{
+   GLboolean   modified;
+   GLboolean   enabled;
+   GLint       size;
+   GLenum      type;
+   GLboolean   normalized;
+   GLsizei     stride;
+   void       *pointer;
+} GL_Vertex_Array_State;
+
+typedef struct _GL_Vertex_Attrib
+{
+   GLboolean   modified;
+   GLfloat     value[4];
+} GL_Vertex_Attrib;
+
+
+#define MAGIC_GLFAST   0x73777770
+
+struct _EvasGlueContext
+{
+
+   int            magic;
+
+   // First time flag
+   int            first_time;
+
+   // Default Framebuffer and RenderBuffers
+   GLuint         fb_zero;
+   GLuint         rb_zero;
+   GLuint         evasgl_enabled;
+
+   GLint          num_tex_units;
+   GLint          num_vertex_attribs;
+
+   //----------------------------------------//
+   // GL States
+   // Bind Functions
+   // glBind {Buffer, Framebuffer, Renderbuffer}
+   // * Texture Binding is done with textures
+   unsigned char _bind_flag;
+   GLuint      gl_array_buffer_binding;               // 0
+   GLuint      gl_element_array_buffer_binding;       // 0
+   GLuint      gl_framebuffer_binding;                // 0
+   GLuint      gl_renderbuffer_binding;               // 0
+
+   //------------------//
+   // Enable States
+   // glEnable()
+   unsigned char _enable_flag1;
+   GLboolean   gl_blend;                              // GL_FALSE
+   GLboolean   gl_cull_face;                          // GL_FALSE
+   GLboolean   gl_depth_test;                         // GL_FALSE
+   GLboolean   gl_dither;                             // GL_TRUE
+
+   unsigned char _enable_flag2;
+   GLboolean   gl_polygon_offset_fill;                // GL_FALSE
+   GLboolean   gl_sample_alpha_to_coverage;           // GL_FALSE
+   GLboolean   gl_sample_coverage;                    // GL_FALSE
+   GLboolean   gl_scissor_test;                       // GL_FALSE
+   GLboolean   gl_stencil_test;                       // GL_FALSE
+
+   //------------------//
+   unsigned char _clear_flag1;
+   // Viewport
+   GLint       gl_viewport[4];                        // (0,0,w,h)
+   // Program (Shaders)
+   GLuint      gl_current_program;                    // 0
+
+   // Clear Color
+   GLclampf    gl_color_clear_value[4];               // (0,0,0,0)
+
+   //------------------//
+   unsigned char _clear_flag2;
+   GLboolean   gl_color_writemask[4];                 // (GL_TRUE x 4)
+   // Depth
+   GLclampf    gl_depth_range[2];                     // (0,1)
+   GLclampf    gl_depth_clear_value;                  // 1
+   GLenum      gl_depth_func;                         // GL_LESS
+   GLboolean   gl_depth_writemask;                    // GL_TRUE
+   GLenum      gl_cull_face_mode;                     // GL_FALSE
+
+   //------------------//
+   unsigned char _tex_flag1;
+   // Texture
+   GL_Texture_State  tex_state[MAX_TEXTURE_UNITS];
+   GLenum            gl_active_texture;               // GL_TEXTURE0
+   GLenum            gl_generate_mipmap_hint;         // GL_DONT_CARE
+   GLuint            gl_texture_binding_2d;           // 0
+   GLuint            gl_texture_binding_cube_map;     // 0
+
+   //unsigned char _tex_flag2[4];
+
+   //------------------//
+   unsigned char _blend_flag;
+   // Blending
+   GLclampf    gl_blend_color[4];
+   GLenum      gl_blend_src_rgb;                      // GL_ONE
+   GLenum      gl_blend_src_alpha;                    // GL_ONE
+   GLenum      gl_blend_dst_rgb;                      // GL_ZERO
+   GLenum      gl_blend_dst_alpha;                    // GL_ZERO
+   GLenum      gl_blend_equation_rgb;
+   GLenum      gl_blend_equation_alpha;
+
+   //------------------//
+   unsigned char _stencil_flag1;
+   // Stencil
+   GLenum      gl_stencil_func;                       // GL_ALWAYS
+   GLint       gl_stencil_ref;
+   GLuint      gl_stencil_value_mask;                 // 0xffffffff
+   GLenum      gl_stencil_fail;                       // GL_KEEP
+   GLenum      gl_stencil_pass_depth_fail;            // GL_KEEP
+   GLenum      gl_stencil_pass_depth_pass;            // GL_KEEP
+   GLuint      gl_stencil_writemask;                  // 0xffffffff
+
+   unsigned char _stencil_flag2;
+   GLenum      gl_stencil_back_func;                  // GL_ALWAYS
+   GLint       gl_stencil_back_ref;
+   GLuint      gl_stencil_back_value_mask;            // 0xffffffff
+   GLenum      gl_stencil_back_fail;                  // GL_KEEP
+   GLenum      gl_stencil_back_depth_fail;            // GL_KEEP
+   GLenum      gl_stencil_back_depth_pass;            // GL_KEEP
+   GLuint      gl_stencil_back_writemask;             // 0xffffffff
+
+   GLint       gl_stencil_clear_value;
+
+
+   //------------------//
+
+
+   //------------------//
+   unsigned char _misc_flag1;
+   GLenum      gl_front_face;                         // GL_CCW
+   GLfloat     gl_line_width;                         // 1
+   GLfloat     gl_polygon_offset_factor;              // 0
+   GLfloat     gl_polygon_offset_units;               // 0
+   GLclampf    gl_sample_coverage_value;
+   GLboolean   gl_sample_coverage_invert;
+
+   unsigned char _misc_flag2;
+   GLint       gl_scissor_box[4];                     // (0,0,w,h)
+   GLint       gl_pack_alignment;                     // 4
+   GLint       gl_unpack_alignment;                   // 4
+
+   //------------------//
+   // Vertex Attrib Array
+   unsigned char _varray_flag;
+   GL_Vertex_Array_State      vertex_array[MAX_VERTEX_ATTRIBS];
+   GLint                      gl_current_vertex_attrib[4];
+
+   // Verte Attribs
+   unsigned char _vattrib_flag;
+   GL_Vertex_Attrib           vertex_attrib[MAX_VERTEX_ATTRIBS];
+
+};
+
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+//------------------------------------------------------//
+
+typedef void (*_eng_fn) (void);
+
+//------------------------------------------------------//
+// EGL APIs... Only ones that are being used.
+
+// Standard EGL APIs
+extern _eng_fn       (*GL(eglGetProcAddress))                     (const char* procname);
+
+extern EGLint        (*GL(eglGetError))                  (void);
+extern EGLDisplay    (*GL(eglGetDisplay))                (EGLNativeDisplayType display_id);
+extern EGLBoolean    (*GL(eglInitialize))                (EGLDisplay dpy, EGLint* major, EGLint *minor);
+extern EGLBoolean    (*GL(eglTerminate))                 (EGLDisplay dpy);
+extern EGLBoolean    (*GL(eglChooseConfig))              (EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config);
+extern EGLSurface    (*GL(eglCreateWindowSurface))       (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list);
+extern EGLSurface    (*GL(eglCreatePixmapSurface))       (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list);
+extern EGLBoolean    (*GL(eglDestroySurface))            (EGLDisplay dpy, EGLSurface surface);
+extern EGLBoolean    (*GL(eglBindAPI))                   (EGLenum api);
+extern EGLBoolean    (*GL(eglWaitClient))                (void);
+extern EGLBoolean    (*GL(eglSurfaceAttrib))             (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
+extern void          (*GL(eglBindTexImage))              (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+extern EGLBoolean    (*GL(eglReleaseTexImage))           (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+extern EGLBoolean    (*GL(eglSwapInterval))              (EGLDisplay dpy, EGLint interval);
+extern EGLContext    (*GL(eglCreateContext))             (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list);
+extern EGLBoolean    (*GL(eglDestroyContext))            (EGLDisplay dpy, EGLContext ctx);
+extern EGLBoolean    (*GL(eglMakeCurrent))               (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+extern EGLContext    (*GL(eglGetCurrentContext))         (void);
+extern EGLSurface    (*GL(eglGetCurrentSurface))         (EGLint readdraw);
+extern EGLDisplay    (*GL(eglGetCurrentDisplay))         (void);
+extern EGLBoolean    (*GL(eglWaitGL))                    (void);
+extern EGLBoolean    (*GL(eglWaitNative))                (EGLint engine);
+extern EGLBoolean    (*GL(eglSwapBuffers))               (EGLDisplay dpy, EGLSurface surface);
+extern EGLBoolean    (*GL(eglCopyBuffers))               (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
+extern char const   *(*GL(eglQueryString))               (EGLDisplay dpy, EGLint name);
+
+// Extensions
+extern void         *(*GL(eglCreateImage))               (void *a, void *b, GLenum c, void *d, const int *e);
+extern unsigned int  (*GL(eglDestroyImage))              (void *a, void *b);
+extern void          (*GL(glEGLImageTargetTexture2DOES)) (int a, void *b);
+extern void          (*GL(glEGLImageTargetRenderbufferStorageOES)) (int a, void *b);
+extern void         *(*GL(eglMapImageSEC))               (void *a, void *b);
+extern unsigned int  (*GL(eglUnmapImageSEC))             (void *a, void *b);
+extern unsigned int  (*GL(eglGetImageAttribSEC))         (void *a, void *b, int c, int *d);
+//extern unsigned int   (*GL(eglLockSurface))              (EGLDisplay a, EGLSurface b, const int *attrib_list);
+//extern unsigned int   (*GL(eglUnlockSurface))            (EGLDisplay a, EGLSurface b);
+
+
+//------------------------------------------------------//
+
+#else
+
+//------------------------------------------------------//
+
+typedef void (*_eng_fn) (void);
+
+//------------------------------------------------------//
+// GLX APIs... Only ones that are being used.
+
+//--------//
+extern _eng_fn      (*GL(glXGetProcAddress))            (const char* procName);
+
+// Standard GL(glX) functions
+extern XVisualInfo* (*GL(glXChooseVisual))              (Display* dpy, int screen, int* attribList);
+extern GLXContext   (*GL(glXCreateContext))             (Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct);
+extern void         (*GL(glXDestroyContext))            (Display* dpy, GLXContext ctx);
+extern GLXContext   (*GL(glXGetCurrentContext))         (void);
+extern GLXDrawable  (*GL(glXGetCurrentDrawable))        (void);
+extern Bool         (*GL(glXMakeCurrent))               (Display* dpy, GLXDrawable draw, GLXContext ctx);
+extern void         (*GL(glXSwapBuffers))               (Display* dpy, GLXDrawable draw);
+extern void         (*GL(glXWaitX))                     (void);
+extern void         (*GL(glXWaitGL))                    (void);
+extern Bool         (*GL(glXQueryExtension))            (Display* dpy, int* errorb, int* event);
+extern const char  *(*GL(glXQueryExtensionsString))     (Display *dpy, int screen);
+
+//--------//
+extern GLXFBConfig* (*GL(glXChooseFBConfig))            (Display* dpy, int screen, const int* attribList, int* nitems);
+extern GLXFBConfig* (*GL(glXGetFBConfigs))              (Display* dpy, int screen, int* nelements);
+extern int          (*GL(glXGetFBConfigAttrib))         (Display* dpy, GLXFBConfig config, int attribute, int* value);
+extern XVisualInfo* (*GL(glXGetVisualFromFBConfig))     (Display* dpy, GLXFBConfig config);
+extern void         (*GL(glXDestroyWindow))             (Display* dpy, GLXWindow window);
+extern Bool         (*GL(glXMakeContextCurrent))        (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+//--------//
+
+extern void         (*GL(glXBindTexImage))              (Display* dpy, GLXDrawable draw, int buffer, int* attribList);
+extern void         (*GL(glXReleaseTexImage))           (Display* dpy, GLXDrawable draw, int buffer);
+extern int          (*GL(glXGetVideoSync))              (unsigned int* count);
+extern int          (*GL(glXWaitVideoSync))             (int divisor, int remainder, unsigned int* count);
+extern XID          (*GL(glXCreatePixmap))              (Display* dpy, void* config, Pixmap pixmap, const int* attribList);
+extern void         (*GL(glXDestroyPixmap))             (Display* dpy, XID pixmap);
+extern void         (*GL(glXQueryDrawable))             (Display* dpy, XID draw, int attribute, unsigned int* value);
+extern int          (*GL(glXSwapIntervalSGI))           (int interval);
+extern void         (*GL(glXSwapIntervalEXT))           (Display* dpy, GLXDrawable draw, int interval);
+
+//--------//
+
+#endif // EGL vs. GLX
+
+//------------------------------------------------------//
+
+typedef enum _Evas_GL_Opt_Flag
+{
+   GL_NORMAL_PATH,
+   GL_WRAPPED_PATH,
+   GL_FAST_PATH
+} Evas_GL_Opt_Flag;
+
+
+//#define GL_ERRORS 1
+   /*
+   { \
+      int __gl_err = _gl.GL(glGetError)(); \
+      if (__gl_err != GL_NO_ERROR) glerr(__gl_err, fl, fn, ln, op); \
+   }
+   */
+#ifdef GL_ERRORS
+# define GLERR(fn, fl, ln, op)
+#else
+# define GLERR(fn, fl, ln, op)
+#endif
+
+//extern Evas_GL_API _gl;
+
+
+extern int  init_gl();
+extern void free_gl();
+
+   /* version 1: */
+extern   void         (*GL(glActiveTexture)) (GLenum texture);
+extern   void         (*GL(glAttachShader)) (GLuint program, GLuint shader);
+extern   void         (*GL(glBindAttribLocation)) (GLuint program, GLuint index, const char* name);
+extern   void         (*GL(glBindBuffer)) (GLenum target, GLuint buffer);
+extern   void         (*GL(glBindFramebuffer)) (GLenum target, GLuint framebuffer);
+extern   void         (*GL(glBindRenderbuffer)) (GLenum target, GLuint renderbuffer);
+extern   void         (*GL(glBindTexture)) (GLenum target, GLuint texture);
+extern   void         (*GL(glBlendColor)) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+extern   void         (*GL(glBlendEquation)) ( GLenum mode );
+extern   void         (*GL(glBlendEquationSeparate)) (GLenum modeRGB, GLenum modeAlpha);
+extern   void         (*GL(glBlendFunc)) (GLenum sfactor, GLenum dfactor);
+extern   void         (*GL(glBlendFuncSeparate)) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+extern   void         (*GL(glBufferData)) (GLenum target, GLsizeiptr size, const void* data, GLenum usage);
+extern   void         (*GL(glBufferSubData)) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
+extern   GLenum       (*GL(glCheckFramebufferStatus)) (GLenum target);
+extern   void         (*GL(glClear)) (GLbitfield mask);
+extern   void         (*GL(glClearColor)) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+extern   void         (*GL(glClearDepthf)) (GLclampf depth);
+extern   void         (*GL(glClearStencil)) (GLint s);
+extern   void         (*GL(glColorMask)) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+extern   void         (*GL(glCompileShader)) (GLuint shader);
+extern   void         (*GL(glCompressedTexImage2D)) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
+extern   void         (*GL(glCompressedTexSubImage2D)) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
+extern   void         (*GL(glCopyTexImage2D)) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+extern   void         (*GL(glCopyTexSubImage2D)) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+extern   GLuint       (*GL(glCreateProgram)) (void);
+extern   GLuint       (*GL(glCreateShader)) (GLenum type);
+extern   void         (*GL(glCullFace)) (GLenum mode);
+extern   void         (*GL(glDeleteBuffers)) (GLsizei n, const GLuint* buffers);
+extern   void         (*GL(glDeleteFramebuffers)) (GLsizei n, const GLuint* framebuffers);
+extern   void         (*GL(glDeleteProgram)) (GLuint program);
+extern   void         (*GL(glDeleteRenderbuffers)) (GLsizei n, const GLuint* renderbuffers);
+extern   void         (*GL(glDeleteShader)) (GLuint shader);
+extern   void         (*GL(glDeleteTextures)) (GLsizei n, const GLuint* textures);
+extern   void         (*GL(glDepthFunc)) (GLenum func);
+extern   void         (*GL(glDepthMask)) (GLboolean flag);
+extern   void         (*GL(glDepthRangef)) (GLclampf zNear, GLclampf zFar);
+extern   void         (*GL(glDetachShader)) (GLuint program, GLuint shader);
+extern   void         (*GL(glDisable)) (GLenum cap);
+extern   void         (*GL(glDisableVertexAttribArray)) (GLuint index);
+extern   void         (*GL(glDrawArrays)) (GLenum mode, GLint first, GLsizei count);
+extern   void         (*GL(glDrawElements)) (GLenum mode, GLsizei count, GLenum type, const void* indices);
+extern   void         (*GL(glEnable)) (GLenum cap);
+extern   void         (*GL(glEnableVertexAttribArray)) (GLuint index);
+extern   void         (*GL(glFinish)) (void);
+extern   void         (*GL(glFlush)) (void);
+extern   void         (*GL(glFramebufferRenderbuffer)) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+extern   void         (*GL(glFramebufferTexture2D)) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+extern   void         (*GL(glFrontFace)) (GLenum mode);
+extern   void         (*GL(glGenBuffers)) (GLsizei n, GLuint* buffers);
+extern   void         (*GL(glGenerateMipmap)) (GLenum target);
+extern   void         (*GL(glGenFramebuffers)) (GLsizei n, GLuint* framebuffers);
+extern   void         (*GL(glGenRenderbuffers)) (GLsizei n, GLuint* renderbuffers);
+extern   void         (*GL(glGenTextures)) (GLsizei n, GLuint* textures);
+extern   void         (*GL(glGetActiveAttrib)) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+extern   void         (*GL(glGetActiveUniform)) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+extern   void         (*GL(glGetAttachedShaders)) (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+extern   int          (*GL(glGetAttribLocation)) (GLuint program, const char* name);
+extern   void         (*GL(glGetBooleanv)) (GLenum pname, GLboolean* params);
+extern   void         (*GL(glGetBufferParameteriv)) (GLenum target, GLenum pname, GLint* params);
+extern   GLenum       (*GL(glGetError)) (void);
+extern   void         (*GL(glGetFloatv)) (GLenum pname, GLfloat* params);
+extern   void         (*GL(glGetFramebufferAttachmentParameteriv)) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
+extern   void         (*GL(glGetIntegerv)) (GLenum pname, GLint* params);
+extern   void         (*GL(glGetProgramiv)) (GLuint program, GLenum pname, GLint* params);
+extern   void         (*GL(glGetProgramInfoLog)) (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
+extern   void         (*GL(glGetRenderbufferParameteriv)) (GLenum target, GLenum pname, GLint* params);
+extern   void         (*GL(glGetShaderiv)) (GLuint shader, GLenum pname, GLint* params);
+extern   void         (*GL(glGetShaderInfoLog)) (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
+extern   void         (*GL(glGetShaderPrecisionFormat)) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+extern   void         (*GL(glGetShaderSource)) (GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
+extern   const GLubyte *(*GL(glGetString)) (GLenum name);
+extern   void         (*GL(glGetTexParameterfv)) (GLenum target, GLenum pname, GLfloat* params);
+extern   void         (*GL(glGetTexParameteriv)) (GLenum target, GLenum pname, GLint* params);
+extern   void         (*GL(glGetUniformfv)) (GLuint program, GLint location, GLfloat* params);
+extern   void         (*GL(glGetUniformiv)) (GLuint program, GLint location, GLint* params);
+extern   int          (*GL(glGetUniformLocation)) (GLuint program, const char* name);
+extern   void         (*GL(glGetVertexAttribfv)) (GLuint index, GLenum pname, GLfloat* params);
+extern   void         (*GL(glGetVertexAttribiv)) (GLuint index, GLenum pname, GLint* params);
+extern   void         (*GL(glGetVertexAttribPointerv)) (GLuint index, GLenum pname, void** pointer);
+extern   void         (*GL(glHint)) (GLenum target, GLenum mode);
+extern   GLboolean    (*GL(glIsBuffer)) (GLuint buffer);
+extern   GLboolean    (*GL(glIsEnabled)) (GLenum cap);
+extern   GLboolean    (*GL(glIsFramebuffer)) (GLuint framebuffer);
+extern   GLboolean    (*GL(glIsProgram)) (GLuint program);
+extern   GLboolean    (*GL(glIsRenderbuffer)) (GLuint renderbuffer);
+extern   GLboolean    (*GL(glIsShader)) (GLuint shader);
+extern   GLboolean    (*GL(glIsTexture)) (GLuint texture);
+extern   void         (*GL(glLineWidth)) (GLfloat width);
+extern   void         (*GL(glLinkProgram)) (GLuint program);
+extern   void         (*GL(glPixelStorei)) (GLenum pname, GLint param);
+extern   void         (*GL(glPolygonOffset)) (GLfloat factor, GLfloat units);
+extern   void         (*GL(glReadPixels)) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
+extern   void         (*GL(glReleaseShaderCompiler)) (void);
+extern   void         (*GL(glRenderbufferStorage)) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+extern   void         (*GL(glSampleCoverage)) (GLclampf value, GLboolean invert);
+extern   void         (*GL(glScissor)) (GLint x, GLint y, GLsizei width, GLsizei height);
+extern   void         (*GL(glShaderBinary)) (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length);
+extern   void         (*GL(glShaderSource)) (GLuint shader, GLsizei count, const char** string, const GLint* length);
+extern   void         (*GL(glStencilFunc)) (GLenum func, GLint ref, GLuint mask);
+extern   void         (*GL(glStencilFuncSeparate)) (GLenum face, GLenum func, GLint ref, GLuint mask);
+extern   void         (*GL(glStencilMask)) (GLuint mask);
+extern   void         (*GL(glStencilMaskSeparate)) (GLenum face, GLuint mask);
+extern   void         (*GL(glStencilOp)) (GLenum fail, GLenum zfail, GLenum zpass);
+extern   void         (*GL(glStencilOpSeparate)) (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+extern   void         (*GL(glTexImage2D)) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels);
+extern   void         (*GL(glTexParameterf)) (GLenum target, GLenum pname, GLfloat param);
+extern   void         (*GL(glTexParameterfv)) (GLenum target, GLenum pname, const GLfloat* params);
+extern   void         (*GL(glTexParameteri)) (GLenum target, GLenum pname, GLint param);
+extern   void         (*GL(glTexParameteriv)) (GLenum target, GLenum pname, const GLint* params);
+extern   void         (*GL(glTexSubImage2D)) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
+extern   void         (*GL(glUniform1f)) (GLint location, GLfloat x);
+extern   void         (*GL(glUniform1fv)) (GLint location, GLsizei count, const GLfloat* v);
+extern   void         (*GL(glUniform1i)) (GLint location, GLint x);
+extern   void         (*GL(glUniform1iv)) (GLint location, GLsizei count, const GLint* v);
+extern   void         (*GL(glUniform2f)) (GLint location, GLfloat x, GLfloat y);
+extern   void         (*GL(glUniform2fv)) (GLint location, GLsizei count, const GLfloat* v);
+extern   void         (*GL(glUniform2i)) (GLint location, GLint x, GLint y);
+extern   void         (*GL(glUniform2iv)) (GLint location, GLsizei count, const GLint* v);
+extern   void         (*GL(glUniform3f)) (GLint location, GLfloat x, GLfloat y, GLfloat z);
+extern   void         (*GL(glUniform3fv)) (GLint location, GLsizei count, const GLfloat* v);
+extern   void         (*GL(glUniform3i)) (GLint location, GLint x, GLint y, GLint z);
+extern   void         (*GL(glUniform3iv)) (GLint location, GLsizei count, const GLint* v);
+extern   void         (*GL(glUniform4f)) (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern   void         (*GL(glUniform4fv)) (GLint location, GLsizei count, const GLfloat* v);
+extern   void         (*GL(glUniform4i)) (GLint location, GLint x, GLint y, GLint z, GLint w);
+extern   void         (*GL(glUniform4iv)) (GLint location, GLsizei count, const GLint* v);
+extern   void         (*GL(glUniformMatrix2fv)) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+extern   void         (*GL(glUniformMatrix3fv)) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+extern   void         (*GL(glUniformMatrix4fv)) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+extern   void         (*GL(glUseProgram)) (GLuint program);
+extern   void         (*GL(glValidateProgram)) (GLuint program);
+extern   void         (*GL(glVertexAttrib1f)) (GLuint indx, GLfloat x);
+extern   void         (*GL(glVertexAttrib1fv)) (GLuint indx, const GLfloat* values);
+extern   void         (*GL(glVertexAttrib2f)) (GLuint indx, GLfloat x, GLfloat y);
+extern   void         (*GL(glVertexAttrib2fv)) (GLuint indx, const GLfloat* values);
+extern   void         (*GL(glVertexAttrib3f)) (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+extern   void         (*GL(glVertexAttrib3fv)) (GLuint indx, const GLfloat* values);
+extern   void         (*GL(glVertexAttrib4f)) (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern   void         (*GL(glVertexAttrib4fv)) (GLuint indx, const GLfloat* values);
+extern   void         (*GL(glVertexAttribPointer)) (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
+extern   void         (*GL(glViewport)) (GLint x, GLint y, GLsizei width, GLsizei height);
+
+/* Extensions */
+extern   void         (*GL(glGetProgramBinary)) (GLuint program, GLsizei bufsize, GLsizei *length, GLenum *binaryFormat, void *binary);
+extern   void         (*GL(glProgramBinary)) (GLuint program, GLenum binaryFormat, const void *binary, GLint length);
+extern   void         (*GL(glProgramParameteri)) (GLuint a, GLuint b, GLint d);
+
+
+#endif // EVAS_GL_CORE_H
index 48499ea..6e616c8 100644 (file)
@@ -20,7 +20,7 @@ evas_gl_common_line_draw(Evas_Engine_GL_Context *gc, int x1, int y1, int x2, int
         r = g = b = a = 255;
      }
 
-   glFlush();
+   glsym_glFlush();
 
    c = gc->dc->clip.use;
    cx = gc->dc->clip.x; cy = gc->dc->clip.y;
index 5903a17..49f1294 100644 (file)
@@ -770,26 +770,26 @@ gl_compile_link_error(GLuint target, const char *action)
    char *logtxt;
 
    /* Shader info log */
-   glGetShaderiv(target, GL_INFO_LOG_LENGTH, &loglen);
+   glsym_glGetShaderiv(target, GL_INFO_LOG_LENGTH, &loglen);
    if (loglen > 0)
      {
         logtxt = calloc(loglen, sizeof(char));
         if (logtxt)
           {
-             glGetShaderInfoLog(target, loglen, &chars, logtxt);
+             glsym_glGetShaderInfoLog(target, loglen, &chars, logtxt);
              ERR("Failed to %s: %s", action, logtxt);
              free(logtxt);
           }
      }
 
    /* Program info log */
-   glGetProgramiv(target, GL_INFO_LOG_LENGTH, &loglen);
+   glsym_glGetProgramiv(target, GL_INFO_LOG_LENGTH, &loglen);
    if (loglen > 0)
      {
         logtxt = calloc(loglen, sizeof(char));
         if (logtxt)
           {
-             glGetProgramInfoLog(target, loglen, &chars, logtxt);
+             glsym_glGetProgramInfoLog(target, loglen, &chars, logtxt);
              ERR("Failed to %s: %s", action, logtxt);
              free(logtxt);
           }
@@ -885,9 +885,9 @@ _evas_gl_shader_file_check(const char *bin_shader_dir, char *bin_shader_file, in
    char *driver = NULL;
    char *version = NULL;
 
-   vendor = (char *)glGetString(GL_VENDOR);
-   driver = (char *)glGetString(GL_RENDERER);
-   version = (char *)glGetString(GL_VERSION);
+   vendor = (char *)glsym_glGetString(GL_VENDOR);
+   driver = (char *)glsym_glGetString(GL_RENDERER);
+   version = (char *)glsym_glGetString(GL_VERSION);
 
    new_path_len = snprintf(before_name, sizeof(before_name), "%s::%s::%s::%s::binary_shader.eet", vendor, version, driver, MODULE_ARCH);
 
@@ -922,36 +922,36 @@ _evas_gl_common_shader_program_binary_init(Evas_GL_Program *p,
    data = eet_read(ef, pname, &length);
    if ((!data) || (length <= 0)) goto finish;
 
-   glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num);
+   glsym_glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num);
    if (num <= 0) goto finish;
 
    formats = calloc(num, sizeof(int));
    if (!formats) goto finish;
 
-   glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, formats);
+   glsym_glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, formats);
    if (!formats[0]) goto finish;
 
-   p->prog = glCreateProgram();
+   p->prog = glsym_glCreateProgram();
 
 #if 1
    // TODO: invalid rendering error occurs when attempting to use a 
    // glProgramBinary. in order to render correctly we should create a dummy 
    // vertex shader.
-   p->vert = glCreateShader(GL_VERTEX_SHADER);
-   glAttachShader(p->prog, p->vert);
-   p->frag = glCreateShader(GL_FRAGMENT_SHADER);
-   glAttachShader(p->prog, p->frag);
+   p->vert = glsym_glCreateShader(GL_VERTEX_SHADER);
+   glsym_glAttachShader(p->prog, p->vert);
+   p->frag = glsym_glCreateShader(GL_FRAGMENT_SHADER);
+   glsym_glAttachShader(p->prog, p->frag);
 #endif
    glsym_glProgramBinary(p->prog, formats[0], data, length);
 
-   glBindAttribLocation(p->prog, SHAD_VERTEX, "vertex");
-   glBindAttribLocation(p->prog, SHAD_COLOR,  "color");
-   glBindAttribLocation(p->prog, SHAD_TEXUV,  "tex_coord");
-   glBindAttribLocation(p->prog, SHAD_TEXUV2, "tex_coord2");
-   glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3");
-   glBindAttribLocation(p->prog, SHAD_TEXM,   "tex_coordm");
+   glsym_glBindAttribLocation(p->prog, SHAD_VERTEX, "vertex");
+   glsym_glBindAttribLocation(p->prog, SHAD_COLOR,  "color");
+   glsym_glBindAttribLocation(p->prog, SHAD_TEXUV,  "tex_coord");
+   glsym_glBindAttribLocation(p->prog, SHAD_TEXUV2, "tex_coord2");
+   glsym_glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3");
+   glsym_glBindAttribLocation(p->prog, SHAD_TEXM,   "tex_coordm");
 
-   glGetProgramiv(p->prog, GL_LINK_STATUS, &ok);
+   glsym_glGetProgramiv(p->prog, GL_LINK_STATUS, &ok);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    if (!ok)
      {
@@ -967,7 +967,7 @@ finish:
    if (data) free(data);
    if ((!res) && (p->prog))
      {
-        glDeleteProgram(p->prog);
+        glsym_glDeleteProgram(p->prog);
         p->prog = 0;
      }
    return res;
@@ -984,7 +984,7 @@ _evas_gl_common_shader_program_binary_save(Evas_GL_Program *p,
 
    if (!glsym_glGetProgramBinary) return 0;
 
-   glGetProgramiv(p->prog, GL_PROGRAM_BINARY_LENGTH, &length);
+   glsym_glGetProgramiv(p->prog, GL_PROGRAM_BINARY_LENGTH, &length);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    if (length <= 0) return 0;
 
@@ -1017,21 +1017,21 @@ _evas_gl_common_shader_program_source_init(Evas_GL_Program *p,
 {
    GLint ok;
 
-   p->vert = glCreateShader(GL_VERTEX_SHADER);
-   p->frag = glCreateShader(GL_FRAGMENT_SHADER);
+   p->vert = glsym_glCreateShader(GL_VERTEX_SHADER);
+   p->frag = glsym_glCreateShader(GL_FRAGMENT_SHADER);
 #if defined (GLES_VARIETY_S3C6410)
-   glShaderBinary(1, &(p->vert), 0, vert->bin, vert->bin_size);
+   glsym_glShaderBinary(1, &(p->vert), 0, vert->bin, vert->bin_size);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glShaderBinary(1, &(p->frag), 0, frag->bin, frag->bin_size);
+   glsym_glShaderBinary(1, &(p->frag), 0, frag->bin, frag->bin_size);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #else
-   glShaderSource(p->vert, 1,
+   glsym_glShaderSource(p->vert, 1,
                   (const char **)&(vert->src), NULL);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glCompileShader(p->vert);
+   glsym_glCompileShader(p->vert);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    ok = 0;
-   glGetShaderiv(p->vert, GL_COMPILE_STATUS, &ok);
+   glsym_glGetShaderiv(p->vert, GL_COMPILE_STATUS, &ok);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    if (!ok)
      {
@@ -1039,13 +1039,13 @@ _evas_gl_common_shader_program_source_init(Evas_GL_Program *p,
         ERR("Abort compile of shader vert (%s): %s", name, vert->src);
         return 0;
      }
-   glShaderSource(p->frag, 1,
-                  (const char **)&(frag->src), NULL);
+   glsym_glShaderSource(p->frag, 1,
+                        (const char **)&(frag->src), NULL);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glCompileShader(p->frag);
+   glsym_glCompileShader(p->frag);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    ok = 0;
-   glGetShaderiv(p->frag, GL_COMPILE_STATUS, &ok);
+   glsym_glGetShaderiv(p->frag, GL_COMPILE_STATUS, &ok);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    if (!ok)
      {
@@ -1054,35 +1054,35 @@ _evas_gl_common_shader_program_source_init(Evas_GL_Program *p,
         return 0;
      }
 #endif
-   p->prog = glCreateProgram();
+   p->prog = glsym_glCreateProgram();
 #if defined(GLES_VARIETY_S3C6410) || defined(GLES_VARIETY_SGX)
 #else
    if ((glsym_glGetProgramBinary) && (glsym_glProgramParameteri))
       glsym_glProgramParameteri(p->prog, GL_PROGRAM_BINARY_RETRIEVABLE_HINT,
                                 GL_TRUE);
 #endif
-   glAttachShader(p->prog, p->vert);
+   glsym_glAttachShader(p->prog, p->vert);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glAttachShader(p->prog, p->frag);
+   glsym_glAttachShader(p->prog, p->frag);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-   glBindAttribLocation(p->prog, SHAD_VERTEX, "vertex");
+   glsym_glBindAttribLocation(p->prog, SHAD_VERTEX, "vertex");
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindAttribLocation(p->prog, SHAD_COLOR,  "color");
+   glsym_glBindAttribLocation(p->prog, SHAD_COLOR,  "color");
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindAttribLocation(p->prog, SHAD_TEXUV,  "tex_coord");
+   glsym_glBindAttribLocation(p->prog, SHAD_TEXUV,  "tex_coord");
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindAttribLocation(p->prog, SHAD_TEXUV2, "tex_coord2");
+   glsym_glBindAttribLocation(p->prog, SHAD_TEXUV2, "tex_coord2");
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3");
+   glsym_glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3");
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindAttribLocation(p->prog, SHAD_TEXM, "tex_coordm");
+   glsym_glBindAttribLocation(p->prog, SHAD_TEXM, "tex_coordm");
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-   glLinkProgram(p->prog);
+   glsym_glLinkProgram(p->prog);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    ok = 0;
-   glGetProgramiv(p->prog, GL_LINK_STATUS, &ok);
+   glsym_glGetProgramiv(p->prog, GL_LINK_STATUS, &ok);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    if (!ok)
      {
@@ -1258,14 +1258,14 @@ void
 evas_gl_common_shader_program_init_done(void)
 {
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   glReleaseShaderCompiler();
+   glsym_glReleaseShaderCompiler();
 #endif
 }
 
 void
 evas_gl_common_shader_program_shutdown(Evas_GL_Program *p)
 {
-   if (p->vert) glDeleteShader(p->vert);
-   if (p->frag) glDeleteShader(p->frag);
-   if (p->prog) glDeleteProgram(p->prog);
+   if (p->vert) glsym_glDeleteShader(p->vert);
+   if (p->frag) glsym_glDeleteShader(p->frag);
+   if (p->prog) glsym_glDeleteProgram(p->prog);
 }
index b43a2d4..a522bc5 100644 (file)
@@ -112,16 +112,23 @@ _tex_2d(int intfmt, int w, int h, int fmt, int type)
 #ifdef GL_TEXTURE_INTERNAL_FORMAT
    int intfmtret = -1;
 #endif   
-   glTexImage2D(GL_TEXTURE_2D, 0, intfmt, w, h, 0, fmt, type, NULL);
+   glsym_glTexImage2D(GL_TEXTURE_2D, 0, intfmt, w, h, 0, fmt, type, NULL);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #ifdef GL_TEXTURE_INTERNAL_FORMAT
-// this is not in opengles!!! hrrrm   
-   glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, 
-                            GL_TEXTURE_INTERNAL_FORMAT, &intfmtret);
-   if (intfmtret != intfmt)
+   // this is not in opengles!!! hrrrm
+   if (glsym_glGetTexLevelParameteriv)
      {
-        ERR("Fail tex alloc %ix%i", w, h);
-//        XXX send async err to evas
+        glsym_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+                                       GL_TEXTURE_INTERNAL_FORMAT, &intfmtret);
+        if (intfmtret != intfmt)
+          {
+             ERR("Fail tex alloc %ix%i", w, h);
+             //        XXX send async err to evas
+          }
+     }
+   else
+     {
+        ERR("GL_TEXTURE_INTERNAL_FORMAT defined but no symbol loaded.");
      }
 #endif   
 }
@@ -129,7 +136,7 @@ _tex_2d(int intfmt, int w, int h, int fmt, int type)
 static void
 _tex_sub_2d(int x, int y, int w, int h, int fmt, int type, const void *pix)
 {
-   glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, fmt, type, pix);
+   glsym_glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, fmt, type, pix);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 }
 
@@ -168,20 +175,20 @@ _pool_tex_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, GLenum fo
 
    _print_tex_count();
 
-   glGenTextures(1, &(pt->texture));
+   glsym_glGenTextures(1, &(pt->texture));
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(pt->intformat, w, h, pt->format, pt->dataformat);
-   glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
+   glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    return pt;
 }
@@ -384,17 +391,17 @@ _pool_tex_render_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, in
 
    _print_tex_count();
 
-   glGenTextures(1, &(pt->texture));
+   glsym_glGenTextures(1, &(pt->texture));
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(pt->intformat, w, h, pt->format, pt->dataformat);
 
@@ -407,7 +414,7 @@ _pool_tex_render_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, in
    glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-   glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
+   glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    return pt;
 }
@@ -444,9 +451,9 @@ _pool_tex_native_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, in
 
    _print_tex_count();
 
-   glGenTextures(1, &(pt->texture));
+   glsym_glGenTextures(1, &(pt->texture));
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(im->native.target, pt->texture);
+   glsym_glBindTexture(im->native.target, pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
@@ -458,17 +465,17 @@ _pool_tex_native_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, in
      }
 #endif
 
-   glTexParameteri(im->native.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(im->native.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(im->native.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(im->native.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(im->native.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(im->native.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(im->native.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(im->native.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(im->native.target, 0);
+   glsym_glBindTexture(im->native.target, 0);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(im->native.target, gc->pipe[0].shader.cur_tex);
+   glsym_glBindTexture(im->native.target, gc->pipe[0].shader.cur_tex);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    return pt;
 }
@@ -481,7 +488,6 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
    int fmt; // EGL_MAP_GL_TEXTURE_RGBA_SEC or EGL_MAP_GL_TEXTURE_RGB_SEC or bust
    int pixtype; // EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC or bust
-   int glformat;
    int attr[] =
      {
         EGL_MAP_GL_TEXTURE_WIDTH_SEC, 32,
@@ -524,17 +530,17 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
 
    _print_tex_count();
 
-   glGenTextures(1, &(pt->texture));
+   glsym_glGenTextures(1, &(pt->texture));
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
    egldisplay = pt->gc->egldisp;
@@ -544,45 +550,45 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
 
    // FIXME: seems a bit slower than i'd like - maybe too many flushes?
    // FIXME: YCbCr no support as yet
-   pt->dyn.img = secsym_eglCreateImage(egldisplay,
+   pt->dyn.img = glsym_eglCreateImage(egldisplay,
                                        EGL_NO_CONTEXT,
                                        EGL_MAP_GL_TEXTURE_2D_SEC,
                                        0, attr);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    if (!pt->dyn.img)
      {
-        glBindTexture(GL_TEXTURE_2D, 0);
+        glsym_glBindTexture(GL_TEXTURE_2D, 0);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glDeleteTextures(1, &(pt->texture));
+        glsym_glDeleteTextures(1, &(pt->texture));
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
         free(pt);
         return NULL;
      }
-   if (secsym_eglGetImageAttribSEC(egldisplay,
+   if (glsym_eglGetImageAttribSEC(egldisplay,
                                    pt->dyn.img,
                                    EGL_MAP_GL_TEXTURE_WIDTH_SEC,
                                    &(pt->dyn.w)) != EGL_TRUE) goto error;
-   if (secsym_eglGetImageAttribSEC(egldisplay,
+   if (glsym_eglGetImageAttribSEC(egldisplay,
                                    pt->dyn.img,
                                    EGL_MAP_GL_TEXTURE_HEIGHT_SEC,
                                    &(pt->dyn.h)) != EGL_TRUE) goto error;
-   if (secsym_eglGetImageAttribSEC(egldisplay,
+   if (glsym_eglGetImageAttribSEC(egldisplay,
                                    pt->dyn.img,
                                    EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC,
                                    &(pt->dyn.stride)) != EGL_TRUE) goto error;
-   if (secsym_eglGetImageAttribSEC(egldisplay,
+   if (glsym_eglGetImageAttribSEC(egldisplay,
                                    pt->dyn.img,
                                    EGL_MAP_GL_TEXTURE_FORMAT_SEC,
                                    &(fmt)) != EGL_TRUE) goto error;
 
-   if (secsym_eglGetImageAttribSEC(egldisplay,
+   if (glsym_eglGetImageAttribSEC(egldisplay,
                                    pt->dyn.img,
                                    EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC,
                                    &(pixtype)) != EGL_TRUE) goto error;
 
    if (pixtype != EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC) goto error;
 
-   glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
+   glsym_glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #else
    gc = NULL;
@@ -596,12 +602,12 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
 /* ERROR HANDLING */
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
 error:
-  secsym_eglDestroyImage(egldisplay, pt->dyn.img);
+  glsym_eglDestroyImage(egldisplay, pt->dyn.img);
   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
   pt->dyn.img = NULL;
-  glBindTexture(GL_TEXTURE_2D, 0);
+  glsym_glBindTexture(GL_TEXTURE_2D, 0);
   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-  glDeleteTextures(1, &(pt->texture));
+  glsym_glDeleteTextures(1, &(pt->texture));
   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
   free(pt);
   return NULL;
@@ -650,8 +656,8 @@ evas_gl_texture_pool_empty(Evas_GL_Texture_Pool *pt)
    if (pt->dyn.img)
      {
         if (pt->dyn.checked_out > 0)
-          secsym_eglUnmapImageSEC(pt->gc->egldisp, pt->dyn.img);
-        secsym_eglDestroyImage(pt->gc->egldisp, pt->dyn.img);
+          glsym_eglUnmapImageSEC(pt->gc->egldisp, pt->dyn.img);
+        glsym_eglDestroyImage(pt->gc->egldisp, pt->dyn.img);
         pt->dyn.img = NULL;
         pt->dyn.data = NULL;
         pt->dyn.w = 0;
@@ -661,7 +667,7 @@ evas_gl_texture_pool_empty(Evas_GL_Texture_Pool *pt)
      }
 #endif
 
-   glDeleteTextures(1, &(pt->texture));
+   glsym_glDeleteTextures(1, &(pt->texture));
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    if (pt->fb)
      {
@@ -853,15 +859,16 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
    if (!im->image.data) return;
 
    fmt = tex->pt->format;
-   glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #ifdef GL_UNPACK_ROW_LENGTH
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+   glsym_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #endif
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+   glsym_glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
+//   printf("tex upload %ix%i\n", im->cache_entry.w, im->cache_entry.h);
    //  +-+
    //  +-+
    //
@@ -891,7 +898,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
                fmt, tex->pt->dataformat,
                im->image.data + ((im->cache_entry.h - 1) * im->cache_entry.w) + (im->cache_entry.w - 1));
 #ifdef GL_UNPACK_ROW_LENGTH
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, im->cache_entry.w);
+   glsym_glPixelStorei(GL_UNPACK_ROW_LENGTH, im->cache_entry.w);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    // |xxx
    // |xxx
@@ -947,7 +954,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
 #endif
    if (tex->pt->texture != tex->gc->pipe[0].shader.cur_tex)
      {
-        glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
+        glsym_glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
      }
 }
@@ -1031,19 +1038,19 @@ evas_gl_common_texture_alpha_update(Evas_GL_Texture *tex, DATA8 *pixels,
                                     unsigned int w, unsigned int h, int fh __UNUSED__)
 {
    if (!tex->pt) return;
-   glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #ifdef GL_UNPACK_ROW_LENGTH
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+   glsym_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 #endif
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+   glsym_glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_sub_2d(tex->x, tex->y, w, h, tex->pt->format, tex->pt->dataformat,
                pixels);
    if (tex->pt->texture != tex->gc->pipe[0].shader.cur_tex)
      {
-        glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
+        glsym_glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
      }
 }
@@ -1110,32 +1117,32 @@ evas_gl_common_texture_yuv_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned i
    if (!tex->pt) return;
    // FIXME: works on lowest size 4 pixel high buffers. must also be multiple of 2
 #ifdef GL_UNPACK_ROW_LENGTH
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[1] - rows[0]);
+   glsym_glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[1] - rows[0]);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+   glsym_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->pt->intformat, w, h, tex->pt->format, tex->pt->dataformat);
    _tex_sub_2d(0, 0, w, h, tex->pt->format, tex->pt->dataformat, rows[0]);
-   glBindTexture(GL_TEXTURE_2D, tex->ptu->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->ptu->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[h + 1] - rows[h]);
+   glsym_glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[h + 1] - rows[h]);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->ptu->intformat, w / 2, h / 2, tex->ptu->format, tex->ptu->dataformat);
    _tex_sub_2d(0, 0, w / 2, h / 2, tex->ptu->format, tex->ptu->dataformat, rows[h]);
-   glBindTexture(GL_TEXTURE_2D, tex->ptv->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->ptv->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[h + (h / 2) + 1] - rows[h + (h / 2)]);
+   glsym_glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[h + (h / 2) + 1] - rows[h + (h / 2)]);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->ptv->intformat, w / 2, h / 2, tex->ptv->format, tex->ptv->dataformat);
    _tex_sub_2d(0, 0, w / 2, h / 2, tex->ptv->format, tex->ptv->dataformat, rows[h + (h / 2)]);
 #else
    unsigned int y;
 
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+   glsym_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->pt->intformat, w, h, tex->pt->format, tex->pt->dataformat);
    if ((rows[1] - rows[0]) == (int)w)
@@ -1146,7 +1153,7 @@ evas_gl_common_texture_yuv_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned i
           _tex_sub_2d(0, y, w, 1, tex->pt->format, tex->pt->dataformat, rows[y]);
      }
 
-   glBindTexture(GL_TEXTURE_2D, tex->ptu->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->ptu->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->ptu->intformat, w / 2, h / 2, tex->ptu->format, tex->ptu->dataformat);
    if ((rows[h + 1] - rows[h]) == (int)(w / 2))
@@ -1157,7 +1164,7 @@ evas_gl_common_texture_yuv_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned i
           _tex_sub_2d(0, y, w / 2, 1, tex->ptu->format, tex->ptu->dataformat, rows[h + y]);
      }
 
-   glBindTexture(GL_TEXTURE_2D, tex->ptv->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->ptv->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->ptv->intformat, w / 2, h / 2, tex->ptv->format, tex->ptv->dataformat);
    if ((rows[h + (h / 2) + 1] - rows[h + (h / 2)]) == (int)(w / 2))
@@ -1170,7 +1177,7 @@ evas_gl_common_texture_yuv_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned i
 #endif
    if (tex->pt->texture != tex->gc->pipe[0].shader.cur_tex)
      {
-        glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
+        glsym_glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
      }
 }
@@ -1317,9 +1324,9 @@ evas_gl_common_texture_yuy2_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
    tex->pt = tex->double_buffer.pt[tex->double_buffer.source];
    tex->ptuv = tex->double_buffer.ptuv[tex->double_buffer.source];
 
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+   glsym_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->pt->intformat, w, h, tex->pt->format, tex->pt->dataformat);
    if ((rows[1] - rows[0]) == (int)w * 4)
@@ -1330,7 +1337,7 @@ evas_gl_common_texture_yuy2_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
           _tex_sub_2d(0, y, w, 1, tex->pt->format, tex->pt->dataformat, rows[y]);
      }
 
-   glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->ptuv->intformat, w / 2, h, tex->ptuv->format, tex->ptuv->dataformat);
 #if 0
@@ -1349,7 +1356,7 @@ evas_gl_common_texture_yuy2_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
 
    if (tex->pt->texture != tex->gc->pipe[0].shader.cur_tex)
      {
-        glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
+        glsym_glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
      }
 }
@@ -1365,26 +1372,26 @@ evas_gl_common_texture_nv12_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
 
    // FIXME: works on lowest size 4 pixel high buffers. must also be multiple of 2
 #ifdef GL_UNPACK_ROW_LENGTH
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[1] - rows[0]);
+   glsym_glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[1] - rows[0]);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+   glsym_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->pt->intformat, w, h, tex->pt->format, tex->pt->dataformat);
    _tex_sub_2d(0, 0, w, h, tex->pt->format, tex->pt->dataformat, rows[0]);
-   glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[h + 1] - rows[h]);
+   glsym_glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[h + 1] - rows[h]);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->ptuv->intformat, w / 2, h / 2, tex->ptuv->format, tex->ptuv->dataformat);
    _tex_sub_2d(0, 0, w / 2, h / 2, tex->ptuv->format, tex->ptuv->dataformat, rows[h]);
 #else
    unsigned int y;
 
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+   glsym_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->pt->intformat, w, h, tex->pt->format, tex->pt->dataformat);
    if ((rows[1] - rows[0]) == (int)w)
@@ -1395,7 +1402,7 @@ evas_gl_common_texture_nv12_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
           _tex_sub_2d(0, y, w, 1, tex->pt->format, tex->pt->dataformat, rows[y]);
      }
 
-   glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
    _tex_2d(tex->ptuv->intformat, w / 2, h / 2, tex->ptuv->format, tex->ptuv->dataformat);
    if ((rows[h + 1] - rows[h]) == (int)(w / 2))
@@ -1408,7 +1415,7 @@ evas_gl_common_texture_nv12_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
 #endif
    if (tex->pt->texture != tex->gc->pipe[0].shader.cur_tex)
      {
-        glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
+        glsym_glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
      }
 }
@@ -1434,7 +1441,7 @@ evas_gl_common_texture_nv12tiled_update(Evas_GL_Texture *tex, DATA8 **rows, unsi
         char *texture_addr;
        char *tmp;
 
-       texture_addr = secsym_eglMapImageSEC(tex->gc->egldisp, tex->pt->dyn.img);
+       texture_addr = glsym_eglMapImageSEC(tex->gc->egldisp, tex->pt->dyn.img);
 
        /* Iterate each Y macroblock like we do in evas_convert_yuv.c */
        for (mb_y = 0; mb_y < (mb_h >> 1); mb_y++)
@@ -1489,9 +1496,9 @@ evas_gl_common_texture_nv12tiled_update(Evas_GL_Texture *tex, DATA8 **rows, unsi
               }
          }
 
-       secsym_eglUnmapImageSEC(tex->gc->egldisp, tex->pt->dyn.img);
+       glsym_eglUnmapImageSEC(tex->gc->egldisp, tex->pt->dyn.img);
 
-       texture_addr = secsym_eglMapImageSEC(tex->gc->egldisp, tex->ptuv->dyn.img);
+       texture_addr = glsym_eglMapImageSEC(tex->gc->egldisp, tex->ptuv->dyn.img);
 
        /* Iterate each UV macroblock like we do in evas_convert_yuv.c */
        base_h = (mb_h >> 1) + (mb_h & 0x1);
@@ -1556,15 +1563,15 @@ evas_gl_common_texture_nv12tiled_update(Evas_GL_Texture *tex, DATA8 **rows, unsi
               }
          }
 
-       secsym_eglUnmapImageSEC(tex->gc->egldisp, tex->ptuv->dyn.img);
+       glsym_eglUnmapImageSEC(tex->gc->egldisp, tex->ptuv->dyn.img);
        return ;
      }
 #endif
 
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+   glsym_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-   glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
    // We are telling the driver to not swizzle back the buffer as we are going to replace all pixel
@@ -1611,7 +1618,7 @@ evas_gl_common_texture_nv12tiled_update(Evas_GL_Texture *tex, DATA8 **rows, unsi
          _tex_sub_2d(x, ry, 64, 32, tex->pt->format, tex->pt->dataformat, rows[mb_y] + rmb_x);
      }
 
-   glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
+   glsym_glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
    _tex_2d(tex->ptuv->intformat, w, h, tex->ptuv->format, tex->ptuv->dataformat);
index 8607ccd..c1bdfee 100644 (file)
@@ -110,51 +110,21 @@ static Eina_TLS   resource_key;
 static Eina_List *resource_list;
 LK(resource_lock);
 
-typedef void            (*_eng_fn) (void);
-typedef _eng_fn         (*glsym_func_eng_fn) ();
 typedef void            (*glsym_func_void) ();
 typedef void           *(*glsym_func_void_ptr) ();
 typedef int             (*glsym_func_int) ();
 typedef unsigned int    (*glsym_func_uint) ();
 typedef unsigned char   (*glsym_func_uchar) ();
-typedef unsigned char  *(*glsym_func_uchar_ptr) ();
-typedef const char     *(*glsym_func_const_char_ptr) ();
 
+/*
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
 
 #ifndef EGL_NATIVE_PIXMAP_KHR
 # define EGL_NATIVE_PIXMAP_KHR 0x30b0
 #endif
-_eng_fn  (*glsym_eglGetProcAddress)            (const char *a) = NULL;
-void     (*glsym_eglBindTexImage)              (EGLDisplay a, EGLSurface b, int c) = NULL;
-void     (*glsym_eglReleaseTexImage)           (EGLDisplay a, EGLSurface b, int c) = NULL;
-void    *(*glsym_eglCreateImage)               (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const int *e) = NULL;
-void     (*glsym_eglDestroyImage)              (EGLDisplay a, void *b) = NULL;
-void     (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b)  = NULL;
-void     (*glsym_glEGLImageTargetRenderbufferStorageOES) (int a, void *b)  = NULL;
-void          *(*glsym_eglMapImageSEC)         (void *a, void *b) = NULL;
-unsigned int   (*glsym_eglUnmapImageSEC)       (void *a, void *b) = NULL;
-const char    *(*glsym_eglQueryString)         (EGLDisplay a, int name) = NULL;
-
-unsigned int   (*glsym_eglLockSurface)          (EGLDisplay a, EGLSurface b, const int *attrib_list) = NULL;
-unsigned int   (*glsym_eglUnlockSurface)        (EGLDisplay a, EGLSurface b) = NULL;
 
-#else
-typedef XID     (*glsym_func_xid) ();
-
-_eng_fn  (*glsym_glXGetProcAddress)  (const char *a) = NULL;
-void     (*glsym_glXBindTexImage)    (Display *a, GLXDrawable b, int c, int *d) = NULL;
-void     (*glsym_glXReleaseTexImage) (Display *a, GLXDrawable b, int c) = NULL;
-int      (*glsym_glXGetVideoSync)    (unsigned int *a) = NULL;
-int      (*glsym_glXWaitVideoSync)   (int a, int b, unsigned int *c) = NULL;
-XID      (*glsym_glXCreatePixmap)    (Display *a, void *b, Pixmap c, const int *d) = NULL;
-void     (*glsym_glXDestroyPixmap)   (Display *a, XID b) = NULL;
-void     (*glsym_glXQueryDrawable)   (Display *a, XID b, int c, unsigned int *d) = NULL;
-int      (*glsym_glXSwapIntervalSGI) (int a) = NULL;
-void     (*glsym_glXSwapIntervalEXT) (Display *s, GLXDrawable b, int c) = NULL;
-
-const char *(*glsym_glXQueryExtensionsString) (Display *a, int screen) = NULL;
 #endif
+*/
 
 // GLES2 Extensions
 void   (*glsym_glGetProgramBinaryOES) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary) = NULL;
@@ -328,89 +298,11 @@ _sym_init(void)
    if ((!dst) && (glsym_eglGetProcAddress)) dst = (typ)glsym_eglGetProcAddress(sym); \
    if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
 
-   FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn);
-   FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressEXT", glsym_func_eng_fn);
-   FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressARB", glsym_func_eng_fn);
-   FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressKHR", glsym_func_eng_fn);
-
-   FINDSYM(glsym_eglBindTexImage, "eglBindTexImage", glsym_func_void);
-   FINDSYM(glsym_eglBindTexImage, "eglBindTexImageEXT", glsym_func_void);
-   FINDSYM(glsym_eglBindTexImage, "eglBindTexImageARB", glsym_func_void);
-   FINDSYM(glsym_eglBindTexImage, "eglBindTexImageKHR", glsym_func_void);
-
-   FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImage", glsym_func_void);
-   FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageEXT", glsym_func_void);
-   FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageARB", glsym_func_void);
-   FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageKHR", glsym_func_void);
-
-   FINDSYM(glsym_eglCreateImage, "eglCreateImage", glsym_func_void_ptr);
-   FINDSYM(glsym_eglCreateImage, "eglCreateImageEXT", glsym_func_void_ptr);
-   FINDSYM(glsym_eglCreateImage, "eglCreateImageARB", glsym_func_void_ptr);
-   FINDSYM(glsym_eglCreateImage, "eglCreateImageKHR", glsym_func_void_ptr);
-
-   FINDSYM(glsym_eglDestroyImage, "eglDestroyImage", glsym_func_void);
-   FINDSYM(glsym_eglDestroyImage, "eglDestroyImageEXT", glsym_func_void);
-   FINDSYM(glsym_eglDestroyImage, "eglDestroyImageARB", glsym_func_void);
-   FINDSYM(glsym_eglDestroyImage, "eglDestroyImageKHR", glsym_func_void);
-
-   FINDSYM(glsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", glsym_func_void);
-
-   FINDSYM(glsym_glEGLImageTargetRenderbufferStorageOES, "glEGLImageTargetRenderbufferStorageOES", glsym_func_void);
-
-   FINDSYM(glsym_eglMapImageSEC, "eglMapImageSEC", glsym_func_void_ptr);
-   FINDSYM(glsym_eglUnmapImageSEC, "eglUnmapImageSEC", glsym_func_uint);
-
-   FINDSYM(glsym_eglQueryString, "eglQueryString", glsym_func_const_char_ptr);
-
-   FINDSYM(glsym_eglLockSurface, "eglLockSurface", glsym_func_uint);
-   FINDSYM(glsym_eglLockSurface, "eglLockSurfaceEXT", glsym_func_uint);
-   FINDSYM(glsym_eglLockSurface, "eglLockSurfaceARB", glsym_func_uint);
-   FINDSYM(glsym_eglLockSurface, "eglLockSurfaceKHR", glsym_func_uint);
-
-   FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurface", glsym_func_uint);
-   FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceEXT", glsym_func_uint);
-   FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceARB", glsym_func_uint);
-   FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceKHR", glsym_func_uint);
-
 #else
 #define FINDSYM(dst, sym, typ) \
    if ((!dst) && (glsym_glXGetProcAddress)) dst = (typ)glsym_glXGetProcAddress(sym); \
    if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
 
-   FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddress", glsym_func_eng_fn);
-   FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressEXT", glsym_func_eng_fn);
-   FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressARB", glsym_func_eng_fn);
-
-   FINDSYM(glsym_glXBindTexImage, "glXBindTexImage", glsym_func_void);
-   FINDSYM(glsym_glXBindTexImage, "glXBindTexImageEXT", glsym_func_void);
-   FINDSYM(glsym_glXBindTexImage, "glXBindTexImageARB", glsym_func_void);
-
-   FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImage", glsym_func_void);
-   FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageEXT", glsym_func_void);
-   FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageARB", glsym_func_void);
-
-   FINDSYM(glsym_glXGetVideoSync, "glXGetVideoSyncSGI", glsym_func_int);
-
-   FINDSYM(glsym_glXWaitVideoSync, "glXWaitVideoSyncSGI", glsym_func_int);
-
-   FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmap", glsym_func_xid);
-   FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmapEXT", glsym_func_xid);
-   FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmapARB", glsym_func_xid);
-
-   FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmap", glsym_func_void);
-   FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmapEXT", glsym_func_void);
-   FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmapARB", glsym_func_void);
-
-   FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawable", glsym_func_void);
-   FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawableEXT", glsym_func_void);
-   FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawableARB", glsym_func_void);
-
-   FINDSYM(glsym_glXSwapIntervalSGI, "glXSwapIntervalMESA", glsym_func_int);
-   FINDSYM(glsym_glXSwapIntervalSGI, "glXSwapIntervalSGI", glsym_func_int);
-
-   FINDSYM(glsym_glXSwapIntervalEXT, "glXSwapIntervalEXT", glsym_func_void);
-
-   FINDSYM(glsym_glXQueryExtensionsString, "glXQueryExtensionsString", glsym_func_const_char_ptr);
 #endif
 
    //----------- GLES 2.0 Extensions ------------//
@@ -565,7 +457,7 @@ _extensions_init(Render_Engine *re)
    memset(_evasgl_ext_string, 0, 1024);
 
    // GLES 2.0 Extensions
-   glexts = (const char*)glGetString(GL_EXTENSIONS);
+   glexts = (const char*)glsym_glGetString(GL_EXTENSIONS);
 
    DBG("--------GLES 2.0 Extensions--------");
    for (i = 0; _gl_ext_entries[i].name != NULL; i++)
@@ -590,7 +482,7 @@ _extensions_init(Render_Engine *re)
 #else
    if (glsym_glXQueryExtensionsString)
      {
-        evasglexts = glXQueryExtensionsString(re->info->info.display,
+        evasglexts = glsym_glXQueryExtensionsString(re->info->info.display,
                                               re->info->info.screen);
 #endif
 
@@ -725,7 +617,7 @@ _create_internal_glue_resources(void *data)
    context_attrs[2] = EGL_NONE;
 
    // Create resource surface for EGL
-   rsc->surface = eglCreateWindowSurface(re->win->egl_disp,
+   rsc->surface = glsym_eglCreateWindowSurface(re->win->egl_disp,
                                          re->win->egl_config,
                                          (EGLNativeWindowType)DefaultRootWindow(re->info->info.display),
                                          NULL);
@@ -737,7 +629,7 @@ _create_internal_glue_resources(void *data)
      }
 
    // Create a resource context for EGL
-   rsc->context = eglCreateContext(re->win->egl_disp,
+   rsc->context = glsym_eglCreateContext(re->win->egl_disp,
                                    re->win->egl_config,
                                    re->win->egl_context[0], // Evas' GL Context
                                    context_attrs);
@@ -763,10 +655,10 @@ _create_internal_glue_resources(void *data)
 
 #else
    // GLX
-   rsc->context = glXCreateContext(re->info->info.display,
-                                   re->win->visualinfo,
-                                   re->win->context,      // Evas' GL Context
-                                   1);
+   rsc->context = glsym_glXCreateContext(re->info->info.display,
+                                         re->win->visualinfo,
+                                         re->win->context,      // Evas' GL Context
+                                         1);
    if (!rsc->context)
      {
         ERR("Internal Resource Context Creations Failed.");
@@ -806,8 +698,8 @@ _destroy_internal_glue_resources(void *data)
    LKL(resource_lock);
    EINA_LIST_FOREACH(resource_list, l, rsc)
      {
-        if (rsc->surface) eglDestroySurface(re->win->egl_disp, rsc->surface);
-        if (rsc->context) eglDestroyContext(re->win->egl_disp, rsc->context);
+        if (rsc->surface) glsym_eglDestroySurface(re->win->egl_disp, rsc->surface);
+        if (rsc->context) glsym_eglDestroyContext(re->win->egl_disp, rsc->context);
         free(rsc);
      }
    eina_list_free(resource_list);
@@ -823,7 +715,7 @@ _destroy_internal_glue_resources(void *data)
      {
         if (rsc)
           {
-             glXDestroyContext(re->info->info.display, rsc->context);
+             glsym_glXDestroyContext(re->info->info.display, rsc->context);
              free(rsc);
           }
      }
@@ -852,7 +744,7 @@ eng_setup(Evas *e, void *in)
 #else
         int eb, evb;
 
-        if (!glXQueryExtension(info->info.display, &eb, &evb)) return 0;
+        if (!glsym_glXQueryExtension(info->info.display, &eb, &evb)) return 0;
 #endif
         re = calloc(1, sizeof(Render_Engine));
         if (!re) return 0;
@@ -1072,7 +964,7 @@ eng_output_free(void *data)
         // Destroy the resource surface
         // Only required for EGL case
         if (re->surface)
-           eglDestroySurface(re->win->egl_disp, re->surface);
+           glsym_eglDestroySurface(re->win->egl_disp, re->surface);
 #endif
 
         // Destroy the resource context
@@ -1282,7 +1174,7 @@ eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x
         if (s) safe_native = atoi(s);
         else
           {
-             s = (const char *)glGetString(GL_RENDERER);
+             s = (const char *)glsym_glGetString(GL_RENDERER);
              if (s)
                {
                   if (strstr(s, "PowerVR SGX 540") ||
@@ -1300,19 +1192,19 @@ eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x
    pt = t0;
 #endif
    // previous rendering should be done and swapped
-   if (!safe_native) eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+   if (!safe_native) glsym_eglWaitNative(EGL_CORE_NATIVE_ENGINE);
 #ifdef FRAMECOUNT
    double t1 = get_time();
    tb = t1 - t0;
    printf("... %1.5f -> %1.5f | ", ta, tb);
 #endif
-//   if (eglGetError() != EGL_SUCCESS)
+//   if (glsym_eglGetError() != EGL_SUCCESS)
 //     {
-//        printf("Error:  eglWaitNative(EGL_CORE_NATIVE_ENGINE) fail.\n");
+//        printf("Error:  glsym_eglWaitNative(EGL_CORE_NATIVE_ENGINE) fail.\n");
 //     }
 #else
    // previous rendering should be done and swapped
-   if (!safe_native) glXWaitX();
+   if (!safe_native) glsym_glXWaitX();
 #endif
 //x//   printf("frame -> push\n");
 }
@@ -1335,16 +1227,16 @@ eng_output_flush(void *data)
 #endif
    if (!re->vsync)
      {
-        if (re->info->vsync) eglSwapInterval(re->win->egl_disp, 1);
-        else eglSwapInterval(re->win->egl_disp, 0);
+        if (re->info->vsync) glsym_eglSwapInterval(re->win->egl_disp, 1);
+        else glsym_eglSwapInterval(re->win->egl_disp, 0);
         re->vsync = 1;
      }
    if (re->info->callback.pre_swap)
      {
         re->info->callback.pre_swap(re->info->callback.data, re->evas);
      }
-   eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
-   if (!safe_native) eglWaitGL();
+   glsym_eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
+   if (!safe_native) glsym_eglWaitGL();
    if (re->info->callback.post_swap)
      {
         re->info->callback.post_swap(re->info->callback.data, re->evas);
@@ -1353,9 +1245,9 @@ eng_output_flush(void *data)
    double t1 = get_time();
    printf("%1.5f\n", t1 - t0);
 #endif
-//   if (eglGetError() != EGL_SUCCESS)
+//   if (glsym_eglGetError() != EGL_SUCCESS)
 //     {
-//        printf("Error:  eglSwapBuffers() fail.\n");
+//        printf("Error:  glsym_eglSwapBuffers() fail.\n");
 //     }
 #else
 #ifdef VSYNC_TO_SCREEN
@@ -1403,12 +1295,12 @@ eng_output_flush(void *data)
      {
 //        double t, t2 = 0.0;
 //        t = get_time();
-        glXSwapBuffers(re->win->disp, re->win->win);
+        glsym_glXSwapBuffers(re->win->disp, re->win->win);
 //        t = get_time() - t;
 //        if (!safe_native)
 //          {
 //             t2 = get_time();
-//             glXWaitGL();
+//             glsym_glXWaitGL();
 //             t2 = get_time() - t2;
 //          }
 //        printf("swap: %3.5f (%3.5fms), x wait gl: %3.5f (%3.5fms)\n", 
@@ -1417,6 +1309,7 @@ eng_output_flush(void *data)
    else
      {
 // FIXME: this doesn't work.. why oh why?
+        /*
         int sx, sy, sw, sh;
 
         sx = re->win->draw.x1;
@@ -1425,15 +1318,17 @@ eng_output_flush(void *data)
         sh = (re->win->draw.y2 - re->win->draw.y1) + 1;
         sy = re->win->h - sy - sh;
         
-        glBitmap(0, 0, 0, 0, sx, re->win->h - sy, NULL);
-        glEnable(GL_SCISSOR_TEST);
-        glScissor(sx, sy, sw, sh);
-        glDrawBuffer(GL_FRONT);
-        glCopyPixels(sx, sy, sw, sh, GL_COLOR);
-        glDrawBuffer(GL_BACK);
-        glDisable(GL_SCISSOR_TEST);
-        glBitmap(0, 0, 0, 0, 0, 0, NULL);
-        glFlush();
+        glsym_glBitmap(0, 0, 0, 0, sx, re->win->h - sy, NULL);
+        glsym_glEnable(GL_SCISSOR_TEST);
+        glsym_glScissor(sx, sy, sw, sh);
+        glsym_glDrawBuffer(GL_FRONT);
+        glsym_glCopyPixels(sx, sy, sw, sh, GL_COLOR);
+        glsym_glDrawBuffer(GL_BACK);
+        glsym_glDisable(GL_SCISSOR_TEST);
+        glsym_glBitmap(0, 0, 0, 0, 0, 0, NULL);
+        glsym_glFlush();
+        */
+        ERR("Need Fixing.  Temporarily Disabled.");
      }
    if (re->info->callback.post_swap)
      {
@@ -1752,11 +1647,11 @@ _native_bind_cb(void *data, void *image)
           if (glsym_glEGLImageTargetTexture2DOES)
             {
               glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface);
-              if (eglGetError() != EGL_SUCCESS)
-                ERR("glEGLImageTargetTexture2DOES() failed.");
+              if (glsym_eglGetError() != EGL_SUCCESS)
+                ERR("glsym_glEGLImageTargetTexture2DOES() failed.");
             }
           else
-            ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
+            ERR("Try glsym_glEGLImageTargetTexture2DOES on EGL with no support");
         }
 #else
 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
@@ -1769,13 +1664,13 @@ _native_bind_cb(void *data, void *image)
           GLERR(__FUNCTION__, __FILE__, __LINE__, "");
         }
       else
-        ERR("Try glXBindTexImage on GLX with no support");
+        ERR("Try glsym_glXBindTexImage on GLX with no support");
 # endif
 #endif
     }
   else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
     {
-      glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
+      glsym_glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
     }
    return;
@@ -1803,13 +1698,13 @@ _native_unbind_cb(void *data, void *image)
           GLERR(__FUNCTION__, __FILE__, __LINE__, "");
         }
       else
-        ERR("Try glXReleaseTexImage on GLX with no support");
+        ERR("Try glsym_glXReleaseTexImage on GLX with no support");
 # endif
 #endif
     }
   else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
     {
-      glBindTexture(GL_TEXTURE_2D, 0);
+      glsym_glBindTexture(GL_TEXTURE_2D, 0);
       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
     }
    return;
@@ -1835,11 +1730,11 @@ _native_free_cb(void *data, void *image)
             {
               glsym_eglDestroyImage(re->win->egl_disp,
                                     n->egl_surface);
-              if (eglGetError() != EGL_SUCCESS)
-                ERR("eglDestroyImage() failed.");
+              if (glsym_eglGetError() != EGL_SUCCESS)
+                ERR("glsym_eglDestroyImage() failed.");
             }
           else
-            ERR("Try eglDestroyImage on EGL with no support");
+            ERR("Try glsym_eglDestroyImage on EGL with no support");
         }
 #else
 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
@@ -1854,7 +1749,7 @@ _native_free_cb(void *data, void *image)
                   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
                 }
               else
-                ERR("Try glXReleaseTexImage on GLX with no support");
+                ERR("Try glsym_glXReleaseTexImage on GLX with no support");
             }
           if (glsym_glXDestroyPixmap)
             {
@@ -1862,7 +1757,7 @@ _native_free_cb(void *data, void *image)
               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
             }
           else
-            ERR("Try glXDestroyPixmap on GLX with no support");
+            ERR("Try glsym_glXDestroyPixmap on GLX with no support");
           n->glx_pixmap = 0;
         }
 # endif
@@ -2018,9 +1913,9 @@ eng_image_native_set(void *data, void *image, void *native)
               config_attrs[i++] = EGL_PIXMAP_BIT;
               config_attrs[i++] = EGL_NONE;
 
-              if (!eglChooseConfig(re->win->egl_disp, config_attrs,
+              if (!glsym_eglChooseConfig(re->win->egl_disp, config_attrs,
                                    &egl_config, 1, &num_config))
-                ERR("eglChooseConfig() failed for pixmap 0x%x, num_config = %i", (unsigned int)pm, num_config);
+                ERR("glsym_eglChooseConfig() failed for pixmap 0x%x, num_config = %i", (unsigned int)pm, num_config);
               memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
               n->pixmap = pm;
               n->visual = vis;
@@ -2031,9 +1926,9 @@ eng_image_native_set(void *data, void *image, void *native)
                                                       (void *)pm,
                                                       NULL);
               else
-                ERR("Try eglCreateImage on EGL with no support");
+                ERR("Try glsym_eglCreateImage on EGL with no support");
               if (!n->egl_surface)
-                ERR("eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm);
+                ERR("glsym_eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm);
               im->native.yinvert     = 1;
               im->native.loose       = 0;
               im->native.data        = n;
@@ -2112,7 +2007,7 @@ eng_image_native_set(void *data, void *image, void *native)
                                                       n->pixmap,
                                                       pixmap_att);
               else
-                ERR("Try glXCreatePixmap on GLX with no support");
+                ERR("Try glsym_glXCreatePixmap on GLX with no support");
               if (n->glx_pixmap)
                 {
 //                  printf("%p: new native texture for %x | %4i x %4i @ %2i = %p\n",
@@ -2859,15 +2754,15 @@ _create_rt_buffers(Render_Engine *data __UNUSED__,
                    Render_Engine_GL_Surface *sfc)
 {
    // Render Target texture
-   glGenTextures(1, &sfc->rt_tex );
+   glsym_glGenTextures(1, &sfc->rt_tex );
 
    // Depth RenderBuffer - Create storage here...
    if (sfc->depth_bits != EVAS_GL_DEPTH_NONE)
-      glGenRenderbuffers(1, &sfc->rb_depth);
+      glsym_glGenRenderbuffers(1, &sfc->rb_depth);
 
    // Stencil RenderBuffer - Create Storage here...
    if (sfc->stencil_bits != EVAS_GL_STENCIL_NONE)
-      glGenRenderbuffers(1, &sfc->rb_stencil);
+      glsym_glGenRenderbuffers(1, &sfc->rb_stencil);
 
    return 1;
 }
@@ -2880,45 +2775,45 @@ _attach_fbo_surface(Render_Engine *data __UNUSED__,
    int fb_status;
 
    // Initialize Texture
-   glBindTexture(GL_TEXTURE_2D, sfc->rt_tex );
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sfc->w, sfc->h, 0,
+   glsym_glBindTexture(GL_TEXTURE_2D, sfc->rt_tex );
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glsym_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glsym_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sfc->w, sfc->h, 0,
                 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-   glBindTexture(GL_TEXTURE_2D, 0);
+   glsym_glBindTexture(GL_TEXTURE_2D, 0);
 
 
    // Attach texture to FBO
-   glBindFramebuffer(GL_FRAMEBUFFER, ctx->context_fbo);
-   glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+   glsym_glBindFramebuffer(GL_FRAMEBUFFER, ctx->context_fbo);
+   glsym_glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                           GL_TEXTURE_2D, sfc->rt_tex, 0);
 
    // Depth RenderBuffer - Attach it to FBO
    if (sfc->depth_bits != EVAS_GL_DEPTH_NONE)
      {
-        glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_depth);
-        glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_depth_fmt,
+        glsym_glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_depth);
+        glsym_glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_depth_fmt,
                               sfc->w, sfc->h);
-        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+        glsym_glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
                                   GL_RENDERBUFFER, sfc->rb_depth);
-        glBindRenderbuffer(GL_RENDERBUFFER, 0);
+        glsym_glBindRenderbuffer(GL_RENDERBUFFER, 0);
      }
 
    // Stencil RenderBuffer - Attach it to FBO
    if (sfc->stencil_bits != EVAS_GL_STENCIL_NONE)
      {
-        glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_stencil);
-        glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_stencil_fmt,
+        glsym_glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_stencil);
+        glsym_glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_stencil_fmt,
                               sfc->w, sfc->h);
-        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+        glsym_glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
                                   GL_RENDERBUFFER, sfc->rb_stencil);
-        glBindRenderbuffer(GL_RENDERBUFFER, 0);
+        glsym_glBindRenderbuffer(GL_RENDERBUFFER, 0);
      }
 
    // Check FBO for completeness
-   fb_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+   fb_status = glsym_glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if (fb_status != GL_FRAMEBUFFER_COMPLETE)
      {
         ERR("FBO not complete!");
@@ -2979,9 +2874,9 @@ eng_gl_surface_create(void *data, void *config, int w, int h)
    // make_current called, the user can't call native_surface_get() right
    // after the surface is created. hence this is done here using evas' context.
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
+   ret = glsym_eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
 #else
-   ret = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
+   ret = glsym_glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
 #endif
    if (!ret)
      {
@@ -2999,9 +2894,9 @@ eng_gl_surface_create(void *data, void *config, int w, int h)
      }
 
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+   ret = glsym_eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 #else
-   ret = glXMakeCurrent(re->info->info.display, None, NULL);
+   ret = glsym_glXMakeCurrent(re->info->info.display, None, NULL);
 #endif
    if (!ret)
      {
@@ -3029,9 +2924,9 @@ eng_gl_surface_destroy(void *data, void *surface)
    if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
 
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
+   ret = glsym_eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
 #else
-   ret = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
+   ret = glsym_glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
 #endif
    if (!ret)
      {
@@ -3041,18 +2936,20 @@ eng_gl_surface_destroy(void *data, void *surface)
 
    // Delete FBO/RBO and Texture here
    if (sfc->rt_tex)
-      glDeleteTextures(1, &sfc->rt_tex);
+      glsym_glDeleteTextures(1, &sfc->rt_tex);
 
    if (sfc->rb_depth)
-      glDeleteRenderbuffers(1, &sfc->rb_depth);
+      glsym_glDeleteRenderbuffers(1, &sfc->rb_depth);
 
    if (sfc->rb_stencil)
-      glDeleteRenderbuffers(1, &sfc->rb_stencil);
+      glsym_glDeleteRenderbuffers(1, &sfc->rb_stencil);
+
+
 
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+   ret = glsym_eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 #else
-   ret = glXMakeCurrent(re->info->info.display, None, NULL);
+   ret = glsym_glXMakeCurrent(re->info->info.display, None, NULL);
 #endif
    if (!ret)
      {
@@ -3094,44 +2991,44 @@ eng_gl_context_create(void *data, void *share_context)
 
    if (share_ctx)
      {
-        ctx->context = eglCreateContext(re->win->egl_disp,
-                                        re->win->egl_config,
-                                        share_ctx->context,      // Share Context
-                                        context_attrs);
+        ctx->context = glsym_eglCreateContext(re->win->egl_disp,
+                                              re->win->egl_config,
+                                              share_ctx->context,      // Share Context
+                                              context_attrs);
      }
    else
      {
-        ctx->context = eglCreateContext(re->win->egl_disp,
-                                        re->win->egl_config,
-                                        re->win->egl_context[0], // Evas' GL Context
-                                        context_attrs);
+        ctx->context = glsym_eglCreateContext(re->win->egl_disp,
+                                              re->win->egl_config,
+                                              re->win->egl_context[0], // Evas' GL Context
+                                              context_attrs);
      }
 
    if (!ctx->context)
      {
-        ERR("eglCreateContext() fail. code=%#x", eglGetError());
+        ERR("glsym_eglCreateContext() fail. code=%#x", glsym_eglGetError());
         return NULL;
      }
 #else
    // GLX
    if (share_context)
      {
-        ctx->context = glXCreateContext(re->info->info.display,
-                                        re->win->visualinfo,
-                                        share_ctx->context,    // Share Context
-                                        1);
+        ctx->context = glsym_glXCreateContext(re->info->info.display,
+                                              re->win->visualinfo,
+                                              share_ctx->context,    // Share Context
+                                              1);
      }
    else
      {
-        ctx->context = glXCreateContext(re->info->info.display,
-                                        re->win->visualinfo,
-                                        re->win->context,      // Evas' GL Context
-                                        1);
+        ctx->context = glsym_glXCreateContext(re->info->info.display,
+                                              re->win->visualinfo,
+                                              re->win->context,      // Evas' GL Context
+                                              1);
      }
 
    if (!ctx->context)
      {
-        ERR("glXCreateContext() fail.");
+        ERR("glsym_glXCreateContext() fail.");
         return NULL;
      }
 #endif
@@ -3158,13 +3055,13 @@ eng_gl_context_destroy(void *data, void *context)
 
    if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
 
-   // 1. Do a make current with the given context
+   // Do a make current with the given context
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
-                        rsc->surface, ctx->context);
+   ret = glsym_eglMakeCurrent(re->win->egl_disp, rsc->surface,
+                              rsc->surface, ctx->context);
 #else
-   ret = glXMakeCurrent(re->info->info.display, re->win->win,
-                        ctx->context);
+   ret = glsym_glXMakeCurrent(re->info->info.display, re->win->win,
+                              ctx->context);
 #endif
    if (!ret)
      {
@@ -3172,24 +3069,24 @@ eng_gl_context_destroy(void *data, void *context)
         return 0;
      }
 
-   // 2. Delete the FBO
+   // Delete the FBO
    if (ctx->context_fbo)
-        glDeleteFramebuffers(1, &ctx->context_fbo);
+      glsym_glDeleteFramebuffers(1, &ctx->context_fbo);
 
-   // 3. Destroy the Context
+   // Destroy the Context
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   eglDestroyContext(re->win->egl_disp, ctx->context);
+   glsym_eglDestroyContext(re->win->egl_disp, ctx->context);
 
    ctx->context = EGL_NO_CONTEXT;
 
-   ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
-                        EGL_NO_SURFACE, EGL_NO_CONTEXT);
+   ret = glsym_eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
+                              EGL_NO_SURFACE, EGL_NO_CONTEXT);
 #else
-   glXDestroyContext(re->info->info.display, ctx->context);
+   glsym_glXDestroyContext(re->info->info.display, ctx->context);
 
    ctx->context = 0;
 
-   ret = glXMakeCurrent(re->info->info.display, None, NULL);
+   ret = glsym_glXMakeCurrent(re->info->info.display, None, NULL);
 #endif
    if (!ret)
      {
@@ -3222,10 +3119,10 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
    if ((!sfc) || (!ctx))
      {
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-        ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
-                             EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        ret = glsym_eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
+                                   EGL_NO_SURFACE, EGL_NO_CONTEXT);
 #else
-        ret = glXMakeCurrent(re->info->info.display, None, NULL);
+        ret = glsym_glXMakeCurrent(re->info->info.display, None, NULL);
 #endif
         if (!ret)
           {
@@ -3243,15 +3140,15 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
    if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
 
-   if ((eglGetCurrentContext() != ctx->context) ||
-       (eglGetCurrentSurface(EGL_READ) != rsc->surface) ||
-       (eglGetCurrentSurface(EGL_DRAW) != rsc->surface) )
+   if ((glsym_eglGetCurrentContext() != ctx->context) ||
+       (glsym_eglGetCurrentSurface(EGL_READ) != rsc->surface) ||
+       (glsym_eglGetCurrentSurface(EGL_DRAW) != rsc->surface) )
      {
         // Flush remainder of what's in Evas' pipeline
         if (re->win) eng_window_use(NULL);
 
         // Do a make current
-        ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
+        ret = glsym_eglMakeCurrent(re->win->egl_disp, rsc->surface,
                              rsc->surface, ctx->context);
         if (!ret)
           {
@@ -3260,14 +3157,14 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
           }
      }
 #else
-   if ((glXGetCurrentContext() != ctx->context) ||
-       (glXGetCurrentDrawable() != re->win->win) )
+   if ((glsym_glXGetCurrentContext() != ctx->context) ||
+       (glsym_glXGetCurrentDrawable() != re->win->win) )
      {
         // Flush remainder of what's in Evas' pipeline
         if (re->win) eng_window_use(NULL);
 
         // Do a make current
-        ret = glXMakeCurrent(re->info->info.display, re->win->win, ctx->context);
+        ret = glsym_glXMakeCurrent(re->info->info.display, re->win->win, ctx->context);
         if (!ret)
           {
              ERR("xxxMakeCurrent() failed!");
@@ -3279,7 +3176,7 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
    // Create FBO if not already created
    if (!ctx->initialized)
      {
-        glGenFramebuffers(1, &ctx->context_fbo);
+        glsym_glGenFramebuffers(1, &ctx->context_fbo);
         ctx->initialized = 1;
      }
 
@@ -3294,10 +3191,10 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
 
         if (ctx->current_fbo)
            // Bind to the previously bound buffer
-           glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
+           glsym_glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
         else
            // Bind FBO
-           glBindFramebuffer(GL_FRAMEBUFFER, ctx->context_fbo);
+           glsym_glBindFramebuffer(GL_FRAMEBUFFER, ctx->context_fbo);
 
         sfc->fbo_attached = 1;
      }
@@ -3361,9 +3258,9 @@ static const GLubyte *
 evgl_glGetString(GLenum name)
 {
    if (name == GL_EXTENSIONS)
-      return (GLubyte *)_gl_ext_string; //glGetString(GL_EXTENSIONS); 
+      return (GLubyte *)_gl_ext_string; //glsym_glGetString(GL_EXTENSIONS);
    else
-      return glGetString(name);
+      return glsym_glGetString(name);
 }
 
 static void
@@ -3376,13 +3273,13 @@ evgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
      {
         if (ctx)
           {
-             glBindFramebuffer(target, ctx->context_fbo);
+             glsym_glBindFramebuffer(target, ctx->context_fbo);
              ctx->current_fbo = 0;
           }
      }
    else
      {
-        glBindFramebuffer(target, framebuffer);
+        glsym_glBindFramebuffer(target, framebuffer);
 
         // Save this for restore when doing make current
         if (ctx)
@@ -3395,16 +3292,16 @@ evgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
 {
    // Add logic to take care when renderbuffer=0
    // On a second thought we don't need this
-   glBindRenderbuffer(target, renderbuffer);
+   glsym_glBindRenderbuffer(target, renderbuffer);
 }
 
 static void
 evgl_glClearDepthf(GLclampf depth)
 {
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   glClearDepthf(depth);
+   glsym_glClearDepthf(depth);
 #else
-   glClearDepth(depth);
+   glsym_glClearDepthf(depth);
 #endif
 }
 
@@ -3412,9 +3309,9 @@ static void
 evgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
 {
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   glDepthRangef(zNear, zFar);
+   glsym_glDepthRangef(zNear, zFar);
 #else
-   glDepthRange(zNear, zFar);
+   glsym_glDepthRangef(zNear, zFar);
 #endif
 }
 
@@ -3422,7 +3319,7 @@ static void
 evgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
 {
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
+   glsym_glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
 #else
    if (range)
      {
@@ -3442,7 +3339,7 @@ static void
 evgl_glReleaseShaderCompiler(void)
 {
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   glReleaseShaderCompiler();
+   glsym_glReleaseShaderCompiler();
 #else
 #endif
 }
@@ -3451,7 +3348,7 @@ static void
 evgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
 {
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   glShaderBinary(n, shaders, binaryformat, binary, length);
+   glsym_glShaderBinary(n, shaders, binaryformat, binary, length);
 #else
 // FIXME: need to dlsym/getprocaddress for this
    return;
@@ -3513,7 +3410,7 @@ eng_gl_api_get(void *data)
 
    gl_funcs.version = EVAS_GL_API_VERSION;
 
-#define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, )
+#define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, glsym_)
    // GLES 2.0
    ORD(glActiveTexture);
    ORD(glAttachShader);
index 4f62c58..007ed7d 100644 (file)
@@ -12,8 +12,8 @@
 
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
 # if defined(GLES_VARIETY_S3C6410)
-#  include <EGL/egl.h>
-#  include <GLES2/gl2.h>
+//#  include <EGL/egl.h>
+//#  include <GLES2/gl2.h>
 #  include <X11/Xlib.h>
 #  include <X11/Xatom.h>
 #  include <X11/Xutil.h>
@@ -21,9 +21,9 @@
 #  include <X11/Xresource.h> // xres - dpi
 # elif defined(GLES_VARIETY_SGX)
 #  define SUPPORT_X11 1
-#  include <EGL/egl.h>
-#  include <GLES2/gl2.h>
-#  include <GLES2/gl2ext.h>
+//#  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,9 +36,9 @@
 # include <X11/Xutil.h>
 # include <X11/extensions/Xrender.h>
 # include <X11/Xresource.h> // xres - dpi
-# include <GL/gl.h>
-# include <GL/glext.h>
-# include <GL/glx.h>
+//# include <GL/gl.h>
+//# include <GL/glext.h>
+//# include <GL/glx.h>
 #endif
 
 extern int _evas_engine_GL_X11_log_dom ;
index 323c976..f6ea4ea 100644 (file)
@@ -156,68 +156,68 @@ eng_window_new(Display *disp,
    config_attrs[n++] = EGL_NONE;
 # endif
 
-   gw->egl_disp = eglGetDisplay((EGLNativeDisplayType)(gw->disp));
+   gw->egl_disp = glsym_eglGetDisplay((EGLNativeDisplayType)(gw->disp));
    if (!gw->egl_disp)
      {
-        ERR("eglGetDisplay() fail. code=%#x", eglGetError());
+        ERR("glsym_eglGetDisplay() fail. code=%#x", glsym_eglGetError());
        eng_window_free(gw);
         return NULL;
      }
-   if (!eglInitialize(gw->egl_disp, &major_version, &minor_version))
+   if (!glsym_eglInitialize(gw->egl_disp, &major_version, &minor_version))
      {
-        ERR("eglInitialize() fail. code=%#x", eglGetError());
+        ERR("glsym_eglInitialize() fail. code=%#x", glsym_eglGetError());
        eng_window_free(gw);
         return NULL;
      }
-   eglBindAPI(EGL_OPENGL_ES_API);
-   if (eglGetError() != EGL_SUCCESS)
+   glsym_eglBindAPI(EGL_OPENGL_ES_API);
+   if (glsym_eglGetError() != EGL_SUCCESS)
      {
-        ERR("eglBindAPI() fail. code=%#x", eglGetError());
+        ERR("glsym_eglBindAPI() fail. code=%#x", glsym_eglGetError());
        eng_window_free(gw);
         return NULL;
      }
 
    num_config = 0;
-   if (!eglChooseConfig(gw->egl_disp, config_attrs, &gw->egl_config,
+   if (!glsym_eglChooseConfig(gw->egl_disp, config_attrs, &gw->egl_config,
                         1, &num_config) || (num_config != 1))
      {
-        ERR("eglChooseConfig() fail. code=%#x", eglGetError());
+        ERR("glsym_eglChooseConfig() fail. code=%#x", glsym_eglGetError());
        eng_window_free(gw);
         return NULL;
      }
-   gw->egl_surface[0] = eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
+   gw->egl_surface[0] = glsym_eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
                                                (EGLNativeWindowType)gw->win,
                                                NULL);
    if (gw->egl_surface[0] == EGL_NO_SURFACE)
      {
-        ERR("eglCreateWindowSurface() fail for %#x. code=%#x",
-            (unsigned int)gw->win, eglGetError());
+        ERR("glsym_eglCreateWindowSurface() fail for %#x. code=%#x",
+            (unsigned int)gw->win, glsym_eglGetError());
        eng_window_free(gw);
         return NULL;
      }
    if (context == EGL_NO_CONTEXT)
-     context = eglCreateContext(gw->egl_disp, gw->egl_config, NULL,
+     context = glsym_eglCreateContext(gw->egl_disp, gw->egl_config, NULL,
                                 context_attrs);
    gw->egl_context[0] = context;
    if (gw->egl_context[0] == EGL_NO_CONTEXT)
      {
-        ERR("eglCreateContext() fail. code=%#x", eglGetError());
+        ERR("glsym_eglCreateContext() fail. code=%#x", glsym_eglGetError());
        eng_window_free(gw);
         return NULL;
      }
-   if (eglMakeCurrent(gw->egl_disp,
+   if (glsym_eglMakeCurrent(gw->egl_disp,
                       gw->egl_surface[0],
                       gw->egl_surface[0],
                       gw->egl_context[0]) == EGL_FALSE)
      {
-        ERR("eglMakeCurrent() fail. code=%#x", eglGetError());
+        ERR("glsym_eglMakeCurrent() fail. code=%#x", glsym_eglGetError());
        eng_window_free(gw);
         return NULL;
      }
 
-   vendor = glGetString(GL_VENDOR);
-   renderer = glGetString(GL_RENDERER);
-   version = glGetString(GL_VERSION);
+   vendor = glsym_glGetString(GL_VENDOR);
+   renderer = glsym_glGetString(GL_RENDERER);
+   version = glsym_glGetString(GL_VERSION);
    if (!vendor)   vendor   = (unsigned char *)"-UNKNOWN-";
    if (!renderer) renderer = (unsigned char *)"-UNKNOWN-";
    if (!version)  version  = (unsigned char *)"-UNKNOWN-";
@@ -233,36 +233,36 @@ eng_window_new(Display *disp,
      {
 #ifdef NEWGL
         if (indirect)
-          context = glXCreateNewContext(gw->disp, fbconf,
+          context = glsym_glXCreateNewContext(gw->disp, fbconf,
                                         GLX_RGBA_TYPE, NULL,
                                         GL_FALSE);
         else
-          context = glXCreateNewContext(gw->disp, fbconf,
+          context = glsym_glXCreateNewContext(gw->disp, fbconf,
                                         GLX_RGBA_TYPE, NULL,
                                         GL_TRUE);
 #else
         if (indirect)
-          context = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_FALSE);
+          context = glsym_glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_FALSE);
         else
-          context = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_TRUE);
+          context = glsym_glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_TRUE);
 #endif
      }
 #ifdef NEWGL
    if ((gw->alpha) && (!rgba_context))
      {
         if (indirect)
-          rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
+          rgba_context = glsym_glXCreateNewContext(gw->disp, rgba_fbconf,
                                              GLX_RGBA_TYPE, context,
                                              GL_FALSE);
         else
-          rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
+          rgba_context = glsym_glXCreateNewContext(gw->disp, rgba_fbconf,
                                              GLX_RGBA_TYPE, context,
                                              GL_TRUE);
      }
    if (gw->alpha)
-     gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
+     gw->glxwin = glsym_glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
    else
-     gw->glxwin = glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
+     gw->glxwin = glsym_glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
    if (!gw->glxwin)
      {
        eng_window_free(gw);
@@ -288,19 +288,19 @@ eng_window_new(Display *disp,
 
         if (gw->glxwin)
           {
-             if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
+             if (!glsym_glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
                                         gw->context))
                {
-                  printf("Error: glXMakeContextCurrent(%p, %p, %p, %p)\n", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
+                  printf("Error: glsym_glXMakeContextCurrent(%p, %p, %p, %p)\n", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
                   eng_window_free(gw);
                   return NULL;
                }
           }
         else
           {
-             if (!glXMakeCurrent(gw->disp, gw->win, gw->context))
+             if (!glsym_glXMakeCurrent(gw->disp, gw->win, gw->context))
                {
-                  printf("Error: glXMakeCurrent(%p, 0x%x, %p) failed\n", (void *)gw->disp, (unsigned int)gw->win, (void *)gw->context);
+                  printf("Error: glsym_glXMakeCurrent(%p, 0x%x, %p) failed\n", (void *)gw->disp, (unsigned int)gw->win, (void *)gw->context);
                   eng_window_free(gw);
                   return NULL;
                }
@@ -308,9 +308,9 @@ eng_window_new(Display *disp,
 
         // FIXME: move this up to context creation
 
-        vendor = glGetString(GL_VENDOR);
-        renderer = glGetString(GL_RENDERER);
-        version = glGetString(GL_VERSION);
+        vendor = glsym_glGetString(GL_VENDOR);
+        renderer = glsym_glGetString(GL_RENDERER);
+        version = glsym_glGetString(GL_VERSION);
         if (getenv("EVAS_GL_INFO"))
           {
              fprintf(stderr, "vendor: %s\n", vendor);
@@ -416,10 +416,10 @@ eng_window_new(Display *disp,
              // noothing yet. add more cases and options over time
           }
 
-        fbc = glXGetFBConfigs(gw->disp, screen, &num);
+        fbc = glsym_glXGetFBConfigs(gw->disp, screen, &num);
         if (!fbc)
           {
-             ERR("glXGetFBConfigs() returned no fb configs");
+             ERR("glsym_glXGetFBConfigs() returned no fb configs");
              eng_window_free(gw);
              return NULL;
           }
@@ -432,15 +432,15 @@ eng_window_new(Display *disp,
                   int alph, val, dbuf, stencil, tdepth;
                   int rgba;
 
-                  vi = glXGetVisualFromFBConfig(gw->disp, fbc[j]);
+                  vi = glsym_glXGetVisualFromFBConfig(gw->disp, fbc[j]);
                   if (!vi) continue;
                   vd = vi->depth;
                   XFree(vi);
 
                   if (vd != i) continue;
 
-                  glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_ALPHA_SIZE, &alph);
-                  glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BUFFER_SIZE, &val);
+                  glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_ALPHA_SIZE, &alph);
+                  glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BUFFER_SIZE, &val);
 
                   if ((val != i) && ((val - alph) != i)) continue;
 
@@ -449,7 +449,7 @@ eng_window_new(Display *disp,
 
                   if (i == 32)
                     {
-                       glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_RGBA_EXT, &val);
+                       glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_RGBA_EXT, &val);
                        if (val)
                          {
                             rgba = 1;
@@ -459,34 +459,34 @@ eng_window_new(Display *disp,
                   if (!val)
                     {
                        if (rgba) continue;
-                       glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_RGB_EXT, &val);
+                       glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_RGB_EXT, &val);
                        if (!val) continue;
                        gw->depth_cfg[i].tex_format = GLX_TEXTURE_FORMAT_RGB_EXT;
                     }
 
                   dbuf = 0x7fff;
-                  glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DOUBLEBUFFER, &val);
+                  glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DOUBLEBUFFER, &val);
                   if (val > dbuf) continue;
                   dbuf = val;
 
                   stencil = 0x7fff;
-                  glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_STENCIL_SIZE, &val);
+                  glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_STENCIL_SIZE, &val);
                   if (val > stencil) continue;
                   stencil = val;
 
                   tdepth = 0x7fff;
-                  glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DEPTH_SIZE, &val);
+                  glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DEPTH_SIZE, &val);
                   if (val > tdepth) continue;
                   tdepth = val;
 
-                  glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val);
+                  glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val);
                   if (val < 0) continue;
                   gw->depth_cfg[i].mipmap = val;
 
-                  glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_Y_INVERTED_EXT, &val);
+                  glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_Y_INVERTED_EXT, &val);
                   gw->depth_cfg[i].yinvert = val;
 
-                  glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &val);
+                  glsym_glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &val);
                   gw->depth_cfg[i].tex_target = val;
 
                   gw->depth_cfg[i].fbc = fbc[j];
@@ -530,20 +530,21 @@ eng_window_free(Evas_GL_X11_Window *gw)
      }
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
    if (gw->egl_surface[0] != EGL_NO_SURFACE)
-      eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
+      glsym_eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
+   glsym_eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    if (ref == 0)
      {
-        if (context) eglDestroyContext(gw->egl_disp, context);
-        eglTerminate(gw->egl_disp);
+        if (context) glsym_eglDestroyContext(gw->egl_disp, context);
+        glsym_eglTerminate(gw->egl_disp);
         context = EGL_NO_CONTEXT;
      }
-   eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+   glsym_eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 #else
-   if (gw->glxwin) glXDestroyWindow(gw->disp, gw->glxwin);
+   if (gw->glxwin) glsym_glXDestroyWindow(gw->disp, gw->glxwin);
    if (ref == 0)
      {
-        if (context) glXDestroyContext(gw->disp, context);
-        if (rgba_context) glXDestroyContext(gw->disp, rgba_context);
+        if (context) glsym_glXDestroyContext(gw->disp, context);
+        if (rgba_context) glsym_glXDestroyContext(gw->disp, rgba_context);
         context = 0;
         rgba_context = 0;
         fbconf = 0;
@@ -561,18 +562,18 @@ eng_window_use(Evas_GL_X11_Window *gw)
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
    if (_evas_gl_x11_window)
      {
-        if ((eglGetCurrentContext() !=
+        if ((glsym_eglGetCurrentContext() !=
              _evas_gl_x11_window->egl_context[0]) ||
-            (eglGetCurrentSurface(EGL_READ) !=
+            (glsym_eglGetCurrentSurface(EGL_READ) !=
                 _evas_gl_x11_window->egl_surface[0]) ||
-            (eglGetCurrentSurface(EGL_DRAW) !=
+            (glsym_eglGetCurrentSurface(EGL_DRAW) !=
                 _evas_gl_x11_window->egl_surface[0]))
            force_use = EINA_TRUE;
      }
 #else
    if (_evas_gl_x11_window)
      {
-        if (glXGetCurrentContext() != _evas_gl_x11_window->context)
+        if (glsym_glXGetCurrentContext() != _evas_gl_x11_window->context)
            force_use = EINA_TRUE;
      }
 #endif
@@ -590,29 +591,29 @@ eng_window_use(Evas_GL_X11_Window *gw)
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
            if (gw->egl_surface[0] != EGL_NO_SURFACE)
              {
-                if (eglMakeCurrent(gw->egl_disp,
+                if (glsym_eglMakeCurrent(gw->egl_disp,
                                    gw->egl_surface[0],
                                    gw->egl_surface[0],
                                    gw->egl_context[0]) == EGL_FALSE)
                   {
-                     ERR("eglMakeCurrent() failed!");
+                     ERR("glsym_eglMakeCurrent() failed!");
                   }
              }
 // GLX
 #else
            if (gw->glxwin)
              {
-               if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
+               if (!glsym_glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
                                           gw->context))
                  {
-                   ERR("glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
+                   ERR("glsym_glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
                  }
              }
            else
              {
-               if (!glXMakeCurrent(gw->disp, gw->win, gw->context))
+               if (!glsym_glXMakeCurrent(gw->disp, gw->win, gw->context))
                  {
-                   ERR("glXMakeCurrent(%p, 0x%x, %p) failed", gw->disp, (unsigned int)gw->win, (void *)gw->context);
+                   ERR("glsym_glXMakeCurrent(%p, 0x%x, %p) failed", gw->disp, (unsigned int)gw->win, (void *)gw->context);
                  }
              }
 #endif
@@ -633,16 +634,16 @@ eng_window_unsurf(Evas_GL_X11_Window *gw)
       evas_gl_common_context_flush(_evas_gl_x11_window->gl_context);
    if (_evas_gl_x11_window == gw)
      {
-        eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        glsym_eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
         if (gw->egl_surface[0] != EGL_NO_SURFACE)
-           eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
+           glsym_eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
         gw->egl_surface[0] = EGL_NO_SURFACE;
         _evas_gl_x11_window = NULL;
      }
 #else
    if (gw->glxwin)
       {
-         glXDestroyWindow(gw->disp, gw->glxwin);
+         glsym_glXDestroyWindow(gw->disp, gw->glxwin);
       }
    else
      {
@@ -658,37 +659,37 @@ eng_window_resurf(Evas_GL_X11_Window *gw)
    if (getenv("EVAS_GL_INFO"))
       printf("resurf %p\n", gw);
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-   gw->egl_surface[0] = eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
-                                               (EGLNativeWindowType)gw->win,
-                                               NULL);
+   gw->egl_surface[0] = glsym_eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
+                                                     (EGLNativeWindowType)gw->win,
+                                                     NULL);
    if (gw->egl_surface[0] == EGL_NO_SURFACE)
      {
-        ERR("eglCreateWindowSurface() fail for %#x. code=%#x",
-            (unsigned int)gw->win, eglGetError());
+        ERR("glsym_eglCreateWindowSurface() fail for %#x. code=%#x",
+            (unsigned int)gw->win, glsym_eglGetError());
         return;
      }
-   if (eglMakeCurrent(gw->egl_disp,
+   if (glsym_eglMakeCurrent(gw->egl_disp,
                       gw->egl_surface[0],
                       gw->egl_surface[0],
                       gw->egl_context[0]) == EGL_FALSE)
      {
-        ERR("eglMakeCurrent() failed!");
+        ERR("glsym_eglMakeCurrent() failed!");
      }
 #else
 #ifdef NEWGL
    if (gw->alpha)
-     gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
+     gw->glxwin = glsym_glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
    else
-     gw->glxwin = glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
-   if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
+     gw->glxwin = glsym_glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
+   if (!glsym_glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
                               gw->context))
      {
-        ERR("glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
+        ERR("glsym_glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
      }
 #else
-   if (!glXMakeCurrent(gw->disp, gw->win, gw->context))
+   if (!glsym_glXMakeCurrent(gw->disp, gw->win, gw->context))
      {
-        ERR("glXMakeCurrent(%p, 0x%x, %p) failed", (void *)gw->disp, (unsigned int)gw->win, (void *)gw->context);
+        ERR("glsym_glXMakeCurrent(%p, 0x%x, %p) failed", (void *)gw->disp, (unsigned int)gw->win, (void *)gw->context);
      }
 #endif
 #endif
@@ -794,12 +795,12 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
              config_attrs[i++] = GLX_NONE;//GLX_NONE;//GLX_TRANSPARENT_INDEX//GLX_TRANSPARENT_RGB;
              config_attrs[i++] = 0;
              
-             configs = glXChooseFBConfig(einfo->info.display,
+             configs = glsym_glXChooseFBConfig(einfo->info.display,
                                          einfo->info.screen,
                                          config_attrs, &num);
              if ((!configs) || (num < 1))
                {
-                  ERR("glXChooseFBConfig returned no configs");
+                  ERR("glsym_glXChooseFBConfig returned no configs");
                   return NULL;
                }
              for (i = 0; i < num; i++)
@@ -807,7 +808,7 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
                   XVisualInfo *visinfo;
                   XRenderPictFormat *format = NULL;
 
-                  visinfo = glXGetVisualFromFBConfig(einfo->info.display,
+                  visinfo = glsym_glXGetVisualFromFBConfig(einfo->info.display,
                                                      configs[i]);
                   if (!visinfo) continue;
                   if (!alpha)