Initial Commit
authorHaegeun Park <haegeun.park@samsung.com>
Mon, 26 Mar 2012 04:41:42 +0000 (21:41 -0700)
committerHaegeun Park <haegeun.park@samsung.com>
Mon, 26 Mar 2012 05:43:42 +0000 (22:43 -0700)
37 files changed:
Makefile [new file with mode: 0644]
include/EGL/def_egl.h [new file with mode: 0644]
include/EGL/egl.h [new file with mode: 0644]
include/EGL/eglext.h [new file with mode: 0644]
include/EGL/eglplatform.h [new file with mode: 0644]
include/EGL/sym_egl.h [new file with mode: 0644]
include/GLES2/def_gl.h [new file with mode: 0644]
include/GLES2/gl2.h [new file with mode: 0644]
include/GLES2/gl2ext.h [new file with mode: 0644]
include/GLES2/gl2platform.h [new file with mode: 0644]
include/GLES2/sym_gl.h [new file with mode: 0644]
packaging/coregl.spec [new file with mode: 0644]
src/coregl.c [new file with mode: 0644]
src/coregl.h [new file with mode: 0644]
src/coregl_fastpath.c [new file with mode: 0644]
src/coregl_fastpath.h [new file with mode: 0644]
src/coregl_fastpath_egl.c [new file with mode: 0644]
src/coregl_fastpath_gl.c [new file with mode: 0644]
src/coregl_fastpath_glx.c [new file with mode: 0644]
src/coregl_fastpath_state.h [new file with mode: 0644]
src/coregl_internal.h [new file with mode: 0644]
src/coregl_override.c [new file with mode: 0644]
src/coregl_thread_pthread.c [new file with mode: 0644]
src/coregl_thread_pthread.h [new file with mode: 0644]
src/coregl_trace.c [new file with mode: 0644]
src/coregl_wrappath.c [new file with mode: 0644]
src/coregl_wrappath.h [new file with mode: 0644]
src/coregl_wrappath_egl.c [new file with mode: 0644]
src/coregl_wrappath_gl.c [new file with mode: 0644]
src/coregl_wrappath_glx.c [new file with mode: 0644]
src/headers/egl.h [new file with mode: 0644]
src/headers/gl.h [new file with mode: 0644]
src/headers/glx.h [new file with mode: 0644]
src/headers/sym.h [new file with mode: 0644]
src/headers/sym_egl.h [new file with mode: 0644]
src/headers/sym_gl.h [new file with mode: 0644]
src/headers/sym_glx.h [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..0fb8c3c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,43 @@
+CC = gcc
+
+CFLAGS = -g -O2 -fPIC -Wall -std=c99 \
+       -D_COREGL_EMBEDDED_GL \
+
+LDFLAGS = -g -O2 -Wall -std=c99 -lpthread
+
+SOURCES = \
+               src/coregl.c \
+               src/coregl_thread_pthread.c \
+               src/coregl_trace.c \
+               src/coregl_override.c \
+               src/coregl_wrappath.c \
+               src/coregl_wrappath_egl.c \
+               src/coregl_wrappath_gl.c \
+               src/coregl_fastpath.c \
+               src/coregl_fastpath_egl.c \
+               src/coregl_fastpath_gl.c
+
+BIN = libCOREGL.so
+
+OBJECTS = $(SOURCES:.c=.o)
+
+all : $(BIN)
+       ln -sf $(BIN) lib/libEGL.so.1.4
+       ln -sf $(BIN) lib/libGLESv2.so.2.0
+       cp src/headers/egl.h include/EGL/def_egl.h
+       cp src/headers/gl.h include/GLES2/def_gl.h
+       cp src/headers/sym_egl.h include/EGL/sym_egl.h
+       cp src/headers/sym_gl.h include/GLES2/sym_gl.h
+#      ln -sf `readlink -f /usr/lib/libEGL.so` lib/libEGL_drv.so
+#      ln -sf `readlink -f /usr/lib/libGLESv2.so` lib/libGLESv2_drv.so
+
+$(BIN) : $(OBJECTS)
+       @mkdir -p lib
+       $(CC) -shared -o lib/$(BIN) $(OBJECTS) $(LDFLAGS)
+
+%.o : %.c
+       $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ 
+
+clean:
+       rm -f $(OBJECTS) lib/$(BIN)
+
diff --git a/include/EGL/def_egl.h b/include/EGL/def_egl.h
new file mode 100644 (file)
index 0000000..6236e08
--- /dev/null
@@ -0,0 +1,212 @@
+//------------------------------------------------------//
+//                         EGL
+//------------------------------------------------------//
+
+/* EGL Types */
+/* EGLint is defined in eglplatform.h */
+
+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_KHR_image
+#define EGL_KHR_image 1
+#define EGL_NATIVE_PIXMAP_KHR                  0x30B0  /* eglCreateImageKHR target */
+typedef void *EGLImageKHR;
+#define EGL_NO_IMAGE_KHR                       ((EGLImageKHR)0)
+#endif
+
diff --git a/include/EGL/egl.h b/include/EGL/egl.h
new file mode 100644 (file)
index 0000000..eeadeee
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __egl_h_
+#define __egl_h_
+
+#define _COREGL_NAME_MANGLE(name) name
+
+typedef void (*_eng_fn) (void);
+
+#include <EGL/eglplatform.h>
+
+#include "def_egl.h"
+#include "sym_egl.h"
+
+#undef GL
+
+#endif /* __egl_h_ */
+
diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/include/EGL/eglplatform.h b/include/EGL/eglplatform.h
new file mode 100644 (file)
index 0000000..d268ea4
--- /dev/null
@@ -0,0 +1,118 @@
+#ifndef __eglplatform_h_
+#define __eglplatform_h_
+
+/*
+** Copyright (c) 2007-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Platform-specific types and definitions for egl.h
+ * $Revision: 1.9 $ on $Date: 2009/03/18 12:53:58 $
+ *
+ * Adopters may modify khrplatform.h and this file to suit their platform.
+ * You are encouraged to submit all modifications to the Khronos group so that
+ * they can be included in future versions of this file.  Please submit changes
+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
+ * by filing a bug against product "EGL" component "Registry".
+ */
+
+#include <KHR/khrplatform.h>
+
+/* Macros used in EGL function prototype declarations.
+ *
+ * EGL functions should be prototyped as:
+ *
+ * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
+ * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
+ *
+ * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
+ */
+
+#ifndef EGLAPI
+#define EGLAPI KHRONOS_APICALL
+#endif
+
+#define EGLAPIENTRY  KHRONOS_APIENTRY
+#define EGLAPIENTRYP KHRONOS_APIENTRY*
+
+/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
+ * are aliases of window-system-dependent types, such as X Display * or
+ * Windows Device Context. They must be defined in platform-specific
+ * code below. The EGL-prefixed versions of Native*Type are the same
+ * types, renamed in EGL 1.3 so all types in the API start with "EGL".
+ */
+
+#if ((defined(__VC32__) && !defined(__CYGWIN__)) && !defined(__SCITECH_SNAP__))
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+
+typedef HDC     EGLNativeDisplayType;
+typedef HBITMAP EGLNativePixmapType;
+typedef HWND    EGLNativeWindowType;
+
+#else
+#if defined(__WINSCW__)
+
+typedef int   EGLNativeDisplayType;
+typedef void *EGLNativeWindowType;
+typedef void *EGLNativePixmapType;
+
+#else
+#if defined(__unix__) && defined(SUPPORT_X11)
+
+/* X11 (tentative)  */
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+typedef Display *EGLNativeDisplayType;
+typedef Pixmap   EGLNativePixmapType;
+typedef Window   EGLNativeWindowType;
+
+#else
+
+/* NULLWS fallback */
+
+typedef int            EGLNativeDisplayType;
+typedef void*  EGLNativePixmapType;
+typedef void*  EGLNativeWindowType;
+
+#endif
+#endif
+#endif
+
+/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
+typedef EGLNativeDisplayType NativeDisplayType;
+typedef EGLNativePixmapType  NativePixmapType;
+typedef EGLNativeWindowType  NativeWindowType;
+
+
+/* Define EGLint. This must be a signed integral type large enough to contain
+ * all legal attribute names and values passed into and out of EGL, whether
+ * their type is boolean, bitmask, enumerant (symbolic constant), integer,
+ * handle, or other.  While in general a 32-bit integer will suffice, if
+ * handles are 64 bit types, then EGLint should be defined as a signed 64-bit
+ * integer type.
+ */
+typedef khronos_int32_t EGLint;
+
+#endif /* __eglplatform_h */
diff --git a/include/EGL/sym_egl.h b/include/EGL/sym_egl.h
new file mode 100644 (file)
index 0000000..17ed9d6
--- /dev/null
@@ -0,0 +1,65 @@
+// Defult use-case for exporting symbols
+#ifndef _COREGL_SYMBOL
+#define _COREGL_SYMBOL_NOT_DEFINED
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     extern RET_TYPE (*_COREGL_NAME_MANGLE(FUNC_NAME)) PARAM_LIST;
+#endif
+
+// Standard EGL APIs
+
+_COREGL_SYMBOL(GL_FALSE, EGLint, eglGetError, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLDisplay, eglGetDisplay, (EGLNativeDisplayType display_id))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglInitialize, (EGLDisplay dpy, EGLint* major, EGLint *minor))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglTerminate, (EGLDisplay dpy))
+_COREGL_SYMBOL(GL_FALSE, const char*, eglQueryString, (EGLDisplay dpy, EGLint name))
+
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglGetConfigs, (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglChooseConfig, (EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglGetConfigAttrib, (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value))
+
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglCreateWindowSurface, (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list))
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglCreatePbufferSurface, (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list))
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglCreatePixmapSurface, (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglDestroySurface, (EGLDisplay dpy, EGLSurface surface))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglQuerySurface, (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value))
+
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglBindAPI, (EGLenum api))
+_COREGL_SYMBOL(GL_FALSE, EGLenum, eglQueryAPI, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglWaitClient, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglReleaseThread, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglCreatePbufferFromClientBuffer, (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list))
+
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglSurfaceAttrib, (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value))
+_COREGL_SYMBOL(GL_FALSE, void, eglBindTexImage, (EGLDisplay dpy, EGLSurface surface, EGLint buffer))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglReleaseTexImage, (EGLDisplay dpy, EGLSurface surface, EGLint buffer))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglSwapInterval, (EGLDisplay dpy, EGLint interval))
+_COREGL_SYMBOL(GL_FALSE, EGLContext, eglCreateContext, (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglDestroyContext, (EGLDisplay dpy, EGLContext ctx))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglMakeCurrent, (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx))
+_COREGL_SYMBOL(GL_FALSE, EGLContext, eglGetCurrentContext, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglGetCurrentSurface, (EGLint readdraw))
+_COREGL_SYMBOL(GL_FALSE, EGLDisplay, eglGetCurrentDisplay, (void))
+
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglQueryContext, (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglWaitGL, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglWaitNative, (EGLint engine))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglSwapBuffers, (EGLDisplay dpy, EGLSurface surface))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglCopyBuffers, (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target))
+
+_COREGL_SYMBOL(GL_FALSE, _eng_fn, eglGetProcAddress, (const char* procname))
+
+
+// Extensions
+_COREGL_SYMBOL(GL_TRUE, EGLImageKHR, eglCreateImageKHR, (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list))
+_COREGL_SYMBOL(GL_TRUE, EGLBoolean, eglDestroyImageKHR, (EGLDisplay dpy, EGLImageKHR image))
+
+_COREGL_SYMBOL(GL_TRUE, void*, eglMapImageSEC, (EGLDisplay dpy, EGLImageKHR image))
+_COREGL_SYMBOL(GL_TRUE, EGLBoolean, eglUnmapImageSEC, (EGLDisplay dpy, EGLImageKHR image))
+_COREGL_SYMBOL(GL_TRUE, EGLBoolean, eglGetImageAttribSEC, (EGLDisplay dpy, EGLImageKHR image, EGLint attribute, EGLint *value))
+
+//_COREGL_SYMBOL(GL_FALSE, unsigned int, eglLockSurface, (EGLDisplay a, EGLSurface b, const int *attrib_list))
+//_COREGL_SYMBOL(GL_FALSE, unsigned int, eglUnlockSurface, (EGLDisplay a, EGLSurface b))
+
+#ifdef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL
+#endif
diff --git a/include/GLES2/def_gl.h b/include/GLES2/def_gl.h
new file mode 100644 (file)
index 0000000..e7b8145
--- /dev/null
@@ -0,0 +1,519 @@
+/*
+ * 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_EGL_image */
+#ifndef GL_OES_EGL_image
+typedef void* GLeglImageOES;
+#endif
+
+#ifndef EGL_SEC_image_map
+#define EGL_SEC_image_map 1
+#define EGL_MAP_GL_TEXTURE_2D_SEC                              0x3201  /* eglCreateImageKHR target */
+#define EGL_MAP_GL_TEXTURE_HEIGHT_SEC                  0x3202  /* eglCreateImageKHR attribute */
+#define EGL_MAP_GL_TEXTURE_WIDTH_SEC                   0x3203  /* eglCreateImageKHR attribute */
+#define EGL_MAP_GL_TEXTURE_FORMAT_SEC                  0x3204  /* eglCreateImageKHR attribute, Specifies the number of color components in the mapped texture. */
+#define EGL_MAP_GL_TEXTURE_RGB_SEC                             0x3205  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_RGBA_SEC                            0x3206  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_BGRA_SEC                            0x3207  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_LUMINANCE_SEC               0x3208  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_LUMINANCE_ALPHA_SEC         0x3209  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC              0x320a  /* eglCreateImageKHR attribute, Specifies the data type of the pixel data. */
+#define EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC   0x320b  /* More config attribute value, for EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC */
+#define EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC  0x320c /* GetImageAttribSEC target */
+#endif
+
+
+/* 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
+
diff --git a/include/GLES2/gl2.h b/include/GLES2/gl2.h
new file mode 100644 (file)
index 0000000..104d5d8
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef __gl2_h_
+#define __gl2_h_
+
+#define _COREGL_NAME_MANGLE(name) name
+
+#include <GLES2/gl2platform.h>
+
+#include "def_gl.h"
+#include "sym_gl.h"
+
+#undef GL
+
+#endif /* __gl2_h_ */
+
diff --git a/include/GLES2/gl2ext.h b/include/GLES2/gl2ext.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/include/GLES2/gl2platform.h b/include/GLES2/gl2platform.h
new file mode 100644 (file)
index 0000000..b85e0f6
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __gl2platform_h_
+#define __gl2platform_h_
+
+/* $Id: gl2platform.h 1.4 2009/10/26 17:23:29 benji.bowman Exp $ */
+
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/* Platform-specific types and definitions for OpenGL ES 2.X  gl2.h
+ * Last modified on 2008/12/19
+ *
+ * Adopters may modify khrplatform.h and this file to suit their platform.
+ * You are encouraged to submit all modifications to the Khronos group so that
+ * they can be included in future versions of this file.  Please submit changes
+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
+ * by filing a bug against product "OpenGL-ES" component "Registry".
+*/
+
+#include <KHR/khrplatform.h>
+
+#ifndef GL_APICALL
+#define GL_APICALL  KHRONOS_APICALL
+#endif
+
+#define GL_APIENTRY KHRONOS_APIENTRY
+
+#endif /* __gl2platform_h_ */
diff --git a/include/GLES2/sym_gl.h b/include/GLES2/sym_gl.h
new file mode 100644 (file)
index 0000000..23247a5
--- /dev/null
@@ -0,0 +1,172 @@
+// Defult use-case for exporting symbols
+#ifndef _COREGL_SYMBOL
+#define _COREGL_SYMBOL_NOT_DEFINED
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     extern RET_TYPE (*_COREGL_NAME_MANGLE(FUNC_NAME)) PARAM_LIST;
+#endif
+
+/* version 1: */
+_COREGL_SYMBOL(GL_FALSE, void, glActiveTexture, (GLenum texture))
+_COREGL_SYMBOL(GL_FALSE, void, glAttachShader, (GLuint program, GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, void, glBindAttribLocation, (GLuint program, GLuint index, const char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glBindBuffer, (GLenum target, GLuint buffer))
+_COREGL_SYMBOL(GL_FALSE, void, glBindFramebuffer, (GLenum target, GLuint framebuffer))
+_COREGL_SYMBOL(GL_FALSE, void, glBindRenderbuffer, (GLenum target, GLuint renderbuffer))
+_COREGL_SYMBOL(GL_FALSE, void, glBindTexture, (GLenum target, GLuint texture))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendEquation, ( GLenum mode ))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendEquationSeparate, (GLenum modeRGB, GLenum modeAlpha))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendFunc, (GLenum sfactor, GLenum dfactor))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendFuncSeparate, (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha))
+_COREGL_SYMBOL(GL_FALSE, void, glBufferData, (GLenum target, GLsizeiptr size, const void* data, GLenum usage))
+_COREGL_SYMBOL(GL_FALSE, void, glBufferSubData, (GLenum target, GLintptr offset, GLsizeiptr size, const void* data))
+_COREGL_SYMBOL(GL_FALSE, GLenum, glCheckFramebufferStatus, (GLenum target))
+_COREGL_SYMBOL(GL_FALSE, void, glClear, (GLbitfield mask))
+_COREGL_SYMBOL(GL_FALSE, void, glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
+#ifndef _COREGL_DESKTOP_GL
+_COREGL_SYMBOL(GL_FALSE, void, glClearDepthf, (GLclampf depth))
+#else
+_COREGL_SYMBOL(GL_FALSE, void, glClearDepth, (GLclampf depth))
+#endif
+_COREGL_SYMBOL(GL_FALSE, void, glClearStencil, (GLint s))
+_COREGL_SYMBOL(GL_FALSE, void, glColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha))
+_COREGL_SYMBOL(GL_FALSE, void, glCompileShader, (GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, void, glCompressedTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data))
+_COREGL_SYMBOL(GL_FALSE, void, glCompressedTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data))
+_COREGL_SYMBOL(GL_FALSE, void, glCopyTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border))
+_COREGL_SYMBOL(GL_FALSE, void, glCopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height))
+_COREGL_SYMBOL(GL_FALSE, GLuint, glCreateProgram, (void))
+_COREGL_SYMBOL(GL_FALSE, GLuint, glCreateShader, (GLenum type))
+_COREGL_SYMBOL(GL_FALSE, void, glCullFace, (GLenum mode))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteBuffers, (GLsizei n, const GLuint* buffers))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteFramebuffers, (GLsizei n, const GLuint* framebuffers))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteRenderbuffers, (GLsizei n, const GLuint* renderbuffers))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteShader, (GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteTextures, (GLsizei n, const GLuint* textures))
+_COREGL_SYMBOL(GL_FALSE, void, glDepthFunc, (GLenum func))
+_COREGL_SYMBOL(GL_FALSE, void, glDepthMask, (GLboolean flag))
+#ifndef _COREGL_DESKTOP_GL
+_COREGL_SYMBOL(GL_FALSE, void, glDepthRangef, (GLclampf zNear, GLclampf zFar))
+#else
+_COREGL_SYMBOL(GL_FALSE, void, glDepthRange, (GLclampf zNear, GLclampf zFar))
+#endif
+_COREGL_SYMBOL(GL_FALSE, void, glDetachShader, (GLuint program, GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, void, glDisable, (GLenum cap))
+_COREGL_SYMBOL(GL_FALSE, void, glDisableVertexAttribArray, (GLuint index))
+_COREGL_SYMBOL(GL_FALSE, void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
+_COREGL_SYMBOL(GL_FALSE, void, glDrawElements, (GLenum mode, GLsizei count, GLenum type, const void* indices))
+_COREGL_SYMBOL(GL_FALSE, void, glEnable, (GLenum cap))
+_COREGL_SYMBOL(GL_FALSE, void, glEnableVertexAttribArray, (GLuint index))
+_COREGL_SYMBOL(GL_FALSE, void, glFinish, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glFlush, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glFramebufferRenderbuffer, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer))
+_COREGL_SYMBOL(GL_FALSE, void, glFramebufferTexture2D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level))
+_COREGL_SYMBOL(GL_FALSE, void, glFrontFace, (GLenum mode))
+_COREGL_SYMBOL(GL_FALSE, void, glGenBuffers, (GLsizei n, GLuint* buffers))
+_COREGL_SYMBOL(GL_FALSE, void, glGenerateMipmap, (GLenum target))
+_COREGL_SYMBOL(GL_FALSE, void, glGenFramebuffers, (GLsizei n, GLuint* framebuffers))
+_COREGL_SYMBOL(GL_FALSE, void, glGenRenderbuffers, (GLsizei n, GLuint* renderbuffers))
+_COREGL_SYMBOL(GL_FALSE, void, glGenTextures, (GLsizei n, GLuint* textures))
+_COREGL_SYMBOL(GL_FALSE, void, glGetActiveAttrib, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetActiveUniform, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetAttachedShaders, (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders))
+_COREGL_SYMBOL(GL_FALSE, int, glGetAttribLocation, (GLuint program, const char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetBooleanv, (GLenum pname, GLboolean* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetBufferParameteriv, (GLenum target, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, GLenum, glGetError, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glGetFloatv, (GLenum pname, GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetFramebufferAttachmentParameteriv, (GLenum target, GLenum attachment, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetIntegerv, (GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetProgramiv, (GLuint program, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetProgramInfoLog, (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog))
+_COREGL_SYMBOL(GL_FALSE, void, glGetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetShaderiv, (GLuint shader, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetShaderInfoLog, (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog))
+_COREGL_SYMBOL(GL_FALSE, void, glGetShaderPrecisionFormat, (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision))
+_COREGL_SYMBOL(GL_FALSE, void, glGetShaderSource, (GLuint shader, GLsizei bufsize, GLsizei* length, char* source))
+_COREGL_SYMBOL(GL_FALSE, const GLubyte *, glGetString, (GLenum name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetTexParameterfv, (GLenum target, GLenum pname, GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetTexParameteriv, (GLenum target, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetUniformfv, (GLuint program, GLint location, GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetUniformiv, (GLuint program, GLint location, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, int, glGetUniformLocation, (GLuint program, const char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetVertexAttribfv, (GLuint index, GLenum pname, GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetVertexAttribiv, (GLuint index, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetVertexAttribPointerv, (GLuint index, GLenum pname, void** pointer))
+_COREGL_SYMBOL(GL_FALSE, void, glHint, (GLenum target, GLenum mode))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsBuffer, (GLuint buffer))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsEnabled, (GLenum cap))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsFramebuffer, (GLuint framebuffer))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsRenderbuffer, (GLuint renderbuffer))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsShader, (GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsTexture, (GLuint texture))
+_COREGL_SYMBOL(GL_FALSE, void, glLineWidth, (GLfloat width))
+_COREGL_SYMBOL(GL_FALSE, void, glLinkProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, void, glPixelStorei, (GLenum pname, GLint param))
+_COREGL_SYMBOL(GL_FALSE, void, glPolygonOffset, (GLfloat factor, GLfloat units))
+_COREGL_SYMBOL(GL_FALSE, void, glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels))
+_COREGL_SYMBOL(GL_FALSE, void, glReleaseShaderCompiler, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glRenderbufferStorage, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height))
+_COREGL_SYMBOL(GL_FALSE, void, glSampleCoverage, (GLclampf value, GLboolean invert))
+_COREGL_SYMBOL(GL_FALSE, void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
+_COREGL_SYMBOL(GL_FALSE, void, glShaderBinary, (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length))
+_COREGL_SYMBOL(GL_FALSE, void, glShaderSource, (GLuint shader, GLsizei count, const char** string, const GLint* length))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilFuncSeparate, (GLenum face, GLenum func, GLint ref, GLuint mask))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilMask, (GLuint mask))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilMaskSeparate, (GLenum face, GLuint mask))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilOpSeparate, (GLenum face, GLenum fail, GLenum zfail, GLenum zpass))
+_COREGL_SYMBOL(GL_FALSE, void, glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels))
+_COREGL_SYMBOL(GL_FALSE, void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param))
+_COREGL_SYMBOL(GL_FALSE, void, glTexParameterfv, (GLenum target, GLenum pname, const GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
+_COREGL_SYMBOL(GL_FALSE, void, glTexParameteriv, (GLenum target, GLenum pname, const GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform1f, (GLint location, GLfloat x))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform1fv, (GLint location, GLsizei count, const GLfloat* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform1i, (GLint location, GLint x))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform1iv, (GLint location, GLsizei count, const GLint* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform2f, (GLint location, GLfloat x, GLfloat y))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform2fv, (GLint location, GLsizei count, const GLfloat* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform2i, (GLint location, GLint x, GLint y))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform2iv, (GLint location, GLsizei count, const GLint* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform3f, (GLint location, GLfloat x, GLfloat y, GLfloat z))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform3fv, (GLint location, GLsizei count, const GLfloat* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform3i, (GLint location, GLint x, GLint y, GLint z))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform3iv, (GLint location, GLsizei count, const GLint* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform4f, (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform4fv, (GLint location, GLsizei count, const GLfloat* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform4i, (GLint location, GLint x, GLint y, GLint z, GLint w))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform4iv, (GLint location, GLsizei count, const GLint* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniformMatrix2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value))
+_COREGL_SYMBOL(GL_FALSE, void, glUniformMatrix3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value))
+_COREGL_SYMBOL(GL_FALSE, void, glUniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value))
+_COREGL_SYMBOL(GL_FALSE, void, glUseProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, void, glValidateProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib1f, (GLuint indx, GLfloat x))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib1fv, (GLuint indx, const GLfloat* values))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib2fv, (GLuint indx, const GLfloat* values))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib3f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib3fv, (GLuint indx, const GLfloat* values))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib4f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib4fv, (GLuint indx, const GLfloat* values))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttribPointer, (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr))
+_COREGL_SYMBOL(GL_FALSE, void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
+
+/* Extensions */
+_COREGL_SYMBOL(GL_TRUE, void, glEGLImageTargetTexture2DOES, (GLenum target, GLeglImageOES image))
+_COREGL_SYMBOL(GL_TRUE, void, glEGLImageTargetRenderbufferStorageOES, (GLenum target, GLeglImageOES image))
+_COREGL_SYMBOL(GL_TRUE, void, glGetProgramBinary, (GLuint program, GLsizei bufsize, GLsizei *length, GLenum *binaryFormat, void *binary))
+_COREGL_SYMBOL(GL_TRUE, void, glProgramBinary, (GLuint program, GLenum binaryFormat, const void *binary, GLint length))
+_COREGL_SYMBOL(GL_TRUE, void, glProgramParameteri, (GLuint a, GLuint b, GLint d))
+_COREGL_SYMBOL(GL_TRUE, void, glRenderbufferStorageMultisampleEXT, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height))
+_COREGL_SYMBOL(GL_TRUE, void, glFramebufferTexture2DMultisampleEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples))
+
+#ifdef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL
+#endif
+
diff --git a/packaging/coregl.spec b/packaging/coregl.spec
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/coregl.c b/src/coregl.c
new file mode 100644 (file)
index 0000000..cb640bf
--- /dev/null
@@ -0,0 +1,435 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+#include "coregl_internal.h"
+
+Mutex                   ctx_list_access_mutex = MUTEX_INITIALIZER;
+
+void                   *egl_lib_handle;
+void                   *gl_lib_handle;
+
+GLContext_List         *glctx_list = NULL;
+
+// Symbol definition for local
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     RET_TYPE (*_COREGL_NAME_MANGLE(FUNC_NAME)) PARAM_LIST = NULL;
+#include "headers/sym.h"
+#undef _COREGL_SYMBOL
+
+// Symbol definition for static
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     RET_TYPE (*_sym_##FUNC_NAME) PARAM_LIST;
+#include "headers/sym.h"
+#undef _COREGL_SYMBOL
+
+const char *
+get_env_setting(const char *name)
+{
+       char *fp_env = NULL;
+       static char *fp_default = "\0";
+       fp_env = getenv(name);
+       if (fp_env == NULL) fp_env = fp_default;
+       return fp_env;
+}
+
+int
+add_context_state_to_list(const void *option, const int option_len, GLContextState *cstate, Mutex *mtx)
+{
+       int ret = 0;
+       int tid = 0;
+       GLContext_List *current = NULL;
+       GLContext_List *newitm = NULL;
+
+       if (mtx != NULL) AST(mutex_lock(mtx) == 1);
+
+       AST(cstate != NULL);
+
+       tid = get_current_thread();
+
+       current = glctx_list;
+       while (current != NULL)
+       {
+               if (current->option_len == option_len &&
+                   memcmp(current->option, option, option_len) == 0 &&
+                   current->thread_id == tid)
+               {
+                       AST(current->cstate == cstate);
+                       goto finish;
+               }
+               current = current->next;
+       }
+
+       newitm = (GLContext_List *)calloc(1, sizeof(GLContext_List));
+       if (newitm == NULL)
+       {
+               ERR("Failed to create context list.\n");
+               goto finish;
+       }
+
+       newitm->cstate = cstate;
+       newitm->thread_id = tid;
+       newitm->option_len = option_len;
+       newitm->option = (void *)malloc(option_len);
+       memcpy(newitm->option, option, option_len);
+
+       if (glctx_list != NULL)
+               newitm->next = glctx_list;
+
+       glctx_list = newitm;
+
+       ret = 1;
+       goto finish;
+
+finish:
+       if (ret != 1)
+       {
+               if (newitm != NULL)
+               {
+                       free(newitm);
+                       newitm = NULL;
+               }
+               if (cstate != NULL)
+               {
+                       free(cstate);
+                       cstate = NULL;
+               }
+       }
+       if (mtx != NULL) AST(mutex_unlock(mtx) == 1);
+
+       return ret;
+}
+
+GLContextState *
+get_context_state_from_list(const void *option, const int option_len, Mutex *mtx)
+{
+       GLContextState *ret = NULL;
+       GLContext_List *current = NULL;
+       int tid = 0;
+
+       if (mtx != NULL) AST(mutex_lock(mtx) == 1);
+
+       tid = get_current_thread();
+
+       current = glctx_list;
+       while (current != NULL)
+       {
+               if (current->option_len == option_len &&
+                   memcmp(current->option, option, option_len) == 0 &&
+                   current->thread_id == tid)
+               {
+                       ret = current->cstate;
+                       goto finish;
+               }
+               current = current->next;
+       }
+       goto finish;
+
+finish:
+       if (mtx != NULL) AST(mutex_unlock(mtx) == 1);
+       return ret;
+}
+
+int
+remove_context_states_from_list(GLContextState *cstate, Mutex *mtx)
+{
+       int ret = 0;
+       int tid = 0;
+       GLContext_List *olditm = NULL;
+       GLContext_List *current = NULL;
+
+       if (mtx != NULL) AST(mutex_lock(mtx) == 1);
+
+       AST(cstate != NULL);
+
+       tid = get_current_thread();
+       current = glctx_list;
+
+       while (current != NULL)
+       {
+               if (current->cstate == cstate)
+               {
+                       GLContext_List *nextitm = NULL;
+                       if (olditm != NULL)
+                       {
+                               olditm->next = current->next;
+                               nextitm = olditm->next;
+                       }
+                       else
+                       {
+                               glctx_list = current->next;
+                               nextitm = glctx_list;
+                       }
+                       free(current);
+                       ret = 1;
+                       current = nextitm;
+                       continue;
+               }
+               olditm = current;
+               current = current->next;
+       }
+       goto finish;
+
+finish:
+       if (mtx != NULL) AST(mutex_unlock(mtx) == 1);
+       return ret;
+}
+
+int
+init_new_thread_state()
+{
+       int ret = 0;
+       GLThreadState *tstate = NULL;
+
+       tstate = get_current_thread_state();
+       AST(tstate == NULL);
+
+       tstate = (GLThreadState *)calloc(1, sizeof(GLThreadState));
+       tstate->thread_id = get_current_thread();
+
+       set_current_thread_state(&ctx_list_access_mutex, tstate);
+
+#ifdef COREGL_TRACE_CONTEXT_INFO
+       add_to_general_trace_list(&thread_trace_list, tstate);
+#endif // COREGL_TRACE_CONTEXT_INFO
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+static void
+_sym_missing()
+{
+       ERR("GL symbol missing!\n");
+}
+
+static int
+_glue_sym_init(void)
+{
+
+#define FINDSYM(libhandle, getproc, dst, sym) \
+   if ((!dst) && (getproc)) dst = (__typeof__(dst))getproc(sym); \
+   if (!dst) dst = (__typeof__(dst))dlsym(libhandle, sym);
+
+#define FALLBAK(dst) \
+   if (!dst) { dst = (__typeof__(dst))_sym_missing; ERR("WARNING : symbol '"#dst"' missing!\n"); }
+
+
+#ifndef _COREGL_DESKTOP_GL
+# define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \
+     FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \
+     if (IS_EXTENSION == GL_TRUE) { \
+        FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \
+        FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \
+        FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \
+        FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"KHR"); \
+     } else { FALLBAK(_sym_##FUNC_NAME); }
+# include "headers/sym_egl.h"
+# undef _COREGL_SYMBOL
+#else
+# define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \
+     FINDSYM(glue_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \
+     if (IS_EXTENSION == GL_TRUE) { \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"MESA"); \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"SGI"); \
+     } else { FALLBAK(_sym_##FUNC_NAME); }
+# include "headers/sym_glx.h"
+# undef _COREGL_SYMBOL
+#endif
+
+#undef FINDSYM
+#undef FALLBAK
+
+       return 1;
+}
+
+static int
+_gl_sym_init(void)
+{
+
+#define FINDSYM(libhandle, getproc, dst, sym) \
+   if ((!dst) && (getproc)) dst = (__typeof__(dst))getproc(sym); \
+   if (!dst) dst = (__typeof__(dst))dlsym(gl_lib_handle, sym);
+#define FALLBAK(dst) \
+   if (!dst) { dst = (__typeof__(dst))_sym_missing; ERR("WARNING : symbol '"#dst"' missing!\n"); }
+
+#ifndef _COREGL_DESKTOP_GL
+# define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \
+     FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \
+     if (IS_EXTENSION == GL_TRUE) { \
+        FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \
+        FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \
+        FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \
+        FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"KHR"); \
+      } else { FALLBAK(_sym_##FUNC_NAME); }
+# include "headers/sym_gl.h"
+# undef _COREGL_SYMBOL
+#else
+# define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \
+     if (IS_EXTENSION == GL_TRUE) { \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \
+        FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \
+     } else { FALLBAK(_sym_##FUNC_NAME); }
+# include "headers/sym_gl.h"
+# undef _COREGL_SYMBOL
+#endif
+
+#undef FINDSYM
+#undef FALLBAK
+
+       return 1;
+}
+
+static int
+_gl_lib_init(void)
+{
+
+#ifndef _COREGL_DESKTOP_GL
+       //------------------------------------------------//
+       // Open EGL Library as EGL is separate
+#ifndef _COREGL_EMBED_EVAS
+       egl_lib_handle = dlopen("libEGL_drv.so", RTLD_NOW | RTLD_GLOBAL);
+#else
+       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);
+#endif
+       if (!egl_lib_handle)
+       {
+               ERR("%s\n", dlerror());
+               return 0;
+       }
+
+       // use gl_lib handle for GL symbols
+#ifndef _COREGL_EMBED_EVAS
+       gl_lib_handle = dlopen("libGLESv2_drv.so", RTLD_NOW);
+#else
+       gl_lib_handle = dlopen("libGLESv2.so.1", RTLD_NOW);
+       if (!gl_lib_handle)
+               gl_lib_handle = dlopen("libGLESv2.so", RTLD_NOW);
+#endif
+       if (!gl_lib_handle)
+       {
+               ERR("%s\n", dlerror());
+               return 0;
+       }
+       //------------------------------------------------//
+
+#else // GLX
+
+
+#ifndef _COREGL_EMBED_EVAS
+       gl_lib_handle = dlopen("libGL_drv.so", RTLD_NOW);
+#else
+       gl_lib_handle = dlopen("libGL.so.1", RTLD_NOW);
+       if (!gl_lib_handle)
+               gl_lib_handle = dlopen("libGL.so", RTLD_NOW);
+#endif
+       if (!gl_lib_handle)
+       {
+               ERR("%s\n", dlerror());
+               return 0;
+       }
+
+       //------------------------------------------------//
+
+#endif // _COREGL_DESKTOP_GL
+
+       if (!_glue_sym_init()) return 0;
+       if (!_gl_sym_init()) return 0;
+
+       return 1;
+}
+
+#ifndef _COREGL_EMBED_EVAS
+__attribute__((constructor))
+#endif
+int
+init_gl()
+{
+       int fastpath_opt = 0;
+       CoreGL_Opt_Flag api_opt = COREGL_NORMAL_PATH;
+
+       LOG("[CoreGL] ");
+
+       if (!_gl_lib_init()) return 0;
+
+       fastpath_opt = atoi(get_env_setting("COREGL_FASTPATH"));
+
+       switch (fastpath_opt)
+       {
+               case 1:
+                       api_opt = COREGL_FAST_PATH;
+                       LOG(": (%d) Fastpath enabled...\n", fastpath_opt);
+                       break;
+               default:
+                       LOG(": (%d) Default API path enabled...\n", fastpath_opt);
+                       api_opt = COREGL_NORMAL_PATH;
+                       break;
+               }
+
+       override_glue_apis(api_opt);
+       override_gl_apis(api_opt);
+
+       return 1;
+}
+
+#ifndef _COREGL_EMBED_EVAS
+__attribute__((destructor))
+#endif
+void
+free_gl()
+{
+       GLContext_List *current = NULL;
+
+       AST(mutex_lock(&ctx_list_access_mutex) == 1);
+
+       {
+               // Destroy remained context & Detect leaks
+               int retry_destroy = 0;
+
+               while (1)
+               {
+                       retry_destroy = 0;
+                       current = glctx_list;
+                       while (current)
+                       {
+                               if (current->cstate != NULL)
+                               {
+                                       ERR("\E[0;31;1mWARNING : Context attached to [dpy=%p|rctx=%p] has not been completely destroyed.(leak)\E[0m\n", current->cstate->rdpy, current->cstate->rctx);
+
+#ifndef _COREGL_DESKTOP_GL
+                                       _sym_eglMakeCurrent(current->cstate->rdpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+                                       _sym_eglDestroyContext(current->cstate->rdpy, current->cstate->rctx);
+#else
+                                       _sym_glXDestroyContext(current->cstate->rdpy, current->cstate->rctx);
+#endif
+
+                                       remove_context_states_from_list(current->cstate, NULL);
+                                       retry_destroy = 1;
+                                       break;
+                               }
+
+                               glctx_list = current->next;
+                               free(current);
+                               current = glctx_list;
+                       }
+                       if (retry_destroy == 0) break;
+               }
+       }
+
+#ifndef _COREGL_DESKTOP_GL
+       if (egl_lib_handle) dlclose(egl_lib_handle);
+#endif
+       if (gl_lib_handle) dlclose(gl_lib_handle);
+       goto finish;
+
+finish:
+       AST(mutex_unlock(&ctx_list_access_mutex) == 1);
+}
+
diff --git a/src/coregl.h b/src/coregl.h
new file mode 100644 (file)
index 0000000..70d770b
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef COREGL_H
+#define COREGL_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+#else
+# define _COREGL_DESKTOP_GL
+#endif
+
+#if defined(_COREGL_EMBEDDED_GL)
+#undef _COREGL_DESKTOP_GL
+#endif
+
+#define _COREGL_NAME_MANGLE(name) glsym_##name
+
+// Include GL/EGL/GLX types
+#ifndef _COREGL_DESKTOP_GL
+# include <GLES/glplatform.h>
+# include <EGL/eglplatform.h>
+# include "headers/egl.h"
+#else
+# include "headers/glx.h"
+#endif
+# include "headers/gl.h"
+
+typedef void (*_eng_fn) (void);
+
+#include "headers/sym.h"
+
+extern int  init_gl();
+extern void free_gl();
+
+#endif // COREGL_H
+
diff --git a/src/coregl_fastpath.c b/src/coregl_fastpath.c
new file mode 100644 (file)
index 0000000..79a7fec
--- /dev/null
@@ -0,0 +1,806 @@
+#include "coregl_fastpath.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+Mutex init_context_mutex = MUTEX_INITIALIZER;
+GLGlueContext *initial_ctx = NULL;
+
+static void
+_get_texture_states(GLenum pname, GLint *params)
+{
+       GLuint cur_active_tex = 0;
+
+       AST(initial_ctx != NULL);
+
+       _sym_glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *)&cur_active_tex);
+       int i;
+       for (i = 0; i < initial_ctx->gl_num_tex_units[0]; i++)
+       {
+               _sym_glActiveTexture(GL_TEXTURE0 + i);
+               _sym_glGetIntegerv(pname, &(((GLint *)params)[i]));
+       }
+       _sym_glActiveTexture(cur_active_tex);
+}
+
+static GLuint
+_get_stencil_max_mask()
+{
+       GLuint stencil_bit = 0;
+
+       _sym_glGetIntegerv(GL_STENCIL_BITS, (GLint *)&stencil_bit);
+       return (1 << stencil_bit) - 1;
+}
+
+GLuint
+sostate_create_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name)
+{
+       GL_Object **object = NULL;
+       GLuint ret = _COREGL_INT_INIT_VALUE;
+       int i;
+
+       switch (type)
+       {
+               case GL_OBJECT_TYPE_TEXTURE: object = sostate->texture; break;
+       }
+
+       for (i = 1; i < MAX_GL_OBJECT_SIZE; i++)
+       {
+               if (object[i] == NULL)
+               {
+                       GL_Object *newobj = (GL_Object *)calloc(1, sizeof(GL_Object));
+                       newobj->id = (int)type + i;
+                       newobj->real_id = real_name;
+                       object[i] = newobj;
+                       ret = newobj->id;
+                       goto finish;
+               }
+       }
+       goto finish;
+
+finish:
+       return ret;
+}
+
+GLuint
+sostate_remove_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name)
+{
+       GL_Object **object = NULL;
+       GLuint ret = _COREGL_INT_INIT_VALUE;
+       int hash = _COREGL_INT_INIT_VALUE;
+
+       switch (type)
+       {
+               case GL_OBJECT_TYPE_TEXTURE: object = sostate->texture; break;
+       }
+
+       hash = glue_name - (int)type;
+       if (hash < 0 ||
+           hash > MAX_GL_OBJECT_SIZE ||
+           object[hash] == NULL ||
+           object[hash]->id != glue_name)
+       {
+               ret = 0;
+               goto finish;
+       }
+
+       free(object[hash]);
+       object[hash] = NULL;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+GLuint
+sostate_get_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name)
+{
+       GL_Object **object = NULL;
+       GLuint ret = _COREGL_INT_INIT_VALUE;
+       int hash = _COREGL_INT_INIT_VALUE;
+
+       switch (type)
+       {
+               case GL_OBJECT_TYPE_TEXTURE: object = sostate->texture; break;
+       }
+
+       hash = glue_name - (int)type;
+       if (hash < 0 ||
+           hash > MAX_GL_OBJECT_SIZE ||
+           object[hash] == NULL ||
+           object[hash]->id != glue_name)
+       {
+               ret = 0;
+               goto finish;
+       }
+       ret = object[hash]->real_id;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+GLuint
+sostate_find_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name)
+{
+       GL_Object **object = NULL;
+       GLuint ret = _COREGL_INT_INIT_VALUE;
+       int i;
+
+       switch (type)
+       {
+               case GL_OBJECT_TYPE_TEXTURE: object = sostate->texture; break;
+       }
+
+       for (i = 1; i < MAX_GL_OBJECT_SIZE; i++)
+       {
+               if (object[i] != NULL && object[i]->real_id == real_name)
+               {
+                       ret = object[i]->id;
+                       goto finish;
+               }
+       }
+       ret = 0;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+void
+dump_context_states(GLGlueContext *ctx, int force_output)
+{
+       static struct timeval tv_last = { 0, 0 };
+
+       {
+               char *fp_env = NULL;
+               int fp_envi = 0;
+               fp_env = getenv("COREGL_TRACE_STATE");
+               if (fp_env) fp_envi = atoi(fp_env);
+               else fp_envi = 0;
+               if (fp_envi == 0) return;
+       }
+
+       if (!force_output)
+       {
+               struct timeval tv_now = { 0, 0 };
+               AST(gettimeofday(&tv_now, NULL) == 0);
+               if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC)
+               {
+                       goto finish;
+               }
+               tv_last = tv_now;
+       }
+
+       LOG("\n");
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+       LOG("\E[0;32;1m  State info \E[1;37;1m: GlueCTX = %p\E[0m\n", ctx);
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+
+#define PRINTF_CHAR_GLenum "%10d"
+#define PRINTF_CHAR_GLboolean "%10d"
+#define PRINTF_CHAR_GLint "%10d"
+#define PRINTF_CHAR_GLsizei "%10u"
+#define PRINTF_CHAR_GLuint "%10u"
+#define PRINTF_CHAR_GLuintmask "0x%8X"
+
+#define PRINTF_CHAR_GLclampf "%10.6f"
+#define PRINTF_CHAR_GLfloat "%10.6f"
+
+#define PRINTF_CHAR_GLvoidptr "%10p"
+
+#define PRINTF_CHAR(type) PRINTF_CHAR_##type
+
+#define INITIAL_CTX initial_ctx
+#define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT)  \
+   { \
+      TYPE valuedata[SIZE]; \
+      TYPE *value = NULL; \
+      value = valuedata; GET_STMT; value = valuedata; \
+      LOG("\E[0;37;1m %-30.30s : (\E[0m ", #NAME); \
+      for (int i = 0; i < SIZE; i++) \
+      { \
+         if (i > 0) { \
+            if (i % 4 == 0) \
+               LOG("\n %-30.30s     ", "");\
+            else \
+               LOG(", "); \
+         } \
+         LOG(PRINTF_CHAR(TYPE), ctx->NAME[i]); \
+         LOG("["PRINTF_CHAR(TYPE)"]", value[i]); \
+      } \
+      LOG(" \E[0;37;1m)\E[0m\n"); \
+   }
+# include "coregl_fastpath_state.h"
+#undef GLUE_STATE
+#undef INITIAL_CTX
+
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+       LOG("\n");
+
+finish:
+       return;
+}
+
+int
+init_context_states(GLGlueContext *ctx)
+{
+       int ret = 0;
+
+       AST(mutex_lock(&init_context_mutex) == 1);
+
+       if (ctx == NULL)
+       {
+               ERR("Context NULL\n");
+               ret = 0;
+               goto finish;
+       }
+
+       AST(ctx->initialized == 0);
+       AST(ctx->sostate != NULL);
+
+       if (initial_ctx == NULL)
+       {
+               initial_ctx = (GLGlueContext *)calloc(1, sizeof(GLGlueContext));
+               AST(initial_ctx != NULL);
+
+//#define FORCE_DEFAULT_VALUE
+#ifdef FORCE_DEFAULT_VALUE
+# define INITIAL_CTX initial_ctx
+# define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT)  \
+      { \
+         int i; \
+         TYPE valuedata[SIZE]; \
+         TYPE *value = NULL; \
+         memset(valuedata, 0xcc, sizeof(TYPE) * SIZE); \
+         value = valuedata; DEFAULT_STMT; value = valuedata; \
+         for (i = 0; i < SIZE; i++) \
+         { \
+            if (*((char *)(&value[i])) == 0xcc) \
+            { \
+               memset(&value[i], 0xaa, sizeof(TYPE)); \
+               value = valuedata; DEFAULT_STMT; value = valuedata; \
+               if (*((char *)(&value[i])) == 0xaa) \
+               { \
+                  ERR("\E[0;31;1mWARNING : GL-state '"#NAME"' cannot be retrieved\E[0m\n"); \
+                  break; \
+               } \
+            } \
+            initial_ctx->NAME[i] = value[i]; \
+         } \
+      }
+#  include "coregl_fastpath_state.h"
+# undef GLUE_STATE
+# undef INITIAL_CTX
+#else
+# define INITIAL_CTX initial_ctx
+# define SET_GLUE_VALUE(DEFAULT_STMT, FALLBACK_STMT) \
+      if (try_step == 1) \
+      { \
+         value = valuedata; DEFAULT_STMT; value = valuedata; \
+      } \
+      else \
+      { \
+         value = valuedata; FALLBACK_STMT; value = valuedata; \
+      }
+
+# define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT)  \
+      { \
+         int i; \
+         int try_step = 0;\
+         TYPE valuedata[SIZE]; \
+         TYPE *value = NULL; \
+         memset(valuedata, 0xcc, sizeof(TYPE) * SIZE); \
+         do { \
+            try_step++; \
+            SET_GLUE_VALUE(GET_STMT, DEFAULT_STMT); \
+            for (i = 0; i < SIZE; i++) \
+            { \
+               if (*((char *)(&value[i])) == 0xcc) \
+               { \
+                  memset(&value[i], 0xaa, sizeof(TYPE)); \
+                  SET_GLUE_VALUE(GET_STMT, DEFAULT_STMT); \
+                  if (*((char *)(&value[i])) == 0xaa) \
+                  { \
+                     try_step++; \
+                     if (try_step == 2) \
+                     { \
+                        ERR("\E[0;31;1mWARNING : GL-state '"#NAME"' cannot be retrieved\E[0m\n"); \
+                     } \
+                     break; \
+                  } \
+               } \
+               initial_ctx->NAME[i] = value[i]; \
+            } \
+            if (try_step != 2) \
+            { \
+               value = valuedata; DEFAULT_STMT; value = valuedata; \
+               for (i = 0; i < SIZE; i++) \
+               { \
+                  if (initial_ctx->NAME[i] != value[i]) \
+                  { \
+                     ERR("WARNING : GL-state '"#NAME"'[%d] value ["PRINTF_CHAR(TYPE)"] is different from SPEC-DEFAULT ["PRINTF_CHAR(TYPE)"]\n", i, ctx->NAME[i], value[i]); \
+                  } \
+               } \
+            } \
+         } \
+         while (try_step == 2); \
+      }
+#  include "coregl_fastpath_state.h"
+# undef SET_GLUE_VALUE
+# undef GLUE_STATE
+# undef INITIAL_CTX
+#endif
+
+               if (initial_ctx->gl_num_vertex_attribs[0] > MAX_VERTEX_ATTRIBS)
+               {
+                       ERR("\E[0;31;1mWARNING : Number of vertex attrib is too big! (%d-%d)\E[0m\n", MAX_VERTEX_ATTRIBS, initial_ctx->gl_num_vertex_attribs[0]);
+               }
+               if (initial_ctx->gl_num_tex_units[0] > MAX_TEXTURE_UNITS)
+               {
+                       ERR("\E[0;31;1mWARNING : Number of texture unit is too big! (%d-%d)\E[0m\n", MAX_TEXTURE_UNITS, initial_ctx->gl_num_tex_units[0]);
+               }
+       }
+
+       {
+               int i;
+#define INITIAL_CTX initial_ctx
+#define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT)  \
+         for (i = 0; i < SIZE; i++) \
+         { \
+            ctx->NAME[i] = initial_ctx->NAME[i]; \
+         }
+# include "coregl_fastpath_state.h"
+#undef GLUE_STATE
+#undef INITIAL_CTX
+       }
+
+       ctx->initialized = 1;
+       ret = 1;
+       goto finish;
+
+finish:
+       AST(mutex_unlock(&init_context_mutex) == 1);
+
+       return ret;
+}
+
+void
+make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
+{
+       unsigned char flag = 0;
+       int i = 0;
+
+       if (atoi(get_env_setting("COREGL_DEBUG_NOFP")) == 1) goto finish;
+
+       // Return if they're the same
+       if (oldctx == newctx) goto finish;
+
+#ifdef EVAS_GL_DEBUG
+#  define STATE_COMPARE(state)
+#  define STATES_COMPARE(state_ptr, bytes)
+#else
+#  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)
+#endif
+
+       _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP glFinish)");
+       _sym_glFlush();
+       _COREGL_TRACE_API_END("eglMakeCurrent(FP glFinish)");
+
+
+       _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP bind buffers)");
+
+       //------------------//
+       // _bind_flag
+       flag = oldctx->_bind_flag | newctx->_bind_flag;
+       if (flag)
+       {
+               STATE_COMPARE(gl_array_buffer_binding[0])
+               {
+                       _sym_glBindBuffer(GL_ARRAY_BUFFER, newctx->gl_array_buffer_binding[0]);
+               }
+               STATE_COMPARE(gl_element_array_buffer_binding[0])
+               {
+                       _sym_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, newctx->gl_element_array_buffer_binding[0]);
+               }
+               STATE_COMPARE(gl_framebuffer_binding[0])
+               {
+                       _sym_glBindFramebuffer(GL_FRAMEBUFFER, newctx->gl_framebuffer_binding[0]);
+               }
+               STATE_COMPARE(gl_renderbuffer_binding[0])
+               {
+                       _sym_glBindRenderbuffer(GL_RENDERBUFFER, newctx->gl_renderbuffer_binding[0]);
+               }
+       }
+
+       _COREGL_TRACE_API_END("eglMakeCurrent(FP bind buffers)");
+
+
+       //------------------//
+       // Enable States
+       // _enable_flag1
+       _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP enable states)");
+
+       flag = oldctx->_enable_flag1 | newctx->_enable_flag1;
+       if (flag)
+       {
+               STATE_COMPARE(gl_blend[0])
+               {
+                       if (newctx->gl_blend[0])
+                               _sym_glEnable(GL_BLEND);
+                       else
+                               _sym_glDisable(GL_BLEND);
+               }
+               STATE_COMPARE(gl_cull_face[0])
+               {
+                       if (newctx->gl_cull_face[0])
+                               _sym_glEnable(GL_CULL_FACE);
+                       else
+                               _sym_glDisable(GL_CULL_FACE);
+               }
+               STATE_COMPARE(gl_depth_test[0])
+               {
+                       if (newctx->gl_depth_test[0])
+                               _sym_glEnable(GL_DEPTH_TEST);
+                       else
+                               _sym_glDisable(GL_DEPTH_TEST);
+               }
+               STATE_COMPARE(gl_dither[0])
+               {
+                       if (newctx->gl_dither[0])
+                               _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[0])
+               {
+                       if (newctx->gl_polygon_offset_fill[0])
+                               _sym_glEnable(GL_POLYGON_OFFSET_FILL);
+                       else
+                               _sym_glDisable(GL_POLYGON_OFFSET_FILL);
+               }
+               STATE_COMPARE(gl_sample_alpha_to_coverage[0])
+               {
+                       if (newctx->gl_sample_alpha_to_coverage[0])
+                               _sym_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+                       else
+                               _sym_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+               }
+               STATE_COMPARE(gl_sample_coverage[0])
+               {
+                       if (newctx->gl_sample_coverage[0])
+                               _sym_glEnable(GL_SAMPLE_COVERAGE);
+                       else
+                               _sym_glDisable(GL_SAMPLE_COVERAGE);
+               }
+               STATE_COMPARE(gl_scissor_test[0])
+               {
+                       if (newctx->gl_scissor_test[0])
+                               _sym_glEnable(GL_SCISSOR_TEST);
+                       else
+                               _sym_glDisable(GL_SCISSOR_TEST);
+               }
+               STATE_COMPARE(gl_stencil_test[0])
+               {
+                       if (newctx->gl_stencil_test[0])
+                               _sym_glEnable(GL_STENCIL_TEST);
+                       else
+                               _sym_glDisable(GL_STENCIL_TEST);
+               }
+       }
+
+       _COREGL_TRACE_API_END("eglMakeCurrent(FP enable states)");
+
+       //------------------//
+       // _clear_flag1
+       _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP clear/viewport)");
+
+       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[0])
+               {
+                       _sym_glUseProgram(newctx->gl_current_program[0]);
+               }
+               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[0])
+               {
+                       _sym_glClearDepthf(newctx->gl_depth_clear_value[0]);
+               }
+               STATE_COMPARE(gl_depth_func[0])
+               {
+                       _sym_glDepthFunc(newctx->gl_depth_func[0]);
+               }
+               STATE_COMPARE(gl_depth_writemask[0])
+               {
+                       _sym_glDepthMask(newctx->gl_depth_writemask[0]);
+               }
+               STATE_COMPARE(gl_cull_face_mode[0])
+               {
+                       _sym_glCullFace(newctx->gl_cull_face_mode[0]);
+               }
+
+       }
+
+       _COREGL_TRACE_API_END("eglMakeCurrent(FP clear/viewport)");
+
+       //------------------//
+       // Texture here...
+       _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP bind textures)");
+
+       flag = oldctx->_tex_flag1 | newctx->_tex_flag1;
+       if (flag)
+       {
+
+               for (i = 0; i < oldctx->gl_num_tex_units[0]; i++)
+               {
+                       STATE_COMPARE(gl_tex_2d_state[i])
+                       {
+                               _sym_glActiveTexture(GL_TEXTURE0 + i);
+                               _sym_glBindTexture(GL_TEXTURE_2D, newctx->gl_tex_2d_state[i]);
+                       }
+
+                       STATE_COMPARE(gl_tex_cube_state[i])
+                       {
+                               _sym_glActiveTexture(GL_TEXTURE0 + i);
+                               _sym_glBindTexture(GL_TEXTURE_CUBE_MAP, newctx->gl_tex_cube_state[i]);
+                       }
+               }
+
+               // Restore active texture
+               _sym_glActiveTexture(newctx->gl_active_texture[0]);
+
+               STATE_COMPARE(gl_generate_mipmap_hint[0])
+               {
+                       _sym_glHint(GL_GENERATE_MIPMAP_HINT, newctx->gl_generate_mipmap_hint[0]);
+               }
+       }
+       _COREGL_TRACE_API_END("eglMakeCurrent(FP bind textures)");
+
+       //------------------//
+       _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP etc.)");
+
+       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[0] != newctx->gl_blend_src_rgb[0]) ||
+                   (oldctx->gl_blend_dst_rgb[0] != newctx->gl_blend_dst_rgb[0]) ||
+                   (oldctx->gl_blend_src_alpha[0] != newctx->gl_blend_src_alpha[0]) ||
+                   (oldctx->gl_blend_dst_alpha[0] != newctx->gl_blend_dst_alpha[0]))
+               {
+                       _sym_glBlendFuncSeparate(newctx->gl_blend_src_rgb[0],
+                                                newctx->gl_blend_dst_rgb[0],
+                                                newctx->gl_blend_src_alpha[0],
+                                                newctx->gl_blend_dst_alpha[0]);
+               }
+               if ((oldctx->gl_blend_equation_rgb[0] != newctx->gl_blend_equation_rgb[0]) ||
+                   (oldctx->gl_blend_equation_alpha[0] != newctx->gl_blend_equation_alpha[0]))
+               {
+                       _sym_glBlendEquationSeparate(newctx->gl_blend_equation_rgb[0], newctx->gl_blend_equation_alpha[0]);
+               }
+
+       }
+
+       //------------------//
+       // _stencil_flag1
+       flag = oldctx->_stencil_flag1 | newctx->_stencil_flag1;
+       if (flag)
+       {
+               if ((oldctx->gl_stencil_func[0] != newctx->gl_stencil_func[0]) ||
+                   (oldctx->gl_stencil_ref[0]  != newctx->gl_stencil_ref[0])  ||
+                   (oldctx->gl_stencil_value_mask[0] != newctx->gl_stencil_value_mask[0]))
+               {
+                       _sym_glStencilFuncSeparate(GL_FRONT,
+                                                  newctx->gl_stencil_func[0],
+                                                  newctx->gl_stencil_ref[0],
+                                                  newctx->gl_stencil_value_mask[0]);
+               }
+               if ((oldctx->gl_stencil_fail[0] != newctx->gl_stencil_fail[0]) ||
+                   (oldctx->gl_stencil_pass_depth_fail[0] != newctx->gl_stencil_pass_depth_fail[0]) ||
+                   (oldctx->gl_stencil_pass_depth_pass[0] != newctx->gl_stencil_pass_depth_pass[0]))
+               {
+                       _sym_glStencilOpSeparate(GL_FRONT,
+                                                newctx->gl_stencil_fail[0],
+                                                newctx->gl_stencil_pass_depth_fail[0],
+                                                newctx->gl_stencil_pass_depth_pass[0]);
+               }
+
+               STATE_COMPARE(gl_stencil_writemask[0])
+               {
+                       _sym_glStencilMaskSeparate(GL_FRONT, newctx->gl_stencil_writemask[0]);
+               }
+       }
+
+
+       // _stencil_flag1
+       flag = oldctx->_stencil_flag2 | newctx->_stencil_flag2;
+       if (flag)
+       {
+               if ((oldctx->gl_stencil_back_func[0] != newctx->gl_stencil_back_func[0]) ||
+                   (oldctx->gl_stencil_back_ref[0]  != newctx->gl_stencil_back_ref[0])  ||
+                   (oldctx->gl_stencil_back_value_mask[0] != newctx->gl_stencil_back_value_mask[0]))
+               {
+                       _sym_glStencilFuncSeparate(GL_BACK,
+                                                  newctx->gl_stencil_back_func[0],
+                                                  newctx->gl_stencil_back_ref[0],
+                                                  newctx->gl_stencil_back_value_mask[0]);
+               }
+               if ((oldctx->gl_stencil_back_fail[0] != newctx->gl_stencil_back_fail[0]) ||
+                   (oldctx->gl_stencil_back_pass_depth_fail[0] != newctx->gl_stencil_back_pass_depth_fail[0]) ||
+                   (oldctx->gl_stencil_back_pass_depth_pass[0] != newctx->gl_stencil_back_pass_depth_pass[0]))
+               {
+                       _sym_glStencilOpSeparate(GL_BACK,
+                                                newctx->gl_stencil_back_fail[0],
+                                                newctx->gl_stencil_back_pass_depth_fail[0],
+                                                newctx->gl_stencil_back_pass_depth_pass[0]);
+               }
+
+               STATE_COMPARE(gl_stencil_back_writemask[0])
+               {
+                       _sym_glStencilMaskSeparate(GL_BACK, newctx->gl_stencil_back_writemask[0]);
+               }
+               STATE_COMPARE(gl_stencil_clear_value[0])
+               {
+                       _sym_glClearStencil(newctx->gl_stencil_clear_value[0]);
+               }
+       }
+
+       //------------------//
+       // _misc_flag1
+       flag = oldctx->_misc_flag1 | newctx->_misc_flag1;
+       if (flag)
+       {
+               STATE_COMPARE(gl_front_face[0])
+               {
+                       _sym_glFrontFace(newctx->gl_front_face[0]);
+               }
+               STATE_COMPARE(gl_line_width[0])
+               {
+                       _sym_glLineWidth(newctx->gl_line_width[0]);
+               }
+               if ((oldctx->gl_polygon_offset_factor[0] != newctx->gl_polygon_offset_factor[0]) ||
+                   (oldctx->gl_polygon_offset_units[0]  != newctx->gl_polygon_offset_units[0]))
+               {
+                       _sym_glPolygonOffset(newctx->gl_polygon_offset_factor[0],
+                                            newctx->gl_polygon_offset_units[0]);
+               }
+               if ((oldctx->gl_sample_coverage_value[0]  != newctx->gl_sample_coverage_value[0]) ||
+                   (oldctx->gl_sample_coverage_invert[0] != newctx->gl_sample_coverage_invert[0]))
+               {
+                       _sym_glSampleCoverage(newctx->gl_sample_coverage_value[0],
+                                             newctx->gl_sample_coverage_invert[0]);
+               }
+       }
+
+       // _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[0])
+               {
+                       _sym_glPixelStorei(GL_PACK_ALIGNMENT, newctx->gl_pack_alignment[0]);
+               }
+               STATE_COMPARE(gl_unpack_alignment[0])
+               {
+                       _sym_glPixelStorei(GL_UNPACK_ALIGNMENT, newctx->gl_unpack_alignment[0]);
+               }
+       }
+       _COREGL_TRACE_API_END("eglMakeCurrent(FP etc.)");
+
+       // _varray_flag
+       _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP vertex attrib)");
+       flag = oldctx->_vattrib_flag | newctx->_vattrib_flag;
+       if (flag)
+       {
+               for (i = 0; i < oldctx->gl_num_vertex_attribs[0]; i++)
+               {
+                       if (newctx->gl_vertex_array_buf_id[i] != oldctx->gl_vertex_array_buf_id[i])
+                       {
+                               _sym_glBindBuffer(GL_ARRAY_BUFFER, newctx->gl_vertex_array_buf_id[i]);
+                       }
+                       else _sym_glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+                       _sym_glVertexAttribPointer(i,
+                                                  newctx->gl_vertex_array_size[i],
+                                                  newctx->gl_vertex_array_type[i],
+                                                  newctx->gl_vertex_array_normalized[i],
+                                                  newctx->gl_vertex_array_stride[i],
+                                                  newctx->gl_vertex_array_pointer[i]);
+
+                       STATES_COMPARE(gl_vertex_attrib_value + 4 * i, 4 * sizeof(GLfloat))
+                       {
+                               _sym_glVertexAttrib4fv(i, &newctx->gl_vertex_attrib_value[4 * i]);
+                       }
+
+                       if (newctx->gl_vertex_array_enabled[i] == GL_TRUE)
+                       {
+                               _sym_glEnableVertexAttribArray(i);
+                       }
+                       else
+                       {
+                               _sym_glDisableVertexAttribArray(i);
+                       }
+               }
+
+               STATE_COMPARE(gl_array_buffer_binding[0])
+               {
+                       _sym_glBindBuffer(GL_ARRAY_BUFFER, newctx->gl_array_buffer_binding[0]);
+               }
+               STATE_COMPARE(gl_element_array_buffer_binding[0])
+               {
+                       _sym_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, newctx->gl_element_array_buffer_binding[0]);
+               }
+
+       }
+
+       _COREGL_TRACE_API_END("eglMakeCurrent(FP vertex attrib)");
+       goto finish;
+
+finish:
+
+#ifdef COREGL_TRACE_STATE_INFO
+       dump_context_states(newctx, 0);
+#endif // COREGL_TRACE_STATE_INFO
+       return;
+#undef STATE_COMPARE
+#undef STATES_COMPARE
+}
+
diff --git a/src/coregl_fastpath.h b/src/coregl_fastpath.h
new file mode 100644 (file)
index 0000000..744e9ce
--- /dev/null
@@ -0,0 +1,124 @@
+#ifndef COREGL_FASTPATH_H
+#define COREGL_FASTPATH_H
+
+#include "coregl_internal.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
+
+#define MAX_TEXTURE_UNITS 32
+#define MAX_VERTEX_ATTRIBS 64
+
+typedef struct
+{
+       GLuint   tex_id;
+} GL_Texture_State;
+
+typedef struct
+{
+       GLboolean    modified;
+       GLboolean    enabled;
+       GLuint       buf_id;
+       GLint        size;
+       GLenum       type;
+       GLboolean    normalized;
+       GLsizei      stride;
+       const void  *pointer;
+} GL_Vertex_Array_State;
+
+typedef struct
+{
+       GLboolean   modified;
+       GLfloat     value[4];
+} GL_Vertex_Attrib;
+
+
+#define MAGIC_GLFAST                0x73777770
+#define MAX_GL_OBJECT_SIZE         100000
+
+typedef enum
+{
+       GL_OBJECT_TYPE_TEXTURE = 0x1000000,
+} GL_Object_Type;
+
+typedef struct _GL_Object
+{
+       GLuint                            id;
+       GLuint                            real_id;
+
+       struct _GL_Shared_Object_State  *parent;
+} GL_Object;
+
+typedef struct _GL_Shared_Object_State
+{
+       int                    ref_count;
+
+       GL_Object              *texture[MAX_GL_OBJECT_SIZE]; // Texture object : 0x10000X
+} GL_Shared_Object_State;
+
+typedef struct _GLGlueContext
+{
+       int                     magic;
+       int                     initialized;
+       int                     surface_attached;
+
+       int                                                     ref_count;
+       int                                                     is_destroyed;
+
+       int                                                     used_count;
+
+       GLDisplay              *rdpy;
+       GLContextState         *cstate;
+       int                     thread_id;
+
+       void                   *real_ctx_option;
+       int                     real_ctx_option_len;
+
+       void                   *real_ctx_sharable_option;
+       int                     real_ctx_sharable_option_len;
+
+       unsigned char           _bind_flag;
+       unsigned char           _enable_flag1;
+       unsigned char           _enable_flag2;
+       unsigned char           _clear_flag1;
+       unsigned char           _clear_flag2;
+       unsigned char           _tex_flag1;
+       unsigned char           _blend_flag;
+       unsigned char           _stencil_flag1;
+       unsigned char           _stencil_flag2;
+       unsigned char           _misc_flag1;
+       unsigned char           _misc_flag2;
+       unsigned char           _vattrib_flag;
+
+       GL_Shared_Object_State *sostate;
+
+       // General state
+#define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT)     TYPE NAME[ARRAY_SIZE];
+# include "coregl_fastpath_state.h"
+#undef GLUE_STATE
+
+} GLGlueContext;
+
+extern GLGlueContext *initial_ctx;
+
+extern int      init_context_states(GLGlueContext *ctx);
+extern void     make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx);
+
+#ifdef COREGL_TRACE_STATE_INFO
+extern void     dump_context_states(GLGlueContext *ctx, int force_output);
+#endif
+
+extern GLuint   sostate_create_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint name);
+extern GLuint   sostate_remove_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name);
+extern GLuint   sostate_get_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint name);
+extern GLuint   sostate_find_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name);
+
+
+#endif // COREGL_FASTPATH_H
+
diff --git a/src/coregl_fastpath_egl.c b/src/coregl_fastpath_egl.c
new file mode 100644 (file)
index 0000000..4b6baed
--- /dev/null
@@ -0,0 +1,1120 @@
+#include "coregl_fastpath.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#ifdef COREGL_TRACE_CONTEXT_INFO
+
+General_Trace_List *glue_ctx_trace_list = NULL;
+General_Trace_List *context_state_trace_list = NULL;
+
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \
+       extern RET_TYPE FUNC_NAME PARAM_LIST;
+#include "headers/sym_egl.h"
+#include "headers/sym_gl.h"
+#undef _COREGL_SYMBOL
+
+
+static void
+_dump_context_info(const char *ment, int force_output)
+{
+       GLThreadState *tstate = NULL;
+       static struct timeval tv_last = { 0, 0 };
+
+       {
+               char *fp_env = NULL;
+               int fp_envi = 0;
+               fp_env = getenv("COREGL_TRACE_CTX");
+               if (fp_env) fp_envi = atoi(fp_env);
+               else fp_envi = 0;
+               if (fp_envi == 0) return;
+       }
+
+       AST(mutex_lock(&ctx_list_access_mutex) == 1);
+       AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
+
+       if (!force_output)
+       {
+               struct timeval tv_now = { 0, 0 };
+               AST(gettimeofday(&tv_now, NULL) == 0);
+               if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC)
+               {
+                       goto finish;
+               }
+               tv_last = tv_now;
+       }
+
+       tstate = get_current_thread_state();
+
+       LOG("\n");
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+       LOG("\E[0;32;1m  Context info \E[1;37;1m: %s\E[0m\n", ment);
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+
+
+       // Thread State List
+       {
+               General_Trace_List *current = NULL;
+               current = thread_trace_list;
+
+               while (current != NULL)
+               {
+                       GLThreadState *cur_tstate = (GLThreadState *)current->value;
+
+                       LOG(" %c Thread  [%12d] : Surf <D=[%12p] R=[%12p]>",
+                           (tstate == cur_tstate) ? '*' : ' ',
+                           cur_tstate->thread_id,
+                           cur_tstate->rsurf_draw,
+                           cur_tstate->rsurf_read);
+
+                       if (cur_tstate->cstate != NULL)
+                       {
+                               LOG(" GlueCTX=[%12p] RealCTX=[%12p]\E[0m\n",
+                                   cur_tstate->cstate->data,
+                                   cur_tstate->cstate);
+                       }
+                       else
+                       {
+                               LOG(" (NOT BINDED TO THREAD)\E[0m\n");
+                       }
+
+                       // Binded Context State List
+                       {
+                               General_Trace_List *current = NULL;
+                               current = context_state_trace_list;
+
+                               while (current != NULL)
+                               {
+                                       GLContextState *cur_cstate = (GLContextState *)current->value;
+
+                                       if (cur_tstate->cstate == cur_cstate)
+                                       {
+                                               LOG("   -> RealCTX [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n",
+                                                   cur_cstate,
+                                                   cur_cstate->rdpy,
+                                                   cur_cstate->rctx,
+                                                   cur_cstate->ref_count);
+
+                                               // Binded Glue Context List
+                                               {
+                                                       General_Trace_List *current = NULL;
+                                                       current = glue_ctx_trace_list;
+
+                                                       while (current != NULL)
+                                                       {
+                                                               GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
+
+                                                               if (cur_gctx->cstate == cur_cstate)
+                                                               {
+                                                                       LOG("    -%c GlueCTX [%12p] : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
+                                                                           (cur_cstate->data == cur_gctx) ? '>' : '-',
+                                                                           cur_gctx,
+                                                                           cur_gctx->rdpy,
+                                                                           cur_gctx->thread_id,
+                                                                           cur_gctx->used_count);
+
+                                                                       LOG(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
+                                                               }
+
+                                                               current = current->next;
+                                                       }
+                                               }
+                                       }
+
+                                       current = current->next;
+                               }
+
+                       }
+
+
+                       current = current->next;
+               }
+       }
+
+       LOG("\E[0;40;33m........................................................................................................................\E[0m\n");
+
+       // Not-binded Context State List
+       {
+               General_Trace_List *current = NULL;
+               current = context_state_trace_list;
+
+               while (current != NULL)
+               {
+                       GLContextState *cur_cstate = (GLContextState *)current->value;
+
+                       int isbinded = 0;
+
+                       if (cur_cstate->data != NULL)
+                       {
+                               General_Trace_List *current_t = NULL;
+                               current_t = thread_trace_list;
+
+                               while (current_t != NULL)
+                               {
+                                       GLThreadState *cur_tstate = (GLThreadState *)current_t->value;
+
+                                       if (cur_tstate->thread_id == ((GLGlueContext *)cur_cstate->data)->thread_id)
+                                       {
+                                               if (cur_tstate->cstate == cur_cstate)
+                                                       isbinded = 1;
+                                               break;
+                                       }
+                                       current_t = current_t->next;
+                               }
+                       }
+
+                       if (isbinded == 0)
+                       {
+                               LOG("   RealCTX   [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n",
+                                   cur_cstate,
+                                   cur_cstate->rdpy,
+                                   cur_cstate->rctx,
+                                   cur_cstate->ref_count);
+
+                               // Binded Glue Context List
+                               {
+                                       General_Trace_List *current = NULL;
+                                       current = glue_ctx_trace_list;
+
+                                       while (current != NULL)
+                                       {
+                                               GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
+
+                                               if (cur_gctx->cstate == cur_cstate)
+                                               {
+                                                       LOG("    -%c GlueCTX [%12p] : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
+                                                           (cur_cstate->data == cur_gctx) ? '>' : '-',
+                                                           cur_gctx,
+                                                           cur_gctx->rdpy,
+                                                           cur_gctx->thread_id,
+                                                           cur_gctx->used_count);
+
+                                                       LOG(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
+                                               }
+
+                                               current = current->next;
+                                       }
+                               }
+                       }
+
+                       current = current->next;
+               }
+
+       }
+
+       LOG("\E[0;40;33m........................................................................................................................\E[0m\n");
+
+       // Not-binded Glue Context List
+       {
+               General_Trace_List *current = NULL;
+               current = glue_ctx_trace_list;
+
+               while (current != NULL)
+               {
+                       GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
+
+                       if (cur_gctx->cstate == NULL)
+                       {
+                               LOG("   GlueCTX [%12p]   : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
+                                   cur_gctx,
+                                   cur_gctx->rdpy,
+                                   cur_gctx->thread_id,
+                                   cur_gctx->used_count);
+
+                               LOG(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
+                       }
+
+                       current = current->next;
+               }
+       }
+
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+       LOG("\n");
+
+       goto finish;
+
+finish:
+
+       AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
+       AST(mutex_unlock(&ctx_list_access_mutex) == 1);
+
+}
+
+#endif // COREGL_TRACE_CONTEXT_INFO
+
+
+typedef struct
+{
+       EGLint                        context_client_version;
+} EGL_packed_attrib_list;
+
+typedef struct
+{
+       EGLDisplay                    dpy;
+       EGLConfig                     cfg;
+       EGL_packed_attrib_list        attrib_list;
+       EGLint                                                          debug;
+} EGL_packed_option;
+
+typedef struct
+{
+       EGLContext                    share_context;
+} EGL_packed_sharable_option;
+
+
+static int
+_pack_egl_context_option(EGL_packed_option *pack_data, EGLDisplay dpy, EGLConfig cfg, EGLint debug, const EGLint *attrib_list)
+{
+       int ret = 0;
+
+       pack_data->dpy = dpy;
+       pack_data->cfg = cfg;
+       pack_data->debug = debug;
+
+       // Default context attributes
+       pack_data->attrib_list.context_client_version = EGL_DONT_CARE;
+
+       // Apply specified attributes
+       EGLint *attrib = (EGLint *)attrib_list;
+       while(attrib[0] != EGL_NONE)
+       {
+               switch(attrib[0])
+               {
+                       case EGL_CONTEXT_CLIENT_VERSION:
+                               pack_data->attrib_list.context_client_version = attrib[1];
+                               break;
+                       default:
+                               ERR("Invalid context attribute.\n");
+                               goto finish;
+                       }
+               attrib += 2;
+       }
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+static int
+_unpack_egl_context_option(EGL_packed_option *pack_data, EGLDisplay *dpy, EGLConfig *cfg, EGLint *debug, EGLint *attrib_list, const int attrib_list_size)
+{
+       int ret = 0;
+
+       if (dpy != NULL) *dpy = pack_data->dpy;
+       if (cfg != NULL) *cfg = pack_data->cfg;
+       if (debug != NULL) *debug = pack_data->debug;
+
+       if (attrib_list != NULL && attrib_list_size > 0)
+       {
+               int attrib_list_index = 0;
+
+               memset(attrib_list, 0x00, sizeof(int) * attrib_list_size);
+
+               if (pack_data->attrib_list.context_client_version != EGL_DONT_CARE)
+               {
+                       AST(attrib_list_index + 2 < attrib_list_size);
+                       attrib_list[attrib_list_index] = EGL_CONTEXT_CLIENT_VERSION;
+                       attrib_list[attrib_list_index + 1] = pack_data->attrib_list.context_client_version;
+                       attrib_list_index += 2;
+               }
+
+               attrib_list[attrib_list_index] = EGL_NONE;
+       }
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+static int
+_pack_egl_context_sharable_option(EGL_packed_sharable_option *pack_data, EGLContext share_context)
+{
+       int ret = 0;
+
+       pack_data->share_context = share_context;
+
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+#if 0
+static int
+_unpack_egl_context_sharable_option(EGL_packed_sharable_option *pack_data, EGLContext *share_context)
+{
+       int ret = 0;
+
+       if (share_context != NULL) *share_context = pack_data->share_context;
+
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+#endif
+
+static void
+_link_context_state(GLGlueContext *gctx, GLContextState *cstate)
+{
+       AST(gctx->cstate == NULL);
+       cstate->ref_count++;
+       gctx->cstate = cstate;
+}
+
+static void
+_unlink_context_state(GLGlueContext *gctx, Mutex *ctx_list_mtx)
+{
+       GLContextState *cstate = NULL;
+
+       cstate = gctx->cstate;
+       AST(cstate != NULL);
+
+       cstate->ref_count--;
+       AST(cstate->ref_count >= 0);
+
+       if (cstate->ref_count == 0)
+       {
+               GLThreadState *tstate = NULL;
+
+               AST(cstate->data == NULL || cstate->data == initial_ctx);
+
+#ifdef COREGL_TRACE_CONTEXT_INFO
+               remove_from_general_trace_list(&context_state_trace_list, cstate);
+#endif // COREGL_TRACE_CONTEXT_INFO
+
+               AST(remove_context_states_from_list(cstate, ctx_list_mtx) == 1);
+
+               tstate = get_current_thread_state();
+               if (tstate != NULL)
+               {
+                       if (tstate->cstate == cstate)
+                       {
+                               _sym_eglMakeCurrent(cstate->rdpy, tstate->rsurf_draw, tstate->rsurf_read, EGL_NO_CONTEXT);
+                               tstate->cstate = NULL;
+                       }
+               }
+               _sym_eglDestroyContext(cstate->rdpy, cstate->rctx);
+               free(cstate);
+               cstate = NULL;
+       }
+}
+
+static void
+_add_shared_obj_state_ref(GL_Shared_Object_State *sostate)
+{
+       AST(sostate->ref_count >= 0);
+       sostate->ref_count++;
+}
+
+static void
+_remove_shared_obj_state_ref(GL_Shared_Object_State *sostate)
+{
+       AST(sostate->ref_count > 0);
+       sostate->ref_count--;
+       if (sostate->ref_count == 0)
+       {
+               free(sostate);
+       }
+}
+
+static void
+_add_context_ref(GLGlueContext *gctx)
+{
+       if (gctx == initial_ctx) return;
+
+       AST(gctx->ref_count >= 0);
+       gctx->ref_count++;
+}
+
+static void
+_remove_context_ref(GLGlueContext *gctx, Mutex *ctx_list_mtx)
+{
+       if (gctx == initial_ctx) return;
+
+       AST(gctx->ref_count > 0);
+       gctx->ref_count--;
+       if (gctx->ref_count == 0)
+       {
+#ifdef COREGL_TRACE_CONTEXT_INFO
+               remove_from_general_trace_list(&glue_ctx_trace_list, gctx);
+#endif // COREGL_TRACE_CONTEXT_INFO
+
+               _unlink_context_state(gctx, ctx_list_mtx);
+
+               AST(gctx->sostate != NULL);
+               _remove_shared_obj_state_ref(gctx->sostate);
+               gctx->sostate = NULL;
+
+               if (gctx->real_ctx_option != NULL)
+               {
+                       free(gctx->real_ctx_option);
+                       gctx->real_ctx_option = NULL;
+               }
+               if (gctx->real_ctx_sharable_option != NULL)
+               {
+                       free(gctx->real_ctx_sharable_option);
+                       gctx->real_ctx_sharable_option = NULL;
+               }
+               free(gctx);
+       }
+}
+
+static void
+_bind_context_state(GLGlueContext *gctx, GLContextState *cstate, Mutex *ctx_list_mtx)
+{
+       if (gctx != NULL)
+       {
+               AST(gctx->cstate == cstate);
+       }
+
+       if (cstate->data != gctx)
+       {
+               GLGlueContext *curctx = (GLGlueContext *)cstate->data;
+               GLGlueContext *newctx = gctx;
+
+               if (newctx == NULL)
+                       newctx = initial_ctx;
+
+               if (curctx == NULL)
+                       curctx = initial_ctx;
+
+               AST(newctx != NULL);
+               AST(curctx != NULL);
+
+               make_context_current(curctx, newctx);
+               cstate->data = (void *)newctx;
+               _remove_context_ref(curctx, ctx_list_mtx);
+               _add_context_ref(newctx);
+       }
+
+}
+
+GLContextState *
+_egl_create_context(EGL_packed_option *real_ctx_option, GLContextState **cstate_new, EGLContext *ctx,
+                    EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list)
+{
+       GLContextState *cstate = NULL;
+
+       AST(real_ctx_option != NULL);
+       AST(cstate_new != NULL);
+       AST(ctx != NULL);
+
+       // Pack context option
+       AST(_pack_egl_context_option(real_ctx_option, dpy, config, 0, attrib_list) == 1);
+
+       if (atoi(get_env_setting("COREGL_DEBUG_NOFP")) == 1)
+       {
+               static int debug_force_real = 100001;
+               AST(_pack_egl_context_option(real_ctx_option, dpy, config, debug_force_real, attrib_list) == 1);
+               debug_force_real++;
+       }
+
+       // Find context state
+       cstate = get_context_state_from_list(real_ctx_option, sizeof(EGL_packed_option), &ctx_list_access_mutex);
+
+       // Create a real context if it hasn't been created
+       if (cstate == NULL)
+       {
+               EGLContext *real_share_context = EGL_NO_CONTEXT;
+
+               AST(mutex_lock(&ctx_list_access_mutex) == 1);
+               {
+                       GLContext_List *current = NULL;
+
+                       current = glctx_list;
+                       while (current != NULL)
+                       {
+                               EGLDisplay cur_dpy = EGL_NO_DISPLAY;
+                               AST(_unpack_egl_context_option(current->option, &cur_dpy, NULL, NULL, NULL, 0) == 1);
+                               if (cur_dpy == dpy)
+                               {
+                                       AST(current->cstate != NULL);
+                                       real_share_context = current->cstate->rctx;
+                                       break;
+                               }
+                               current = current->next;
+                       }
+               }
+               AST(mutex_unlock(&ctx_list_access_mutex) == 1);
+
+               *ctx = _sym_eglCreateContext(dpy, config, real_share_context, attrib_list);
+
+               if (*ctx == EGL_NO_CONTEXT)
+               {
+                       ERR("Failed creating a egl real context for Fastpath.\n");
+                       goto finish;
+               }
+
+               *cstate_new = (GLContextState *)calloc(1, sizeof(GLContextState));
+               if (*cstate_new == NULL)
+               {
+                       ERR("Error creating a new context state.\n");
+                       goto finish;
+               }
+               (*cstate_new)->rctx = *ctx;
+               (*cstate_new)->rdpy = dpy;
+               (*cstate_new)->data = NULL;
+
+               AST(add_context_state_to_list(real_ctx_option, sizeof(EGL_packed_option), *cstate_new, &ctx_list_access_mutex) == 1);
+
+#ifdef COREGL_TRACE_CONTEXT_INFO
+               add_to_general_trace_list(&context_state_trace_list, *cstate_new);
+#endif // COREGL_TRACE_CONTEXT_INFO
+
+               cstate = *cstate_new;
+       }
+
+       goto finish;
+
+finish:
+       return cstate;
+
+}
+
+
+
+
+//----------------------------------------------------------------//
+//                   Fastpath EGL Functions                       //
+//    The functions have prefix 'fpgl_' for (fastpath gl)         //
+//----------------------------------------------------------------//
+EGLContext
+fpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
+{
+       GLGlueContext *gctx = NULL;
+       GLContextState *cstate = NULL;
+       GLContextState *cstate_new = NULL;
+       GL_Shared_Object_State *sostate_new = NULL;
+       GLContext ctx = NULL;
+
+       EGL_packed_option *real_ctx_option = NULL;
+       EGL_packed_sharable_option *real_ctx_sharable_option = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       real_ctx_option = (EGL_packed_option *)calloc(1, sizeof(EGL_packed_option));
+       if (real_ctx_option == NULL)
+       {
+               ERR("Error creating a new GLGlueContext(1)\n");
+               goto finish;
+       }
+       cstate = _egl_create_context(real_ctx_option, &cstate_new, &ctx, dpy, config, attrib_list);
+       AST(cstate != NULL);
+
+       // Pack shared context options
+       real_ctx_sharable_option = (EGL_packed_sharable_option *)calloc(1, sizeof(EGL_packed_sharable_option));
+       if (real_ctx_sharable_option == NULL)
+       {
+               ERR("Error creating a new GLGlueContext(2)\n");
+               goto finish;
+       }
+       AST(_pack_egl_context_sharable_option(real_ctx_sharable_option, share_context) == 1);
+
+       // Allocate a new context
+       gctx = (GLGlueContext *)calloc(1, sizeof(GLGlueContext));
+       if (gctx == NULL)
+       {
+               ERR("Error creating a new GLGlueContext(3)\n");
+               goto finish;
+       }
+
+       gctx->magic = MAGIC_GLFAST;
+       gctx->initialized = 0;
+       gctx->rdpy = dpy;
+       gctx->thread_id = get_current_thread();
+
+       if (share_context != EGL_NO_CONTEXT)
+       {
+               GLGlueContext *shared_gctx = (GLGlueContext *)share_context;
+               AST(shared_gctx->magic == MAGIC_GLFAST);
+               AST(shared_gctx->sostate != NULL);
+               gctx->sostate = shared_gctx->sostate;
+       }
+       else
+       {
+               sostate_new = (GL_Shared_Object_State *)calloc(1, sizeof(GL_Shared_Object_State));
+               if (sostate_new == NULL)
+               {
+                       ERR("Error creating a new GLGlueContext(4)\n");
+                       goto finish;
+               }
+               gctx->sostate = sostate_new;
+       }
+       _add_shared_obj_state_ref(gctx->sostate);
+       gctx->real_ctx_option = real_ctx_option;
+       gctx->real_ctx_option_len = sizeof(EGL_packed_option);
+       gctx->real_ctx_sharable_option = real_ctx_sharable_option;
+       gctx->real_ctx_sharable_option_len = sizeof(EGL_packed_sharable_option);
+
+       _link_context_state(gctx, cstate);
+       _add_context_ref(gctx);
+
+       gctx->cstate = cstate;
+
+#ifdef COREGL_TRACE_CONTEXT_INFO
+       add_to_general_trace_list(&glue_ctx_trace_list, gctx);
+
+       {
+               char ment[256];
+               sprintf(ment, "eglCreateContext completed (GlueCTX=[%12p])", gctx);
+               _dump_context_info(ment, 1);
+       }
+#endif // COREGL_TRACE_CONTEXT_INFO
+
+       goto finish;
+
+finish:
+       if (gctx == NULL)
+       {
+               if (ctx != NULL)
+               {
+                       _sym_eglDestroyContext(dpy, ctx);
+                       ctx = NULL;
+               }
+               if (sostate_new != NULL)
+               {
+                       free(sostate_new);
+                       sostate_new = NULL;
+               }
+               if (real_ctx_option != NULL)
+               {
+                       free(real_ctx_option);
+                       real_ctx_option = NULL;
+               }
+               if (real_ctx_sharable_option != NULL)
+               {
+                       free(real_ctx_sharable_option);
+                       real_ctx_sharable_option = NULL;
+               }
+               if (cstate_new != NULL)
+               {
+#ifdef COREGL_TRACE_CONTEXT_INFO
+                       remove_from_general_trace_list(&context_state_trace_list, cstate_new);
+#endif // COREGL_TRACE_CONTEXT_INFO
+
+                       remove_context_states_from_list(cstate_new, &ctx_list_access_mutex);
+                       free(cstate_new);
+                       cstate_new = NULL;
+               }
+       }
+
+       _COREGL_FAST_FUNC_END();
+       return (EGLContext)gctx;
+}
+
+EGLBoolean
+fpgl_eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+       EGLBoolean ret = EGL_FALSE;
+       GLGlueContext *gctx = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       gctx = (GLGlueContext *)ctx;
+
+       if (gctx != NULL)
+       {
+               GLContextState *cstate = NULL;
+               if (gctx->magic != MAGIC_GLFAST)
+               {
+                       ERR("Magic Check Failed!!!\n");
+                       ret = EGL_FALSE;
+                       goto finish;
+               }
+               cstate = gctx->cstate;
+               AST(cstate != NULL);
+
+               if (gctx->is_destroyed == 1)
+               {
+                       ERR("\E[0;31;1mWARNING : Context [%p] is already destroyed!!!\E[0m\n", ctx);
+               }
+               else
+               {
+                       gctx->is_destroyed = 1;
+                       _remove_context_ref(gctx, &ctx_list_access_mutex);
+               }
+       }
+       else
+       {
+               ERR("Invalid Context.\n");
+               ret = EGL_FALSE;
+               goto finish;
+       }
+
+       ret = EGL_TRUE;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+
+#ifdef COREGL_TRACE_CONTEXT_INFO
+       {
+               char ment[256];
+               sprintf(ment, "eglDestroyContext completed (GlueCTX=[%12p])", ctx);
+               _dump_context_info(ment, 1);
+       }
+#endif // COREGL_TRACE_CONTEXT_INFO
+
+       return ret;
+}
+
+EGLBoolean
+fpgl_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+{
+       EGLBoolean ret = EGL_FALSE;
+       EGLContext real_ctx = EGL_NO_CONTEXT;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       if (ctx != EGL_NO_CONTEXT)
+       {
+               GLGlueContext *gctx = NULL;
+               gctx = (GLGlueContext *)ctx;
+
+               AST(gctx->cstate != NULL);
+               real_ctx = gctx->cstate->rctx;
+       }
+
+       ret = _sym_eglQueryContext(dpy, real_ctx, attribute, value);
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
+
+EGLBoolean
+fpgl_eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       // BB : NO OP
+       ret = _sym_eglDestroySurface(dpy, surface);
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
+
+
+EGLBoolean
+fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+       EGLBoolean ret = EGL_FALSE;
+       EGLBoolean need_mc = EGL_FALSE;
+       GLGlueContext *gctx = NULL;
+
+       GLThreadState *tstate = NULL;
+       GLContextState *cstate = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       gctx = (GLGlueContext *)ctx;
+
+       tstate = get_current_thread_state();
+       if (tstate == NULL)
+       {
+               AST(init_new_thread_state() == 1);
+
+               tstate = get_current_thread_state();
+               AST(tstate != NULL);
+       }
+
+       // Special path for context deletion
+       if (ctx == EGL_NO_CONTEXT)
+       {
+               AST(gctx == NULL);
+
+               if (tstate->cstate != NULL)
+               {
+                       _bind_context_state(NULL, tstate->cstate, &ctx_list_access_mutex);
+                       tstate->cstate = NULL;
+               }
+               if (!_sym_eglMakeCurrent(dpy, draw, read, EGL_NO_CONTEXT))
+               {
+                       ERR("WARNING : Error making EGL_NO_CONTEXT current. (invalid EGL display [%p] or EGL surface [D:%p/R:%p])\n", dpy, draw, read);
+                       ret = EGL_FALSE;
+                       goto finish;
+               }
+
+               tstate->rsurf_draw = draw;
+               tstate->rsurf_read = read;
+
+               ret = EGL_TRUE;
+               goto finish;
+       }
+
+       AST(gctx != NULL);
+       AST(gctx->cstate != NULL);
+
+       if (gctx->rdpy != dpy)
+       {
+               ERR("Invalid context (or invalid EGL display)\n");
+               ret = EGL_FALSE;
+               goto finish;
+       }
+
+       AST(gctx->real_ctx_option != NULL);
+       AST(gctx->real_ctx_sharable_option != NULL);
+
+       // Handle cross threading of context (when used by two or more gctx)
+       if (gctx->thread_id != get_current_thread() && gctx->cstate->ref_count > 1)
+       {
+#define ATTRIB_LIST_BUFFER_SIZE 8
+
+               GLContextState *cstate_new = NULL;
+               EGLContext new_real_ctx = EGL_NO_CONTEXT;
+
+               EGLDisplay dpy = EGL_NO_DISPLAY;
+               EGLConfig config = NULL;
+               int attrib_list[ATTRIB_LIST_BUFFER_SIZE];
+
+               AST(_unpack_egl_context_option(gctx->real_ctx_option, &dpy, &config, NULL, attrib_list, ATTRIB_LIST_BUFFER_SIZE) == 1);
+               AST(dpy == gctx->rdpy);
+
+               _egl_create_context(gctx->real_ctx_option, &cstate_new, &new_real_ctx, dpy, config, attrib_list);
+
+               AST(cstate_new != NULL);
+
+               _bind_context_state(gctx, cstate_new, &ctx_list_access_mutex);
+
+               // TODO : Setup context state for new real ctx
+               ERR("\E[0;31;1mWARNING : Cross-thread usage(makecurrent) can cause a state-broken situation!\E[0m\n");
+
+               _unlink_context_state(gctx, &ctx_list_access_mutex);
+               _link_context_state(gctx, cstate_new);
+
+               // Apply to new thread
+               gctx->thread_id = get_current_thread();
+
+       }
+
+       // Check if the object is correct
+       if (gctx->magic != MAGIC_GLFAST)
+       {
+               ERR("Glue-CTX Magic Check Failed!!!\n");
+               ret = EGL_FALSE;
+               goto finish;
+
+       }
+
+       cstate = tstate->cstate;
+
+       // If it's a first time or drawable changed, do a make current
+       if (cstate == NULL)
+       {
+               cstate = get_context_state_from_list(gctx->real_ctx_option, gctx->real_ctx_option_len, &ctx_list_access_mutex);
+
+               if (cstate == NULL)
+               {
+                       ERR("Error making context current because context not ready.\n");
+                       ret = EGL_FALSE;
+                       goto finish;
+               }
+               need_mc = EGL_TRUE;
+       }
+
+       // If drawable changed, do a make current
+       if ((tstate->rsurf_draw != draw) ||
+           (tstate->rsurf_read != read))
+               need_mc = EGL_TRUE;
+
+       AST(gctx->cstate != NULL);
+
+       // If binded real context changed, do a make current
+       if (gctx->cstate->rctx != cstate->rctx)
+               need_mc = EGL_TRUE;
+
+       if (need_mc == EGL_TRUE)
+       {
+               // BB : full makecurrent
+               if (!_sym_eglMakeCurrent(dpy, draw, read, gctx->cstate->rctx))
+               {
+                       ERR("Error making context current with the drawable.\n");
+                       ret = EGL_FALSE;
+                       goto finish;
+               }
+
+               tstate->cstate = gctx->cstate;
+
+               tstate->rsurf_draw = draw;
+               tstate->rsurf_read = read;
+       }
+
+       // Initialize context states
+       if (gctx->initialized == 0)
+       {
+               if (init_context_states(gctx) != 1)
+               {
+                       ERR("Error intializing context\n");
+                       goto finish;
+               }
+       }
+
+       // Setup initial Viewport & Scissor
+       if (gctx->surface_attached == 0 && draw != EGL_NO_SURFACE)
+       {
+               EGLint width;
+               EGLint height;
+               _sym_eglQuerySurface(dpy, draw, EGL_WIDTH, &width);
+               _sym_eglQuerySurface(dpy, draw, EGL_HEIGHT, &height);
+
+               gctx->_clear_flag1 |= FLAG_BIT_0;
+               gctx->gl_viewport[0] = 0;
+               gctx->gl_viewport[1] = 0;
+               gctx->gl_viewport[2] = width;
+               gctx->gl_viewport[3] = height;
+
+               gctx->_misc_flag2 |= FLAG_BIT_0;
+               gctx->gl_scissor_box[0] = 0;
+               gctx->gl_scissor_box[1] = 0;
+               gctx->gl_scissor_box[2] = width;
+               gctx->gl_scissor_box[3] = height;
+
+               gctx->surface_attached = 1;
+       }
+
+       _bind_context_state(gctx, tstate->cstate, &ctx_list_access_mutex);
+       gctx->used_count++;
+
+       ret = EGL_TRUE;
+       goto finish;
+
+finish:
+
+       _COREGL_FAST_FUNC_END();
+
+#ifdef COREGL_TRACE_CONTEXT_INFO
+       {
+               char ment[256];
+               sprintf(ment, "eglMakeCurrent finished (GlueCTX=[%12p] Surf=[D:%12p R:%12p])", ctx, draw, read);
+               _dump_context_info(ment, 0);
+       }
+#endif // COREGL_TRACE_CONTEXT_INFO
+
+       return ret;
+}
+
+
+EGLContext
+fpgl_eglGetCurrentContext(void)
+{
+       GLGlueContext *ret = NULL;
+       GLThreadState *tstate = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       tstate = get_current_thread_state();
+
+       if (tstate != NULL)
+       {
+               if (tstate->cstate != NULL)
+               {
+                       ret = (GLGlueContext *)tstate->cstate->data;
+               }
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return (EGLContext)ret;
+}
+
+
+EGLSurface
+fpgl_eglGetCurrentSurface(EGLint readdraw)
+{
+       EGLSurface ret = EGL_NO_SURFACE;
+       GLThreadState *tstate = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       tstate = get_current_thread_state();
+
+       if (tstate != NULL)
+       {
+               switch (readdraw)
+               {
+                       case EGL_DRAW :
+                               ret = (GLGlueContext *)tstate->rsurf_draw;
+                               break;
+                       case EGL_READ :
+                               ret = (GLGlueContext *)tstate->rsurf_read;
+                               break;
+                       }
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
+EGLImageKHR
+fpgl_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+       void *ret = NULL;
+       GLThreadState *tstate = NULL;
+       EGLContext real_ctx = EGL_NO_CONTEXT;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       tstate = get_current_thread_state();
+
+       if (ctx != NULL && ctx != EGL_NO_CONTEXT)
+       {
+               GLGlueContext *gctx = (GLGlueContext *)ctx;
+
+               AST(gctx->cstate != NULL);
+               real_ctx = gctx->cstate->rctx;
+       }
+       ret = _sym_eglCreateImageKHR(dpy, real_ctx, target, buffer, attrib_list);
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
+_eng_fn
+fpgl_eglGetProcAddress(const char* procname)
+{
+       _eng_fn ret = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \
+       if (strcmp(procname, #FUNC_NAME) == 0) \
+       { \
+               ret = (_eng_fn)FUNC_NAME; \
+               goto finish; \
+       }
+#include "headers/sym_egl.h"
+#include "headers/sym_gl.h"
+#undef _COREGL_SYMBOL
+
+       ret = _sym_eglGetProcAddress(procname);
+       if (ret != NULL)
+       {
+               LOG("\E[0;31;1mWARNING : COREGL can't support '%s' (unmanaged situation may occur)\E[0m\n", procname);
+       }
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
diff --git a/src/coregl_fastpath_gl.c b/src/coregl_fastpath_gl.c
new file mode 100644 (file)
index 0000000..743a2f3
--- /dev/null
@@ -0,0 +1,2007 @@
+#include "coregl_fastpath.h"
+
+#include <stdlib.h>
+
+//----------------------------------------------------------------//
+//                                                                //
+//                      Fastpath GL Functions                     //
+// The functions have prefix 'fpgl_' for (fastpath gl)            //
+//                                                                //
+//----------------------------------------------------------------//
+
+#define CURR_STATE_COMPARE(curr_state, state ) \
+   if ((current_ctx->curr_state[0]) != (state))
+
+#define DEFINE_FAST_GL_FUNC() \
+   GLThreadState *tstate = NULL; \
+   GLGlueContext *current_ctx = NULL;
+
+#define INIT_FAST_GL_FUNC() \
+   tstate = get_current_thread_state(); \
+   AST(tstate != NULL); \
+   AST(tstate->cstate != NULL); \
+   current_ctx = (GLGlueContext *)tstate->cstate->data; \
+   AST(current_ctx != NULL);
+
+
+void
+fpgl_glActiveTexture(GLenum texture)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = texture;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glBindBuffer(GLenum target, GLuint buffer)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+
+       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[0] = 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[0] = buffer;
+               }
+       }
+       else
+       {
+               // For error recording
+               _sym_glBindBuffer(target, buffer);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = framebuffer;
+               }
+       }
+       else
+       {
+               // For error recording
+               _sym_glBindFramebuffer(target, framebuffer);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = renderbuffer;
+               }
+       }
+       else
+       {
+               // For error recording
+               _sym_glBindRenderbuffer(target, renderbuffer);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+void
+fpgl_glGenTextures(GLsizei n, GLuint* textures)
+{
+       int i;
+       GLuint *texid_array = NULL;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if (textures == NULL) goto finish;
+
+       AST(current_ctx->sostate != NULL);
+
+       texid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
+
+       _sym_glGenTextures(n, texid_array);
+
+       for (i = 0; i < n; i++)
+       {
+               textures[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, texid_array[i]);
+       }
+
+       free(texid_array);
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glBindTexture(GLenum target, GLuint texture)
+{
+       int active_idx;
+       GLuint real_texobj;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       active_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0;
+
+       if (texture == 0)
+       {
+               real_texobj = 0;
+       }
+       else
+       {
+               AST(current_ctx->sostate != NULL);
+               real_texobj = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, texture);
+               if (real_texobj == 0)
+               {
+                       // GLERROR : OUT_OF_MEMORY
+                       LOG("\E[0;31;1mWARNING : Try binding invalid texture object\E[0m\n");
+                       goto finish;
+               }
+       }
+
+       if (target == GL_TEXTURE_2D)
+       {
+               if (current_ctx->gl_tex_2d_state[active_idx] != real_texobj)
+               {
+                       _sym_glBindTexture(target, real_texobj);
+
+                       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+                       current_ctx->_tex_flag1 |= FLAG_BIT_3;
+
+                       current_ctx->gl_tex_2d_state[active_idx] = real_texobj;
+               }
+       }
+       else if (target == GL_TEXTURE_CUBE_MAP)
+       {
+               if (current_ctx->gl_tex_cube_state[active_idx] != real_texobj)
+               {
+                       _sym_glBindTexture(target, real_texobj);
+
+                       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+                       current_ctx->_tex_flag1 |= FLAG_BIT_4;
+
+                       current_ctx->gl_tex_cube_state[active_idx] = real_texobj;
+               }
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+       GLuint real_texobj;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if (texture == 0)
+       {
+               real_texobj = 0;
+       }
+       else
+       {
+               AST(current_ctx->sostate != NULL);
+               real_texobj = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, texture);
+               if (real_texobj == 0)
+               {
+                       // GLERROR : OUT_OF_MEMORY
+                       LOG("\E[0;31;1mWARNING : Try using invalid texture object\E[0m\n");
+                       goto finish;
+               }
+       }
+
+       _sym_glFramebufferTexture2D(target, attachment, textarget, real_texobj, level);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+void
+fpgl_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
+{
+       GLuint real_texobj;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if (texture == 0)
+       {
+               real_texobj = 0;
+       }
+       else
+       {
+               AST(current_ctx->sostate != NULL);
+               real_texobj = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, texture);
+               if (real_texobj == 0)
+               {
+                       // GLERROR : OUT_OF_MEMORY
+                       LOG("\E[0;31;1mWARNING : Try using invalid texture object\E[0m\n");
+                       goto finish;
+               }
+       }
+
+       _sym_glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, real_texobj, level, samples);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+GLboolean
+fpgl_glIsTexture(GLuint texture)
+{
+       GLboolean ret;
+       GLuint real_texobj;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if (texture == 0)
+       {
+               real_texobj = 0;
+       }
+       else
+       {
+               AST(current_ctx->sostate != NULL);
+               real_texobj = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, texture);
+               if (real_texobj == 0)
+               {
+                       ret = GL_FALSE;
+                       goto finish;
+               }
+       }
+
+       ret = _sym_glIsTexture(real_texobj);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
+
+void
+fpgl_glDeleteTextures(GLsizei n, const GLuint* textures)
+{
+       int i, j;
+       GLuint *texid_array = NULL;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if (textures == NULL) goto finish;
+
+       AST(current_ctx->sostate != NULL);
+
+       texid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
+       {
+               int real_n = 0;
+
+               for (i = 0; i < n; i++)
+               {
+                       int real_texid = _COREGL_INT_INIT_VALUE;
+                       if (textures[i] == 0) continue;
+
+                       real_texid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]);
+                       if (real_texid == 0) continue;
+
+                       sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]);
+                       texid_array[real_n++] = real_texid;
+               }
+
+               _sym_glDeleteTextures(real_n, texid_array);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+               for (i = 0; i < real_n; i++)
+               {
+                       for (j = 0; j < current_ctx->gl_num_tex_units[0]; j++)
+                       {
+                               if (current_ctx->gl_tex_2d_state[j] == texid_array[i])
+                                       current_ctx->gl_tex_2d_state[j] = 0;
+                               if (current_ctx->gl_tex_cube_state[j] == texid_array[i])
+                                       current_ctx->gl_tex_cube_state[j] = 0;
+                       }
+               }
+       }
+
+       free(texid_array);
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+void
+fpgl_glDeleteBuffers(GLsizei n, const GLuint* buffers)
+{
+       int i;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glDeleteBuffers(n, buffers);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       for (i = 0; i < n; i++)
+       {
+               if (current_ctx->gl_array_buffer_binding[0] == buffers[i])
+                       current_ctx->gl_array_buffer_binding[0] = 0;
+               if (current_ctx->gl_element_array_buffer_binding[0] == buffers[i])
+                       current_ctx->gl_element_array_buffer_binding[0] = 0;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+{
+       int i;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glDeleteFramebuffers(n, framebuffers);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       for (i = 0; i < n; i++)
+       {
+               if (current_ctx->gl_framebuffer_binding[0] == framebuffers[i])
+                       current_ctx->gl_framebuffer_binding[0] = 0;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+{
+       int i;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glDeleteRenderbuffers(n, renderbuffers);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       for (i = 0; i < n; i++)
+       {
+               if (current_ctx->gl_renderbuffer_binding[0] == renderbuffers[i])
+                       current_ctx->gl_renderbuffer_binding[0] = 0;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+//!!! Optimze?
+void
+fpgl_glBlendEquation(GLenum mode)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _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));
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((current_ctx->gl_blend_equation_rgb[0] != modeRGB) ||
+           (current_ctx->gl_blend_equation_alpha[0] != 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[0]    = modeRGB;
+               current_ctx->gl_blend_equation_alpha[0]  = modeAlpha;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+//!!! Optimze?
+void
+fpgl_glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _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));
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((current_ctx->gl_blend_src_rgb[0] != srcRGB) ||
+           (current_ctx->gl_blend_dst_rgb[0] != dstRGB) ||
+           (current_ctx->gl_blend_src_alpha[0] != srcAlpha) ||
+           (current_ctx->gl_blend_dst_alpha[0] != 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[0]   = srcRGB;
+               current_ctx->gl_blend_dst_rgb[0]   = dstRGB;
+               current_ctx->gl_blend_src_alpha[0] = srcAlpha;
+               current_ctx->gl_blend_dst_alpha[0] = dstAlpha;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glClearDepthf(GLclampf depth)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = depth;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glClearStencil(GLint s)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = s;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glCullFace(GLenum mode)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = mode;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDepthFunc(GLenum func)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_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[0] = func;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDepthMask(GLboolean flag)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = flag;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDisable(GLenum cap)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = 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[0] = 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[0] = 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[0] = 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[0] = 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[0] = 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[0] = 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[0] = 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[0] = GL_FALSE;
+                       }
+                       break;
+               }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDisableVertexAttribArray(GLuint index)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glDisableVertexAttribArray(index);
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_1;
+       current_ctx->gl_vertex_array_enabled[index]    = GL_FALSE;
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glDrawArrays(mode, first, count);
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glDrawElements(mode, count, type, indices);
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glEnable(GLenum cap)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = 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[0] = 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[0] = 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[0] = 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[0] = 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[0] = 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[0] = 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[0] = 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[0] = GL_TRUE;
+                       }
+                       break;
+               }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optimze?
+void
+fpgl_glEnableVertexAttribArray(GLuint index)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glEnableVertexAttribArray(index);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_1;
+       current_ctx->gl_vertex_array_enabled[index]    = GL_TRUE;
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glFrontFace(GLenum mode)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = mode;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glGetVertexAttribfv(index, pname, params);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glGetVertexAttribiv(index, pname, params);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glGetVertexAttribPointerv(index, pname, pointer);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+// Fix Maybe?
+void
+fpgl_glHint(GLenum target, GLenum mode)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = mode;
+               }
+       }
+       else
+       {
+               // For GL Error to be picked up
+               _sym_glHint(target, mode);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glLineWidth(GLfloat width)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = width;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glPixelStorei(GLenum pname, GLint param)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = 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[0] = param;
+               }
+       }
+       else
+       {
+               // For GL Error to be picked up
+               _sym_glPixelStorei(pname, param);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glPolygonOffset(GLfloat factor, GLfloat units)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((current_ctx->gl_polygon_offset_factor[0] != factor) ||
+           (current_ctx->gl_polygon_offset_units[0] != 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[0] = factor;
+               current_ctx->gl_polygon_offset_units[0]  = units;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glSampleCoverage(GLclampf value, GLboolean invert)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((current_ctx->gl_sample_coverage_value[0] != value) ||
+           (current_ctx->gl_sample_coverage_invert[0] != 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[0]  = value;
+               current_ctx->gl_sample_coverage_invert[0] = invert;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((current_ctx->gl_stencil_func[0] != func) ||
+           (current_ctx->gl_stencil_ref[0] != ref) ||
+           (current_ctx->gl_stencil_value_mask[0] != mask) ||
+           (current_ctx->gl_stencil_back_func[0] != func) ||
+           (current_ctx->gl_stencil_back_ref[0] != ref) ||
+           (current_ctx->gl_stencil_back_value_mask[0] != 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[0]             = func;
+               current_ctx->gl_stencil_ref[0]              = ref;
+               current_ctx->gl_stencil_value_mask[0]       = mask;
+
+               current_ctx->_stencil_flag2 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
+               current_ctx->gl_stencil_back_func[0]        = func;
+               current_ctx->gl_stencil_back_ref[0]         = ref;
+               current_ctx->gl_stencil_back_value_mask[0]  = mask;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
+       {
+               if ((current_ctx->gl_stencil_func[0] != func) ||
+                   (current_ctx->gl_stencil_ref[0] != ref) ||
+                   (current_ctx->gl_stencil_value_mask[0] != 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[0]             = func;
+                       current_ctx->gl_stencil_ref[0]              = ref;
+                       current_ctx->gl_stencil_value_mask[0]       = mask;
+               }
+       }
+       else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
+       {
+               if ((current_ctx->gl_stencil_back_func[0] != func) ||
+                   (current_ctx->gl_stencil_back_ref[0] != ref) ||
+                   (current_ctx->gl_stencil_back_value_mask[0] != 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[0]        = func;
+                       current_ctx->gl_stencil_back_ref[0]         = ref;
+                       current_ctx->gl_stencil_back_value_mask[0]  = mask;
+               }
+       }
+       else
+       {
+               // Have GL pick up the error
+               _sym_glStencilFuncSeparate(face, func, ref, mask);
+
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glStencilMask(GLuint mask)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((current_ctx->gl_stencil_writemask[0] != mask) ||
+           (current_ctx->gl_stencil_back_writemask[0] != 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[0]        = mask;
+               current_ctx->gl_stencil_back_writemask[0]   = mask;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glStencilMaskSeparate(GLenum face, GLuint mask)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
+       {
+               if (current_ctx->gl_stencil_writemask[0] != mask)
+               {
+                       _sym_glStencilMaskSeparate(face, mask);
+
+                       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+                       current_ctx->_stencil_flag1 |= (FLAG_BIT_6);
+                       current_ctx->gl_stencil_writemask[0] = mask;
+               }
+       }
+       else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
+       {
+               if (current_ctx->gl_stencil_back_writemask[0] != mask)
+               {
+                       _sym_glStencilMaskSeparate(face, mask);
+
+                       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+                       current_ctx->_stencil_flag2 |= (FLAG_BIT_6);
+                       current_ctx->gl_stencil_back_writemask[0]   = mask;
+               }
+       }
+       else
+       {
+               // Have GL pick up the error
+               _sym_glStencilMaskSeparate(face, mask);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((current_ctx->gl_stencil_fail[0] != fail) ||
+           (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) ||
+           (current_ctx->gl_stencil_pass_depth_pass[0] != zpass) ||
+           (current_ctx->gl_stencil_back_fail[0] != fail) ||
+           (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) ||
+           (current_ctx->gl_stencil_back_pass_depth_pass[0] != 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[0]              = fail;
+               current_ctx->gl_stencil_pass_depth_fail[0]   = zfail;
+               current_ctx->gl_stencil_pass_depth_pass[0]   = zpass;
+
+               current_ctx->_stencil_flag2 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
+               current_ctx->gl_stencil_back_fail[0]         = fail;
+               current_ctx->gl_stencil_back_pass_depth_fail[0]   = zfail;
+               current_ctx->gl_stencil_back_pass_depth_pass[0]   = zpass;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
+       {
+               if ((current_ctx->gl_stencil_fail[0] != fail) ||
+                   (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) ||
+                   (current_ctx->gl_stencil_pass_depth_pass[0] != 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[0]              = fail;
+                       current_ctx->gl_stencil_pass_depth_fail[0]   = zfail;
+                       current_ctx->gl_stencil_pass_depth_pass[0]   = zpass;
+               }
+       }
+       else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
+       {
+               if ((current_ctx->gl_stencil_back_fail[0] != fail) ||
+                   (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) ||
+                   (current_ctx->gl_stencil_back_pass_depth_pass[0] != 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[0]         = fail;
+                       current_ctx->gl_stencil_back_pass_depth_fail[0]   = zfail;
+                       current_ctx->gl_stencil_back_pass_depth_pass[0]   = zpass;
+               }
+       }
+       else
+       {
+               // For picking up error purpose
+               _sym_glStencilOpSeparate(face, fail, zfail, zpass);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glUseProgram(GLuint program)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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[0] = program;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optmize?
+void
+fpgl_glVertexAttrib1f(GLuint indx, GLfloat x)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttrib1f(indx, x);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = 0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optmize?
+void
+fpgl_glVertexAttrib1fv(GLuint indx, const GLfloat* values)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttrib1fv(indx, values);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = 0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optmize?
+void
+fpgl_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttrib2f(indx, x, y);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optmize?
+void
+fpgl_glVertexAttrib2fv(GLuint indx, const GLfloat* values)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttrib2fv(indx, values);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optmize?
+void
+fpgl_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttrib3f(indx, x, y, z);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = z;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optmize?
+void
+fpgl_glVertexAttrib3fv(GLuint indx, const GLfloat* values)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttrib3fv(indx, values);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = values[2];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optmize?
+void
+fpgl_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttrib4f(indx, x, y, z, w);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = z;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = w;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+// Optmize?
+void
+fpgl_glVertexAttrib4fv(GLuint indx, const GLfloat* values)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttrib4fv(indx, values);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_0;
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = values[2];
+       current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = values[3];
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+
+// Optmize?
+void
+fpgl_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       _sym_glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       current_ctx->_vattrib_flag |= FLAG_BIT_1;
+
+       current_ctx->gl_vertex_array_buf_id[indx]     = current_ctx->gl_array_buffer_binding[0];
+       current_ctx->gl_vertex_array_size[indx]       = size;
+       current_ctx->gl_vertex_array_type[indx]       = type;
+       current_ctx->gl_vertex_array_normalized[indx] = normalized;
+       current_ctx->gl_vertex_array_stride[indx]     = stride;
+       current_ctx->gl_vertex_array_pointer[indx]    = (GLvoid *)ptr;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       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;
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+void
+fpgl_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+       int tex_idx;
+
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       tex_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0;
+
+       switch (target)
+       {
+               case GL_TEXTURE_2D:
+                       current_ctx->gl_tex_2d_state[tex_idx] = -1;
+                       break;
+               case GL_TEXTURE_CUBE_MAP:
+                       current_ctx->gl_tex_cube_state[tex_idx] = -1;
+                       break;
+               }
+
+       _sym_glEGLImageTargetTexture2DOES(target, image);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+static GLboolean
+_process_getfunc(GLenum pname, GLvoid *ptr, GLenum get_type)
+{
+       GLboolean ret = GL_FALSE;
+
+       DEFINE_FAST_GL_FUNC();
+       INIT_FAST_GL_FUNC();
+
+       switch (pname)
+       {
+               case GL_TEXTURE_BINDING_2D:
+               {
+                       GLint real_tex_id = _COREGL_INT_INIT_VALUE;
+                       GLuint glue_tex_id = _COREGL_INT_INIT_VALUE;
+                       _sym_glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)real_tex_id);
+
+                       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+                       if (real_tex_id == 0)
+                       {
+                               glue_tex_id = 0;
+                       }
+                       else
+                       {
+                               AST(current_ctx->sostate != NULL);
+                               glue_tex_id = sostate_find_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, real_tex_id);
+                       }
+
+                       switch (get_type)
+                       {
+                               case GL_INT: ((GLint *)ptr)[0] = glue_tex_id; break;
+                               case GL_FLOAT: ((GLfloat *)ptr)[0] = (GLfloat)glue_tex_id; break;
+                               case GL_BOOL: ((GLboolean *)ptr)[0] = (glue_tex_id == 0) ? GL_FALSE : GL_TRUE; break;
+                       }
+                       ret = GL_TRUE;
+                       break;
+               }
+       }
+       goto finish;
+
+finish:
+       return ret;
+}
+
+
+void
+fpgl_glGetBooleanv(GLenum pname, GLboolean* params)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if (_process_getfunc(pname, params, GL_BOOL) != GL_TRUE)
+       {
+               _sym_glGetBooleanv(pname, params);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+fpgl_glGetFloatv(GLenum pname, GLfloat* params)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if (_process_getfunc(pname, params, GL_FLOAT) != GL_TRUE)
+       {
+               _sym_glGetFloatv(pname, params);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+fpgl_glGetIntegerv(GLenum pname, GLint* params)
+{
+       DEFINE_FAST_GL_FUNC();
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GL_FUNC();
+
+       if (_process_getfunc(pname, params, GL_INT) != GL_TRUE)
+       {
+               _sym_glGetIntegerv(pname, params);
+               GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       }
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
diff --git a/src/coregl_fastpath_glx.c b/src/coregl_fastpath_glx.c
new file mode 100644 (file)
index 0000000..c90c86b
--- /dev/null
@@ -0,0 +1,1194 @@
+#include "coregl_internal.h"
+#include "coregl_fastpath.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#define INIT_FAST_GLX_FUNC() \
+   LOG("WARNING : GLX fastpath is not implemented!!!!\n");
+
+#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO
+
+typedef struct _General_Trace_List
+{
+       void                          *value;
+       struct _General_Trace_List    *next;
+} General_Trace_List;
+
+General_Trace_List *glue_ctx_trace_list = NULL;
+General_Trace_List *thread_trace_list = NULL;
+Mutex               general_trace_lists_access_mutex = MUTEX_INITIALIZER;
+
+static int
+_add_to_general_trace_list(General_Trace_List **gtl, void *value)
+{
+       int ret = 0;
+       General_Trace_List *newitm = NULL;
+
+       AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
+
+       newitm = (General_Trace_List *)calloc(1, sizeof(General_Trace_List));
+       newitm->value = value;
+       newitm->next = *gtl;
+       *gtl = newitm;
+       ret = 1;
+       goto finish;
+
+finish:
+       AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
+       return ret;
+}
+
+static int
+_remove_from_general_trace_list(General_Trace_List **gtl, void *value)
+{
+       int ret = 0;
+       General_Trace_List *current = NULL;
+       General_Trace_List *priv = NULL;
+
+       AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
+
+       current = *gtl;
+
+       while(current != NULL)
+       {
+               if (current->value == value)
+               {
+                       if (priv == NULL)
+                               *gtl = current->next;
+                       else
+                               priv->next = current->next;
+
+                       free(current);
+                       ret = 1;
+                       goto finish;
+               }
+               priv = current;
+               current = current->next;
+       }
+       goto finish;
+
+finish:
+       AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
+
+       return ret;
+}
+
+static void
+_dump_context_info(const char *ment, int force_output)
+{
+       GLThreadState *tstate = NULL;
+       static struct timeval tv_last = { 0, 0 };
+
+       AST(mutex_lock(&ctx_list_access_mutex) == 1);
+       AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
+
+       if (!force_output)
+       {
+               struct timeval tv_now = { 0, 0 };
+               AST(gettimeofday(&tv_now, NULL) == 0);
+               if (tv_now.tv_sec - tv_last.tv_sec < 5)
+               {
+                       goto finish;
+               }
+               tv_last = tv_now;
+       }
+
+       tstate = get_current_thread_state();
+
+       LOG("\n");
+       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
+       LOG("\E[0;32;1m  Context info \E[1;37;1m: %s\E[0m\n", ment);
+       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
+
+       // Context State List
+       {
+               GLContextState *cstate = NULL;
+               void *iter = NULL;
+
+               iter = traverse_context_state_from_list(NULL, &cstate);
+               while (cstate != NULL)
+               {
+
+                       LOG("   RealCTX [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] GlueCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n",
+                           cstate,
+                           cstate->rdpy,
+                           cstate->rctx,
+                           cstate->data,
+                           cstate->ref_count);
+
+                       if (iter == NULL) break;
+                       iter = traverse_context_state_from_list(iter, &cstate);
+               }
+
+       }
+
+       LOG("\E[0;40;33m...................................................................................................................\E[0m\n");
+
+       // Glue Context List
+       {
+               General_Trace_List *current = NULL;
+               current = glue_ctx_trace_list;
+
+               while(current != NULL)
+               {
+                       GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
+
+                       LOG(" %c GlueCTX [%12p] : EGLDPY=[%12p] TID=[%12d]",
+                           (cur_gctx->cstate != NULL && cur_gctx->cstate->data == cur_gctx) ? '*' : ' ',
+                           cur_gctx,
+                           cur_gctx->rdpy,
+                           cur_gctx->thread_id);
+
+                       if (cur_gctx->cstate != NULL)
+                       {
+                               LOG(" RealCTX=[%12p]\n",
+                                   cur_gctx->cstate);
+                       }
+                       else
+                       {
+                               LOG(" (NOT BINDED)        \E[0m\n");
+                       }
+
+                       current = current->next;
+               }
+       }
+
+       LOG("\E[0;40;33m...................................................................................................................\E[0m\n");
+
+       // Thread State List
+       {
+               General_Trace_List *current = NULL;
+               current = thread_trace_list;
+
+               while(current != NULL)
+               {
+                       GLThreadState *cur_tstate = (GLThreadState *)current->value;
+
+                       LOG(" %c Thread  [%12d] : Surf <D=[%12p] R=[%12p]>",
+                           (tstate == cur_tstate) ? '*' : ' ',
+                           cur_tstate->thread_id,
+                           cur_tstate->rsurf_draw,
+                           cur_tstate->rsurf_read);
+
+                       if (cur_tstate->cstate != NULL)
+                       {
+                               LOG(" GlueCTX=[%12p] RealCTX=[%12p]\E[0m\n",
+                                   cur_tstate->cstate->data,
+                                   cur_tstate->cstate);
+                       }
+                       else
+                       {
+                               LOG(" (NOT BINDED TO THREAD)\E[0m\n");
+                       }
+
+                       current = current->next;
+               }
+       }
+
+       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
+       LOG("\n");
+
+       goto finish;
+
+finish:
+
+       AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
+       AST(mutex_unlock(&ctx_list_access_mutex) == 1);
+
+}
+
+#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO
+
+
+typedef struct
+{
+       EGLint                        context_client_version;
+} EGL_packed_attrib_list;
+
+typedef struct
+{
+       EGLDisplay                    dpy;
+       EGLConfig                     cfg;
+       EGL_packed_attrib_list        attrib_list;
+} EGL_packed_option;
+
+typedef struct
+{
+       EGLContext                    share_context;
+} EGL_packed_sharable_option;
+
+
+static int
+_pack_egl_context_option(EGL_packed_option *pack_data, EGLDisplay dpy, EGLConfig cfg, const EGLint *attrib_list)
+{
+       int ret = 0;
+
+       pack_data->dpy = dpy;
+       pack_data->cfg = cfg;
+
+       // Default context attributes
+       pack_data->attrib_list.context_client_version = EGL_DONT_CARE;
+
+       // Apply specified attributes
+       EGLint *attrib = (EGLint *)attrib_list;
+       while(attrib[0] != EGL_NONE)
+       {
+               switch(attrib[0])
+               {
+                       case EGL_CONTEXT_CLIENT_VERSION:
+                               pack_data->attrib_list.context_client_version = attrib[1];
+                               break;
+                       default:
+                               ERR("Invalid context attribute.\n");
+                               goto finish;
+                       }
+               attrib += 2;
+       }
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+static int
+_unpack_egl_context_option(EGL_packed_option *pack_data, EGLDisplay *dpy, EGLConfig *cfg, EGLint *attrib_list, const int attrib_list_size)
+{
+       int ret = 0;
+
+       AST(dpy != NULL);
+       AST(cfg != NULL);
+       AST(attrib_list != NULL);
+       AST(attrib_list_size < 1);
+
+       *dpy = pack_data->dpy;
+       *cfg = pack_data->cfg;
+
+       {
+               int attrib_list_index = 0;
+
+               memset(attrib_list, 0x00, sizeof(int) * attrib_list_size);
+
+               if (pack_data->attrib_list.context_client_version != EGL_DONT_CARE)
+               {
+                       AST(attrib_list_index + 2 < attrib_list_size);
+                       attrib_list[attrib_list_index] = EGL_CONTEXT_CLIENT_VERSION;
+                       attrib_list[attrib_list_index + 1] = pack_data->attrib_list.context_client_version;
+                       attrib_list_index += 2;
+               }
+
+               attrib_list[attrib_list_index] = EGL_NONE;
+       }
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+static int
+_pack_egl_context_sharable_option(EGL_packed_sharable_option *pack_data, EGLContext share_context)
+{
+       int ret = 0;
+
+       pack_data->share_context = share_context;
+
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+static int
+_unpack_egl_context_sharable_option(EGL_packed_sharable_option *pack_data, EGLContext *share_context)
+{
+       int ret = 0;
+
+       *share_context = pack_data->share_context;
+
+       ret = 1;
+       goto finish;
+
+finish:
+       return ret;
+}
+
+static void
+_link_context_state(GLContextState *cstate, GLGlueContext *gctx)
+{
+       cstate->ref_count++;
+}
+
+static void
+_unlink_context_state(GLContextState *cstate, GLGlueContext *gctx)
+{
+       cstate->ref_count--;
+       if (cstate->ref_count == 0)
+       {
+               GLThreadState *tstate = NULL;
+
+               AST(remove_context_state_from_list(cstate) == 1);
+
+               tstate = get_current_thread_state();
+               if (tstate != NULL)
+               {
+                       if (tstate->cstate == cstate)
+                       {
+                               _sym_glXMakeCurrent(gctx->rdpy, tstate->rsurf_draw, NULL);
+                               tstate->cstate = NULL;
+                       }
+               }
+               _sym_glXDestroyContext(gctx->rdpy, cstate->rctx);
+               free(cstate);
+               cstate = NULL;
+       }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//----------------------------------------------------------------//
+//                   Fastpath GLX Functions                       //
+//       The functions have prefix 'fpgl_' for (fastpath gl)      //
+//----------------------------------------------------------------//
+GLXContext
+fpgl_glXCreateContext(Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct)
+{
+       GLGlueContext *gctx = NULL;
+       GLContextState *cstate = NULL;
+       GLContextState *cstate_new = NULL;
+       GLContext ctx = NULL;
+       GLXContext real_share_context = NULL;
+
+       EGL_packed_option *real_ctx_option = NULL;
+       EGL_packed_sharable_option *real_ctx_sharable_option = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       if (share_context != NULL)
+       {
+               GLGlueContext *share_gctx = NULL;
+               share_gctx = (GLGlueContext *)share_context;
+               if (share_gctx->cstate == NULL)
+               {
+                       ERR("Invalid (not initialized) share context handle\n");
+                       goto finish;
+               }
+               real_share_context = share_gctx->cstate->rctx;
+       }
+
+
+       // Create a global context if it hasn't been created
+       if (cstate == NULL)
+       {
+               // Create a global context if it hasn't been created yet
+               ctx = _sym_glXCreateContext(dpy, vis, real_share_context, 1);
+               if (ctx == NULL)
+               {
+                       ERR("Failed creating a glx global context for Fastpath.\n");
+                       goto finish;
+               }
+
+               cstate_new = (GLContextState *)calloc(1, sizeof(GLContextState));
+               if (cstate_new == NULL)
+               {
+                       ERR("Error creating a new context state.\n");
+                       goto finish;
+               }
+               cstate_new->rctx = ctx;
+               cstate_new->rdpy = dpy;
+               cstate_new->data = NULL;
+
+               ctx = NULL;
+
+               AST(add_context_state_to_list(real_ctx_option, sizeof(EGL_packed_option), cstate_new) == 1);
+
+               cstate = cstate_new;
+       }
+
+       // Allocate a new context
+       gctx = (GLGlueContext *)calloc(1, sizeof(GLGlueContext));
+       if (gctx == NULL)
+       {
+               ERR("Error creating a new GLGlueContext.\n");
+               goto finish;
+       }
+
+       gctx->magic = MAGIC_GLFAST;
+       gctx->initialized = 0;
+       gctx->rdpy = dpy;
+       gctx->thread_id = get_current_thread();
+
+       gctx->real_ctx_option = real_ctx_option;
+       gctx->real_ctx_option_len = sizeof(EGL_packed_option);
+       gctx->real_ctx_sharable_option = real_ctx_sharable_option;
+       gctx->real_ctx_sharable_option_len = sizeof(EGL_packed_sharable_option);
+
+       gctx->cstate = cstate;
+
+       _add_to_general_trace_list(&glue_ctx_trace_list, gctx);
+
+       cstate->ref_count++;
+
+#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO
+       {
+               char ment[256];
+               sprintf(ment, "eglCreateContext completed (GlueCTX=[%12p])", gctx);
+               _dump_context_info(ment, 1);
+       }
+#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO
+
+       goto finish;
+
+finish:
+       if (gctx == NULL)
+       {
+               if (ctx != NULL)
+               {
+                       _sym_eglDestroyContext(dpy, ctx);
+                       ctx = NULL;
+               }
+               if (real_ctx_option != NULL)
+               {
+                       free(real_ctx_option);
+                       real_ctx_option = NULL;
+               }
+               if (real_ctx_sharable_option != NULL)
+               {
+                       free(real_ctx_sharable_option);
+                       real_ctx_sharable_option = NULL;
+               }
+               if (cstate_new != NULL)
+               {
+                       remove_context_state_from_list(cstate_new);
+                       free(cstate_new);
+                       cstate_new = NULL;
+               }
+       }
+
+       _COREGL_FAST_FUNC_END();
+       return (GLXContext)gctx;
+}
+
+
+
+void
+fpgl_glXDestroyContext(Display* dpy, GLXContext ctx)
+{
+       int ret = 0;
+       GLGlueContext *gctx = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       gctx = (GLGlueContext *)ctx;
+
+       if (gctx != NULL)
+       {
+               GLContextState *cstate = NULL;
+               if (gctx->magic != MAGIC_GLFAST)
+               {
+                       ERR("Magic Check Failed!!!\n");
+                       ret = 0;
+                       goto finish;
+               }
+               cstate = gctx->cstate;
+               AST(cstate != NULL);
+
+               _unlink_context_state(cstate, gctx);
+
+               _remove_from_general_trace_list(&glue_ctx_trace_list, gctx);
+
+               if (gctx->real_ctx_option != NULL)
+               {
+                       free(gctx->real_ctx_option);
+                       gctx->real_ctx_option = NULL;
+               }
+               if (gctx->real_ctx_sharable_option != NULL)
+               {
+                       free(gctx->real_ctx_sharable_option);
+                       gctx->real_ctx_sharable_option = NULL;
+               }
+               free(gctx);
+       }
+       else
+       {
+               ERR("Invalid Context.\n");
+               ret = 0;
+               goto finish;
+       }
+
+#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO
+       {
+               char ment[256];
+               sprintf(ment, "eglDestroyContext completed (GlueCTX=[%12p])", ctx);
+               _dump_context_info(ment, 1);
+       }
+#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO
+
+       ret = 1;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
+
+
+
+
+
+
+
+
+GLXContext
+fpgl_glXGetCurrentContext(void)
+{
+       GLGlueContext *ret = NULL;
+       GLThreadState *tstate = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       tstate = get_current_thread_state();
+
+       if (tstate != NULL)
+       {
+               if (tstate->cstate != NULL)
+               {
+                       ret = (GLGlueContext *)tstate->cstate->data;
+               }
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return (EGLContext)ret;
+}
+
+
+GLXDrawable
+fpgl_glXGetCurrentDrawable(void)
+{
+       GLXDrawable ret = None;
+       GLThreadState *tstate = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       tstate = get_current_thread_state();
+
+       if (tstate != NULL)
+               ret = (GLGlueContext *)tstate->rsurf_draw;
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
+Bool
+fpgl_glXMakeCurrent(Display* dpy, GLXDrawable draw, GLXContext ctx)
+{
+       Bool ret = False;
+       Bool need_mc = False;
+       GLGlueContext *gctx = NULL;
+
+       GLThreadState *tstate = NULL;
+       GLContextState *cstate = NULL;
+
+       _COREGL_FAST_FUNC_BEGIN();
+
+       gctx = (GLGlueContext *)ctx;
+
+       tstate = get_current_thread_state();
+       if (tstate == NULL)
+       {
+               // TODO : Move to Initialize
+               tstate = (GLThreadState *)calloc(1, sizeof(GLThreadState));
+               tstate->thread_id = get_current_thread();
+
+               set_current_thread_state(&ctx_list_access_mutex, tstate);
+
+               _add_to_general_trace_list(&thread_trace_list, tstate);
+
+               tstate = get_current_thread_state();
+               AST(tstate != NULL);
+       }
+
+       // Fast path for context deletion
+       if (ctx == NULL)
+       {
+               AST(gctx == NULL);
+               if (draw != None)
+               {
+                       // BB : full makecurrent when draw/read is specified
+                       if (!_sym_glXMakeCurrent(dpy, draw, NULL))
+                       {
+                               ERR("Error making context current with the drawable.\n");
+                               ret = False;
+                               goto finish;
+                       }
+                       tstate->cstate = NULL;
+               }
+
+               tstate->rsurf_draw = draw;
+               tstate->rsurf_read = draw;
+               ret = True;
+               goto finish;
+       }
+
+       AST(gctx != NULL);
+       AST(gctx->cstate != NULL);
+
+       if (gctx->rdpy != dpy)
+       {
+               ERR("Invalid context (or invalid Display)\n");
+               ret = False;
+               goto finish;
+       }
+
+       AST(gctx->real_ctx_option != NULL);
+       AST(gctx->real_ctx_sharable_option != NULL);
+
+       // Handle cross threading of context (when used by two or more gctx)
+       if (gctx->thread_id != get_current_thread() && gctx->cstate->ref_count > 1)
+       {
+               GLContextState *cstate_new = NULL;
+               GLXContext *new_real_ctx = NULL;
+
+               // Create a new context
+               {
+#define ATTRIB_LIST_BUFFER_SIZE 8
+
+                       Display dpy = NULL;
+                       EGLConfig config = NULL;
+                       int attrib_list[ATTRIB_LIST_BUFFER_SIZE];
+                       GLXContext real_share_context = NULL;
+
+                       _unpack_egl_context_option(gctx->real_ctx_option, &dpy, &config, attrib_list, ATTRIB_LIST_BUFFER_SIZE);
+                       _unpack_egl_context_sharable_option(gctx->real_ctx_sharable_option, &real_share_context);
+
+                       AST(dpy == gctx->rdpy);
+
+                       new_real_ctx = _sym_glXCreateContext(dpy, config, real_share_context);
+                       if (new_real_ctx == NULL)
+                       {
+                               ERR("Failed creating a egl context.\n");
+                               goto finish;
+                       }
+               }
+
+               cstate_new = (GLContextState *)calloc(1, sizeof(GLContextState));
+               if (cstate_new == NULL)
+               {
+                       ERR("Error creating a new context state.\n");
+                       goto finish;
+               }
+
+               cstate_new->rctx = new_real_ctx;
+               cstate_new->rdpy = gctx->rdpy;
+               cstate_new->data = gctx;
+
+               // TODO : Setup context state for new real ctx
+
+               AST(add_context_state_to_list(gctx->real_ctx_option, gctx->real_ctx_option_len, cstate_new) == 1);
+
+               _unlink_context_state(gctx->cstate, gctx);
+               gctx->cstate = cstate_new;
+               _link_context_state(gctx->cstate, gctx);
+
+               // Apply to new thread
+               gctx->thread_id = get_current_thread();
+
+       }
+
+       // Check if the object is correct
+       if (gctx->magic != MAGIC_GLFAST)
+       {
+               ERR("Magic Check Failed!!!\n");
+               ret = False;
+               goto finish;
+
+       }
+
+       cstate = tstate->cstate;
+
+       // If it's a first time or drawable changed, do a make current
+       if (cstate == NULL)
+       {
+               cstate = get_context_state_from_list(gctx->real_ctx_option, gctx->real_ctx_option_len);
+
+               if (cstate == NULL)
+               {
+                       ERR("Error making context current because context not ready.\n");
+                       ret = False;
+                       goto finish;
+               }
+               need_mc = EGL_TRUE;
+       }
+
+       // If drawable changed, do a make current
+       if ((tstate->rsurf_draw != draw) ||
+           (tstate->rsurf_read != read))
+               need_mc = True;
+
+       // If binded real context changed, do a make current
+       if (gctx->cstate == NULL ||
+           gctx->cstate->rctx != cstate->rctx)
+               need_mc = True;
+
+       if (need_mc == True)
+       {
+               // BB : full makecurrent
+               if (!_sym_glXMakeCurrent(dpy, draw, cstate->rctx))
+               {
+                       ERR("Error making context current with the drawable.\n");
+                       ret = False;
+                       goto finish;
+               }
+
+               tstate->cstate = cstate;
+
+               tstate->rsurf_draw = draw;
+               tstate->rsurf_read = read;
+
+               gctx->cstate = cstate;
+       }
+
+       // Initialize context states
+       if (gctx->initialized == 0)
+       {
+               if (init_context_states(gctx) != 1)
+               {
+                       ERR("Error intializing context\n");
+                       goto finish;
+               }
+               if (tstate->cstate->data == NULL)
+                       tstate->cstate->data = (void *)gctx;
+       }
+
+       AST(tstate->cstate->data != NULL);
+
+       if (tstate->cstate->data != gctx)
+       {
+               // restore needed
+               make_context_current((GLGlueContext *)tstate->cstate->data, gctx);
+               tstate->cstate->data = (void *)gctx;
+       }
+
+       ret = True;
+       goto finish;
+
+finish:
+
+#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO
+       {
+               char ment[256];
+               sprintf(ment, "eglMakeCurrent finished (GlueCTX=[%12p] Surf=[D:%12p R:%12p])", ctx, draw, read);
+               _dump_context_info(ment, 0);
+       }
+#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO
+
+       _COREGL_FAST_FUNC_END();
+       return ret;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+GLGlueContext ectx = (GLGlueContext)ctx;
+
+_COREGL_FAST_FUNC_BEGIN();
+INIT_FAST_GLX_FUNC();
+
+// 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;
+goto finish;
+
+finish:
+_COREGL_FAST_FUNC_END();
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//----------------------------------------------------------------//
+//                   Fastpath GLX Functions                       //
+//       The functions have prefix 'fpgl_' for (fastpath gl)      //
+//----------------------------------------------------------------//
+GLXContext
+fpgl_glXCreateContext(Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct)
+{
+       GLGlueContext ctx;
+
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GLX_FUNC();
+
+       // 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 _GLGlueContext));
+       if (!ctx)
+       {
+               ERR("Error creating a new GLGlueContext.\n");
+               return NULL;
+       }
+
+       if (!init_context_states(ctx))
+       {
+               ERR("Error intialing intial context\n");
+               free(ctx);
+               return NULL;
+       }
+
+       ctx_ref_count++;
+
+       return (GLXContext)ctx;
+
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+void
+fpgl_glXDestroyContext(Display* dpy, GLXContext ctx)
+{
+       GLGlueContext ectx = (GLGlueContext)ctx;
+
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GLX_FUNC();
+
+       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;
+               }
+       }
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+
+GLXContext
+fpgl_glXGetCurrentContext(void)
+{
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GLX_FUNC();
+
+       return (GLXContext)current_ctx;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+GLXDrawable
+fpgl_glXGetCurrentDrawable(void)
+{
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GLX_FUNC();
+
+       //return _sym_glXGetCurrentDrawable();
+       return (GLXDrawable)current_surf;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+
+Bool
+fpgl_glXMakeCurrent(Display* dpy, GLXDrawable draw, GLXContext ctx)
+{
+       GLGlueContext ectx = (GLGlueContext)ctx;
+
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GLX_FUNC();
+
+       // 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;
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+
+Bool
+fpgl_glXMakeContextCurrent(Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+{
+       _COREGL_FAST_FUNC_BEGIN();
+       INIT_FAST_GLX_FUNC();
+
+       ERR("NOT IMPLEMENTED YET!!! GLX Function Wrapped. Not fastpathed yet...\n");
+       return _sym_glXMakeContextCurrent(dpy, draw, read, ctx);
+       goto finish;
+
+finish:
+       _COREGL_FAST_FUNC_END();
+}
+
+#endif
+
diff --git a/src/coregl_fastpath_state.h b/src/coregl_fastpath_state.h
new file mode 100644 (file)
index 0000000..30c722a
--- /dev/null
@@ -0,0 +1,135 @@
+#ifndef GLUE_STATE
+#error GLUE_STATE_NOT_DEFINED
+#endif
+
+#define SET_1(v1)               value[0] = v1;
+#define SET_2(v1, v2)           value[0] = v1; value[1] = v2;
+#define SET_3(v1, v2, v3)       value[0] = v1; value[1] = v2; value[2] = v3;
+#define SET_4(v1, v2, v3, v4)   value[0] = v1; value[1] = v2; value[2] = v3; value[3] = v4;
+#define SET_N(n, inc, stmt) \
+   { \
+      int i; \
+      for (i = 0; i < n; i++) \
+      { \
+         stmt \
+         value += inc; \
+      } \
+   }
+
+GLUE_STATE(GLuint, gl_num_tex_units, 1, 1,
+           _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint *)value); /* DEFAULT NOT EFFECT */,
+           _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint *)value);)
+
+GLUE_STATE(GLuint, gl_num_vertex_attribs, 1, 1,
+           _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)value); /* DEFAULT NOT EFFECT */,
+           _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)value);)
+
+GLUE_STATE(GLuint, gl_array_buffer_binding, 1, 1, SET_1(0), _sym_glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint *)value);)
+GLUE_STATE(GLuint, gl_element_array_buffer_binding, 1, 1, SET_1(0), _sym_glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint *)value);)
+GLUE_STATE(GLuint, gl_framebuffer_binding, 1, 1, SET_1(0), _sym_glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *)value);)
+GLUE_STATE(GLuint, gl_renderbuffer_binding, 1, 1, SET_1(0), _sym_glGetIntegerv(GL_RENDERBUFFER_BINDING, (GLint *)value);)
+
+GLUE_STATE(GLboolean, gl_blend, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_BLEND, (GLboolean *)value);)
+GLUE_STATE(GLboolean, gl_cull_face, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_CULL_FACE, (GLboolean *)value);)
+GLUE_STATE(GLboolean, gl_depth_test, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)value);)
+GLUE_STATE(GLboolean, gl_dither, 1, 1, SET_1(GL_TRUE), _sym_glGetBooleanv(GL_DITHER, (GLboolean *)value);)
+
+GLUE_STATE(GLboolean, gl_polygon_offset_fill, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_POLYGON_OFFSET_FILL, (GLboolean *)value);)
+GLUE_STATE(GLboolean, gl_sample_alpha_to_coverage, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_SAMPLE_ALPHA_TO_COVERAGE, (GLboolean *)value);)
+GLUE_STATE(GLboolean, gl_sample_coverage, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_SAMPLE_COVERAGE, (GLboolean *)value);)
+GLUE_STATE(GLboolean, gl_scissor_test, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_SCISSOR_TEST, (GLboolean *)value);)
+GLUE_STATE(GLboolean, gl_stencil_test, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_STENCIL_TEST, (GLboolean *)value);)
+
+GLUE_STATE(GLint, gl_viewport, 4, 4,
+           _sym_glGetIntegerv(GL_VIEWPORT, (GLint *)value); /* DEFAULT NOT EFFECT */,
+           _sym_glGetIntegerv(GL_VIEWPORT, (GLint *)value);)
+
+GLUE_STATE(GLuint, gl_current_program, 1, 1, SET_1(0), _sym_glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *)value);)
+GLUE_STATE(GLclampf, gl_color_clear_value, 4, 4, SET_4(0.0f, 0.0f, 0.0f, 0.0f), _sym_glGetFloatv(GL_COLOR_CLEAR_VALUE, (GLfloat *)value);)
+
+GLUE_STATE(GLboolean, gl_color_writemask, 4, 4, SET_4(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE), _sym_glGetBooleanv(GL_COLOR_WRITEMASK, (GLboolean *)value);)
+GLUE_STATE(GLclampf, gl_depth_range, 2, 2, SET_2(0.0f, 1.0f), _sym_glGetFloatv(GL_DEPTH_RANGE, (GLfloat *)value);)
+GLUE_STATE(GLclampf, gl_depth_clear_value, 1, 1, SET_1(1.0f), _sym_glGetFloatv(GL_DEPTH_CLEAR_VALUE, (GLfloat *)value);)
+GLUE_STATE(GLenum, gl_depth_func, 1, 1, SET_1(GL_LESS), _sym_glGetIntegerv(GL_DEPTH_FUNC, (GLint *)value);)
+GLUE_STATE(GLboolean, gl_depth_writemask, 1, 1, SET_1(GL_TRUE), _sym_glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)value);)
+GLUE_STATE(GLenum, gl_cull_face_mode, 1, 1, SET_1(GL_BACK), _sym_glGetIntegerv(GL_CULL_FACE_MODE, (GLint *)value);)
+
+GLUE_STATE(GLuint, gl_tex_2d_state, INITIAL_CTX->gl_num_tex_units[0], MAX_TEXTURE_UNITS,
+           SET_N(INITIAL_CTX->gl_num_tex_units[0], 1, SET_1(0)),
+           _get_texture_states(GL_TEXTURE_BINDING_2D, (GLint *)value);)
+GLUE_STATE(GLuint, gl_tex_cube_state, INITIAL_CTX->gl_num_tex_units[0], MAX_TEXTURE_UNITS,
+           SET_N(INITIAL_CTX->gl_num_tex_units[0], 1, SET_1(0)),
+           _get_texture_states(GL_TEXTURE_BINDING_CUBE_MAP, (GLint *)value);)
+
+GLUE_STATE(GLenum, gl_active_texture, 1, 1, SET_1(GL_TEXTURE0), _sym_glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *)value))
+GLUE_STATE(GLenum, gl_generate_mipmap_hint, 1, 1, SET_1(GL_DONT_CARE), _sym_glGetIntegerv(GL_GENERATE_MIPMAP_HINT, (GLint *)value))
+
+GLUE_STATE(GLclampf, gl_blend_color, 4, 4, SET_4(0.0f, 0.0f, 0.0f, 0.0f), _sym_glGetFloatv(GL_BLEND_COLOR, (GLfloat *)value);)
+GLUE_STATE(GLenum, gl_blend_src_rgb, 1, 1, SET_1(GL_ONE), _sym_glGetIntegerv(GL_BLEND_SRC_RGB, (GLint *)value);)
+GLUE_STATE(GLenum, gl_blend_src_alpha, 1, 1, SET_1(GL_ONE), _sym_glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint *)value);)
+GLUE_STATE(GLenum, gl_blend_dst_rgb, 1, 1, SET_1(GL_ZERO), _sym_glGetIntegerv(GL_BLEND_DST_RGB, (GLint *)value);)
+GLUE_STATE(GLenum, gl_blend_dst_alpha, 1, 1, SET_1(GL_ZERO), _sym_glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint *)value);)
+GLUE_STATE(GLenum, gl_blend_equation_rgb, 1, 1, SET_1(GL_FUNC_ADD), _sym_glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint *)value);)
+GLUE_STATE(GLenum, gl_blend_equation_alpha, 1, 1, SET_1(GL_FUNC_ADD), _sym_glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint *)value);)
+
+
+GLUE_STATE(GLenum, gl_stencil_func, 1, 1, SET_1(GL_ALWAYS), _sym_glGetIntegerv(GL_STENCIL_FUNC, (GLint *)value);)
+GLUE_STATE(GLint, gl_stencil_ref, 1, 1, SET_1(0), _sym_glGetIntegerv(GL_STENCIL_REF, (GLint *)value);)
+GLUE_STATE(GLuintmask, gl_stencil_value_mask, 1, 1, SET_1(_get_stencil_max_mask()), _sym_glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)value);)
+GLUE_STATE(GLenum, gl_stencil_fail, 1, 1, SET_1(GL_KEEP), _sym_glGetIntegerv(GL_STENCIL_FAIL, (GLint *)value);)
+GLUE_STATE(GLenum, gl_stencil_pass_depth_fail, 1, 1, SET_1(GL_KEEP), _sym_glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)value);)
+GLUE_STATE(GLenum, gl_stencil_pass_depth_pass, 1, 1, SET_1(GL_KEEP), _sym_glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)value);)
+GLUE_STATE(GLuintmask, gl_stencil_writemask, 1, 1, SET_1(_get_stencil_max_mask()), _sym_glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)value);)
+
+GLUE_STATE(GLenum, gl_stencil_back_func, 1, 1, SET_1(GL_ALWAYS), _sym_glGetIntegerv(GL_STENCIL_BACK_FUNC, (GLint *)value);)
+GLUE_STATE(GLint, gl_stencil_back_ref, 1, 1, SET_1(0), _sym_glGetIntegerv(GL_STENCIL_BACK_REF, (GLint *)value);)
+GLUE_STATE(GLuintmask, gl_stencil_back_value_mask, 1, 1, SET_1(_get_stencil_max_mask()), _sym_glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, (GLint *)value);)
+GLUE_STATE(GLenum, gl_stencil_back_fail, 1, 1, SET_1(GL_KEEP), _sym_glGetIntegerv(GL_STENCIL_BACK_FAIL, (GLint *)value);)
+GLUE_STATE(GLenum, gl_stencil_back_pass_depth_fail, 1, 1, SET_1(GL_KEEP), _sym_glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_FAIL, (GLint *)value);)
+GLUE_STATE(GLenum, gl_stencil_back_pass_depth_pass, 1, 1, SET_1(GL_KEEP), _sym_glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_PASS, (GLint *)value);)
+GLUE_STATE(GLuintmask, gl_stencil_back_writemask, 1, 1, SET_1(_get_stencil_max_mask()), _sym_glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, (GLint *)value);)
+
+GLUE_STATE(GLint, gl_stencil_clear_value, 1, 1, SET_1(0), _sym_glGetIntegerv(GL_STENCIL_CLEAR_VALUE, (GLint *)value);)
+
+// MISC FLAG 1
+GLUE_STATE(GLenum, gl_front_face, 1, 1, SET_1(GL_CCW), _sym_glGetIntegerv(GL_FRONT_FACE, (GLint *)value);)
+GLUE_STATE(GLfloat, gl_line_width, 1, 1, SET_1(1.0f), _sym_glGetFloatv(GL_LINE_WIDTH, (GLfloat *)value);)
+GLUE_STATE(GLfloat, gl_polygon_offset_factor, 1, 1, SET_1(0.0f), _sym_glGetFloatv(GL_POLYGON_OFFSET_FACTOR, (GLfloat *)value);)
+GLUE_STATE(GLfloat, gl_polygon_offset_units, 1, 1, SET_1(0.0f), _sym_glGetFloatv(GL_POLYGON_OFFSET_UNITS, (GLfloat *)value);)
+GLUE_STATE(GLclampf, gl_sample_coverage_value, 1, 1, SET_1(1.0f), _sym_glGetFloatv(GL_SAMPLE_COVERAGE_VALUE, (GLfloat *)value);)
+GLUE_STATE(GLboolean, gl_sample_coverage_invert, 1, 1, SET_1(GL_FALSE), _sym_glGetBooleanv(GL_SAMPLE_COVERAGE_INVERT, (GLboolean *)value);)
+
+// MISC FLAG 2
+GLUE_STATE(GLint, gl_scissor_box, 4, 4,
+           _sym_glGetIntegerv(GL_SCISSOR_BOX, (GLint *)value); /* DEFAULT NOT EFFECT */,
+           _sym_glGetIntegerv(GL_SCISSOR_BOX, (GLint *)value);)
+
+GLUE_STATE(GLint, gl_pack_alignment, 1, 1, SET_1(4), _sym_glGetIntegerv(GL_PACK_ALIGNMENT, (GLint *)value);)
+GLUE_STATE(GLint, gl_unpack_alignment, 1, 1, SET_1(4), _sym_glGetIntegerv(GL_UNPACK_ALIGNMENT, (GLint *)value);)
+
+GLUE_STATE(GLuint, gl_vertex_array_buf_id, INITIAL_CTX->gl_num_vertex_attribs[0], MAX_VERTEX_ATTRIBS,
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, SET_1(0)),
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, _sym_glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, (GLint *)value);))
+GLUE_STATE(GLboolean, gl_vertex_array_enabled, INITIAL_CTX->gl_num_vertex_attribs[0], MAX_VERTEX_ATTRIBS,
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, SET_1(GL_FALSE)),
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, _sym_glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, (GLint *)value);))
+GLUE_STATE(GLint, gl_vertex_array_size, INITIAL_CTX->gl_num_vertex_attribs[0], MAX_VERTEX_ATTRIBS,
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, SET_1(4)),
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, _sym_glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_SIZE, (GLint *)value);))
+GLUE_STATE(GLenum, gl_vertex_array_type, INITIAL_CTX->gl_num_vertex_attribs[0], MAX_VERTEX_ATTRIBS,
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, SET_1(GL_FLOAT)),
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, _sym_glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_TYPE, (GLint *)value);))
+GLUE_STATE(GLboolean, gl_vertex_array_normalized, INITIAL_CTX->gl_num_vertex_attribs[0], MAX_VERTEX_ATTRIBS,
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, SET_1(GL_FALSE)),
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, _sym_glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, (GLint *)value);))
+GLUE_STATE(GLsizei, gl_vertex_array_stride, INITIAL_CTX->gl_num_vertex_attribs[0], MAX_VERTEX_ATTRIBS,
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, SET_1(GL_FALSE)),
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, _sym_glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_STRIDE, (GLint *)value);))
+GLUE_STATE(GLvoidptr, gl_vertex_array_pointer, INITIAL_CTX->gl_num_vertex_attribs[0], MAX_VERTEX_ATTRIBS,
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, SET_1(NULL)),
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 1, _sym_glGetVertexAttribPointerv(i, GL_VERTEX_ATTRIB_ARRAY_POINTER, (GLvoidptr *)value);))
+
+GLUE_STATE(GLfloat, gl_vertex_attrib_value, 4 * INITIAL_CTX->gl_num_vertex_attribs[0], MAX_VERTEX_ATTRIBS,
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 4, SET_4(0, 0, 0, 1)),
+           SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 4, _sym_glGetVertexAttribfv(i, GL_CURRENT_VERTEX_ATTRIB, (GLfloat *)value);))
+
diff --git a/src/coregl_internal.h b/src/coregl_internal.h
new file mode 100644 (file)
index 0000000..d9fa663
--- /dev/null
@@ -0,0 +1,197 @@
+#ifndef COREGL_INTERNAL_H
+#define COREGL_INTERNAL_H
+
+#include <stdio.h>
+
+#include "coregl.h"
+
+#define COREGL_DEBUG
+
+# define ERR(...) \
+     fprintf(stderr, __VA_ARGS__)
+# ifdef COREGL_DEBUG
+#  define DBG(...) \
+     fprintf(stderr, __VA_ARGS__)
+# else
+#  define DBG(...)
+# endif
+
+# define LOG(...) \
+     fprintf(stderr, __VA_ARGS__)
+
+#ifdef COREGL_DEBUG
+# define AST(expr) \
+     if (!(expr)) { fprintf(stderr, "\E[0;31;1m%s(%d) error. '"#expr"'\E[0m\n", __func__, __LINE__); }
+#else
+# define AST(expr) \
+     if (expr)
+#endif
+
+typedef GLvoid *     GLvoidptr;
+typedef GLuint       GLuintmask;
+
+//#define COREGL_TRACE_ALL
+#define COREGL_TRACE_CONTEXT_INFO
+#define COREGL_TRACE_STATE_INFO
+#define COREGL_TRACE_APICALL_INFO
+
+#ifdef COREGL_TRACE_ALL
+#define COREGL_TRACE_CONTEXT_INFO   // Context state & thread state & Glue-context info
+#define COREGL_TRACE_STATE_INFO     // Glue-context state info
+#define COREGL_TRACE_APICALL_INFO   // API call frequency info
+#endif
+
+#define _COREGL_TRACE_OUTPUT_INTERVAL_SEC 5
+
+// Symbol definition for static
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     extern RET_TYPE (*_sym_##FUNC_NAME) PARAM_LIST;
+# include "headers/sym.h"
+#undef _COREGL_SYMBOL
+
+// Symbol definition for wrappath
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     extern RET_TYPE (evgl_##FUNC_NAME) PARAM_LIST;
+# include "headers/sym.h"
+#undef _COREGL_SYMBOL
+
+// Symbol definition for fastpath
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     extern RET_TYPE (fpgl_##FUNC_NAME) PARAM_LIST;
+# include "headers/sym.h"
+#undef _COREGL_SYMBOL
+
+#define _COREGL_INT_INIT_VALUE -3
+
+
+#ifdef COREGL_ERRORS
+# define GLERR(fn, fl, ln, op)
+#else
+# define GLERR(fn, fl, ln, op)
+#endif
+
+
+typedef struct _Trace_Data Trace_Data;
+
+#ifdef COREGL_TRACE_APICALL_INFO
+# define _COREGL_TRACE_API_BEGIN(api) \
+   trace_begin(api);
+# define _COREGL_TRACE_API_END(api) \
+   trace_end(api);
+# define _COREGL_TRACE_API_OUTPUT(force_output) \
+   trace_output(force_output);
+#else
+# define _COREGL_TRACE_API_BEGIN(api)
+# define _COREGL_TRACE_API_END(api)
+# define _COREGL_TRACE_API_OUTPUT(force_output)
+#endif
+
+
+#define _COREGL_FAST_FUNC_BEGIN()
+
+#define _COREGL_FAST_FUNC_END()
+
+#define _COREGL_WRAP_FUNC_BEGIN() \
+   _COREGL_TRACE_API_BEGIN(__func__);
+
+#define _COREGL_WRAP_FUNC_END() \
+   _COREGL_TRACE_API_END(__func__);
+
+typedef enum _CoreGL_Opt_Flag
+{
+    COREGL_NORMAL_PATH,
+    GL_WRAPPED_PATH,
+    COREGL_FAST_PATH
+} CoreGL_Opt_Flag;
+
+
+#ifndef _COREGL_DESKTOP_GL
+typedef EGLSurface     GLSurface;
+typedef EGLDisplay     GLDisplay;
+typedef EGLContext     GLContext;
+#else
+typedef GLXDrawable    GLSurface;
+typedef Display        GLDisplay;
+typedef GLXContext     GLContext;
+#endif
+
+typedef struct _GLContextState
+{
+       int                      ref_count;
+       GLContext               *rctx;
+       GLDisplay               *rdpy;
+       void                    *data;
+} GLContextState;
+
+typedef struct _GLThreadState
+{
+       int                      thread_id;
+       GLContextState          *cstate;
+       GLSurface               *rsurf_draw;
+       GLSurface               *rsurf_read;
+       Trace_Data             **ftd_table;
+} GLThreadState;
+
+typedef struct _GLContext_List
+{
+       void                    *option;
+       int                      option_len;
+       int                      thread_id;
+       GLContextState          *cstate;
+       struct _GLContext_List *next;
+} GLContext_List;
+
+extern void                *glue_lib_handle;
+extern void                *egl_lib_handle;
+
+extern GLContext_List      *glctx_list;
+
+#include "coregl_thread_pthread.h"
+extern Mutex                ctx_list_access_mutex;
+
+typedef struct _General_Trace_List
+{
+       void                          *value;
+       struct _General_Trace_List    *next;
+} General_Trace_List;
+
+extern General_Trace_List  *thread_trace_list;
+extern Mutex                general_trace_lists_access_mutex;
+
+extern int                  trace_api_flag;
+
+// Environment functions
+extern const char *get_env_setting(const char *name);
+
+// Main utility functions
+extern int                 init_new_thread_state();
+
+// Thread functions
+extern int                 mutex_lock(Mutex *mt);
+extern int                 mutex_unlock(Mutex *mt);
+extern int                 get_current_thread();
+extern int                 set_current_thread_state(Mutex *mt, GLThreadState *tstate);
+extern GLThreadState      *get_current_thread_state();
+
+
+// Context state functions
+extern int                 add_context_state_to_list(const void *data, const int datalen, GLContextState *cstate, Mutex *mtx);
+extern int                 remove_context_states_from_list(GLContextState *cstate, Mutex *mtx);
+extern GLContextState     *get_context_state_from_list(const void *data, const int datalen, Mutex *mtx);
+
+
+// Override functions
+extern void                override_glue_normal_path();
+extern void                override_glue_fast_path();
+extern void                override_gl_normal_path();
+extern void                override_gl_fast_path();
+extern void                override_glue_apis(CoreGL_Opt_Flag opt);
+extern void                override_gl_apis(CoreGL_Opt_Flag opt);
+
+
+// Debug & Trace functions
+extern int                 add_to_general_trace_list(General_Trace_List **gtl, void *value);
+extern int                 remove_from_general_trace_list(General_Trace_List **gtl, void *value);
+extern void                trace_begin(const char *name);
+extern void                trace_end(const char *name);
+extern void                trace_output(int force_output);
+
+#endif // COREGL_INTERNAL_H
+
diff --git a/src/coregl_override.c b/src/coregl_override.c
new file mode 100644 (file)
index 0000000..1d7c3dd
--- /dev/null
@@ -0,0 +1,200 @@
+#include "coregl_internal.h"
+
+#include <stdlib.h>
+
+#define COREGL_API_OVERRIDE(func, prefix) \
+   _COREGL_NAME_MANGLE(func) = prefix##func
+
+void
+override_glue_normal_path()
+{
+#define N_ORD(f) COREGL_API_OVERRIDE(f, _sym_) // GL Normal Path
+
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     N_ORD(FUNC_NAME);
+# ifndef _COREGL_DESKTOP_GL
+#  include "headers/sym_egl.h"
+# else
+#  include "headers/sym_glx.h"
+# endif
+#undef _COREGL_SYMBOL
+
+#undef N_ORD
+}
+
+void
+override_glue_fast_path()
+{
+       // Inherit from normal path
+       override_glue_normal_path();
+
+#define F_ORD(f) COREGL_API_OVERRIDE(f, fpgl_) // GL Fast Path
+
+
+#ifndef _COREGL_DESKTOP_GL
+       // Fast-Path Core Functions
+       F_ORD(eglGetProcAddress);
+
+       F_ORD(eglCreateContext);
+       F_ORD(eglCreateImageKHR);
+       F_ORD(eglMakeCurrent);
+       F_ORD(eglDestroyContext);
+       F_ORD(eglQueryContext);
+       F_ORD(eglGetCurrentContext);
+
+       if (atoi(get_env_setting("COREGL_DEBUG_NOFP")) != 1)
+       {
+               F_ORD(eglGetCurrentSurface);
+               F_ORD(eglDestroySurface);
+       }
+       else
+       {
+               LOG("\E[0;35;1m[CoreGL] SKIP GLUE FASTPATH...\E[0m\n");
+       }
+
+#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
+}
+
+void
+override_gl_normal_path()
+{
+#define N_ORD(f) COREGL_API_OVERRIDE(f, _sym_) // GL Normal Path
+
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     N_ORD(FUNC_NAME);
+# include "headers/sym_gl.h"
+#undef _COREGL_SYMBOL
+
+#undef N_ORD
+}
+
+void
+override_gl_fast_path()
+{
+       // Inherit from normal path
+       override_gl_normal_path();
+
+#define F_ORD(f) COREGL_API_OVERRIDE(f, fpgl_) // GL Wrapped Path
+
+       // Fast-Path Functions
+       if (atoi(get_env_setting("COREGL_DEBUG_NOFP")) != 1)
+       {
+               F_ORD(glActiveTexture);
+               F_ORD(glBindBuffer);
+               F_ORD(glDeleteBuffers);
+
+               F_ORD(glGenTextures);
+               F_ORD(glBindTexture);
+               F_ORD(glIsTexture);
+               F_ORD(glFramebufferTexture2D);
+               F_ORD(glDeleteTextures);
+
+               F_ORD(glBindFramebuffer);
+               F_ORD(glDeleteFramebuffers);
+               F_ORD(glBindRenderbuffer);
+               F_ORD(glDeleteRenderbuffers);
+               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);
+
+               F_ORD(glGetIntegerv);
+               F_ORD(glGetFloatv);
+               F_ORD(glGetBooleanv);
+
+               F_ORD(glEGLImageTargetTexture2DOES);
+               F_ORD(glFramebufferTexture2DMultisampleEXT);
+
+       }
+       else
+       {
+               LOG("\E[0;35;1m[CoreGL] SKIP GL FASTPATH...\E[0m\n");
+       }
+
+#undef F_ORD
+}
+
+
+void
+override_glue_apis(CoreGL_Opt_Flag opt)
+{
+       switch (opt)
+       {
+               case COREGL_NORMAL_PATH:
+                       override_glue_normal_path();
+                       break;
+               case COREGL_FAST_PATH:
+                       override_glue_fast_path();
+                       break;
+               default:
+                       ERR("Invalide GL Override Option!!!\n");
+               }
+}
+
+void
+override_gl_apis(CoreGL_Opt_Flag opt)
+{
+       switch (opt)
+       {
+               case COREGL_NORMAL_PATH:
+                       override_gl_normal_path();
+                       break;
+               case COREGL_FAST_PATH:
+                       override_gl_fast_path();
+                       break;
+               default:
+                       ERR("Invalide GL Override Option!!!\n");
+               }
+}
+
diff --git a/src/coregl_thread_pthread.c b/src/coregl_thread_pthread.c
new file mode 100644 (file)
index 0000000..aee8ae3
--- /dev/null
@@ -0,0 +1,94 @@
+#include "coregl_internal.h"
+
+//////////////////////////////////////////////////////////////////////////
+// Need implement this
+int mutex_lock(Mutex *mt);
+int mutex_unlock(Mutex *mt);
+int get_current_thread();
+int set_current_thread_state(Mutex *mt, GLThreadState *tstate);
+GLThreadState * get_current_thread_state();
+//////////////////////////////////////////////////////////////////////////
+
+static int              thread_key_inited = 0;
+static pthread_key_t    thread_key = 0;
+
+int
+mutex_lock(Mutex *mt)
+{
+       int ret = 0;
+
+       if (pthread_mutex_lock(mt) == 0)
+               ret = 1;
+       else
+               ret = 0;
+
+       return ret;
+}
+
+int
+mutex_unlock(Mutex *mt)
+{
+       int ret = 0;
+
+       if (pthread_mutex_unlock(mt) == 0)
+               ret = 1;
+       else
+               ret = 0;
+
+       return ret;
+}
+
+int
+get_current_thread()
+{
+       return pthread_self();
+}
+
+int
+set_current_thread_state(Mutex *mt, GLThreadState *tstate)
+{
+       int ret = 0;
+
+       AST(mutex_lock(mt) == 1);
+
+       if (thread_key_inited == 0)
+       {
+               if (pthread_key_create(&thread_key, NULL) != 0)
+               {
+                       ERR("Failed to create thread key.\n");
+                       ret = 0;
+                       goto finish;
+               }
+               thread_key_inited = 1;
+       }
+
+       if (pthread_setspecific(thread_key, (void *)tstate) != 0)
+       {
+               ERR("Failed to set thread data.\n");
+               ret = 0;
+               goto finish;
+       }
+
+       ret = 1;
+       goto finish;
+
+finish:
+       AST(mutex_unlock(mt) == 1);
+
+       return ret;
+}
+
+GLThreadState *
+get_current_thread_state()
+{
+       GLThreadState *ret = NULL;
+       if (thread_key_inited)
+       {
+               ret = (GLThreadState *)pthread_getspecific(thread_key);
+       }
+       goto finish;
+
+finish:
+       return ret;
+}
+
diff --git a/src/coregl_thread_pthread.h b/src/coregl_thread_pthread.h
new file mode 100644 (file)
index 0000000..4a84f13
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef COREGL_THREAD_PTHREAD_H
+#define COREGL_THREAD_PTHREAD_H
+
+#include <pthread.h>
+
+//////////////////////////////////////////////////////////////////////////
+// Need define this
+typedef pthread_mutex_t Mutex;
+
+#define MUTEX_INITIALIZER  PTHREAD_MUTEX_INITIALIZER
+//////////////////////////////////////////////////////////////////////////
+
+#endif // COREGL_THREAD_PTHREAD_H
+
diff --git a/src/coregl_trace.c b/src/coregl_trace.c
new file mode 100644 (file)
index 0000000..8433072
--- /dev/null
@@ -0,0 +1,343 @@
+#include "coregl_internal.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#define MAX_TRACE_NAME_LENGTH 256
+#define MAX_TRACE_TABLE_SIZE 65536
+
+struct _Trace_Data
+{
+       char                         name[MAX_TRACE_NAME_LENGTH];
+       int                          call_count;
+       int                          last_call_count;
+       long                         elapsed_time;
+       long                         last_elapsed_time;
+       struct timeval              last_time;
+
+       int                          traced;
+
+       struct _Trace_Data          *next;
+};
+
+General_Trace_List *thread_trace_list = NULL;
+Mutex               general_trace_lists_access_mutex = MUTEX_INITIALIZER;
+
+int                 trace_api_flag = 1;
+
+
+static unsigned short
+_generate_hash_short(const char *string)
+{
+       unsigned short hash = 0;
+       int i;
+       for (i = 0; i < strlen(string); i++)
+       {
+               hash = 253 * hash + string[i];
+       }
+       return hash ^ (hash >> 8);
+}
+
+static Trace_Data *
+_get_trace_data(Trace_Data **ftd_table, const char *name)
+{
+       Trace_Data *ret = NULL;
+       Trace_Data *current = NULL;
+       Trace_Data *prev = NULL;
+       unsigned short hash = 0;
+
+       AST(strlen(name) < MAX_TRACE_NAME_LENGTH);
+
+       hash = _generate_hash_short(name);
+
+       current = ftd_table[hash];
+
+       while (current != NULL)
+       {
+               if (strcmp(current->name, name) == 0)
+                       break;
+               prev = current;
+               current = current->next;
+       }
+
+       if (current != NULL)
+       {
+               ret = current;
+       }
+       else
+       {
+               Trace_Data *newitm = NULL;
+               newitm = (Trace_Data *)calloc(1, sizeof(Trace_Data));
+               strcpy(newitm->name, name);
+               newitm->next = NULL;
+
+               if (prev != NULL)
+               {
+                       prev->next = newitm;
+               }
+               else
+               {
+                       ftd_table[hash] = newitm;
+               }
+               ret = newitm;
+       }
+       goto finish;
+
+finish:
+       return ret;
+}
+
+int
+add_to_general_trace_list(General_Trace_List **gtl, void *value)
+{
+       int ret = 0;
+       General_Trace_List *newitm = NULL;
+
+       AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
+
+       newitm = (General_Trace_List *)calloc(1, sizeof(General_Trace_List));
+       newitm->value = value;
+       newitm->next = *gtl;
+       *gtl = newitm;
+       ret = 1;
+       goto finish;
+
+finish:
+       AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
+       return ret;
+}
+
+int
+remove_from_general_trace_list(General_Trace_List **gtl, void *value)
+{
+       int ret = 0;
+       General_Trace_List *current = NULL;
+       General_Trace_List *priv = NULL;
+
+       AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
+
+       current = *gtl;
+
+       while (current != NULL)
+       {
+               if (current->value == value)
+               {
+                       if (priv == NULL)
+                               *gtl = current->next;
+                       else
+                               priv->next = current->next;
+
+                       free(current);
+                       ret = 1;
+                       goto finish;
+               }
+               priv = current;
+               current = current->next;
+       }
+       goto finish;
+
+finish:
+       AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
+
+       return ret;
+}
+
+void
+trace_begin(const char *funcname)
+{
+       GLThreadState *tstate = NULL;
+
+       tstate = get_current_thread_state();
+
+       if (tstate == NULL)
+       {
+               init_new_thread_state();
+
+               tstate = get_current_thread_state();
+               AST(tstate != NULL);
+       }
+
+       if (tstate->ftd_table == NULL)
+       {
+               tstate->ftd_table = (Trace_Data **)calloc(1, sizeof(Trace_Data *) * MAX_TRACE_TABLE_SIZE);
+       }
+
+       if (trace_api_flag == 1)
+       {
+               Trace_Data *ftd = _get_trace_data(tstate->ftd_table, funcname);
+               AST(ftd != NULL);
+
+               ftd->call_count++;
+               AST(ftd->last_time.tv_sec == 0);
+
+               AST(gettimeofday(&ftd->last_time, NULL) == 0);
+       }
+}
+
+void
+trace_end(const char *funcname)
+{
+       GLThreadState *tstate = NULL;
+       struct timeval t = {0};
+
+       AST(gettimeofday(&t, NULL) == 0);
+
+       tstate = get_current_thread_state();
+
+       if (tstate == NULL)
+       {
+               init_new_thread_state();
+
+               tstate = get_current_thread_state();
+               AST(tstate != NULL);
+       }
+
+       AST(tstate->ftd_table != NULL);
+
+       if (trace_api_flag == 1)
+       {
+               Trace_Data *ftd = _get_trace_data(tstate->ftd_table, funcname);
+               AST(ftd != NULL);
+
+               ftd->elapsed_time +=
+                   (t.tv_sec - ftd->last_time.tv_sec) * 100000 +
+                   (t.tv_usec - ftd->last_time.tv_usec) / 10;
+               ftd->last_time.tv_sec = 0;
+       }
+}
+
+void
+trace_output(int force_output)
+{
+       static struct timeval tv_last = { 0, 0 };
+       GLThreadState *tstate = NULL;
+       Trace_Data **ftd_table = NULL;
+       int i;
+
+       {
+               char *fp_env = NULL;
+               int fp_envi = 0;
+               fp_env = getenv("COREGL_TRACE_API");
+               if (fp_env) fp_envi = atoi(fp_env);
+               else fp_envi = 0;
+               if (fp_envi == 0) return;
+       }
+
+       if (!force_output)
+       {
+               struct timeval tv_now = { 0, 0 };
+               AST(gettimeofday(&tv_now, NULL) == 0);
+               if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC)
+               {
+                       goto finish;
+               }
+               tv_last = tv_now;
+       }
+
+       tstate = get_current_thread_state();
+
+       if (tstate == NULL)
+       {
+               init_new_thread_state();
+
+               tstate = get_current_thread_state();
+               AST(tstate != NULL);
+       }
+
+
+       ftd_table = tstate->ftd_table;
+       if (ftd_table == NULL) return;
+
+       LOG("\n");
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+       LOG("\E[0;32;1m  API call info \E[1;37;1m: Thread ID = %d\E[0m\n", tstate->thread_id);
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+
+       // highlighted
+       for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++)
+       {
+               if (ftd_table[i] != NULL)
+               {
+                       Trace_Data *current = ftd_table[i];
+
+                       while (current != NULL)
+                       {
+                               double elapsed_time = current->elapsed_time / 100.0;
+                               double elapsed_time_per_call = elapsed_time / current->call_count;
+
+                               current->traced = 0;
+
+                               if (current->call_count > current->last_call_count)
+                               {
+                                       double elapsed_time_period = (current->elapsed_time - current->last_elapsed_time) / 100.0;
+                                       double elapsed_time_per_call_period = elapsed_time_period / (current->call_count - current->last_call_count);
+
+                                       if (elapsed_time_per_call_period >= 0.01)
+                                       {
+                                               LOG("\E[0;37;1m %-42.42s : %10d call(s), %10.2f ms, %9.2f ms/API, %9.2f ms/API(P) \E[0m\n",
+                                                   current->name, current->call_count, elapsed_time, elapsed_time_per_call, elapsed_time_per_call_period);
+                                               current->traced = 1;
+                                       }
+                               }
+                               current = current->next;
+                       }
+               }
+       }
+
+       {
+               char *fp_env = NULL;
+               int fp_envi = 0;
+               fp_env = getenv("COREGL_TRACE_API_ALL");
+               if (fp_env) fp_envi = atoi(fp_env);
+               else fp_envi = 0;
+               if (fp_envi != 0)
+               {
+                       // other
+                       for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++)
+                       {
+                               if (ftd_table[i] != NULL)
+                               {
+                                       Trace_Data *current = ftd_table[i];
+
+                                       while (current != NULL)
+                                       {
+                                               if (current->traced == 0)
+                                               {
+                                                       double elapsed_time = current->elapsed_time / 100.0;
+                                                       double elapsed_time_per_call = elapsed_time / current->call_count;
+
+                                                       LOG(" %-42.42s : %10d call(s), %10.2f ms, %9.2f ms/API\n",
+                                                           current->name, current->call_count, elapsed_time, elapsed_time_per_call);
+                                               }
+                                               current = current->next;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++)
+       {
+               if (ftd_table[i] != NULL)
+               {
+                       Trace_Data *current = ftd_table[i];
+
+                       while (current != NULL)
+                       {
+                               current->last_call_count = current->call_count;
+                               current->last_elapsed_time = current->elapsed_time;
+                               current = current->next;
+                       }
+               }
+       }
+
+       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+       LOG("\n");
+
+       goto finish;
+
+finish:
+       return;
+}
+
diff --git a/src/coregl_wrappath.c b/src/coregl_wrappath.c
new file mode 100644 (file)
index 0000000..bd83f00
--- /dev/null
@@ -0,0 +1,111 @@
+#include "coregl_wrappath.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+typedef struct _GLGlueFakeContext
+{
+       GLuint gl_num_tex_units[1];
+       GLuint gl_num_vertex_attribs[1];
+} GLGlueFakeContext;
+
+GLGlueFakeContext initial_fake_ctx_real;
+GLGlueFakeContext *initial_fake_ctx = &initial_fake_ctx_real;
+
+
+static void
+_get_texture_states(GLenum pname, GLint *params)
+{
+       GLuint cur_active_tex = 0;
+
+       AST(initial_fake_ctx != NULL);
+
+       _sym_glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *)&cur_active_tex);
+       int i;
+       for (i = 0; i < initial_fake_ctx->gl_num_tex_units[0]; i++)
+       {
+               _sym_glActiveTexture(GL_TEXTURE0 + i);
+               _sym_glGetIntegerv(pname, &(((GLint *)params)[i]));
+       }
+       _sym_glActiveTexture(cur_active_tex);
+}
+
+void
+dump_wrap_context_states(int force_output)
+{
+       static struct timeval tv_last = { 0, 0 };
+
+
+       _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint *)initial_fake_ctx->gl_num_tex_units);
+       _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)initial_fake_ctx->gl_num_vertex_attribs);
+
+       {
+               char *fp_env = NULL;
+               int fp_envi = 0;
+               fp_env = getenv("COREGL_TRACE_STATE");
+               if (fp_env) fp_envi = atoi(fp_env);
+               else fp_envi = 0;
+               if (fp_envi == 0) return;
+       }
+
+       if (!force_output)
+       {
+               struct timeval tv_now = { 0, 0 };
+               AST(gettimeofday(&tv_now, NULL) == 0);
+               if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC)
+               {
+                       goto finish;
+               }
+               tv_last = tv_now;
+       }
+
+       LOG("\n");
+       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
+       LOG("\E[0;32;1m  State info \E[1;37;1m: (CURRENT BINDED CONTEXT)\E[0m\n");
+       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
+
+#define PRINTF_CHAR_GLenum "%10d"
+#define PRINTF_CHAR_GLboolean "%10d"
+#define PRINTF_CHAR_GLint "%10d"
+#define PRINTF_CHAR_GLsizei "%10u"
+#define PRINTF_CHAR_GLuint "%10u"
+#define PRINTF_CHAR_GLuintmask "0x%8X"
+
+#define PRINTF_CHAR_GLclampf "%10.6f"
+#define PRINTF_CHAR_GLfloat "%10.6f"
+
+#define PRINTF_CHAR_GLvoidptr "%10p"
+
+#define PRINTF_CHAR(type) PRINTF_CHAR_##type
+
+#define INITIAL_CTX initial_fake_ctx
+
+#define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT)  \
+   { \
+      TYPE valuedata[SIZE]; \
+      TYPE *value = NULL; \
+      value = valuedata; GET_STMT; value = valuedata; \
+      LOG("\E[0;37;1m %-30.30s : (\E[0m ", #NAME); \
+      for (int i = 0; i < SIZE; i++) \
+      { \
+         if (i > 0) { \
+            if (i % 4 == 0) \
+               LOG("\n %-30.30s     ", "");\
+            else \
+               LOG(", "); \
+         } \
+         LOG("["PRINTF_CHAR(TYPE)"]", value[i]); \
+      } \
+      LOG(" \E[0;37;1m)\E[0m\n"); \
+   }
+# include "coregl_fastpath_state.h"
+#undef GLUE_STATE
+
+       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
+       LOG("\n");
+
+finish:
+       return;
+}
+
diff --git a/src/coregl_wrappath.h b/src/coregl_wrappath.h
new file mode 100644 (file)
index 0000000..55d0626
--- /dev/null
@@ -0,0 +1,5 @@
+\r
+#include "coregl_internal.h"\r
+\r
+extern void dump_wrap_context_states(int force_output);\r
+\r
diff --git a/src/coregl_wrappath_egl.c b/src/coregl_wrappath_egl.c
new file mode 100644 (file)
index 0000000..3f543ec
--- /dev/null
@@ -0,0 +1,552 @@
+#include "coregl_wrappath.h"
+
+EGLint
+eglGetError(void)
+{
+       EGLint ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetError();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLDisplay
+eglGetDisplay(EGLNativeDisplayType display_id)
+{
+       EGLDisplay ret = EGL_NO_DISPLAY;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetDisplay(display_id);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglInitialize(dpy, major, minor);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglTerminate(EGLDisplay dpy)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglTerminate(dpy);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetConfigs(dpy, configs, config_size, num_config);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetConfigAttrib(dpy, config, attribute, value);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+
+EGLSurface
+eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list)
+{
+       EGLSurface ret = EGL_NO_SURFACE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglCreateWindowSurface(dpy, config, win, attrib_list);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLSurface
+eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+{
+       EGLSurface ret = EGL_NO_SURFACE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglCreatePbufferSurface(dpy, config, attrib_list);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLSurface
+eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list)
+{
+       EGLSurface ret = EGL_NO_SURFACE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglDestroySurface(dpy, surface);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglQuerySurface(dpy, surface, attribute, value);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglBindAPI(EGLenum api)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglBindAPI(api);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLenum
+eglQueryAPI(void)
+{
+       EGLenum ret = 0;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglQueryAPI();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglWaitClient(void)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglWaitClient();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglReleaseThread(void)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglReleaseThread();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLSurface
+eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+{
+       EGLSurface ret = EGL_NO_SURFACE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglSurfaceAttrib(dpy, surface, attribute, value);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_eglBindTexImage(dpy, surface, buffer);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+EGLBoolean
+eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglReleaseTexImage(dpy, surface, buffer);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglSwapInterval(EGLDisplay dpy, EGLint interval)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglSwapInterval(dpy, interval);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLContext
+eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
+{
+       EGLContext ret = EGL_NO_CONTEXT;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglCreateContext(dpy, config, share_context, attrib_list);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglDestroyContext(dpy, ctx);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglMakeCurrent(dpy, draw, read, ctx);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+#ifdef COREGL_TRACE_STATE_INFO
+       if (glsym_eglMakeCurrent != fpgl_eglMakeCurrent)
+               dump_wrap_context_states(0);
+#endif // COREGL_TRACE_STATE_INFO
+       return ret;
+}
+
+EGLContext
+eglGetCurrentContext(void)
+{
+       EGLContext ret = EGL_NO_CONTEXT;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetCurrentContext();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLSurface
+eglGetCurrentSurface(EGLint readdraw)
+{
+       EGLSurface ret = EGL_NO_SURFACE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetCurrentSurface(readdraw);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLDisplay
+eglGetCurrentDisplay(void)
+{
+       EGLDisplay ret = EGL_NO_DISPLAY;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetCurrentDisplay();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglQueryContext(dpy, ctx, attribute, value);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglWaitGL(void)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglWaitGL();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglWaitNative(EGLint engine)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglWaitNative(engine);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglSwapBuffers(dpy, surface);
+
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       _COREGL_TRACE_API_OUTPUT(0);
+       return ret;
+}
+
+EGLBoolean
+eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+{
+       EGLBoolean ret = EGL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglCopyBuffers(dpy, surface, target);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+_eng_fn
+eglGetProcAddress(const char* procname)
+{
+       _eng_fn ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetProcAddress(procname);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+const char *
+eglQueryString(EGLDisplay dpy, EGLint name)
+{
+       const char *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglQueryString(dpy, name);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLImageKHR
+eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+       void *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
+{
+       unsigned int ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglDestroyImageKHR(dpy, image);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void *
+eglMapImageSEC(EGLDisplay dpy, EGLImageKHR image)
+{
+       void *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglMapImageSEC(dpy, image);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglUnmapImageSEC(EGLDisplay dpy, EGLImageKHR image)
+{
+       unsigned int ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglUnmapImageSEC(dpy, image);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+EGLBoolean
+eglGetImageAttribSEC(EGLDisplay dpy, EGLImageKHR image, EGLint attribute, EGLint *value)
+{
+       unsigned int ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_eglGetImageAttribSEC(dpy, image, attribute, value);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
diff --git a/src/coregl_wrappath_gl.c b/src/coregl_wrappath_gl.c
new file mode 100644 (file)
index 0000000..ac62c4b
--- /dev/null
@@ -0,0 +1,1861 @@
+#include "coregl_wrappath.h"
+
+void
+glActiveTexture(GLenum texture)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glActiveTexture(texture);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glAttachShader(GLuint program, GLuint shader)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glAttachShader(program, shader);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBindAttribLocation(GLuint program, GLuint index, const char* name)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBindAttribLocation(program, index, name);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBindBuffer(GLenum target, GLuint buffer)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBindBuffer(target, buffer);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBindFramebuffer(GLenum target, GLuint framebuffer)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBindFramebuffer(target, framebuffer);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBindRenderbuffer(target, renderbuffer);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBindTexture(GLenum target, GLuint texture)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBindTexture(target, texture);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBlendColor(red, green, blue, alpha);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBlendEquation(GLenum mode)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBlendEquation(mode);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBlendEquationSeparate(modeRGB, modeAlpha);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBlendFunc(sfactor, dfactor);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBufferData(target, size, data, usage);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glBufferSubData(target, offset, size, data);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+GLenum
+glCheckFramebufferStatus(GLenum target)
+{
+       GLenum ret = GL_NONE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glCheckFramebufferStatus(target);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glClear(GLbitfield mask)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glClear(mask);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glClearColor(red, green, blue, alpha);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glClearDepthf(GLclampf depth)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glClearDepthf(depth);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glClearStencil(GLint s)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glClearStencil(s);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glColorMask(red, green, blue, alpha);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glCompileShader(GLuint shader)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glCompileShader(shader);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+GLuint
+glCreateProgram(void)
+{
+       GLuint ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glCreateProgram();
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLuint
+glCreateShader(GLenum type)
+{
+       GLuint ret = _COREGL_INT_INIT_VALUE;
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glCreateShader(type);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glCullFace(GLenum mode)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glCullFace(mode);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDeleteBuffers(GLsizei n, const GLuint* buffers)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDeleteBuffers(n, buffers);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDeleteFramebuffers(n, framebuffers);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDeleteProgram(GLuint program)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDeleteProgram(program);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDeleteRenderbuffers(n, renderbuffers);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDeleteShader(GLuint shader)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDeleteShader(shader);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDeleteTextures(GLsizei n, const GLuint* textures)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDeleteTextures(n, textures);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDepthFunc(GLenum func)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDepthFunc(func);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDepthMask(GLboolean flag)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDepthMask(flag);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDepthRangef(GLclampf zNear, GLclampf zFar)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDepthRangef(zNear, zFar);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDetachShader(GLuint program, GLuint shader)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDetachShader(program, shader);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDisable(GLenum cap)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDisable(cap);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDisableVertexAttribArray(GLuint index)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDisableVertexAttribArray(index);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDrawArrays(mode, first, count);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glDrawElements(mode, count, type, indices);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glEnable(GLenum cap)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glEnable(cap);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glEnableVertexAttribArray(GLuint index)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glEnableVertexAttribArray(index);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glFinish(void)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glFinish();
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       _COREGL_TRACE_API_OUTPUT(0);
+}
+
+void
+glFlush(void)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glFlush();
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       _COREGL_TRACE_API_OUTPUT(0);
+}
+
+void
+glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glFramebufferTexture2D(target, attachment, textarget, texture, level);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glFrontFace(GLenum mode)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glFrontFace(mode);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetVertexAttribfv(index, pname, params);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetVertexAttribiv(index, pname, params);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetVertexAttribPointerv(index, pname, pointer);
+
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glHint(GLenum target, GLenum mode)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glHint(target, mode);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGenBuffers(GLsizei n, GLuint* buffers)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGenBuffers(n, buffers);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGenerateMipmap(GLenum target)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGenerateMipmap(target);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGenFramebuffers(GLsizei n, GLuint* framebuffers)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGenFramebuffers(n, framebuffers);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGenRenderbuffers(n, renderbuffers);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGenTextures(GLsizei n, GLuint* textures)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGenTextures(n, textures);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetActiveAttrib(program, index, bufsize, length, size, type, name);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetActiveUniform(program, index, bufsize, length, size, type, name);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetAttachedShaders(program, maxcount, count, shaders);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+int
+glGetAttribLocation(GLuint program, const char* name)
+{
+       int ret = _COREGL_INT_INIT_VALUE;
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glGetAttribLocation(program, name);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glGetBooleanv(GLenum pname, GLboolean* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetBooleanv(pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetBufferParameteriv(target, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+GLenum
+glGetError(void)
+{
+       GLenum ret = GL_NONE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glGetError();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glGetFloatv(GLenum pname, GLfloat* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetFloatv(pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetIntegerv(GLenum pname, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetIntegerv(pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetProgramiv(GLuint program, GLenum pname, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetProgramiv(program, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetProgramInfoLog(program, bufsize, length, infolog);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetRenderbufferParameteriv(target, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetShaderiv(shader, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetShaderInfoLog(shader, bufsize, length, infolog);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+#ifndef _COREGL_DESKTOP_GL
+       glsym_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
+
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetShaderSource(shader, bufsize, length, source);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+const GLubyte *
+glGetString(GLenum name)
+{
+       const GLubyte *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glGetString(name);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetTexParameterfv(target, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetTexParameteriv(target, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetUniformfv(GLuint program, GLint location, GLfloat* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetUniformfv(program, location, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetUniformiv(GLuint program, GLint location, GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetUniformiv(program, location, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+int
+glGetUniformLocation(GLuint program, const char* name)
+{
+       int ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glGetUniformLocation(program, name);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLboolean
+glIsBuffer(GLuint buffer)
+{
+       GLboolean ret = GL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glIsBuffer(buffer);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLboolean
+glIsEnabled(GLenum cap)
+{
+       GLboolean ret = GL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glIsEnabled(cap);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLboolean
+glIsFramebuffer(GLuint framebuffer)
+{
+       GLboolean ret = GL_FALSE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glIsFramebuffer(framebuffer);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLboolean
+glIsProgram(GLuint program)
+{
+       GLboolean ret;
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glIsProgram(program);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLboolean
+glIsRenderbuffer(GLuint renderbuffer)
+{
+       GLboolean ret;
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glIsRenderbuffer(renderbuffer);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLboolean
+glIsShader(GLuint shader)
+{
+       GLboolean ret;
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glIsShader(shader);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLboolean
+glIsTexture(GLuint texture)
+{
+       GLboolean ret;
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glIsTexture(texture);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glLineWidth(GLfloat width)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glLineWidth(width);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glLinkProgram(GLuint program)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glLinkProgram(program);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glPixelStorei(GLenum pname, GLint param)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glPixelStorei(pname, param);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glPolygonOffset(GLfloat factor, GLfloat units)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glPolygonOffset(factor, units);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glReadPixels(x, y, width, height, format, type, pixels);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glReleaseShaderCompiler(void)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+#ifndef _COREGL_DESKTOP_GL
+       glsym_glReleaseShaderCompiler();
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+#else
+       //FIXME!!! need something here?
+
+#endif
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glRenderbufferStorage(target, internalformat, width, height);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glSampleCoverage(GLclampf value, GLboolean invert)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glSampleCoverage(value, invert);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glScissor(x, y, width, height);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+#ifndef _COREGL_DESKTOP_GL
+       glsym_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
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glShaderSource(shader, count, string, length);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glStencilFunc(func, ref, mask);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glStencilFuncSeparate(face, func, ref, mask);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glStencilMask(GLuint mask)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glStencilMask(mask);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glStencilMaskSeparate(GLenum face, GLuint mask)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glStencilMaskSeparate(face, mask);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glStencilOp(fail, zfail, zpass);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glStencilOpSeparate(face, fail, zfail, zpass);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glTexParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glTexParameterf(target, pname, param);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glTexParameterfv(target, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glTexParameteri(GLenum target, GLenum pname, GLint param)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glTexParameteri(target, pname, param);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glTexParameteriv(target, pname, params);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform1f(GLint location, GLfloat x)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform1f(location, x);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform1fv(location, count, v);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform1i(GLint location, GLint x)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform1i(location, x);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform1iv(GLint location, GLsizei count, const GLint* v)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform1iv(location, count, v);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform2f(GLint location, GLfloat x, GLfloat y)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform2f(location, x, y);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform2fv(location, count, v);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform2i(GLint location, GLint x, GLint y)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform2i(location, x, y);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform2iv(GLint location, GLsizei count, const GLint* v)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform2iv(location, count, v);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform3f(location, x, y, z);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform3fv(location, count, v);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform3i(GLint location, GLint x, GLint y, GLint z)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform3i(location, x, y, z);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform3iv(GLint location, GLsizei count, const GLint* v)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform3iv(location, count, v);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform4f(location, x, y, z, w);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform4fv(location, count, v);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform4i(location, x, y, z, w);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniform4iv(GLint location, GLsizei count, const GLint* v)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniform4iv(location, count, v);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniformMatrix2fv(location, count, transpose, value);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniformMatrix3fv(location, count, transpose, value);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUniformMatrix4fv(location, count, transpose, value);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glUseProgram(GLuint program)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glUseProgram(program);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glValidateProgram(GLuint program)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glValidateProgram(program);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttrib1f(GLuint indx, GLfloat x)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttrib1f(indx, x);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttrib1fv(GLuint indx, const GLfloat* values)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttrib1fv(indx, values);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttrib2f(indx, x, y);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttrib2fv(GLuint indx, const GLfloat* values)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttrib2fv(indx, values);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttrib3f(indx, x, y, z);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttrib3fv(GLuint indx, const GLfloat* values)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttrib3fv(indx, values);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttrib4f(indx, x, y, z, w);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttrib4fv(GLuint indx, const GLfloat* values)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttrib4fv(indx, values);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glViewport(x, y, width, height);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+
+// GLES Extensions...
+void
+glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glEGLImageTargetTexture2DOES(target, image);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glEGLImageTargetRenderbufferStorageOES(target, image);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glGetProgramBinary(program, bufsize, length, binaryFormat, binary);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glProgramBinary(program, binaryFormat, binary, length);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+
+void
+glProgramParameteri(GLuint program, GLuint pname, GLint value)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glProgramParameteri(program, pname, value);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glRenderbufferStorageMultisampleEXT(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, texture, level, samples);
+       GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
diff --git a/src/coregl_wrappath_glx.c b/src/coregl_wrappath_glx.c
new file mode 100644 (file)
index 0000000..200dd3d
--- /dev/null
@@ -0,0 +1,352 @@
+#include "coregl_wrappath.h"
+
+_eng_fn
+glXGetProcAddress(const char* procName)
+{
+       _eng_fn ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXGetProcAddress(procName);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+XVisualInfo*
+glXChooseVisual(Display* dpy, int screen, int* attribList)
+{
+       XVisualInfo *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXChooseVisual(dpy, screen, attribList);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLXContext
+glXCreateContext(Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct)
+{
+       GLXContext ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXCreateContext(dpy, vis, shareList, direct);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glXDestroyContext(Display* dpy, GLXContext ctx)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXDestroyContext(dpy, ctx);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+GLXContext
+glXGetCurrentContext(void)
+{
+       GLXContext ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXGetCurrentContext();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLXDrawable
+glXGetCurrentDrawable(void)
+{
+       GLXDrawable ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXGetCurrentDrawable();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+
+Bool
+glXMakeCurrent(Display* dpy, GLXDrawable draw, GLXContext ctx)
+{
+       Bool ret = False;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXMakeCurrent(dpy, draw, ctx);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glXSwapBuffers(Display* dpy, GLXDrawable draw)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXSwapBuffers(dpy, draw);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glXWaitX(void)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXWaitX();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glXWaitGL(void)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXWaitGL();
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+Bool
+glXQueryExtension(Display* dpy, int* errorb, int* event)
+{
+       Bool ret = False;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXQueryExtension(dpy, errorb, event);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+const char *
+glXQueryExtensionsString(Display *dpy, int screen)
+{
+       const char *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXQueryExtensionsString(dpy, screen);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLXFBConfig*
+glXChooseFBConfig(Display* dpy, int screen, const int* attribList, int* nitems)
+{
+       GLXFBConfig *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXChooseFBConfig(dpy, screen, attribList, nitems);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+GLXFBConfig*
+glXGetFBConfigs(Display* dpy, int screen, int* nelements)
+{
+       GLXFBConfig *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXGetFBConfigs(dpy, screen, nelements);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+//!!!!! FIXME Called too many times
+int
+glXGetFBConfigAttrib(Display* dpy, GLXFBConfig config, int attribute, int* value)
+{
+       int ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXGetFBConfigAttrib(dpy, config, attribute, value);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+//!!!!! FIXME Called too many times
+XVisualInfo*
+glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig config)
+{
+       XVisualInfo *ret = NULL;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXGetVisualFromFBConfig(dpy, config);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glXDestroyWindow(Display* dpy, GLXWindow window)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXDestroyWindow(dpy, window);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+Bool
+glXMakeContextCurrent(Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+{
+       Bool ret = False;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXMakeContextCurrent(dpy, draw, read, ctx);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glXBindTexImage(Display* dpy, GLXDrawable draw, int buffer, int* attribList)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXBindTexImage(dpy, draw, buffer, attribList);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glXReleaseTexImage(Display* dpy, GLXDrawable draw, int buffer)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXReleaseTexImage(dpy, draw, buffer);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+int
+glXGetVideoSync(unsigned int* count)
+{
+       int ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXGetVideoSync(count);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+int
+glXWaitVideoSync(int divisor, int remainder, unsigned int* count)
+{
+       int ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXWaitVideoSync(divisor, remainder, count);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+XID
+glXCreatePixmap(Display* dpy, void* config, Pixmap pixmap, const int* attribList)
+{
+       XID ret = None;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXCreatePixmap(dpy, config, pixmap, attribList);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glXDestroyPixmap(Display* dpy, XID pixmap)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXDestroyPixmap(dpy, pixmap);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+void
+glXQueryDrawable(Display* dpy, XID draw, int attribute, unsigned int* value)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXQueryDrawable(dpy, draw, attribute, value);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
+int
+glXSwapIntervalSGI(int interval)
+{
+       int ret = _COREGL_INT_INIT_VALUE;
+
+       _COREGL_WRAP_FUNC_BEGIN();
+       ret = glsym_glXSwapIntervalSGI(interval);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+       return ret;
+}
+
+void
+glXSwapIntervalEXT(Display* dpy, GLXDrawable draw, int interval)
+{
+       _COREGL_WRAP_FUNC_BEGIN();
+       glsym_glXSwapIntervalEXT(dpy, draw, interval);
+       goto finish;
+
+finish:
+       _COREGL_WRAP_FUNC_END();
+}
+
diff --git a/src/headers/egl.h b/src/headers/egl.h
new file mode 100644 (file)
index 0000000..6236e08
--- /dev/null
@@ -0,0 +1,212 @@
+//------------------------------------------------------//
+//                         EGL
+//------------------------------------------------------//
+
+/* EGL Types */
+/* EGLint is defined in eglplatform.h */
+
+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_KHR_image
+#define EGL_KHR_image 1
+#define EGL_NATIVE_PIXMAP_KHR                  0x30B0  /* eglCreateImageKHR target */
+typedef void *EGLImageKHR;
+#define EGL_NO_IMAGE_KHR                       ((EGLImageKHR)0)
+#endif
+
diff --git a/src/headers/gl.h b/src/headers/gl.h
new file mode 100644 (file)
index 0000000..e7b8145
--- /dev/null
@@ -0,0 +1,519 @@
+/*
+ * 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_EGL_image */
+#ifndef GL_OES_EGL_image
+typedef void* GLeglImageOES;
+#endif
+
+#ifndef EGL_SEC_image_map
+#define EGL_SEC_image_map 1
+#define EGL_MAP_GL_TEXTURE_2D_SEC                              0x3201  /* eglCreateImageKHR target */
+#define EGL_MAP_GL_TEXTURE_HEIGHT_SEC                  0x3202  /* eglCreateImageKHR attribute */
+#define EGL_MAP_GL_TEXTURE_WIDTH_SEC                   0x3203  /* eglCreateImageKHR attribute */
+#define EGL_MAP_GL_TEXTURE_FORMAT_SEC                  0x3204  /* eglCreateImageKHR attribute, Specifies the number of color components in the mapped texture. */
+#define EGL_MAP_GL_TEXTURE_RGB_SEC                             0x3205  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_RGBA_SEC                            0x3206  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_BGRA_SEC                            0x3207  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_LUMINANCE_SEC               0x3208  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_LUMINANCE_ALPHA_SEC         0x3209  /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */
+#define EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC              0x320a  /* eglCreateImageKHR attribute, Specifies the data type of the pixel data. */
+#define EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC   0x320b  /* More config attribute value, for EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC */
+#define EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC  0x320c /* GetImageAttribSEC target */
+#endif
+
+
+/* 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
+
diff --git a/src/headers/glx.h b/src/headers/glx.h
new file mode 100644 (file)
index 0000000..b88fa7e
--- /dev/null
@@ -0,0 +1,183 @@
+//------------------------------------------------------//
+//                         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
+
+
diff --git a/src/headers/sym.h b/src/headers/sym.h
new file mode 100644 (file)
index 0000000..4f7ab6b
--- /dev/null
@@ -0,0 +1,10 @@
+// Include all symbols\r
+\r
+#include "sym_gl.h"\r
+\r
+#ifndef _COREGL_DESKTOP_GL\r
+# include "sym_egl.h"\r
+#else\r
+# include "sym_glx.h"\r
+#endif\r
+\r
diff --git a/src/headers/sym_egl.h b/src/headers/sym_egl.h
new file mode 100644 (file)
index 0000000..17ed9d6
--- /dev/null
@@ -0,0 +1,65 @@
+// Defult use-case for exporting symbols
+#ifndef _COREGL_SYMBOL
+#define _COREGL_SYMBOL_NOT_DEFINED
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     extern RET_TYPE (*_COREGL_NAME_MANGLE(FUNC_NAME)) PARAM_LIST;
+#endif
+
+// Standard EGL APIs
+
+_COREGL_SYMBOL(GL_FALSE, EGLint, eglGetError, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLDisplay, eglGetDisplay, (EGLNativeDisplayType display_id))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglInitialize, (EGLDisplay dpy, EGLint* major, EGLint *minor))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglTerminate, (EGLDisplay dpy))
+_COREGL_SYMBOL(GL_FALSE, const char*, eglQueryString, (EGLDisplay dpy, EGLint name))
+
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglGetConfigs, (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglChooseConfig, (EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglGetConfigAttrib, (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value))
+
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglCreateWindowSurface, (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list))
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglCreatePbufferSurface, (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list))
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglCreatePixmapSurface, (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglDestroySurface, (EGLDisplay dpy, EGLSurface surface))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglQuerySurface, (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value))
+
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglBindAPI, (EGLenum api))
+_COREGL_SYMBOL(GL_FALSE, EGLenum, eglQueryAPI, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglWaitClient, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglReleaseThread, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglCreatePbufferFromClientBuffer, (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list))
+
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglSurfaceAttrib, (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value))
+_COREGL_SYMBOL(GL_FALSE, void, eglBindTexImage, (EGLDisplay dpy, EGLSurface surface, EGLint buffer))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglReleaseTexImage, (EGLDisplay dpy, EGLSurface surface, EGLint buffer))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglSwapInterval, (EGLDisplay dpy, EGLint interval))
+_COREGL_SYMBOL(GL_FALSE, EGLContext, eglCreateContext, (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglDestroyContext, (EGLDisplay dpy, EGLContext ctx))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglMakeCurrent, (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx))
+_COREGL_SYMBOL(GL_FALSE, EGLContext, eglGetCurrentContext, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLSurface, eglGetCurrentSurface, (EGLint readdraw))
+_COREGL_SYMBOL(GL_FALSE, EGLDisplay, eglGetCurrentDisplay, (void))
+
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglQueryContext, (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglWaitGL, (void))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglWaitNative, (EGLint engine))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglSwapBuffers, (EGLDisplay dpy, EGLSurface surface))
+_COREGL_SYMBOL(GL_FALSE, EGLBoolean, eglCopyBuffers, (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target))
+
+_COREGL_SYMBOL(GL_FALSE, _eng_fn, eglGetProcAddress, (const char* procname))
+
+
+// Extensions
+_COREGL_SYMBOL(GL_TRUE, EGLImageKHR, eglCreateImageKHR, (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list))
+_COREGL_SYMBOL(GL_TRUE, EGLBoolean, eglDestroyImageKHR, (EGLDisplay dpy, EGLImageKHR image))
+
+_COREGL_SYMBOL(GL_TRUE, void*, eglMapImageSEC, (EGLDisplay dpy, EGLImageKHR image))
+_COREGL_SYMBOL(GL_TRUE, EGLBoolean, eglUnmapImageSEC, (EGLDisplay dpy, EGLImageKHR image))
+_COREGL_SYMBOL(GL_TRUE, EGLBoolean, eglGetImageAttribSEC, (EGLDisplay dpy, EGLImageKHR image, EGLint attribute, EGLint *value))
+
+//_COREGL_SYMBOL(GL_FALSE, unsigned int, eglLockSurface, (EGLDisplay a, EGLSurface b, const int *attrib_list))
+//_COREGL_SYMBOL(GL_FALSE, unsigned int, eglUnlockSurface, (EGLDisplay a, EGLSurface b))
+
+#ifdef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL
+#endif
diff --git a/src/headers/sym_gl.h b/src/headers/sym_gl.h
new file mode 100644 (file)
index 0000000..23247a5
--- /dev/null
@@ -0,0 +1,172 @@
+// Defult use-case for exporting symbols
+#ifndef _COREGL_SYMBOL
+#define _COREGL_SYMBOL_NOT_DEFINED
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     extern RET_TYPE (*_COREGL_NAME_MANGLE(FUNC_NAME)) PARAM_LIST;
+#endif
+
+/* version 1: */
+_COREGL_SYMBOL(GL_FALSE, void, glActiveTexture, (GLenum texture))
+_COREGL_SYMBOL(GL_FALSE, void, glAttachShader, (GLuint program, GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, void, glBindAttribLocation, (GLuint program, GLuint index, const char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glBindBuffer, (GLenum target, GLuint buffer))
+_COREGL_SYMBOL(GL_FALSE, void, glBindFramebuffer, (GLenum target, GLuint framebuffer))
+_COREGL_SYMBOL(GL_FALSE, void, glBindRenderbuffer, (GLenum target, GLuint renderbuffer))
+_COREGL_SYMBOL(GL_FALSE, void, glBindTexture, (GLenum target, GLuint texture))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendEquation, ( GLenum mode ))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendEquationSeparate, (GLenum modeRGB, GLenum modeAlpha))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendFunc, (GLenum sfactor, GLenum dfactor))
+_COREGL_SYMBOL(GL_FALSE, void, glBlendFuncSeparate, (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha))
+_COREGL_SYMBOL(GL_FALSE, void, glBufferData, (GLenum target, GLsizeiptr size, const void* data, GLenum usage))
+_COREGL_SYMBOL(GL_FALSE, void, glBufferSubData, (GLenum target, GLintptr offset, GLsizeiptr size, const void* data))
+_COREGL_SYMBOL(GL_FALSE, GLenum, glCheckFramebufferStatus, (GLenum target))
+_COREGL_SYMBOL(GL_FALSE, void, glClear, (GLbitfield mask))
+_COREGL_SYMBOL(GL_FALSE, void, glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
+#ifndef _COREGL_DESKTOP_GL
+_COREGL_SYMBOL(GL_FALSE, void, glClearDepthf, (GLclampf depth))
+#else
+_COREGL_SYMBOL(GL_FALSE, void, glClearDepth, (GLclampf depth))
+#endif
+_COREGL_SYMBOL(GL_FALSE, void, glClearStencil, (GLint s))
+_COREGL_SYMBOL(GL_FALSE, void, glColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha))
+_COREGL_SYMBOL(GL_FALSE, void, glCompileShader, (GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, void, glCompressedTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data))
+_COREGL_SYMBOL(GL_FALSE, void, glCompressedTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data))
+_COREGL_SYMBOL(GL_FALSE, void, glCopyTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border))
+_COREGL_SYMBOL(GL_FALSE, void, glCopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height))
+_COREGL_SYMBOL(GL_FALSE, GLuint, glCreateProgram, (void))
+_COREGL_SYMBOL(GL_FALSE, GLuint, glCreateShader, (GLenum type))
+_COREGL_SYMBOL(GL_FALSE, void, glCullFace, (GLenum mode))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteBuffers, (GLsizei n, const GLuint* buffers))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteFramebuffers, (GLsizei n, const GLuint* framebuffers))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteRenderbuffers, (GLsizei n, const GLuint* renderbuffers))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteShader, (GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, void, glDeleteTextures, (GLsizei n, const GLuint* textures))
+_COREGL_SYMBOL(GL_FALSE, void, glDepthFunc, (GLenum func))
+_COREGL_SYMBOL(GL_FALSE, void, glDepthMask, (GLboolean flag))
+#ifndef _COREGL_DESKTOP_GL
+_COREGL_SYMBOL(GL_FALSE, void, glDepthRangef, (GLclampf zNear, GLclampf zFar))
+#else
+_COREGL_SYMBOL(GL_FALSE, void, glDepthRange, (GLclampf zNear, GLclampf zFar))
+#endif
+_COREGL_SYMBOL(GL_FALSE, void, glDetachShader, (GLuint program, GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, void, glDisable, (GLenum cap))
+_COREGL_SYMBOL(GL_FALSE, void, glDisableVertexAttribArray, (GLuint index))
+_COREGL_SYMBOL(GL_FALSE, void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
+_COREGL_SYMBOL(GL_FALSE, void, glDrawElements, (GLenum mode, GLsizei count, GLenum type, const void* indices))
+_COREGL_SYMBOL(GL_FALSE, void, glEnable, (GLenum cap))
+_COREGL_SYMBOL(GL_FALSE, void, glEnableVertexAttribArray, (GLuint index))
+_COREGL_SYMBOL(GL_FALSE, void, glFinish, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glFlush, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glFramebufferRenderbuffer, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer))
+_COREGL_SYMBOL(GL_FALSE, void, glFramebufferTexture2D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level))
+_COREGL_SYMBOL(GL_FALSE, void, glFrontFace, (GLenum mode))
+_COREGL_SYMBOL(GL_FALSE, void, glGenBuffers, (GLsizei n, GLuint* buffers))
+_COREGL_SYMBOL(GL_FALSE, void, glGenerateMipmap, (GLenum target))
+_COREGL_SYMBOL(GL_FALSE, void, glGenFramebuffers, (GLsizei n, GLuint* framebuffers))
+_COREGL_SYMBOL(GL_FALSE, void, glGenRenderbuffers, (GLsizei n, GLuint* renderbuffers))
+_COREGL_SYMBOL(GL_FALSE, void, glGenTextures, (GLsizei n, GLuint* textures))
+_COREGL_SYMBOL(GL_FALSE, void, glGetActiveAttrib, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetActiveUniform, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetAttachedShaders, (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders))
+_COREGL_SYMBOL(GL_FALSE, int, glGetAttribLocation, (GLuint program, const char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetBooleanv, (GLenum pname, GLboolean* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetBufferParameteriv, (GLenum target, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, GLenum, glGetError, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glGetFloatv, (GLenum pname, GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetFramebufferAttachmentParameteriv, (GLenum target, GLenum attachment, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetIntegerv, (GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetProgramiv, (GLuint program, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetProgramInfoLog, (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog))
+_COREGL_SYMBOL(GL_FALSE, void, glGetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetShaderiv, (GLuint shader, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetShaderInfoLog, (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog))
+_COREGL_SYMBOL(GL_FALSE, void, glGetShaderPrecisionFormat, (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision))
+_COREGL_SYMBOL(GL_FALSE, void, glGetShaderSource, (GLuint shader, GLsizei bufsize, GLsizei* length, char* source))
+_COREGL_SYMBOL(GL_FALSE, const GLubyte *, glGetString, (GLenum name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetTexParameterfv, (GLenum target, GLenum pname, GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetTexParameteriv, (GLenum target, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetUniformfv, (GLuint program, GLint location, GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetUniformiv, (GLuint program, GLint location, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, int, glGetUniformLocation, (GLuint program, const char* name))
+_COREGL_SYMBOL(GL_FALSE, void, glGetVertexAttribfv, (GLuint index, GLenum pname, GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetVertexAttribiv, (GLuint index, GLenum pname, GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glGetVertexAttribPointerv, (GLuint index, GLenum pname, void** pointer))
+_COREGL_SYMBOL(GL_FALSE, void, glHint, (GLenum target, GLenum mode))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsBuffer, (GLuint buffer))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsEnabled, (GLenum cap))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsFramebuffer, (GLuint framebuffer))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsRenderbuffer, (GLuint renderbuffer))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsShader, (GLuint shader))
+_COREGL_SYMBOL(GL_FALSE, GLboolean, glIsTexture, (GLuint texture))
+_COREGL_SYMBOL(GL_FALSE, void, glLineWidth, (GLfloat width))
+_COREGL_SYMBOL(GL_FALSE, void, glLinkProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, void, glPixelStorei, (GLenum pname, GLint param))
+_COREGL_SYMBOL(GL_FALSE, void, glPolygonOffset, (GLfloat factor, GLfloat units))
+_COREGL_SYMBOL(GL_FALSE, void, glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels))
+_COREGL_SYMBOL(GL_FALSE, void, glReleaseShaderCompiler, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glRenderbufferStorage, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height))
+_COREGL_SYMBOL(GL_FALSE, void, glSampleCoverage, (GLclampf value, GLboolean invert))
+_COREGL_SYMBOL(GL_FALSE, void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
+_COREGL_SYMBOL(GL_FALSE, void, glShaderBinary, (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length))
+_COREGL_SYMBOL(GL_FALSE, void, glShaderSource, (GLuint shader, GLsizei count, const char** string, const GLint* length))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilFuncSeparate, (GLenum face, GLenum func, GLint ref, GLuint mask))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilMask, (GLuint mask))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilMaskSeparate, (GLenum face, GLuint mask))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
+_COREGL_SYMBOL(GL_FALSE, void, glStencilOpSeparate, (GLenum face, GLenum fail, GLenum zfail, GLenum zpass))
+_COREGL_SYMBOL(GL_FALSE, void, glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels))
+_COREGL_SYMBOL(GL_FALSE, void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param))
+_COREGL_SYMBOL(GL_FALSE, void, glTexParameterfv, (GLenum target, GLenum pname, const GLfloat* params))
+_COREGL_SYMBOL(GL_FALSE, void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
+_COREGL_SYMBOL(GL_FALSE, void, glTexParameteriv, (GLenum target, GLenum pname, const GLint* params))
+_COREGL_SYMBOL(GL_FALSE, void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform1f, (GLint location, GLfloat x))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform1fv, (GLint location, GLsizei count, const GLfloat* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform1i, (GLint location, GLint x))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform1iv, (GLint location, GLsizei count, const GLint* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform2f, (GLint location, GLfloat x, GLfloat y))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform2fv, (GLint location, GLsizei count, const GLfloat* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform2i, (GLint location, GLint x, GLint y))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform2iv, (GLint location, GLsizei count, const GLint* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform3f, (GLint location, GLfloat x, GLfloat y, GLfloat z))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform3fv, (GLint location, GLsizei count, const GLfloat* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform3i, (GLint location, GLint x, GLint y, GLint z))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform3iv, (GLint location, GLsizei count, const GLint* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform4f, (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform4fv, (GLint location, GLsizei count, const GLfloat* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform4i, (GLint location, GLint x, GLint y, GLint z, GLint w))
+_COREGL_SYMBOL(GL_FALSE, void, glUniform4iv, (GLint location, GLsizei count, const GLint* v))
+_COREGL_SYMBOL(GL_FALSE, void, glUniformMatrix2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value))
+_COREGL_SYMBOL(GL_FALSE, void, glUniformMatrix3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value))
+_COREGL_SYMBOL(GL_FALSE, void, glUniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value))
+_COREGL_SYMBOL(GL_FALSE, void, glUseProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, void, glValidateProgram, (GLuint program))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib1f, (GLuint indx, GLfloat x))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib1fv, (GLuint indx, const GLfloat* values))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib2fv, (GLuint indx, const GLfloat* values))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib3f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib3fv, (GLuint indx, const GLfloat* values))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib4f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttrib4fv, (GLuint indx, const GLfloat* values))
+_COREGL_SYMBOL(GL_FALSE, void, glVertexAttribPointer, (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr))
+_COREGL_SYMBOL(GL_FALSE, void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
+
+/* Extensions */
+_COREGL_SYMBOL(GL_TRUE, void, glEGLImageTargetTexture2DOES, (GLenum target, GLeglImageOES image))
+_COREGL_SYMBOL(GL_TRUE, void, glEGLImageTargetRenderbufferStorageOES, (GLenum target, GLeglImageOES image))
+_COREGL_SYMBOL(GL_TRUE, void, glGetProgramBinary, (GLuint program, GLsizei bufsize, GLsizei *length, GLenum *binaryFormat, void *binary))
+_COREGL_SYMBOL(GL_TRUE, void, glProgramBinary, (GLuint program, GLenum binaryFormat, const void *binary, GLint length))
+_COREGL_SYMBOL(GL_TRUE, void, glProgramParameteri, (GLuint a, GLuint b, GLint d))
+_COREGL_SYMBOL(GL_TRUE, void, glRenderbufferStorageMultisampleEXT, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height))
+_COREGL_SYMBOL(GL_TRUE, void, glFramebufferTexture2DMultisampleEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples))
+
+#ifdef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL
+#endif
+
diff --git a/src/headers/sym_glx.h b/src/headers/sym_glx.h
new file mode 100644 (file)
index 0000000..2aaba66
--- /dev/null
@@ -0,0 +1,43 @@
+// Defult use-case for exporting symbols
+#ifndef _COREGL_SYMBOL
+#define _COREGL_SYMBOL_NOT_DEFINED
+#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     extern RET_TYPE (*_COREGL_NAME_MANGLE(FUNC_NAME)) PARAM_LIST;
+#endif
+
+_COREGL_SYMBOL(GL_FALSE, _eng_fn, glXGetProcAddress, (const char* procName))
+
+// Standard GL(glX) functions
+_COREGL_SYMBOL(GL_FALSE, XVisualInfo*, glXChooseVisual, (Display* dpy, int screen, int* attribList))
+_COREGL_SYMBOL(GL_FALSE, GLXContext, glXCreateContext, (Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct))
+_COREGL_SYMBOL(GL_FALSE, void, glXDestroyContext, (Display* dpy, GLXContext ctx))
+_COREGL_SYMBOL(GL_FALSE, GLXContext, glXGetCurrentContext, (void))
+_COREGL_SYMBOL(GL_FALSE, GLXDrawable, glXGetCurrentDrawable, (void))
+_COREGL_SYMBOL(GL_FALSE, Bool, glXMakeCurrent, (Display* dpy, GLXDrawable draw, GLXContext ctx))
+_COREGL_SYMBOL(GL_FALSE, void, glXSwapBuffers, (Display* dpy, GLXDrawable draw))
+_COREGL_SYMBOL(GL_FALSE, void, glXWaitX, (void))
+_COREGL_SYMBOL(GL_FALSE, void, glXWaitGL, (void))
+_COREGL_SYMBOL(GL_FALSE, Bool, glXQueryExtension, (Display* dpy, int* errorb, int* event))
+_COREGL_SYMBOL(GL_FALSE, const char*, glXQueryExtensionsString, (Display *dpy, int screen))
+
+_COREGL_SYMBOL(GL_FALSE, GLXFBConfig*, glXChooseFBConfig, (Display* dpy, int screen, const int* attribList, int* nitems))
+_COREGL_SYMBOL(GL_FALSE, GLXFBConfig*, glXGetFBConfigs, (Display* dpy, int screen, int* nelements))
+_COREGL_SYMBOL(GL_FALSE, int, glXGetFBConfigAttrib, (Display* dpy, GLXFBConfig config, int attribute, int* value))
+_COREGL_SYMBOL(GL_FALSE, XVisualInfo*, glXGetVisualFromFBConfig, (Display* dpy, GLXFBConfig config))
+_COREGL_SYMBOL(GL_FALSE, void, glXDestroyWindow, (Display* dpy, GLXWindow window))
+_COREGL_SYMBOL(GL_FALSE, Bool, glXMakeContextCurrent, (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx))
+
+_COREGL_SYMBOL(GL_FALSE, void, glXBindTexImage, (Display* dpy, GLXDrawable draw, int buffer, int* attribList))
+_COREGL_SYMBOL(GL_FALSE, void, glXReleaseTexImage, (Display* dpy, GLXDrawable draw, int buffer))
+_COREGL_SYMBOL(GL_FALSE, int, glXGetVideoSync, (unsigned int* count))
+_COREGL_SYMBOL(GL_FALSE, int, glXWaitVideoSync, (int divisor, int remainder, unsigned int* count))
+_COREGL_SYMBOL(GL_FALSE, XID, glXCreatePixmap, (Display* dpy, void* config, Pixmap pixmap, const int* attribList))
+_COREGL_SYMBOL(GL_FALSE, void, glXDestroyPixmap, (Display* dpy, XID pixmap))
+_COREGL_SYMBOL(GL_FALSE, void, glXQueryDrawable, (Display* dpy, XID draw, int attribute, unsigned int* value))
+_COREGL_SYMBOL(GL_FALSE, int, glXSwapIntervalSGI, (int interval))
+_COREGL_SYMBOL(GL_FALSE, void, glXSwapIntervalEXT, (Display* dpy, GLXDrawable draw, int interval))
+
+#ifdef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL_NOT_DEFINED
+#undef _COREGL_SYMBOL
+#endif
+