DEADSOFTWARE

Initial version
authorNicknekit <nyokda@yandex.ru>
Sun, 22 Mar 2015 14:09:16 +0000 (17:09 +0300)
committerNicknekit <nyokda@yandex.ru>
Sun, 22 Mar 2015 14:09:16 +0000 (17:09 +0300)
12 files changed:
.gitignore [new file with mode: 0644]
Android.mk [new file with mode: 0644]
GL/egl.h [new file with mode: 0644]
GL/gl.h [new file with mode: 0644]
GL/gl_entries.in [new file with mode: 0644]
GL/glesinterface.h [new file with mode: 0644]
GL/glu.h [new file with mode: 0644]
GL/nanogl.h [new file with mode: 0644]
README.md [new file with mode: 0644]
eglwrap.cpp [new file with mode: 0644]
nanoWrap.cpp [new file with mode: 0644]
nanogl.cpp [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..b25c15b
--- /dev/null
@@ -0,0 +1 @@
+*~
diff --git a/Android.mk b/Android.mk
new file mode 100644 (file)
index 0000000..ff7c50e
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE    := NanoGL
+
+LOCAL_CFLAGS := -O2
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/GL
+
+LOCAL_SRC_FILES := \
+       nanogl.cpp \
+       nanoWrap.cpp
+  
+
+include $(BUILD_STATIC_LIBRARY)
+
diff --git a/GL/egl.h b/GL/egl.h
new file mode 100644 (file)
index 0000000..cbbd7d1
--- /dev/null
+++ b/GL/egl.h
@@ -0,0 +1,192 @@
+#ifndef __EGL__H__
+#define __EGL__H__
+
+
+
+typedef int EGLBoolean;
+typedef int EGLint;
+typedef int EGLDisplay;
+typedef int EGLConfig;
+typedef int EGLSurface;
+typedef int EGLContext;
+
+typedef int NativeDisplayType;
+typedef void* NativeWindowType;
+typedef void* NativePixmapType;
+
+#define EGL_DEFAULT_DISPLAY 0
+#define EGL_NO_CONTEXT 0
+#define EGL_NO_DISPLAY 0
+#define EGL_NO_SURFACE 0
+
+/*
+** Versioning and extensions
+*/
+#define EGL_VERSION_1_0                1
+#define EGL_VERSION_1_1                       1
+
+/*
+** Boolean
+*/
+#define EGL_FALSE                      0
+#define EGL_TRUE                       1
+
+/*
+** Errors
+*/
+#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
+/* 0x300F - 0x301F reserved 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   /* Also a config value */
+#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
+
+/*
+** Config values
+*/
+#define EGL_DONT_CARE                 ((EGLint) -1)
+
+#define EGL_SLOW_CONFIG                       0x3050   /* EGL_CONFIG_CAVEAT value */
+#define EGL_NON_CONFORMANT_CONFIG      0x3051  /* " */
+#define EGL_TRANSPARENT_RGB           0x3052   /* EGL_TRANSPARENT_TYPE value */
+#define EGL_NO_TEXTURE                0x305C   /* EGL_TEXTURE_FORMAT/TARGET value */
+#define EGL_TEXTURE_RGB                       0x305D   /* EGL_TEXTURE_FORMAT value */
+#define EGL_TEXTURE_RGBA              0x305E   /* " */
+#define EGL_TEXTURE_2D                0x305F   /* EGL_TEXTURE_TARGET value */
+
+/*
+** Config attribute mask bits
+*/
+#define EGL_PBUFFER_BIT                       0x01     /* EGL_SURFACE_TYPE mask bit */
+#define EGL_PIXMAP_BIT                0x02     /* " */
+#define EGL_WINDOW_BIT                0x04     /* " */
+
+/*
+** String names
+*/
+#define EGL_VENDOR                     0x3053
+#define EGL_VERSION                    0x3054
+#define EGL_EXTENSIONS                 0x3055
+
+/*
+** Surface attributes
+*/
+#define EGL_HEIGHT                     0x3056
+#define EGL_WIDTH                      0x3057
+#define EGL_LARGEST_PBUFFER            0x3058
+#define EGL_TEXTURE_FORMAT            0x3080   /* For pbuffers bound as textures */
+#define EGL_TEXTURE_TARGET            0x3081   /* " */
+#define EGL_MIPMAP_TEXTURE            0x3082   /* " */
+#define EGL_MIPMAP_LEVEL              0x3083   /* " */
+
+/*
+** BindTexImage / ReleaseTexImage buffer target
+*/
+#define EGL_BACK_BUFFER                       0x3084
+
+/*
+** Current surfaces
+*/
+#define EGL_DRAW                       0x3059
+#define EGL_READ                       0x305A
+
+/*
+** Engines
+*/
+#define EGL_CORE_NATIVE_ENGINE         0x305B
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EGLint eglGetError (void);
+
+EGLDisplay eglGetDisplay (NativeDisplayType display);
+EGLBoolean eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
+EGLBoolean eglTerminate (EGLDisplay dpy);
+const char * eglQueryString (EGLDisplay dpy, EGLint name);
+//#ifdef __cplusplus
+//void (* eglGetProcAddress (const char *procname))(...);
+//#else
+void * eglGetProcAddress (const char *procname);
+//#endif
+
+EGLBoolean eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+EGLBoolean eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+EGLBoolean eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
+
+EGLSurface eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
+EGLSurface eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list);
+EGLSurface eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+EGLBoolean eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
+EGLBoolean eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
+/* EGL 1.1 render-to-texture APIs */
+EGLBoolean eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
+EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+
+/* EGL 1.1 swap control API */
+EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval);
+
+EGLContext eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
+EGLBoolean eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
+EGLBoolean eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+EGLContext eglGetCurrentContext (void);
+EGLSurface eglGetCurrentSurface (EGLint readdraw);
+EGLDisplay eglGetCurrentDisplay (void);
+EGLBoolean eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
+
+EGLBoolean eglWaitGL (void);
+EGLBoolean eglWaitNative (EGLint engine);
+EGLBoolean eglSwapBuffers (EGLDisplay dpy, EGLSurface draw);
+EGLBoolean eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, NativePixmapType target);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ___egl_h_ */
diff --git a/GL/gl.h b/GL/gl.h
new file mode 100644 (file)
index 0000000..5bdc472
--- /dev/null
+++ b/GL/gl.h
@@ -0,0 +1,700 @@
+#ifndef __GL__H__
+#define __GL__H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef signed char GLbyte;
+typedef short GLshort;
+typedef int GLint;
+typedef int GLsizei;
+typedef unsigned char GLubyte;
+typedef unsigned short GLushort;
+typedef unsigned int GLuint;
+typedef float GLfloat;
+typedef double GLdouble;
+typedef float GLclampf;
+typedef float GLclampd;
+typedef void GLvoid;
+typedef int GLfixed;
+typedef int GLclampx;
+
+/* Boolean values */
+#define GL_FALSE                               0x0
+#define GL_TRUE                                        0x1
+
+/* Data types */
+#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_2_BYTES                             0x1407
+#define GL_3_BYTES                             0x1408
+#define GL_4_BYTES                             0x1409
+#define GL_DOUBLE                              0x140A
+
+/* StringName */
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+
+/* TextureEnvMode */
+#define GL_MODULATE                       0x2100
+#define GL_DECAL                          0x2101
+/*      GL_BLEND */
+#define GL_ADD                            0x0104
+/*      GL_REPLACE */
+
+
+/* Primitives */
+#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
+#define GL_QUADS                               0x0007
+#define GL_QUAD_STRIP                          0x0008
+#define GL_POLYGON                             0x0009
+
+/* EnableCap */
+#define GL_FOG                            0x0B60
+#define GL_LIGHTING                       0x0B50
+#define GL_TEXTURE_2D                     0x0DE1
+#define GL_CULL_FACE                      0x0B44
+#define GL_ALPHA_TEST                     0x0BC0
+#define GL_BLEND                          0x0BE2
+#define GL_COLOR_LOGIC_OP                 0x0BF2
+#define GL_DITHER                         0x0BD0
+#define GL_STENCIL_TEST                   0x0B90
+#define GL_DEPTH_TEST                     0x0B71
+/*      GL_LIGHT0 */
+/*      GL_LIGHT1 */
+/*      GL_LIGHT2 */
+/*      GL_LIGHT3 */
+/*      GL_LIGHT4 */
+/*      GL_LIGHT5 */
+/*      GL_LIGHT6 */
+/*      GL_LIGHT7 */
+#define GL_POINT_SMOOTH                   0x0B10
+#define GL_LINE_SMOOTH                    0x0B20
+#define GL_SCISSOR_TEST                   0x0C11
+#define GL_COLOR_MATERIAL                 0x0B57
+#define GL_NORMALIZE                      0x0BA1
+#define GL_RESCALE_NORMAL                 0x803A
+#define GL_POLYGON_OFFSET_FILL            0x8037
+#define GL_VERTEX_ARRAY                   0x8074
+#define GL_NORMAL_ARRAY                   0x8075
+#define GL_COLOR_ARRAY                    0x8076
+#define GL_TEXTURE_COORD_ARRAY            0x8078
+#define GL_MULTISAMPLE                    0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE            0x809F
+#define GL_SAMPLE_COVERAGE                0x80A0
+
+
+/* Texture mapping */
+#define GL_TEXTURE_ENV                         0x2300
+#define GL_TEXTURE_ENV_MODE                    0x2200
+#define GL_TEXTURE_1D                          0x0DE0
+#define GL_TEXTURE_2D                          0x0DE1
+#define GL_TEXTURE_WRAP_S                      0x2802
+#define GL_TEXTURE_WRAP_T                      0x2803
+#define GL_TEXTURE_MAG_FILTER                  0x2800
+#define GL_TEXTURE_MIN_FILTER                  0x2801
+#define GL_TEXTURE_ENV_COLOR                   0x2201
+#define GL_TEXTURE_GEN_S                       0x0C60
+#define GL_TEXTURE_GEN_T                       0x0C61
+#define GL_TEXTURE_GEN_MODE                    0x2500
+#define GL_TEXTURE_BORDER_COLOR                        0x1004
+#define GL_TEXTURE_WIDTH                       0x1000
+#define GL_TEXTURE_HEIGHT                      0x1001
+#define GL_TEXTURE_BORDER                      0x1005
+#define GL_TEXTURE_COMPONENTS                  0x1003
+#define GL_TEXTURE_RED_SIZE                    0x805C
+#define GL_TEXTURE_GREEN_SIZE                  0x805D
+#define GL_TEXTURE_BLUE_SIZE                   0x805E
+#define GL_TEXTURE_ALPHA_SIZE                  0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE              0x8060
+#define GL_TEXTURE_INTENSITY_SIZE              0x8061
+#define GL_NEAREST_MIPMAP_NEAREST              0x2700
+#define GL_NEAREST_MIPMAP_LINEAR               0x2702
+#define GL_LINEAR_MIPMAP_NEAREST               0x2701
+#define GL_LINEAR_MIPMAP_LINEAR                        0x2703
+#define GL_OBJECT_LINEAR                       0x2401
+#define GL_OBJECT_PLANE                                0x2501
+#define GL_EYE_LINEAR                          0x2400
+#define GL_EYE_PLANE                           0x2502
+#define GL_SPHERE_MAP                          0x2402
+#define GL_DECAL                               0x2101
+#define GL_MODULATE                            0x2100
+#define GL_NEAREST                             0x2600
+#define GL_REPEAT                              0x2901
+#define GL_CLAMP                               0x2900
+#define GL_S                                   0x2000
+#define GL_T                                   0x2001
+#define GL_R                                   0x2002
+#define GL_Q                                   0x2003
+#define GL_TEXTURE_GEN_R                       0x0C62
+#define GL_TEXTURE_GEN_Q                       0x0C63
+#define GL_CLAMP_TO_EDGE                  0x812F
+
+/* Matrix Mode */
+#define GL_MATRIX_MODE                         0x0BA0
+#define GL_MODELVIEW                           0x1700
+#define GL_PROJECTION                          0x1701
+#define GL_TEXTURE                             0x1702
+
+/* Buffers, Pixel Drawing/Reading */
+#define GL_NONE                                        0x0
+#define GL_LEFT                                        0x0406
+#define GL_RIGHT                               0x0407
+/*GL_FRONT                                     0x0404 */
+/*GL_BACK                                      0x0405 */
+/*GL_FRONT_AND_BACK                            0x0408 */
+#define GL_FRONT_LEFT                          0x0400
+#define GL_FRONT_RIGHT                         0x0401
+#define GL_BACK_LEFT                           0x0402
+#define GL_BACK_RIGHT                          0x0403
+#define GL_AUX0                                        0x0409
+#define GL_AUX1                                        0x040A
+#define GL_AUX2                                        0x040B
+#define GL_AUX3                                        0x040C
+#define GL_COLOR_INDEX                         0x1900
+#define GL_RED                                 0x1903
+#define GL_GREEN                               0x1904
+#define GL_BLUE                                        0x1905
+#define GL_ALPHA                               0x1906
+#define GL_LUMINANCE                           0x1909
+#define GL_LUMINANCE_ALPHA                     0x190A
+#define GL_ALPHA_BITS                          0x0D55
+#define GL_RED_BITS                            0x0D52
+#define GL_GREEN_BITS                          0x0D53
+#define GL_BLUE_BITS                           0x0D54
+#define GL_INDEX_BITS                          0x0D51
+#define GL_SUBPIXEL_BITS                       0x0D50
+#define GL_AUX_BUFFERS                         0x0C00
+#define GL_READ_BUFFER                         0x0C02
+#define GL_DRAW_BUFFER                         0x0C01
+#define GL_DOUBLEBUFFER                                0x0C32
+#define GL_STEREO                              0x0C33
+#define GL_BITMAP                              0x1A00
+#define GL_COLOR                               0x1800
+#define GL_DEPTH                               0x1801
+#define GL_STENCIL                             0x1802
+#define GL_DITHER                              0x0BD0
+#define GL_RGB                                 0x1907
+#define GL_RGBA                                        0x1908
+
+/* Fog */
+#define GL_FOG                                 0x0B60
+#define GL_FOG_MODE                            0x0B65
+#define GL_FOG_DENSITY                         0x0B62
+#define GL_FOG_COLOR                           0x0B66
+#define GL_FOG_INDEX                           0x0B61
+#define GL_FOG_START                           0x0B63
+#define GL_FOG_END                             0x0B64
+#define GL_LINEAR                              0x2601
+#define GL_EXP                                 0x0800
+#define GL_EXP2                                        0x0801
+
+/* Polygons */
+#define GL_POINT                               0x1B00
+#define GL_LINE                                        0x1B01
+#define GL_FILL                                        0x1B02
+#define GL_CW                                  0x0900
+#define GL_CCW                                 0x0901
+#define GL_FRONT                               0x0404
+#define GL_BACK                                        0x0405
+#define GL_POLYGON_MODE                                0x0B40
+#define GL_POLYGON_SMOOTH                      0x0B41
+#define GL_POLYGON_STIPPLE                     0x0B42
+#define GL_EDGE_FLAG                           0x0B43
+#define GL_CULL_FACE                           0x0B44
+#define GL_CULL_FACE_MODE                      0x0B45
+#define GL_FRONT_FACE                          0x0B46
+#define GL_POLYGON_OFFSET_FACTOR               0x8038
+#define GL_POLYGON_OFFSET_UNITS                        0x2A00
+#define GL_POLYGON_OFFSET_POINT                        0x2A01
+#define GL_POLYGON_OFFSET_LINE                 0x2A02
+#define GL_POLYGON_OFFSET_FILL                 0x8037
+
+/* Lighting */
+#define GL_LIGHTING                            0x0B50
+#define GL_LIGHT0                              0x4000
+#define GL_LIGHT1                              0x4001
+#define GL_LIGHT2                              0x4002
+#define GL_LIGHT3                              0x4003
+#define GL_LIGHT4                              0x4004
+#define GL_LIGHT5                              0x4005
+#define GL_LIGHT6                              0x4006
+#define GL_LIGHT7                              0x4007
+#define GL_SPOT_EXPONENT                       0x1205
+#define GL_SPOT_CUTOFF                         0x1206
+#define GL_CONSTANT_ATTENUATION                        0x1207
+#define GL_LINEAR_ATTENUATION                  0x1208
+#define GL_QUADRATIC_ATTENUATION               0x1209
+#define GL_AMBIENT                             0x1200
+#define GL_DIFFUSE                             0x1201
+#define GL_SPECULAR                            0x1202
+#define GL_SHININESS                           0x1601
+#define GL_EMISSION                            0x1600
+#define GL_POSITION                            0x1203
+#define GL_SPOT_DIRECTION                      0x1204
+#define GL_AMBIENT_AND_DIFFUSE                 0x1602
+#define GL_COLOR_INDEXES                       0x1603
+#define GL_LIGHT_MODEL_TWO_SIDE                        0x0B52
+#define GL_LIGHT_MODEL_LOCAL_VIEWER            0x0B51
+#define GL_LIGHT_MODEL_AMBIENT                 0x0B53
+#define GL_FRONT_AND_BACK                      0x0408
+#define GL_SHADE_MODEL                         0x0B54
+#define GL_FLAT                                        0x1D00
+#define GL_SMOOTH                              0x1D01
+#define GL_COLOR_MATERIAL                      0x0B57
+#define GL_COLOR_MATERIAL_FACE                 0x0B55
+#define GL_COLOR_MATERIAL_PARAMETER            0x0B56
+#define GL_NORMALIZE                           0x0BA1
+
+/* Blending */
+#define GL_BLEND                               0x0BE2
+#define GL_BLEND_SRC                           0x0BE1
+#define GL_BLEND_DST                           0x0BE0
+#define GL_ZERO                                        0x0
+#define GL_ONE                                 0x1
+#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
+#define GL_DST_COLOR                           0x0306
+#define GL_ONE_MINUS_DST_COLOR                 0x0307
+#define GL_SRC_ALPHA_SATURATE                  0x0308
+
+/* ClipPlaneName */
+#define GL_CLIP_PLANE0                    0x3000
+#define GL_CLIP_PLANE1                    0x3001
+#define GL_CLIP_PLANE2                    0x3002
+#define GL_CLIP_PLANE3                    0x3003
+#define GL_CLIP_PLANE4                    0x3004
+#define GL_CLIP_PLANE5                    0x3005
+
+
+/* OpenGL 1.1 */
+#define GL_PROXY_TEXTURE_1D                    0x8063
+#define GL_PROXY_TEXTURE_2D                    0x8064
+#define GL_TEXTURE_PRIORITY                    0x8066
+#define GL_TEXTURE_RESIDENT                    0x8067
+#define GL_TEXTURE_BINDING_1D                  0x8068
+#define GL_TEXTURE_BINDING_2D                  0x8069
+#define GL_TEXTURE_INTERNAL_FORMAT             0x1003
+#define GL_ALPHA4                              0x803B
+#define GL_ALPHA8                              0x803C
+#define GL_ALPHA12                             0x803D
+#define GL_ALPHA16                             0x803E
+#define GL_LUMINANCE4                          0x803F
+#define GL_LUMINANCE8                          0x8040
+#define GL_LUMINANCE12                         0x8041
+#define GL_LUMINANCE16                         0x8042
+#define GL_LUMINANCE4_ALPHA4                   0x8043
+#define GL_LUMINANCE6_ALPHA2                   0x8044
+#define GL_LUMINANCE8_ALPHA8                   0x8045
+#define GL_LUMINANCE12_ALPHA4                  0x8046
+#define GL_LUMINANCE12_ALPHA12                 0x8047
+#define GL_LUMINANCE16_ALPHA16                 0x8048
+#define GL_INTENSITY                           0x8049
+#define GL_INTENSITY4                          0x804A
+#define GL_INTENSITY8                          0x804B
+#define GL_INTENSITY12                         0x804C
+#define GL_INTENSITY16                         0x804D
+#define GL_R3_G3_B2                            0x2A10
+#define GL_RGB4                                        0x804F
+#define GL_RGB5                                        0x8050
+#define GL_RGB8                                        0x8051
+#define GL_RGB10                               0x8052
+#define GL_RGB12                               0x8053
+#define GL_RGB16                               0x8054
+#define GL_RGBA2                               0x8055
+#define GL_RGBA4                               0x8056
+#define GL_RGB5_A1                             0x8057
+#define GL_RGBA8                               0x8058
+#define GL_RGB10_A2                            0x8059
+#define GL_RGBA12                              0x805A
+#define GL_RGBA16                              0x805B
+#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
+
+
+#define GL_CLIENT_PIXEL_STORE_BIT              0x00000001
+#define GL_CLIENT_VERTEX_ARRAY_BIT             0x00000002
+#define GL_ALL_CLIENT_ATTRIB_BITS              0xFFFFFFFF
+#define GL_CLIENT_ALL_ATTRIB_BITS              0xFFFFFFFF
+
+/* Stencil */
+#define GL_STENCIL_TEST                                0x0B90
+#define GL_STENCIL_WRITEMASK                   0x0B98
+#define GL_STENCIL_BITS                                0x0D57
+#define GL_STENCIL_FUNC                                0x0B92
+#define GL_STENCIL_VALUE_MASK                  0x0B93
+#define GL_STENCIL_REF                         0x0B97
+#define GL_STENCIL_FAIL                                0x0B94
+#define GL_STENCIL_PASS_DEPTH_PASS             0x0B96
+#define GL_STENCIL_PASS_DEPTH_FAIL             0x0B95
+#define GL_STENCIL_CLEAR_VALUE                 0x0B91
+#define GL_STENCIL_INDEX                       0x1901
+#define GL_KEEP                                        0x1E00
+#define GL_REPLACE                             0x1E01
+#define GL_INCR                                        0x1E02
+#define GL_DECR                                        0x1E03
+
+/* Hints */
+#define GL_FOG_HINT                            0x0C54
+#define GL_LINE_SMOOTH_HINT                    0x0C52
+#define GL_PERSPECTIVE_CORRECTION_HINT         0x0C50
+#define GL_POINT_SMOOTH_HINT                   0x0C51
+#define GL_POLYGON_SMOOTH_HINT                 0x0C53
+#define GL_DONT_CARE                           0x1100
+#define GL_FASTEST                             0x1101
+#define GL_NICEST                              0x1102
+
+/* Gets */
+#define GL_ATTRIB_STACK_DEPTH                  0x0BB0
+#define GL_CLIENT_ATTRIB_STACK_DEPTH           0x0BB1
+#define GL_COLOR_CLEAR_VALUE                   0x0C22
+#define GL_COLOR_WRITEMASK                     0x0C23
+#define GL_CURRENT_INDEX                       0x0B01
+#define GL_CURRENT_COLOR                       0x0B00
+#define GL_CURRENT_NORMAL                      0x0B02
+#define GL_CURRENT_RASTER_COLOR                        0x0B04
+#define GL_CURRENT_RASTER_DISTANCE             0x0B09
+#define GL_CURRENT_RASTER_INDEX                        0x0B05
+#define GL_CURRENT_RASTER_POSITION             0x0B07
+#define GL_CURRENT_RASTER_TEXTURE_COORDS       0x0B06
+#define GL_CURRENT_RASTER_POSITION_VALID       0x0B08
+#define GL_CURRENT_TEXTURE_COORDS              0x0B03
+#define GL_INDEX_CLEAR_VALUE                   0x0C20
+#define GL_INDEX_MODE                          0x0C30
+#define GL_INDEX_WRITEMASK                     0x0C21
+#define GL_MODELVIEW_MATRIX                    0x0BA6
+#define GL_MODELVIEW_STACK_DEPTH               0x0BA3
+#define GL_NAME_STACK_DEPTH                    0x0D70
+#define GL_PROJECTION_MATRIX                   0x0BA7
+#define GL_PROJECTION_STACK_DEPTH              0x0BA4
+#define GL_RENDER_MODE                         0x0C40
+#define GL_RGBA_MODE                           0x0C31
+#define GL_TEXTURE_MATRIX                      0x0BA8
+#define GL_TEXTURE_STACK_DEPTH                 0x0BA5
+#define GL_VIEWPORT                            0x0BA2
+
+/* glPush/PopAttrib bits */
+#define GL_CURRENT_BIT                         0x00000001
+#define GL_POINT_BIT                           0x00000002
+#define GL_LINE_BIT                            0x00000004
+#define GL_POLYGON_BIT                         0x00000008
+#define GL_POLYGON_STIPPLE_BIT                 0x00000010
+#define GL_PIXEL_MODE_BIT                      0x00000020
+#define GL_LIGHTING_BIT                                0x00000040
+#define GL_FOG_BIT                             0x00000080
+#define GL_DEPTH_BUFFER_BIT                    0x00000100
+#define GL_ACCUM_BUFFER_BIT                    0x00000200
+#define GL_STENCIL_BUFFER_BIT                  0x00000400
+#define GL_VIEWPORT_BIT                                0x00000800
+#define GL_TRANSFORM_BIT                       0x00001000
+#define GL_ENABLE_BIT                          0x00002000
+#define GL_COLOR_BUFFER_BIT                    0x00004000
+#define GL_HINT_BIT                            0x00008000
+#define GL_EVAL_BIT                            0x00010000
+#define GL_LIST_BIT                            0x00020000
+#define GL_TEXTURE_BIT                         0x00040000
+#define GL_SCISSOR_BIT                         0x00080000
+#define GL_ALL_ATTRIB_BITS                     0x000FFFFF
+
+/* Depth buffer */
+#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
+#define GL_DEPTH_TEST                          0x0B71
+#define GL_DEPTH_BITS                          0x0D56
+#define GL_DEPTH_CLEAR_VALUE                   0x0B73
+#define GL_DEPTH_FUNC                          0x0B74
+#define GL_DEPTH_RANGE                         0x0B70
+#define GL_DEPTH_WRITEMASK                     0x0B72
+#define GL_DEPTH_COMPONENT                     0x1902
+
+/* 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
+#define GL_CLIENT_ACTIVE_TEXTURE          0x84E1
+
+/* GetPName */
+#define GL_CURRENT_COLOR                  0x0B00
+#define GL_CURRENT_NORMAL                 0x0B02
+#define GL_CURRENT_TEXTURE_COORDS         0x0B03
+#define GL_POINT_SIZE                     0x0B11
+#define GL_POINT_SIZE_MIN                 0x8126
+#define GL_POINT_SIZE_MAX                 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE      0x8128
+#define GL_POINT_DISTANCE_ATTENUATION     0x8129
+#define GL_SMOOTH_POINT_SIZE_RANGE        0x0B12
+#define GL_LINE_WIDTH                     0x0B21
+#define GL_SMOOTH_LINE_WIDTH_RANGE        0x0B22
+#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_SHADE_MODEL                    0x0B54
+#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_VALUE_MASK             0x0B93
+#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_WRITEMASK              0x0B98
+#define GL_MATRIX_MODE                    0x0BA0
+#define GL_VIEWPORT                       0x0BA2
+#define GL_MODELVIEW_STACK_DEPTH          0x0BA3
+#define GL_PROJECTION_STACK_DEPTH         0x0BA4
+#define GL_TEXTURE_STACK_DEPTH            0x0BA5
+#define GL_MODELVIEW_MATRIX               0x0BA6
+#define GL_PROJECTION_MATRIX              0x0BA7
+#define GL_TEXTURE_MATRIX                 0x0BA8
+#define GL_ALPHA_TEST_FUNC                0x0BC1
+#define GL_ALPHA_TEST_REF                 0x0BC2
+#define GL_BLEND_DST                      0x0BE0
+#define GL_BLEND_SRC                      0x0BE1
+#define GL_LOGIC_OP_MODE                  0x0BF0
+#define GL_SCISSOR_BOX                    0x0C10
+#define GL_SCISSOR_TEST                   0x0C11
+#define GL_COLOR_CLEAR_VALUE              0x0C22
+#define GL_COLOR_WRITEMASK                0x0C23
+#define GL_UNPACK_ALIGNMENT               0x0CF5
+#define GL_PACK_ALIGNMENT                 0x0D05
+#define GL_MAX_LIGHTS                     0x0D31
+#define GL_MAX_CLIP_PLANES                0x0D32
+#define GL_MAX_TEXTURE_SIZE               0x0D33
+#define GL_MAX_MODELVIEW_STACK_DEPTH      0x0D36
+#define GL_MAX_PROJECTION_STACK_DEPTH     0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH        0x0D39
+#define GL_MAX_VIEWPORT_DIMS              0x0D3A
+#define GL_MAX_ELEMENTS_VERTICES          0x80E8
+#define GL_MAX_ELEMENTS_INDICES           0x80E9
+#define GL_MAX_TEXTURE_UNITS              0x84E2
+#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
+#define GL_POLYGON_OFFSET_FILL            0x8037
+#define GL_POLYGON_OFFSET_FACTOR          0x8038
+#define GL_TEXTURE_BINDING_2D             0x8069
+#define GL_VERTEX_ARRAY_SIZE              0x807A
+#define GL_VERTEX_ARRAY_TYPE              0x807B
+#define GL_VERTEX_ARRAY_STRIDE            0x807C
+#define GL_NORMAL_ARRAY_TYPE              0x807E
+#define GL_NORMAL_ARRAY_STRIDE            0x807F
+#define GL_COLOR_ARRAY_SIZE               0x8081
+#define GL_COLOR_ARRAY_TYPE               0x8082
+#define GL_COLOR_ARRAY_STRIDE             0x8083
+#define GL_TEXTURE_COORD_ARRAY_SIZE       0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE       0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE     0x808A
+#define GL_VERTEX_ARRAY_POINTER           0x808E
+#define GL_NORMAL_ARRAY_POINTER           0x808F
+#define GL_COLOR_ARRAY_POINTER            0x8090
+#define GL_TEXTURE_COORD_ARRAY_POINTER    0x8092
+#define GL_SAMPLE_BUFFERS                 0x80A8
+#define GL_SAMPLES                        0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE          0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT         0x80AB
+
+
+/* ErrorCode */
+#define GL_NO_ERROR                       0
+#define GL_INVALID_ENUM                   0x0500
+#define GL_INVALID_VALUE                  0x0501
+#define GL_INVALID_OPERATION              0x0502
+#define GL_STACK_OVERFLOW                 0x0503
+#define GL_STACK_UNDERFLOW                0x0504
+#define GL_OUT_OF_MEMORY                  0x0505
+
+// Vladimir
+#define glVertex2i(x,y) glVertex3f(x,y,0.0)
+#define glTexCoord2d glTexCoord2f
+#define glVertex3d glVertex3f
+//#define glColor4ub(x,y,z,p) glColor4f(x,y,z,p) //nicknekit: wtf???
+#define glFogi glFogf
+//
+
+void glBegin(GLenum mode);
+void glEnd(void);
+void glEnable (GLenum cap);
+void glDisable (GLenum cap);
+void glVertex2f(GLfloat x, GLfloat y);
+void glColor3f(        GLfloat red, GLfloat green, GLfloat blue);
+void glTexCoord2f(GLfloat s, GLfloat t);
+void glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+void glLoadIdentity (void);
+void glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+void glOrtho (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+void glMatrixMode (GLenum mode);
+void glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+void glDrawBuffer(GLenum mode);
+void glTranslatef (GLfloat x, GLfloat y, GLfloat z);
+void glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+void glScalef (GLfloat x, GLfloat y, GLfloat z);
+void glDepthRange(GLclampf zNear, GLclampf zFar);
+void glDepthFunc (GLenum func);
+void glFinish (void);
+void glGetFloatv (GLenum pname, GLfloat *params);
+void glGetIntegerv (GLenum pname, GLint *params);
+void glCullFace (GLenum mode);
+void glFrustum (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+void glClear (GLbitfield mask);
+void glVertex3f( GLfloat x, GLfloat y, GLfloat z );
+void glColor4fv( const GLfloat *v );
+void glHint (GLenum target, GLenum mode);
+void glBlendFunc (GLenum sfactor, GLenum dfactor);
+void glPopMatrix (void);
+void glShadeModel (GLenum mode);
+void glPushMatrix (void);
+void glTexEnvf (GLenum target, GLenum pname, GLfloat param);
+void glVertex3fv( const GLfloat *v );
+void glDepthMask (GLboolean flag);
+void glBindTexture (GLenum target, GLuint texture);
+const GLubyte* glGetString (GLenum name);
+void glAlphaFunc (GLenum func, GLclampf ref);
+void glFlush (void);
+void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+void glReadBuffer( GLenum mode );
+void glLoadMatrixf (const GLfloat *m);
+void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GLenum glGetError (void);
+void glActiveTexture (GLenum texture);
+void glClientActiveTexture (GLenum texture);
+void glColor3ubv( const GLubyte* v);
+void glPolygonMode( GLenum face, GLenum mode );
+
+void glArrayElement(GLint i);
+void glLineWidth(GLfloat width);
+void glCallList( GLuint list );
+void glTexCoord2fv( const GLfloat *v );
+void glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha );
+void glStencilFunc( GLenum func, GLint ref, GLuint mask );
+void glStencilOp( GLenum fail, GLenum zfail, GLenum zpass );
+void glColor4ubv( const GLubyte *v );
+
+void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices );
+void glEnableClientState( GLenum array );
+void glDisableClientState(GLenum  array);
+void glVertexPointer(  GLint size,     GLenum type,GLsizei     stride, const GLvoid *pointer );
+void glTexCoordPointer( GLint  size,  GLenum type,  GLsizei stride,  const     GLvoid *pointer );
+void glColorPointer( GLint size,  GLenum type,  GLsizei stride,  const GLvoid *pointer );
+void glPolygonOffset(  GLfloat factor, GLfloat units );
+void glClearDepth( GLclampf depth );
+void glDeleteTextures( GLsizei n,       const GLuint *textures );
+void glTexParameterfv( GLenum          target, GLenum          pname,  const GLfloat *         params);
+void glStencilMask( GLuint mask );
+void glClearStencil( GLint s );
+void glScissor( GLint  x,  GLint       y,  GLsizei width,  GLsizei height );
+void glClipPlane( GLenum plane, const GLdouble *equation );
+void glColor3fv( const GLfloat *v );
+void glPointSize( GLfloat size );
+
+// Vladimir
+void glDrawArrays( GLenum mode, int first, int count); 
+void glMultMatrixf (const GLfloat *m);
+void glPixelStorei (GLenum pname, GLint param);
+void glFogf (GLenum pname, GLfloat param);
+void glFogfv (GLenum pname, const GLfloat *params);
+void glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
+
+void glTexParameteri (GLenum target, GLenum pname, GLint param);
+void glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+void glTexParameterx (GLenum target, GLenum pname, GLfixed param);
+void glGenTextures (GLsizei n, GLuint *textures);
+void glFrontFace (GLenum mode);
+
+
+
+//nicknekit: for xash3d
+
+void glColor3ub( GLubyte red, GLubyte green, GLubyte blue);
+void glNormal3fv( const GLfloat *v );
+void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border );
+void glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels );
+void glTexSubImage3D( GLenum target, GLint level,
+                                         GLint xoffset, GLint yoffset,
+                                         GLint zoffset, GLsizei width,
+                                         GLsizei height, GLsizei depth,
+                                         GLenum format,
+                                         GLenum type, const GLvoid *pixels);
+GLboolean glIsTexture(GLuint texture);
+void glTexGeni( GLenum coord, GLenum pname, GLint param );
+void glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params );
+void glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/GL/gl_entries.in b/GL/gl_entries.in
new file mode 100644 (file)
index 0000000..9ca48a8
--- /dev/null
@@ -0,0 +1,184 @@
+// 
+    GL_ENTRY(int,eglChooseConfig,int dpy, const int *attrib_list, int *configs, int config_size, int *num_config)
+    GL_ENTRY(int,eglCopyBuffers,int dpy, int surface, void* target)
+    GL_ENTRY(int,eglCreateContext,int dpy, int config, int share_list, const int *attrib_list)
+    GL_ENTRY(int,eglCreatePbufferSurface,int dpy, int config, const int *attrib_list)
+    GL_ENTRY(int,eglCreatePixmapSurface,int dpy, int config, void* pixmap, const int *attrib_list)
+    GL_ENTRY(int,eglCreateWindowSurface,int dpy, int config, void* window, const int *attrib_list)
+    GL_ENTRY(int,eglDestroyContext,int dpy, int ctx)
+    GL_ENTRY(int,eglDestroySurface,int dpy, int surface)
+    GL_ENTRY(int,eglGetConfigAttrib,int dpy, int config, int attribute, int *value)
+    GL_ENTRY(int,eglGetConfigs,int dpy, int *configs, int config_size, int *num_config)
+    GL_ENTRY(int,eglGetCurrentContext,void)
+    GL_ENTRY(int,eglGetCurrentDisplay,void)
+    GL_ENTRY(int,eglGetCurrentSurface,int readdraw)
+    GL_ENTRY(int,eglGetDisplay,int display)
+    GL_ENTRY(int,eglGetError,void)
+
+    GL_ENTRY(void, eglGetProcAddress,const char *procname)
+
+    GL_ENTRY(int,eglInitialize,int dpy, int *major, int *minor)
+    GL_ENTRY(int,eglMakeCurrent,int dpy, int draw, int read, int ctx)
+    GL_ENTRY(int,eglQueryContext,int dpy, int ctx, int attribute, int *value)
+    GL_ENTRY(const char * ,eglQueryString,int dpy, int name)
+    GL_ENTRY(int,eglQuerySurface,int dpy, int surface, int attribute, int *value)
+    GL_ENTRY(int,eglSwapBuffers,int dpy, int draw)
+    GL_ENTRY(int,eglTerminate,int dpy)
+    GL_ENTRY(int,eglWaitGL,void)
+    GL_ENTRY(int,eglWaitNative,int engine)     
+
+// GL
+    GL_ENTRY(void,glActiveTexture,unsigned int texture)
+    GL_ENTRY(void,glAlphaFunc,unsigned int func, float ref)
+    GL_ENTRY(void,glAlphaFuncx,unsigned int func, int ref)
+    GL_ENTRY(void,glBindTexture,unsigned int target, unsigned int texture)
+    GL_ENTRY(void,glBlendFunc,unsigned int sfactor, unsigned int dfactor)
+    GL_ENTRY(void,glClear,unsigned int mask)
+    GL_ENTRY(void,glClearColor,float red, float green, float blue, float alpha)
+    GL_ENTRY(void,glClearColorx,int red, int green, int blue, int alpha)
+    GL_ENTRY(void,glClearDepthf,float depth)
+    GL_ENTRY(void,glClearDepthx,int depth)
+    GL_ENTRY(void,glClearStencil,int s)
+    GL_ENTRY(void,glClientActiveTexture,unsigned int texture)
+    GL_ENTRY(void,glColor4f,float red, float green, float blue, float alpha)
+    GL_ENTRY(void,glColor4x,int red, int green, int blue, int alpha)    
+    GL_ENTRY(void,glColorMask,unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
+    GL_ENTRY(void,glColorPointer,int size, unsigned int type, int stride, const void *pointer)
+    GL_ENTRY(void,glCompressedTexImage2D,unsigned int target, int level, unsigned int internalformat, int width, int height, int border, int imageSize, const void *data)
+    GL_ENTRY(void,glCompressedTexSubImage2D,unsigned int target, int level, int xoffset, int yoffset, int width, int height, unsigned int format, int imageSize, const void *data)
+    GL_ENTRY(void,glCopyTexImage2D,unsigned int target, int level, unsigned int internalformat, int x, int y, int width, int height, int border)
+    GL_ENTRY(void,glCopyTexSubImage2D,unsigned int target, int level, int xoffset, int yoffset, int x, int y, int width, int height)
+    GL_ENTRY(void,glCullFace,unsigned int mode)
+    GL_ENTRY(void,glDeleteTextures,int n, const unsigned int *textures)
+    GL_ENTRY(void,glDepthFunc,unsigned int func)
+    GL_ENTRY(void,glDepthMask,unsigned char flag)
+    GL_ENTRY(void,glDepthRangef,float zNear, float zFar)
+    GL_ENTRY(void,glDepthRangex,int zNear, int zFar)
+    GL_ENTRY(void,glDisable,unsigned int cap)
+    GL_ENTRY(void,glDisableClientState,unsigned int array)
+    GL_ENTRY(void,glDrawArrays,unsigned int mode, int first, int count)
+    GL_ENTRY(void,glDrawElements,unsigned int mode, int count, unsigned int type, const void *indices)
+    GL_ENTRY(void,glEnable,unsigned int cap)
+    GL_ENTRY(void,glEnableClientState,unsigned int array)
+    GL_ENTRY(void,glFinish,void)
+    GL_ENTRY(void,glFlush,void)
+    GL_ENTRY(void,glFogf,unsigned int pname, float param)
+    GL_ENTRY(void,glFogfv,unsigned int pname, const float *params)
+    GL_ENTRY(void,glFogx,unsigned int pname, int param)
+    GL_ENTRY(void,glFogxv,unsigned int pname, const int *params)
+    GL_ENTRY(void,glFrontFace,unsigned int mode)
+    GL_ENTRY(void,glFrustumf,float left, float right, float bottom, float top, float zNear, float zFar)
+    GL_ENTRY(void,glFrustumx,int left, int right, int bottom, int top, int zNear, int zFar)
+    GL_ENTRY(void,glGenTextures,int n, unsigned int *textures)
+    GL_ENTRY(unsigned int , glGetError,void)
+    GL_ENTRY(void,glGetIntegerv,unsigned int pname, int *params)
+    GL_ENTRY(const unsigned char * , glGetString,unsigned int name)
+    GL_ENTRY(void,glHint,unsigned int target, unsigned int mode)
+    GL_ENTRY(void,glLightModelf,unsigned int pname, float param)
+    GL_ENTRY(void,glLightModelfv,unsigned int pname, const float *params)
+    GL_ENTRY(void,glLightModelx,unsigned int pname, int param)
+    GL_ENTRY(void,glLightModelxv,unsigned int pname, const int *params)
+    GL_ENTRY(void,glLightf,unsigned int light, unsigned int pname, float param)
+    GL_ENTRY(void,glLightfv,unsigned int light, unsigned int pname, const float *params)
+    GL_ENTRY(void,glLightx,unsigned int light, unsigned int pname, int param)
+    GL_ENTRY(void,glLightxv,unsigned int light, unsigned int pname, const int *params)
+    GL_ENTRY(void,glLineWidth,float width)
+    GL_ENTRY(void,glLineWidthx,int width)
+    GL_ENTRY(void,glLoadIdentity,void)
+    GL_ENTRY(void,glLoadMatrixf,const float *m)
+    GL_ENTRY(void,glLoadMatrixx,const int *m)
+    GL_ENTRY(void,glLogicOp,unsigned int opcode)
+    GL_ENTRY(void,glMaterialf,unsigned int face, unsigned int pname, float param)     
+    GL_ENTRY(void,glMaterialfv,unsigned int face, unsigned int pname, const float *params)
+    GL_ENTRY(void,glMaterialx,unsigned int face, unsigned int pname, int param)
+    GL_ENTRY(void,glMaterialxv,unsigned int face, unsigned int pname, const int *params)
+    GL_ENTRY(void,glMatrixMode,unsigned int mode)
+    GL_ENTRY(void,glMultMatrixf,const float *m)
+    GL_ENTRY(void,glMultMatrixx,const int *m)
+    GL_ENTRY(void,glMultiTexCoord4f,unsigned int target, float s, float t, float r, float q)  
+    GL_ENTRY(void,glMultiTexCoord4x,unsigned int target, int s, int t, int r, int q)
+    GL_ENTRY(void,glNormal3f,float nx, float ny, float nz)
+    GL_ENTRY(void,glNormal3x,int nx, int ny, int nz)
+    GL_ENTRY(void,glNormalPointer,unsigned int type, int stride, const void *pointer)
+    GL_ENTRY(void,glOrthof,float left, float right, float bottom, float top, float zNear, float zFar)
+    GL_ENTRY(void,glOrthox,int left, int right, int bottom, int top, int zNear, int zFar)
+    GL_ENTRY(void,glPixelStorei,unsigned int pname, int param)
+    GL_ENTRY(void,glPointSize,float size)
+    GL_ENTRY(void,glPointSizex,int size)
+    GL_ENTRY(void,glPolygonOffset,float factor, float units)
+    GL_ENTRY(void,glPolygonOffsetx,int factor, int units)
+    GL_ENTRY(void,glPopMatrix,void)
+    GL_ENTRY(void,glPushMatrix,void)
+    GL_ENTRY(unsigned int , glQueryMatrixxOES,int mantissa[16], int exponent[16])
+    GL_ENTRY(void,glReadPixels,int x, int y, int width, int height, unsigned int format, unsigned int type, void *pixels)
+    GL_ENTRY(void,glRotatef,float angle, float x, float y, float z)
+    GL_ENTRY(void,glRotatex,int angle, int x, int y, int z)
+    GL_ENTRY(void,glSampleCoverage,float value, unsigned char invert)
+    GL_ENTRY(void,glSampleCoveragex,int value, unsigned char invert)
+    GL_ENTRY(void,glScalef,float x, float y, float z)
+    GL_ENTRY(void,glScalex,int x, int y, int z)
+    GL_ENTRY(void,glScissor,int x, int y, int width, int height)
+    GL_ENTRY(void,glShadeModel,unsigned int mode)
+    GL_ENTRY(void,glStencilFunc,unsigned int func, int ref, unsigned int mask)
+    GL_ENTRY(void,glStencilMask,unsigned int mask)
+    GL_ENTRY(void,glStencilOp,unsigned int fail, unsigned int zfail, unsigned int zpass)
+    GL_ENTRY(void,glTexCoordPointer,int size, unsigned int type, int stride, const void *pointer)
+    GL_ENTRY(void,glTexEnvf,unsigned int target, unsigned int pname, float param)
+    GL_ENTRY(void,glTexEnvfv,unsigned int target, unsigned int pname, const float *params)
+    GL_ENTRY(void,glTexEnvx,unsigned int target, unsigned int pname, int param)
+    GL_ENTRY(void,glTexEnvxv,unsigned int target, unsigned int pname, const int *params)
+    GL_ENTRY(void,glTexImage2D,unsigned int target, int level, int internalformat, int width, int height, int border, unsigned int format, unsigned int type, const void *pixels)
+    GL_ENTRY(void,glTexParameterf,unsigned int target, unsigned int pname, float param)
+    GL_ENTRY(void,glTexParameterx,unsigned int target, unsigned int pname, int param)
+    GL_ENTRY(void,glTexSubImage2D,unsigned int target, int level, int xoffset, int yoffset, int width, int height, unsigned int format, unsigned int type, const void *pixels)
+    GL_ENTRY(void,glTranslatef,float x, float y, float z)
+    GL_ENTRY(void,glTranslatex,int x, int y, int z)
+    GL_ENTRY(void,glVertexPointer,int size, unsigned int type, int stride, const void *pointer)
+    GL_ENTRY(void,glViewport,int x, int y, int width, int height)
+    GL_ENTRY(int , eglSwapInterval,int dpy, int interval)
+    GL_ENTRY(void,glBindBuffer,unsigned int target, unsigned int buffer)
+    GL_ENTRY(void,glBufferData,unsigned int target, int size, const void *data, unsigned int usage)
+    GL_ENTRY(void,glBufferSubData,unsigned int target, int offset,int size, const void *data)
+    GL_ENTRY(void,glClipPlanef,unsigned int plane, const float *equation)
+    GL_ENTRY(void,glClipPlanex,unsigned int plane, const int *equation)
+    GL_ENTRY(void,glColor4ub,unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
+    GL_ENTRY(void,glDeleteBuffers,int n, const unsigned int *buffers)
+    GL_ENTRY(void,glGenBuffers,int n, unsigned int *buffers)
+    GL_ENTRY(void,glGetBooleanv,unsigned int pname, unsigned char *params)
+    GL_ENTRY(void,glGetBufferParameteriv,unsigned int target, unsigned int pname, int *params)
+    GL_ENTRY(void,glGetClipPlanef,unsigned int pname, float eqn[4])
+    GL_ENTRY(void,glGetClipPlanex,unsigned int pname, int eqn[4])
+    GL_ENTRY(void,glGetFixedv,unsigned int pname, int *params)
+    GL_ENTRY(void,glGetFloatv,unsigned int pname, float *params)
+    GL_ENTRY(void,glGetLightfv,unsigned int light, unsigned int pname, float *params)
+    GL_ENTRY(void,glGetLightxv,unsigned int light, unsigned int pname, int *params)
+    GL_ENTRY(void,glGetMaterialfv,unsigned int face, unsigned int pname, float *params)
+    GL_ENTRY(void,glGetMaterialxv,unsigned int face, unsigned int pname, int *params)
+    GL_ENTRY(void,glGetPointerv,unsigned int pname, void **params)
+    GL_ENTRY(void,glGetTexEnvfv,unsigned int env, unsigned int pname, float *params)
+    GL_ENTRY(void,glGetTexEnviv,unsigned int env, unsigned int pname, int *params)
+    GL_ENTRY(void,glGetTexEnvxv,unsigned int env, unsigned int pname, int *params)     
+    GL_ENTRY(void,glGetTexParameterfv,unsigned int target, unsigned int pname, float *params)
+    GL_ENTRY(void,glGetTexParameteriv,unsigned int target, unsigned int pname, int *params)
+    GL_ENTRY(void,glGetTexParameterxv,unsigned int target, unsigned int pname, int *params)
+    GL_ENTRY(unsigned char ,glIsBuffer,unsigned int buffer)
+    GL_ENTRY(unsigned char ,glIsEnabled,unsigned int cap)
+    GL_ENTRY(unsigned char ,glIsTexture,unsigned int texture)
+    GL_ENTRY(void,glPointParameterf,unsigned int pname, float param)
+    GL_ENTRY(void,glPointParameterfv,unsigned int pname, const float *params)  
+    GL_ENTRY(void,glPointParameterx,unsigned int pname, int param)
+    GL_ENTRY(void,glPointParameterxv,unsigned int pname, const int *params)
+    GL_ENTRY(void,glPointSizePointerOES,unsigned int type, int stride, const void *pointer)
+    GL_ENTRY(void,glTexEnvi,unsigned int target, unsigned int pname, int param)
+    GL_ENTRY(void,glTexEnviv,unsigned int target, unsigned int pname, const int *params)
+    GL_ENTRY(void,glTexParameterfv,unsigned int target, unsigned int pname, const float *params)
+    GL_ENTRY(void,glTexParameteri,unsigned int target, unsigned int pname, int param)
+    GL_ENTRY(void,glTexParameteriv,unsigned int target, unsigned int pname, const int *params)
+    GL_ENTRY(void,glTexParameterxv,unsigned int target, unsigned int pname, const int *params)
+
+// EGL EXT
+    GL_ENTRY(int,eglBindTexImage,int dpy, int surface, int buffer)
+    GL_ENTRY(int,eglReleaseTexImage,int dpy, int surface, int buffer)
+    GL_ENTRY(int,eglSurfaceAttrib,int dpy, int surface, int attribute, int value)
+
+
diff --git a/GL/glesinterface.h b/GL/glesinterface.h
new file mode 100644 (file)
index 0000000..81ceb0f
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+Copyright (C) 2007-2009 Olli Hinkka
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifndef __GLESINTERFACE_H__
+#define __GLESINTERFACE_H__
+
+
+#if !defined (__WINS__)
+    #if        defined(__TARGET_FPU_VFP)
+        #pragma softfp_linkage
+    #endif
+#endif
+struct GlESInterface
+    {
+
+    int (*eglChooseConfig) (int dpy, const int *attrib_list, int *configs, int config_size, int *num_config);
+       int (*eglCopyBuffers) (int dpy, int surface, void* target);
+    int (*eglCreateContext) (int dpy, int config, int share_list, const int *attrib_list);
+    int (*eglCreatePbufferSurface) (int dpy, int config, const int *attrib_list);
+    int (*eglCreatePixmapSurface) (int dpy, int config, void* pixmap, const int *attrib_list);
+    int (*eglCreateWindowSurface) (int dpy, int config, void* window, const int *attrib_list);
+    int (*eglDestroyContext) (int dpy, int ctx);
+    int (*eglDestroySurface) (int dpy, int surface);
+    int (*eglGetConfigAttrib) (int dpy, int config, int attribute, int *value);
+    int (*eglGetConfigs) (int dpy, int *configs, int config_size, int *num_config);
+    int (*eglGetCurrentContext) (void);
+    int (*eglGetCurrentDisplay) (void);
+    int (*eglGetCurrentSurface) (int readdraw);
+    int (*eglGetDisplay) (int display);
+    int (*eglGetError) (void);
+
+    void (*(*eglGetProcAddress) (const char *procname))(...);
+
+    int (*eglInitialize) (int dpy, int *major, int *minor);
+    int (*eglMakeCurrent) (int dpy, int draw, int read, int ctx);
+    int (*eglQueryContext) (int dpy, int ctx, int attribute, int *value);
+    const char * (*eglQueryString) (int dpy, int name);
+    int (*eglQuerySurface) (int dpy, int surface, int attribute, int *value);
+    int (*eglSwapBuffers) (int dpy, int draw);
+    int (*eglTerminate) (int dpy);
+    int (*eglWaitGL) (void);
+    int (*eglWaitNative) (int engine); 
+
+    void (*glActiveTexture) (unsigned int texture);
+    void (*glAlphaFunc) (unsigned int func, float ref);
+    void (*glAlphaFuncx) (unsigned int func, int ref);
+    void (*glBindTexture) (unsigned int target, unsigned int texture);
+    void (*glBlendFunc) (unsigned int sfactor, unsigned int dfactor);
+    void (*glClear) (unsigned int mask);
+    void (*glClearColor) (float red, float green, float blue, float alpha);
+    void (*glClearColorx) (int red, int green, int blue, int alpha);
+    void (*glClearDepthf) (float depth);
+    void (*glClearDepthx) (int depth);
+    void (*glClearStencil) (int s);
+    void (*glClientActiveTexture) (unsigned int texture);
+    void (*glColor4f) (float red, float green, float blue, float alpha);
+    void (*glColor4x) (int red, int green, int blue, int alpha);    
+    void (*glColorMask) (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
+    void (*glColorPointer) (int size, unsigned int type, int stride, const void *pointer);
+       void (*glCompressedTexImage2D) (unsigned int target, int level, unsigned int internalformat, int width, int height, int border, int imageSize, const void *data);
+       void (*glCompressedTexSubImage2D) (unsigned int target, int level, int xoffset, int yoffset, int width, int height, unsigned int format, int imageSize, const void *data);
+       void (*glCopyTexImage2D) (unsigned int target, int level, unsigned int internalformat, int x, int y, int width, int height, int border);
+       void (*glCopyTexSubImage2D) (unsigned int target, int level, int xoffset, int yoffset, int x, int y, int width, int height);
+       void (*glCullFace) (unsigned int mode);
+    void (*glDeleteTextures) (int n, const unsigned int *textures);
+    void (*glDepthFunc) (unsigned int func);
+    void (*glDepthMask) (unsigned char flag);
+    void (*glDepthRangef) (float zNear, float zFar);
+    void (*glDepthRangex) (int zNear, int zFar);
+    void (*glDisable) (unsigned int cap);
+    void (*glDisableClientState) (unsigned int array);
+    void (*glDrawArrays) (unsigned int mode, int first, int count);
+    void (*glDrawElements) (unsigned int mode, int count, unsigned int type, const void *indices);
+    void (*glEnable) (unsigned int cap);
+    void (*glEnableClientState) (unsigned int array);
+    void (*glFinish) (void);
+    void (*glFlush) (void);
+    void (*glFogf) (unsigned int pname, float param);
+       void (*glFogfv) (unsigned int pname, const float *params);
+    void (*glFogx) (unsigned int pname, int param);
+    void (*glFogxv) (unsigned int pname, const int *params);
+    void (*glFrontFace) (unsigned int mode);
+    void (*glFrustumf) (float left, float right, float bottom, float top, float zNear, float zFar);
+       void (*glFrustumx) (int left, int right, int bottom, int top, int zNear, int zFar);
+    void (*glGenTextures) (int n, unsigned int *textures);
+    unsigned int (*glGetError) (void);
+       void (*glGetIntegerv) (unsigned int pname, int *params);
+    const unsigned char * (*glGetString) (unsigned int name);
+    void (*glHint) (unsigned int target, unsigned int mode);
+       void (*glLightModelf) (unsigned int pname, float param);
+    void (*glLightModelfv) (unsigned int pname, const float *params);
+    void (*glLightModelx) (unsigned int pname, int param);
+    void (*glLightModelxv) (unsigned int pname, const int *params);
+    void (*glLightf) (unsigned int light, unsigned int pname, float param);
+    void (*glLightfv) (unsigned int light, unsigned int pname, const float *params);
+    void (*glLightx) (unsigned int light, unsigned int pname, int param);
+    void (*glLightxv) (unsigned int light, unsigned int pname, const int *params);
+    void (*glLineWidth) (float width);
+    void (*glLineWidthx) (int width);
+    void (*glLoadIdentity) (void);
+    void (*glLoadMatrixf) (const float *m);
+    void (*glLoadMatrixx) (const int *m);
+    void (*glLogicOp) (unsigned int opcode);
+    void (*glMaterialf) (unsigned int face, unsigned int pname, float param);     
+    void (*glMaterialfv) (unsigned int face, unsigned int pname, const float *params);
+    void (*glMaterialx) (unsigned int face, unsigned int pname, int param);
+    void (*glMaterialxv) (unsigned int face, unsigned int pname, const int *params);
+    void (*glMatrixMode) (unsigned int mode);
+    void (*glMultMatrixf) (const float *m);
+    void (*glMultMatrixx) (const int *m);
+    void (*glMultiTexCoord4f) (unsigned int target, float s, float t, float r, float q);  
+    void (*glMultiTexCoord4x) (unsigned int target, int s, int t, int r, int q);
+    void (*glNormal3f) (float nx, float ny, float nz);
+    void (*glNormal3x) (int nx, int ny, int nz);
+    void (*glNormalPointer) (unsigned int type, int stride, const void *pointer);
+    void (*glOrthof) (float left, float right, float bottom, float top, float zNear, float zFar);
+    void (*glOrthox) (int left, int right, int bottom, int top, int zNear, int zFar);
+    void (*glPixelStorei) (unsigned int pname, int param);
+    void (*glPointSize) (float size);
+    void (*glPointSizex) (int size);
+    void (*glPolygonOffset) (float factor, float units);
+    void (*glPolygonOffsetx) (int factor, int units);
+    void (*glPopMatrix) (void);
+    void (*glPushMatrix) (void);
+    unsigned int (*glQueryMatrixxOES) (int mantissa[16], int exponent[16]);
+    void (*glReadPixels) (int x, int y, int width, int height, unsigned int format, unsigned int type, void *pixels);
+    void (*glRotatef) (float angle, float x, float y, float z);
+    void (*glRotatex) (int angle, int x, int y, int z);
+    void (*glSampleCoverage) (float value, unsigned char invert);
+    void (*glSampleCoveragex) (int value, unsigned char invert);
+    void (*glScalef) (float x, float y, float z);
+    void (*glScalex) (int x, int y, int z);
+    void (*glScissor) (int x, int y, int width, int height);
+    void (*glShadeModel) (unsigned int mode);
+    void (*glStencilFunc) (unsigned int func, int ref, unsigned int mask);
+    void (*glStencilMask) (unsigned int mask);
+    void (*glStencilOp) (unsigned int fail, unsigned int zfail, unsigned int zpass);
+    void (*glTexCoordPointer) (int size, unsigned int type, int stride, const void *pointer);
+    void (*glTexEnvf) (unsigned int target, unsigned int pname, float param);
+    void (*glTexEnvfv) (unsigned int target, unsigned int pname, const float *params);
+    void (*glTexEnvx) (unsigned int target, unsigned int pname, int param);
+    void (*glTexEnvxv) (unsigned int target, unsigned int pname, const int *params);
+    void (*glTexImage2D) (unsigned int target, int level, int internalformat, int width, int height, int border, unsigned int format, unsigned int type, const void *pixels);
+    void (*glTexParameterf) (unsigned int target, unsigned int pname, float param);
+    void (*glTexParameterx) (unsigned int target, unsigned int pname, int param);
+    void (*glTexSubImage2D) (unsigned int target, int level, int xoffset, int yoffset, int width, int height, unsigned int format, unsigned int type, const void *pixels);
+    void (*glTranslatef) (float x, float y, float z);
+    void (*glTranslatex) (int x, int y, int z);
+    void (*glVertexPointer) (int size, unsigned int type, int stride, const void *pointer);
+    void (*glViewport) (int x, int y, int width, int height);
+    int (*eglSwapInterval) (int dpy, int interval);
+    void (*glBindBuffer) (unsigned int target, unsigned int buffer);
+    void (*glBufferData) (unsigned int target, int size, const void *data, unsigned int usage);
+    void (*glBufferSubData) (unsigned int target, int offset,int size, const void *data);
+    void (*glClipPlanef) (unsigned int plane, const float *equation);
+    void (*glClipPlanex) (unsigned int plane, const int *equation);
+    void (*glColor4ub) (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
+    void (*glDeleteBuffers) (int n, const unsigned int *buffers);
+    void (*glGenBuffers) (int n, unsigned int *buffers);
+    void (*glGetBooleanv) (unsigned int pname, unsigned char *params);
+    void (*glGetBufferParameteriv) (unsigned int target, unsigned int pname, int *params);
+    void (*glGetClipPlanef) (unsigned int pname, float eqn[4]);
+    void (*glGetClipPlanex) (unsigned int pname, int eqn[4]);
+    void (*glGetFixedv) (unsigned int pname, int *params);
+    void (*glGetFloatv) (unsigned int pname, float *params);
+    void (*glGetLightfv) (unsigned int light, unsigned int pname, float *params);
+    void (*glGetLightxv) (unsigned int light, unsigned int pname, int *params);
+    void (*glGetMaterialfv) (unsigned int face, unsigned int pname, float *params);
+    void (*glGetMaterialxv) (unsigned int face, unsigned int pname, int *params);
+    void (*glGetPointerv) (unsigned int pname, void **params);
+    void (*glGetTexEnvfv) (unsigned int env, unsigned int pname, float *params);
+    void (*glGetTexEnviv) (unsigned int env, unsigned int pname, int *params);
+    void (*glGetTexEnvxv) (unsigned int env, unsigned int pname, int *params); 
+    void (*glGetTexParameterfv) (unsigned int target, unsigned int pname, float *params);
+    void (*glGetTexParameteriv) (unsigned int target, unsigned int pname, int *params);
+    void (*glGetTexParameterxv) (unsigned int target, unsigned int pname, int *params);
+    unsigned char (*glIsBuffer) (unsigned int buffer);
+    unsigned char (*glIsEnabled) (unsigned int cap);
+    unsigned char (*glIsTexture) (unsigned int texture);
+    void (*glPointParameterf) (unsigned int pname, float param);
+    void (*glPointParameterfv) (unsigned int pname, const float *params);      
+    void (*glPointParameterx) (unsigned int pname, int param);
+    void (*glPointParameterxv) (unsigned int pname, const int *params);
+    void (*glPointSizePointerOES) (unsigned int type, int stride, const void *pointer);
+    void (*glTexEnvi) (unsigned int target, unsigned int pname, int param);
+    void (*glTexEnviv) (unsigned int target, unsigned int pname, const int *params);
+    void (*glTexParameterfv) (unsigned int target, unsigned int pname, const float *params);
+    void (*glTexParameteri) (unsigned int target, unsigned int pname, int param);
+    void (*glTexParameteriv) (unsigned int target, unsigned int pname, const int *params);
+    void (*glTexParameterxv) (unsigned int target, unsigned int pname, const int *params);
+
+    int (*eglBindTexImage) (int dpy, int surface, int buffer);
+    int (*eglReleaseTexImage) (int dpy, int surface, int buffer);
+    int (*eglSurfaceAttrib) (int dpy, int surface, int attribute, int value);
+
+    };
+#if !defined (__WINS__)
+    #if        defined(__TARGET_FPU_VFP)
+        #pragma no_softfp_linkage
+    #endif
+#endif
+
+
+#endif
diff --git a/GL/glu.h b/GL/glu.h
new file mode 100644 (file)
index 0000000..8448766
--- /dev/null
+++ b/GL/glu.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+                          glu_rip.h  -  description
+
+                A few convenience routines ripped from MesaGL
+ ***************************************************************************/
+
+#ifndef _GLU_RIP_H_
+#define _GLU_RIP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <GL/gl.h>
+
+#include <malloc.h>
+#include <math.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+
+void gluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
+               GLdouble centerx, GLdouble centery, GLdouble centerz,
+               GLdouble upx, GLdouble upy, GLdouble upz );
+
+void gluPerspective( GLdouble fovy, GLdouble aspect,
+                     GLdouble zNear, GLdouble zFar );
+
+GLint gluScaleImage( GLenum format,
+                    GLint widthin, GLint heightin,
+                    GLenum typein, const void *datain,
+                    GLint widthout, GLint heightout,
+                    GLenum typeout, void *dataout );
+                                        
+GLint gluBuild2DMipmaps( GLenum target, GLint components,
+                         GLint width, GLint height, GLenum format,
+                         GLenum type, const void *data );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/GL/nanogl.h b/GL/nanogl.h
new file mode 100644 (file)
index 0000000..ff7ca61
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+Copyright (C) 2007-2009 Olli Hinkka
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifndef __NANOGL__H__
+#define __NANOGL__H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int nanoGL_Init(void);
+void nanoGL_Destroy(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..28c4c04
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+OpenGL 1.x to OpenGL ES 1.x wrapper by Olli Hinkka
+
+Extracted from Quake 2 port
diff --git a/eglwrap.cpp b/eglwrap.cpp
new file mode 100644 (file)
index 0000000..ab57519
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+Copyright (C) 2007-2009 Olli Hinkka
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+
+#include "egl.h"
+#include "glesinterface.h"
+#include "gl.h"
+
+#include <string.h>
+
+
+extern "C++" GlESInterface* glEsImpl;
+extern "C++" void FlushOnStateChange();
+
+
+EGLint eglGetError (void)
+    {
+    return glEsImpl->eglGetError();
+    }
+
+EGLDisplay eglGetDisplay (NativeDisplayType display)
+    {
+    return glEsImpl->eglGetDisplay(display);
+    }
+
+EGLBoolean eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor)
+    {
+    return glEsImpl->eglInitialize(dpy,major,minor);
+    }
+    
+EGLBoolean eglTerminate (EGLDisplay dpy)
+    {
+    return glEsImpl->eglTerminate(dpy);
+    }
+const char * eglQueryString (EGLDisplay dpy, EGLint name)
+    {
+    return glEsImpl->eglQueryString(dpy,name);
+    }
+
+#if defined(__MULTITEXTURE_SUPPORT__)
+extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t );
+#endif
+
+void * eglGetProcAddress (const char *procname)
+    {
+#if defined(__MULTITEXTURE_SUPPORT__)
+    if (!strcmp(procname, "glMultiTexCoord2fARB"))
+        {
+        return (void*)&glMultiTexCoord2fARB;
+        }
+    else if (!strcmp(procname, "glActiveTextureARB"))
+        {
+        return (void*)&glActiveTexture;
+        }        
+    else if (!strcmp(procname, "glClientActiveTextureARB"))
+        {
+        return (void*)&glClientActiveTexture;
+        }        
+
+#endif
+    return (void*)glEsImpl->eglGetProcAddress(procname);
+    }
+
+EGLBoolean eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+    {
+    return glEsImpl->eglGetConfigs(dpy,configs, config_size, num_config);
+    }
+    
+EGLBoolean eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+    {
+    return glEsImpl->eglChooseConfig(dpy,attrib_list,configs,config_size, num_config);
+    }
+    
+EGLBoolean eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+    {
+    return glEsImpl->eglGetConfigAttrib(dpy,config,attribute,value);
+    }
+
+EGLSurface eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list)
+    {
+    return glEsImpl->eglCreateWindowSurface(dpy,config,window,attrib_list);
+    }
+    
+EGLSurface eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list)
+    {
+    return glEsImpl->eglCreatePixmapSurface(dpy,config,pixmap,attrib_list);
+    }
+    
+EGLSurface eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+    {
+    return glEsImpl->eglCreatePbufferSurface(dpy, config, attrib_list);
+    }
+    
+EGLBoolean eglDestroySurface (EGLDisplay dpy, EGLSurface surface)
+    {
+    return glEsImpl->eglDestroySurface(dpy,surface);
+    }
+EGLBoolean eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
+    {
+    return glEsImpl->eglQuerySurface(dpy,surface,attribute,value);
+    }
+/* EGL 1.1 render-to-texture APIs */
+EGLBoolean eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+    {
+    return glEsImpl->eglSurfaceAttrib(dpy,surface,attribute,value);
+    }
+
+EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+    {
+    return glEsImpl->eglBindTexImage(dpy,surface,buffer);    
+    }
+EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+    {
+    return glEsImpl->eglReleaseTexImage(dpy,surface,buffer);
+    }
+
+/* EGL 1.1 swap control API */
+EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
+    {
+    return glEsImpl->eglSwapInterval(dpy,interval);
+    }
+
+EGLContext eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list)
+    {
+    return glEsImpl->eglCreateContext(dpy,config,share_list,attrib_list);
+    }
+    
+EGLBoolean eglDestroyContext (EGLDisplay dpy, EGLContext ctx)
+    {
+    return glEsImpl->eglDestroyContext(dpy,ctx);
+    }
+    
+EGLBoolean eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+    {
+    FlushOnStateChange();
+    return glEsImpl->eglMakeCurrent(dpy,draw,read,ctx);
+    }
+    
+EGLContext eglGetCurrentContext (void)
+    {
+    return glEsImpl->eglGetCurrentContext();
+    }
+EGLSurface eglGetCurrentSurface (EGLint readdraw)
+    {
+    return glEsImpl->eglGetCurrentSurface(readdraw);
+    }
+EGLDisplay eglGetCurrentDisplay (void)
+    {
+    return glEsImpl->eglGetCurrentDisplay();
+    }
+    
+EGLBoolean eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+    {
+    return glEsImpl->eglQueryContext(dpy,ctx,attribute,value);
+    }
+
+EGLBoolean eglWaitGL (void)
+    {
+    FlushOnStateChange();
+    return glEsImpl->eglWaitGL();
+    }
+    
+EGLBoolean eglWaitNative (EGLint engine)
+    {
+    FlushOnStateChange();
+    return glEsImpl->eglWaitNative(engine);
+    }
+    
+
+EGLBoolean eglSwapBuffers (EGLDisplay dpy, EGLSurface draw)
+    {
+    FlushOnStateChange();
+    return glEsImpl->eglSwapBuffers(dpy,draw);
+    }
+    
+EGLBoolean eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, NativePixmapType target)
+    {
+    FlushOnStateChange();
+    return glEsImpl->eglCopyBuffers(dpy,surface,target);
+    }
diff --git a/nanoWrap.cpp b/nanoWrap.cpp
new file mode 100644 (file)
index 0000000..eea514e
--- /dev/null
@@ -0,0 +1,1782 @@
+/*
+Copyright (C) 2007-2009 Olli Hinkka
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+/*
+#include <e32def.h>
+#include <e32std.h>
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gl.h"
+#include "glesinterface.h"
+
+#define GL_TEXTURE0_ARB                     0x84C0
+#define GL_TEXTURE1_ARB                     0x84C1
+
+struct nanoState                 
+    {                                  
+    GLboolean alpha_test;              
+    GLboolean blend;                   
+    GLboolean clip_planei;             
+    GLboolean color_logic_op;          
+    GLboolean color_material;          
+    GLboolean cull_face;               
+    GLboolean depth_test;              
+    GLboolean dither;                  
+    GLboolean fog;                     
+    GLboolean lighti;                  
+    GLboolean lighting;                
+    GLboolean line_smooth;             
+    GLboolean matrix_palette_oes;      
+    GLboolean multisample;             
+    GLboolean normalize;               
+    GLboolean point_smooth;            
+    GLboolean point_sprite_oes;        
+    GLboolean polygon_offset_fill;     
+    GLboolean rescale_normal;          
+    GLboolean sample_alpha_to_coverage;
+    GLboolean sample_alpha_to_one;     
+    GLboolean sample_coverage;         
+    GLboolean scissor_test;            
+    GLboolean stencil_test;            
+    GLboolean depthmask;               
+    GLclampf depth_range_near;         
+    GLclampf depth_range_far;          
+    GLenum depth_func;                 
+    GLenum cullface;                   
+    GLenum shademodel;                 
+    GLenum sfactor;                    
+    GLenum dfactor;                    
+    GLenum matrixmode;                 
+    };                                 
+
+static struct nanoState nanoglState;
+
+static struct nanoState nanoglInitState = 
+    {                                
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_TRUE,                         
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_TRUE,                         
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_FALSE,                        
+    GL_TRUE,                         
+    0.0f,                            
+    1.0f,                            
+    GL_LESS,                         
+    GL_BACK,                         
+    GL_SMOOTH,                       
+    GL_ONE,                          
+    GL_ZERO,                         
+    GL_MODELVIEW,                                        
+    };                               
+
+struct booleanstate
+    {
+    GLboolean value;
+    GLboolean changed;
+    };
+
+struct floatstate
+    {
+    GLfloat value;
+    GLboolean changed;
+    };
+    
+struct uintstate
+    {
+    GLuint value;
+    GLboolean changed;
+    };
+    
+struct ptrstate
+    {
+    GLint size;
+    GLenum type;
+    GLsizei stride;
+    GLvoid* ptr;
+    GLboolean changed;
+    GLboolean enabled;
+    };
+
+
+struct nanotmuState
+    {
+    struct booleanstate texture_2d;
+    struct floatstate texture_env_mode;                                         
+    struct uintstate boundtexture;      
+    struct ptrstate vertex_array;                                       
+    struct ptrstate color_array;
+    struct ptrstate texture_coord_array;
+    };
+
+static struct nanotmuState tmuState0;
+static struct nanotmuState tmuState1;
+        
+static struct nanotmuState tmuInitState = 
+    {
+    {GL_FALSE, GL_FALSE},           
+    {GL_MODULATE,GL_FALSE},        
+    {0x7fffffff,GL_FALSE},
+    {4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
+    {4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
+    {4,GL_FLOAT,0, NULL, GL_FALSE, GL_FALSE},
+    };   
+
+static struct nanotmuState* activetmuState = &tmuState0;
+
+extern "C++" GlESInterface* glEsImpl;
+
+static GLenum wrapperPrimitiveMode = GL_QUADS;
+GLboolean useTexCoordArray = GL_FALSE;
+static GLenum activetmu = GL_TEXTURE0;
+static GLenum clientactivetmu = GL_TEXTURE0;
+
+#if defined(__MULTITEXTURE_SUPPORT__)
+GLboolean useMultiTexCoordArray = GL_FALSE;
+#endif
+
+
+#if !defined (__WINS__)
+//#define __FORCEINLINE __forceinline
+#define __FORCEINLINE inline
+#else
+#define __FORCEINLINE
+#endif
+
+static GLboolean delayedttmuchange = GL_FALSE;
+static GLenum delayedtmutarget = GL_TEXTURE0;
+
+struct VertexAttrib
+    {
+    float x;
+    float y;
+    float z;
+#if !defined(__MULTITEXTURE_SUPPORT__)
+    float padding;
+#endif
+    unsigned char red;
+    unsigned char green;
+    unsigned char blue;
+    unsigned char alpha;
+    
+    float s;
+    float t;
+#if defined(__MULTITEXTURE_SUPPORT__)
+    float s_multi;
+    float t_multi;
+#endif
+    };
+
+static VertexAttrib vertexattribs[8000];
+
+static GLushort indexArray[30000];
+
+static GLuint vertexCount = 0;
+static GLuint indexCount = 0;
+static GLuint vertexMark = 0;
+static int indexbase = 0;
+
+static VertexAttrib* ptrVertexAttribArray = NULL;
+static VertexAttrib* ptrVertexAttribArrayMark = NULL;
+
+static VertexAttrib currentVertexAttrib;
+#if defined(__MULTITEXTURE_SUPPORT__)
+static VertexAttrib currentVertexAttribInit = {0.0f,0.0f,0.0f,
+                                    255,255,255,255,
+                                    0.0f,0.0f,
+                                    0.0f,0.0f
+                                    };
+#else
+static VertexAttrib currentVertexAttribInit = {0.0f,0.0f,0.0f,0.0f,
+                                    255,255,255,255,
+                                    0.0f,0.0f,
+                                    };
+#endif
+static GLushort* ptrIndexArray = NULL;
+
+static GLboolean arraysValid = GL_FALSE;
+
+void InitGLStructs()
+    {
+    ptrVertexAttribArray = vertexattribs;
+    ptrVertexAttribArrayMark = ptrVertexAttribArray;
+    ptrIndexArray = indexArray;
+    
+    memcpy(&nanoglState, &nanoglInitState, sizeof(struct nanoState));
+    memcpy(&tmuState0,&tmuInitState,sizeof(struct nanotmuState));
+    memcpy(&tmuState1,&tmuInitState,sizeof(struct nanotmuState));    
+    memcpy(&currentVertexAttrib,&currentVertexAttribInit,sizeof(struct VertexAttrib));
+    
+    activetmuState = &tmuState0;
+    wrapperPrimitiveMode = GL_QUADS;
+    useTexCoordArray = GL_FALSE;
+    activetmu = GL_TEXTURE0;
+    clientactivetmu = GL_TEXTURE0;
+    delayedttmuchange = GL_FALSE;
+    delayedtmutarget = GL_TEXTURE0;
+    vertexCount = 0;
+    indexCount = 0;
+    vertexMark = 0;
+    indexbase = 0;
+    arraysValid = GL_FALSE;
+    }
+
+
+void FlushOnStateChange()
+    {
+    if (delayedttmuchange)
+        {
+        delayedttmuchange = GL_FALSE;
+        glEsImpl->glActiveTexture(delayedtmutarget);
+        }
+
+    if (!vertexCount)
+        return;
+
+    if (!arraysValid)
+        {
+        glEsImpl->glClientActiveTexture(GL_TEXTURE0);
+        glEsImpl->glVertexPointer(3, GL_FLOAT, sizeof(VertexAttrib), &vertexattribs[0].x);
+        glEsImpl->glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexAttrib), &vertexattribs[0].red);
+        glEsImpl->glTexCoordPointer(2, GL_FLOAT, sizeof(VertexAttrib), &vertexattribs[0].s);    
+        glEsImpl->glEnableClientState(GL_VERTEX_ARRAY);
+        glEsImpl->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+        glEsImpl->glEnableClientState(GL_COLOR_ARRAY);
+#if defined(__MULTITEXTURE_SUPPORT__)        
+        glEsImpl->glClientActiveTexture(GL_TEXTURE1);
+        glEsImpl->glTexCoordPointer(2, GL_FLOAT, sizeof(VertexAttrib), &vertexattribs[0].s_multi); 
+        glEsImpl->glEnableClientState(GL_TEXTURE_COORD_ARRAY);  
+        glEsImpl->glClientActiveTexture(GL_TEXTURE0);   
+#endif
+        arraysValid = GL_TRUE;
+        }
+
+    glEsImpl->glDrawElements( GL_TRIANGLES,vertexCount,GL_UNSIGNED_SHORT, indexArray );
+
+
+#if defined(__MULTITEXTURE_SUPPORT__)            
+    useMultiTexCoordArray = GL_FALSE;
+#endif
+    vertexCount = 0;
+    indexCount = 0;
+    ptrVertexAttribArray = vertexattribs;
+    ptrVertexAttribArrayMark = ptrVertexAttribArray;
+    ptrIndexArray = indexArray;
+    useTexCoordArray = GL_FALSE;
+    }
+
+void glBegin(GLenum mode)
+    {
+    wrapperPrimitiveMode = mode;
+    vertexMark = vertexCount;    
+    ptrVertexAttribArrayMark = ptrVertexAttribArray;
+    indexbase = indexCount;
+    }
+    
+void glEnd(void)
+    {
+    vertexCount+=((unsigned char*)ptrVertexAttribArray-(unsigned char*)ptrVertexAttribArrayMark)/sizeof(VertexAttrib);
+    if (vertexCount < 3)
+        {
+        return;
+        }
+    switch (wrapperPrimitiveMode)
+        {
+        case GL_QUADS:
+            {
+            *ptrIndexArray++ = indexCount;
+            *ptrIndexArray++ = indexCount+1;
+            *ptrIndexArray++ = indexCount+2;
+            *ptrIndexArray++ = indexCount;
+            *ptrIndexArray++ = indexCount+2;
+            *ptrIndexArray++ = indexCount+3;
+            indexCount+=4;
+            vertexCount+=2;
+            }
+            break;
+        case GL_TRIANGLES:
+            {
+            int  vcount = (vertexCount-vertexMark)/3;
+            for (int count = 0; count < vcount; count++)
+                {
+                *ptrIndexArray++ = indexCount;
+                *ptrIndexArray++ = indexCount+1;
+                *ptrIndexArray++ = indexCount+2;            
+                indexCount+=3;    
+                }
+            }
+            break;
+        case GL_TRIANGLE_STRIP:
+            {
+            *ptrIndexArray++ = indexCount;
+            *ptrIndexArray++ = indexCount+1;
+            *ptrIndexArray++ = indexCount+2;
+            indexCount+=3;
+            int vcount = ((vertexCount-vertexMark)-3);
+            if (vcount && ((long)ptrIndexArray & 0x02))
+                {
+                *ptrIndexArray++ = indexCount-1; // 2 
+                *ptrIndexArray++ = indexCount-2; // 1
+                *ptrIndexArray++ = indexCount;   // 3
+                indexCount++;
+                vcount-=1;    
+                int odd = vcount&1;
+                vcount/=2;
+                unsigned int* longptr = (unsigned int*) ptrIndexArray;
+
+                for (int count = 0; count < vcount; count++)
+                    {
+                    *(longptr++) = (indexCount-2) | ((indexCount-1)<<16);                    
+                    *(longptr++) = (indexCount) | ((indexCount)<<16);                    
+                    *(longptr++) = (indexCount-1) | ((indexCount+1)<<16);
+                    indexCount+=2;
+                    }
+                ptrIndexArray = (unsigned short*)(longptr);
+                if (odd)
+                    {
+                    *ptrIndexArray++ = indexCount-2; // 2 
+                    *ptrIndexArray++ = indexCount-1; // 1
+                    *ptrIndexArray++ = indexCount;   // 3
+                    indexCount++;    
+                    }
+                }
+           else
+                {
+                //already aligned
+                int odd = vcount&1;
+                vcount/=2;
+                unsigned int* longptr = (unsigned int*) ptrIndexArray;
+
+                for (int count = 0; count < vcount; count++)
+                    {                    
+                    *(longptr++) = (indexCount-1) | ((indexCount-2)<<16);                    
+                    *(longptr++) = (indexCount) | ((indexCount-1)<<16);                    
+                    *(longptr++) = (indexCount) | ((indexCount+1)<<16);
+                    indexCount+=2;
+
+                    }
+                ptrIndexArray = (unsigned short*)(longptr);
+                if (odd)
+                    {
+                    
+                    *ptrIndexArray++ = indexCount-1; // 2 
+                    *ptrIndexArray++ = indexCount-2; // 1
+                    *ptrIndexArray++ = indexCount;   // 3
+                    indexCount++;    
+                    }
+                }            
+            vertexCount+=(vertexCount-vertexMark-3)*2;
+            }
+            break;
+        case GL_POLYGON:
+        case GL_TRIANGLE_FAN:
+            {
+            *ptrIndexArray++ = indexCount++;
+            *ptrIndexArray++ = indexCount++;
+            *ptrIndexArray++ = indexCount++;
+            int vcount = ((vertexCount-vertexMark)-3);
+            for (int count = 0; count < vcount; count++)
+                {
+                *ptrIndexArray++ = indexbase;
+                *ptrIndexArray++ = indexCount-1;
+                *ptrIndexArray++ = indexCount++;                
+                vertexCount+=2;
+                }
+             }   
+            break;
+
+        default:
+            break;
+        }
+    }
+
+void glEnable (GLenum cap)
+    {
+    GLboolean statechanged = GL_FALSE;
+    switch(cap)
+        {
+        case GL_ALPHA_TEST:
+            {
+            if (!nanoglState.alpha_test)
+                {
+                nanoglState.alpha_test = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_BLEND:
+            {
+            if (!nanoglState.blend)
+                {
+                nanoglState.blend = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        //case GL_CLIP_PLANEi
+        case GL_COLOR_LOGIC_OP:
+            {
+            if (!nanoglState.color_logic_op)
+                {
+                nanoglState.color_logic_op = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_COLOR_MATERIAL:
+            {
+            if (!nanoglState.color_material)
+                {
+                nanoglState.color_material = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_CULL_FACE:
+            {
+            if (!nanoglState.cull_face)
+                {
+                nanoglState.cull_face = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_DEPTH_TEST:
+            {
+            if (!nanoglState.depth_test)
+                {
+                nanoglState.depth_test = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_DITHER:
+            {
+            if (!nanoglState.dither)
+                {
+                nanoglState.dither = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_FOG:
+        //case GL_LIGHTi
+            {
+            if (!nanoglState.fog)
+                {
+                nanoglState.fog = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_LIGHTING:
+            {
+            if (!nanoglState.lighting)
+                {
+                nanoglState.lighting = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_LINE_SMOOTH:
+            {
+            if (!nanoglState.line_smooth)
+                {
+                nanoglState.line_smooth = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+/*        case GL_MATRIX_PALETTE_OES:
+            {
+            if (!nanoglState.matrix_palette_oes)
+                {
+                nanoglState.matrix_palette_oes = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }*/
+        case GL_MULTISAMPLE:
+            {
+            if (!nanoglState.multisample)
+                {
+                nanoglState.multisample = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_NORMALIZE:
+            {
+            if (!nanoglState.normalize)
+                {
+                nanoglState.normalize = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+/*        case GL_POINT_SPRITE_OES:
+            {
+            if (!nanoglState.point_sprite_oes)
+                {
+                nanoglState.point_sprite_oes = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }*/
+        case GL_POLYGON_OFFSET_FILL:
+            {
+            if (!nanoglState.polygon_offset_fill)
+                {
+                nanoglState.polygon_offset_fill = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_RESCALE_NORMAL:
+            {
+            if (!nanoglState.rescale_normal)
+                {
+                nanoglState.rescale_normal = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_SAMPLE_ALPHA_TO_COVERAGE:
+            {
+            if (!nanoglState.sample_alpha_to_coverage)
+                {
+                nanoglState.sample_alpha_to_coverage = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_SAMPLE_ALPHA_TO_ONE:
+            {
+            if (!nanoglState.sample_alpha_to_one)
+                {
+                nanoglState.sample_alpha_to_one = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_SAMPLE_COVERAGE:
+            {
+            if (!nanoglState.sample_coverage)
+                {
+                nanoglState.sample_coverage = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_SCISSOR_TEST:
+            {
+            if (!nanoglState.scissor_test)
+                {
+                nanoglState.scissor_test = GL_TRUE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_STENCIL_TEST:
+            {
+            return;
+/*            if (!nanoglState.stencil_test)
+                {
+                nanoglState.stencil_test = GL_TRUE;
+                statechanged = GL_TRUE;
+                }*/
+            break;
+            }
+        case GL_TEXTURE_2D:   
+            {
+            if (!activetmuState->texture_2d.value)
+                {
+                FlushOnStateChange();
+                glEsImpl->glEnable(cap);
+                activetmuState->texture_2d.value = GL_TRUE;
+                return;              
+                }
+            break;
+            }
+        default:
+            break;
+        }
+        
+    if (statechanged)
+        {
+        FlushOnStateChange();
+        glEsImpl->glEnable(cap);
+        }    
+    }
+
+void glDisable (GLenum cap)
+    {
+    GLboolean statechanged = GL_FALSE;
+    switch(cap)
+        {
+        case GL_ALPHA_TEST:
+            {
+            if (nanoglState.alpha_test)
+                {
+                nanoglState.alpha_test = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_BLEND:
+            {
+            if (nanoglState.blend)
+                {
+                nanoglState.blend = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        //case GL_CLIP_PLANEi
+        case GL_COLOR_LOGIC_OP:
+            {
+            if (nanoglState.color_logic_op)
+                {
+                nanoglState.color_logic_op = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_COLOR_MATERIAL:
+            {
+            if (nanoglState.color_material)
+                {
+                nanoglState.color_material = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_CULL_FACE:
+            {
+            if (nanoglState.cull_face)
+                {
+                nanoglState.cull_face = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_DEPTH_TEST:
+            {
+            if (nanoglState.depth_test)
+                {
+                nanoglState.depth_test = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_DITHER:
+            {
+            if (nanoglState.dither)
+                {
+                nanoglState.dither = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_FOG:
+        //case GL_LIGHTi
+            {
+            if (nanoglState.fog)
+                {
+                nanoglState.fog = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_LIGHTING:
+            {
+            if (nanoglState.lighting)
+                {
+                nanoglState.lighting = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_LINE_SMOOTH:
+            {
+            if (nanoglState.line_smooth)
+                {
+                nanoglState.line_smooth = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+/*        case GL_MATRIX_PALETTE_OES:
+            {
+            if (nanoglState.matrix_palette_oes)
+                {
+                nanoglState.matrix_palette_oes = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }*/
+        case GL_MULTISAMPLE:
+            {
+            if (nanoglState.multisample)
+                {
+                nanoglState.multisample = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_NORMALIZE:
+            {
+            if (nanoglState.normalize)
+                {
+                nanoglState.normalize = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+/*        case GL_POINT_SPRITE_OES:
+            {
+            if (nanoglState.point_sprite_oes)
+                {
+                nanoglState.point_sprite_oes = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }*/
+        case GL_POLYGON_OFFSET_FILL:
+            {
+            if (nanoglState.polygon_offset_fill)
+                {
+                nanoglState.polygon_offset_fill = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_RESCALE_NORMAL:
+            {
+            if (nanoglState.rescale_normal)
+                {
+                nanoglState.rescale_normal = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_SAMPLE_ALPHA_TO_COVERAGE:
+            {
+            if (nanoglState.sample_alpha_to_coverage)
+                {
+                nanoglState.sample_alpha_to_coverage = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_SAMPLE_ALPHA_TO_ONE:
+            {
+            if (nanoglState.sample_alpha_to_one)
+                {
+                nanoglState.sample_alpha_to_one = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_SAMPLE_COVERAGE:
+            {
+            if (nanoglState.sample_coverage)
+                {
+                nanoglState.sample_coverage = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_SCISSOR_TEST:
+            {
+            if (nanoglState.scissor_test)
+                {
+                nanoglState.scissor_test = GL_FALSE;
+                statechanged = GL_TRUE;
+                }
+            break;
+            }
+        case GL_STENCIL_TEST:
+            {
+            return;
+/*            if (nanoglState.stencil_test)
+                {
+                nanoglState.stencil_test = GL_FALSE;
+                statechanged = GL_TRUE;
+                }*/
+            break;
+            }
+        case GL_TEXTURE_2D:   
+            {
+            if (activetmuState->texture_2d.value)
+                {
+                FlushOnStateChange();
+                glEsImpl->glDisable(cap);
+                activetmuState->texture_2d.value = GL_FALSE;
+                return;
+
+
+                }
+            break;
+            }
+        default:
+            break;
+        }
+        
+    if (statechanged)
+        {
+        FlushOnStateChange();
+        glEsImpl->glDisable(cap);
+        }    
+    }
+    
+void glVertex2f(GLfloat x, GLfloat y)
+    {
+    glVertex3f(x,y,0.0f);
+    }
+
+
+__FORCEINLINE unsigned int ClampTo255(float value)
+    {
+    unsigned int retval = (unsigned int)(value);
+    if (retval > 255)
+        {
+        retval = 255;
+        }
+    return retval;
+    }
+
+void glColor3f(        GLfloat red, GLfloat green, GLfloat blue)
+    {
+    currentVertexAttrib.red = (unsigned char)ClampTo255(red*255.0f);
+    currentVertexAttrib.green = (unsigned char)ClampTo255(green*255.0f);
+    currentVertexAttrib.blue = (unsigned char)ClampTo255(blue*255.0f);
+    currentVertexAttrib.alpha = 255;
+    }
+
+
+void glTexCoord2fv( const GLfloat *v ) 
+    {
+    memcpy(&currentVertexAttrib.s, v, 2*sizeof(float));
+    }
+
+
+void glTexCoord2f(GLfloat s, GLfloat t)
+    {
+    currentVertexAttrib.s = s;
+    currentVertexAttrib.t = t;
+    }
+    
+void glViewport (GLint x, GLint y, GLsizei width, GLsizei height)
+    {
+    FlushOnStateChange();
+    glEsImpl->glViewport(x,y,width,height);
+    }
+    
+void glLoadIdentity (void)
+    {
+    FlushOnStateChange();
+    glEsImpl->glLoadIdentity();
+    }
+    
+void glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+    {
+    currentVertexAttrib.red = (unsigned char)ClampTo255(red*255.0f);
+    currentVertexAttrib.green = (unsigned char)ClampTo255(green*255.0f);
+    currentVertexAttrib.blue = (unsigned char)ClampTo255(blue*255.0f);
+    currentVertexAttrib.alpha = (unsigned char)ClampTo255(alpha*255.0f);
+    }
+
+void glOrtho (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+    {
+    FlushOnStateChange();
+    glEsImpl->glOrthof(left,right,bottom,top, zNear,zFar);
+    }
+
+void glMatrixMode (GLenum mode)
+    {
+    if (nanoglState.matrixmode == mode)
+        {
+        return;
+        }
+    nanoglState.matrixmode = mode;
+    FlushOnStateChange();
+    glEsImpl->glMatrixMode(mode);
+    }
+
+void glTexParameterf (GLenum target, GLenum pname, GLfloat param)
+    {
+    if (pname == GL_TEXTURE_BORDER_COLOR)
+        {
+        return; // not supported by opengl es
+        }
+    if (    (pname == GL_TEXTURE_WRAP_S ||
+             pname == GL_TEXTURE_WRAP_T) &&
+             param == GL_CLAMP)
+             {
+             param = 0x812F;
+             }
+
+    FlushOnStateChange();
+    glEsImpl->glTexParameterf(target, pname,param);
+    }
+    
+void glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params) 
+    {
+    glTexParameterf(target, pname, params[0]);
+    }
+
+void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
+    {
+    FlushOnStateChange();
+    internalformat = format;
+    glEsImpl->glTexImage2D(target, level, internalformat, width, height,border,format,type,pixels);
+    }
+
+void glDrawBuffer(GLenum /*mode*/)
+    {
+    }
+
+void glTranslatef (GLfloat x, GLfloat y, GLfloat z)
+    {
+    FlushOnStateChange();
+    glEsImpl->glTranslatef(x,y,z);
+    }
+    
+void glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+    {
+    FlushOnStateChange();
+    glEsImpl->glRotatef(angle, x, y, z);
+    }
+
+void glScalef (GLfloat x, GLfloat y, GLfloat z)
+    {
+    FlushOnStateChange();
+    glEsImpl->glScalef(x,y,z);
+    }
+    
+void glDepthRange(GLclampf zNear, GLclampf zFar)
+    {
+    if ((nanoglState.depth_range_near == zNear) &&(nanoglState.depth_range_far == zFar))
+        {
+        return;
+        }
+    else
+        {
+        nanoglState.depth_range_near = zNear;
+        nanoglState.depth_range_far = zFar;
+        }
+    FlushOnStateChange();
+    glEsImpl->glDepthRangef(zNear, zFar);
+    }
+
+void glDepthFunc (GLenum func)
+    {
+    if (nanoglState.depth_func == func)
+        {
+        return;
+        }
+    else
+        {
+        nanoglState.depth_func = func;
+        }
+    FlushOnStateChange();
+    glEsImpl->glDepthFunc(func);
+    }
+
+void glFinish (void)
+    {
+    FlushOnStateChange();
+    glEsImpl->glFinish();
+    }
+
+void glGetFloatv (GLenum pname, GLfloat *params)
+    {
+    FlushOnStateChange();
+    glEsImpl->glGetFloatv(pname, params);
+    }
+
+void glCullFace (GLenum mode)
+    {
+    if (nanoglState.cullface == mode)
+        {
+        return;
+        }
+    else
+        {
+        nanoglState.cullface = mode;
+        }
+    FlushOnStateChange();
+    glEsImpl->glCullFace(mode);
+    }
+
+void glFrustum (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+    {
+    FlushOnStateChange();
+    glEsImpl->glFrustumf(left,right,bottom,top,zNear,zFar);
+    }
+
+void glClear (GLbitfield mask)
+    {
+    FlushOnStateChange();
+    glEsImpl->glClear(mask);
+    }
+
+
+void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
+    {
+    GLfloat* vert = (GLfloat*)ptrVertexAttribArray++;
+    *vert++ = x;
+    *vert++ = y;
+    *vert++ = z;
+#if defined(__MULTITEXTURE_SUPPORT__)
+    memcpy(vert, &currentVertexAttrib.red, 5*sizeof(GLfloat));
+#else
+    memcpy(vert+1, &currentVertexAttrib.red, 3*sizeof(GLfloat));
+#endif
+
+    }
+
+void glColor4fv( const GLfloat *v )
+    {
+    currentVertexAttrib.red = (unsigned char)ClampTo255(v[0]*255.0f);
+    currentVertexAttrib.green = (unsigned char)ClampTo255(v[1]*255.0f);
+    currentVertexAttrib.blue = (unsigned char)ClampTo255(v[2]*255.0f);
+    currentVertexAttrib.alpha = (unsigned char)ClampTo255(v[3]*255.0f);
+    }
+    
+void glColor3ubv( const GLubyte* v)
+    {
+    currentVertexAttrib.red = v[0];
+    currentVertexAttrib.green = v[1];
+    currentVertexAttrib.blue = v[2];
+    currentVertexAttrib.alpha = 255;
+    }
+    
+void glColor4ubv( const GLubyte *v ) 
+    {  
+    //*((unsigned int*)(&currentVertexAttrib.red)) = *((unsigned int*)(v));
+    currentVertexAttrib.red = v[0];
+    currentVertexAttrib.green = v[1];
+    currentVertexAttrib.blue = v[2];
+    currentVertexAttrib.alpha = v[3];
+    }
+    
+void glColor3fv( const GLfloat *v ) 
+    {
+    currentVertexAttrib.red = (unsigned char)ClampTo255(v[0]*255.0f);
+    currentVertexAttrib.green = (unsigned char)ClampTo255(v[1]*255.0f);
+    currentVertexAttrib.blue = (unsigned char)ClampTo255(v[2]*255.0f);
+    currentVertexAttrib.alpha = 255;
+    }
+
+//-- nicknekit: xash3d funcs --
+
+void glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
+    {
+    currentVertexAttrib.red = red;
+    currentVertexAttrib.green = green;
+    currentVertexAttrib.blue = blue;
+    currentVertexAttrib.alpha = alpha;
+    }
+
+void glColor3ub( GLubyte red, GLubyte green, GLubyte blue)
+    {
+    currentVertexAttrib.red = red;
+    currentVertexAttrib.green = green;
+    currentVertexAttrib.blue = blue;
+    currentVertexAttrib.alpha = 255;
+    }
+
+void glNormal3fv( const GLfloat *v ) 
+    {
+    FlushOnStateChange();
+    glEsImpl->glNormal3f(v[0],v[1],v[2]);
+    }
+
+void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
+    {
+    FlushOnStateChange();
+    glEsImpl->glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
+    }
+
+void glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
+    {
+    glTexImage2D(GL_TEXTURE_2D, level, internalformat,  width, 1, border, format, type, pixels);
+    }
+
+void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
+    {
+    glTexImage2D(GL_TEXTURE_2D, level, internalformat,  width, height, border, format, type, pixels);
+    }
+
+void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
+    {
+    glTexSubImage2D(target,level,xoffset,0,width,1,format,type,pixels);
+    }
+
+void glTexSubImage3D( GLenum target, GLint level,
+                                         GLint xoffset, GLint yoffset,
+                                         GLint zoffset, GLsizei width,
+                                         GLsizei height, GLsizei depth,
+                                         GLenum format,
+                                         GLenum type, const GLvoid *pixels)
+    {
+    glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
+    }
+
+
+
+GLboolean glIsTexture(GLuint texture)
+    {
+    FlushOnStateChange();
+    return glEsImpl->glIsTexture(texture);
+    }
+
+
+void glTexGeni( GLenum coord, GLenum pname, GLint param )
+{
+//for mirrors? not needed for original hl?
+}
+
+void glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
+{
+//for mirrors? not needed for original hl?
+}
+
+//-- --//
+
+void glHint (GLenum target, GLenum mode)
+    {
+    FlushOnStateChange();
+    glEsImpl->glHint(target, mode);
+    }
+
+void glBlendFunc (GLenum sfactor, GLenum dfactor)
+    {
+    if ((nanoglState.sfactor == sfactor) && (nanoglState.dfactor == dfactor))
+        {
+        return;
+        }
+    nanoglState.sfactor = sfactor;
+    nanoglState.dfactor = dfactor;
+    FlushOnStateChange();
+    glEsImpl->glBlendFunc(sfactor, dfactor);
+    }
+
+void glPopMatrix (void)
+    {
+    FlushOnStateChange();
+    glEsImpl->glPopMatrix();
+    }
+
+void glShadeModel (GLenum mode)
+    {
+    if (nanoglState.shademodel == mode)
+        {
+        return;
+        }
+    nanoglState.shademodel = mode;
+    FlushOnStateChange();
+    glEsImpl->glShadeModel(mode);
+    }
+
+void glPushMatrix (void)
+    {
+    FlushOnStateChange();
+    glEsImpl->glPushMatrix();
+    }
+
+void glTexEnvf (GLenum target, GLenum pname, GLfloat param)
+    {
+    if (target == GL_TEXTURE_ENV)
+        {
+        if (pname == GL_TEXTURE_ENV_MODE)
+            {
+            if (param == activetmuState->texture_env_mode.value)
+                {
+                return;
+                } 
+            else
+                {
+                FlushOnStateChange();
+                glEsImpl->glTexEnvf(target, pname, param);
+                activetmuState->texture_env_mode.value = param;
+                return;
+                }
+            }
+        }
+    FlushOnStateChange();
+    glEsImpl->glTexEnvf(target, pname, param);
+    }
+
+void glVertex3fv( const GLfloat *v )
+    {
+    GLfloat* vert = (GLfloat*)ptrVertexAttribArray++;
+    memcpy(vert, v, 3*sizeof(GLfloat));
+#if defined(__MULTITEXTURE_SUPPORT__)
+    memcpy(vert+3, &currentVertexAttrib.red, 5*sizeof(GLfloat));
+#else
+    memcpy(vert+4, &currentVertexAttrib.red, 3*sizeof(GLfloat));
+#endif
+    }
+    
+
+void glDepthMask (GLboolean flag)
+    {
+    if (nanoglState.depthmask == flag)
+        {
+        return;
+        }
+    nanoglState.depthmask = flag;
+    FlushOnStateChange();
+    glEsImpl->glDepthMask(flag);
+    }
+
+void glBindTexture (GLenum target, GLuint texture)
+    {
+    if (activetmuState->boundtexture.value == texture)
+        {
+        return;
+        }
+    FlushOnStateChange();
+    activetmuState->boundtexture.value = texture;
+    glEsImpl->glBindTexture(target, texture);
+    }
+
+
+void glGetIntegerv (GLenum pname, GLint *params)
+    {
+    FlushOnStateChange();
+    glEsImpl->glGetIntegerv(pname, params);
+    }
+
+GLubyte nano_extensions_string[4096];
+const GLubyte* glGetString (GLenum name)
+    {
+
+    if (name == GL_EXTENSIONS)
+        {
+#if defined(__MULTITEXTURE_SUPPORT__)
+        sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"GL_ARB_multitexture EXT_texture_env_add");
+#else
+        sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"EXT_texture_env_add");
+#endif
+        return nano_extensions_string;
+        }
+    return glEsImpl->glGetString(name);
+    }
+
+void glAlphaFunc (GLenum func, GLclampf ref)
+    {
+    FlushOnStateChange();
+    glEsImpl->glAlphaFunc(func,ref);
+    }
+
+void glFlush (void)
+    {
+    FlushOnStateChange();
+    glEsImpl->glFlush();
+    }
+
+void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+    {
+    if (format == GL_DEPTH_COMPONENT)
+        {
+        // OpenglEs 1.1 does not support reading depth buffer without an extension
+        memset(pixels, 0xff,4);
+        return;   
+        }
+    FlushOnStateChange();
+    glEsImpl->glReadPixels(x,y,width,height,format,type,pixels);
+    }
+
+void glReadBuffer( GLenum /*mode*/ )
+    {
+    
+    }
+
+void glLoadMatrixf (const GLfloat *m)
+    {
+    FlushOnStateChange();
+    glEsImpl->glLoadMatrixf(m);
+    }
+
+void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+    {
+    FlushOnStateChange();
+    glEsImpl->glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
+    }
+
+void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+    {
+    FlushOnStateChange();
+    glEsImpl->glClearColor(red,green,blue,alpha);
+    }
+
+GLenum glGetError (void)
+    {
+    FlushOnStateChange();
+    return GL_NO_ERROR;//glEsImpl->glGetError();
+    }
+
+void glActiveTexture (GLenum texture)
+    {
+    if (activetmu == texture)
+        {
+        return;
+        }
+    if (delayedttmuchange)
+        {
+        delayedttmuchange = GL_FALSE;
+        }
+    else
+        {
+        delayedttmuchange = GL_TRUE;
+        delayedtmutarget = texture;
+        }
+    if (texture == GL_TEXTURE0)
+        {
+        activetmuState = &tmuState0;
+        }
+    else
+        {
+        activetmuState = &tmuState1;
+        }
+    activetmu = texture;
+    }
+    
+void glClientActiveTexture (GLenum texture)
+    {
+    clientactivetmu = texture;
+    }
+    
+void glPolygonMode( GLenum face, GLenum mode )
+    {
+    }
+
+void glDeleteTextures( GLsizei n, const GLuint *textures ) 
+    {
+    FlushOnStateChange();
+    glEsImpl->glDeleteTextures(n,textures);
+    }
+
+void glClearDepth( GLclampf depth ) 
+    {
+    FlushOnStateChange();
+    glEsImpl->glClearDepthf( depth ); 
+    }
+
+void glClipPlane( GLenum plane, const GLdouble *equation ) 
+    {
+    FlushOnStateChange();
+    float array[4];
+    array[0] = (GLfloat)(equation[0]);
+    array[1] = (GLfloat)(equation[1]);
+    array[2] = (GLfloat)(equation[2]);
+    array[3] = (GLfloat)(equation[3]);
+    glEsImpl->glClipPlanef( plane, array );
+    }
+
+void glScissor( GLint x, GLint y, GLsizei width, GLsizei height ) 
+    {
+    FlushOnStateChange();
+    glEsImpl->glScissor( x, y, width,height);
+    }
+
+void glPointSize( GLfloat size ) 
+    {
+    FlushOnStateChange();
+    glEsImpl->glPointSize( size );
+    }
+
+void glArrayElement(GLint i) {}
+void glLineWidth(GLfloat width) {}
+void glCallList( GLuint list ) {}
+void glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ) {}
+void glStencilFunc( GLenum func, GLint ref, GLuint mask ) {}
+void glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ) {}
+
+struct ptrstate vertex_array;                                       
+struct ptrstate color_array;
+struct ptrstate texture_coord_array;
+
+void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ) 
+    {
+    // ensure that all primitives specified between glBegin/glEnd pairs
+    // are rendered first, and that we have correct tmu in use..
+    FlushOnStateChange();
+    // setup correct vertex/color/texcoord pointers
+    if (arraysValid || 
+        tmuState0.vertex_array.changed ||
+        tmuState0.color_array.changed ||
+        tmuState0.texture_coord_array.changed)
+        {
+        glEsImpl->glClientActiveTexture(GL_TEXTURE0);
+        }
+    if (arraysValid || tmuState0.vertex_array.changed)
+        {
+        if (tmuState0.vertex_array.enabled)
+            {
+            glEsImpl->glEnableClientState(GL_VERTEX_ARRAY);
+            }
+        else
+            {
+            glEsImpl->glDisableClientState(GL_VERTEX_ARRAY);
+            }
+        glEsImpl->glVertexPointer(tmuState0.vertex_array.size, 
+                                  tmuState0.vertex_array.type, 
+                                  tmuState0.vertex_array.stride, 
+                                  tmuState0.vertex_array.ptr);
+        tmuState0.vertex_array.changed = GL_FALSE;
+        }
+    if (arraysValid || tmuState0.color_array.changed)
+        {
+        if (tmuState0.color_array.enabled)
+            {
+            glEsImpl->glEnableClientState(GL_COLOR_ARRAY);
+            }
+        else
+            {
+            glEsImpl->glDisableClientState(GL_COLOR_ARRAY);
+            }
+        glEsImpl->glColorPointer(tmuState0.color_array.size, 
+                                 tmuState0.color_array.type, 
+                                 tmuState0.color_array.stride, 
+                                 tmuState0.color_array.ptr);
+        tmuState0.color_array.changed = GL_FALSE;
+        }
+    if (arraysValid || tmuState0.texture_coord_array.changed)
+        {
+        tmuState0.texture_coord_array.changed = GL_FALSE;
+        if (tmuState0.texture_coord_array.enabled)
+            {
+            glEsImpl->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+            }
+        else
+            {
+            glEsImpl->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+            }
+        glEsImpl->glTexCoordPointer(tmuState0.texture_coord_array.size, 
+                                        tmuState0.texture_coord_array.type, 
+                                        tmuState0.texture_coord_array.stride, 
+                                        tmuState0.texture_coord_array.ptr);
+        }
+    if (arraysValid || tmuState1.texture_coord_array.changed)
+        {
+        tmuState1.texture_coord_array.changed = GL_FALSE;
+        glEsImpl->glClientActiveTexture(GL_TEXTURE1);
+        if (tmuState1.texture_coord_array.enabled)
+            {
+            glEsImpl->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+            }
+        else
+            {
+            glEsImpl->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+            }
+        glEsImpl->glTexCoordPointer(tmuState1.texture_coord_array.size, 
+                                        tmuState1.texture_coord_array.type, 
+                                        tmuState1.texture_coord_array.stride, 
+                                        tmuState1.texture_coord_array.ptr);
+        }
+
+    arraysValid = GL_FALSE;
+    glEsImpl->glDrawElements(mode, count, type, indices);
+    }
+
+void glEnableClientState(GLenum  array) 
+    {
+    struct nanotmuState* clientstate = NULL;
+    if (clientactivetmu == GL_TEXTURE0)
+        {
+        clientstate = &tmuState0;
+        }
+    else if (clientactivetmu == GL_TEXTURE1)
+        {
+        clientstate = &tmuState1;
+        }
+    else
+        {
+        return;
+        }
+    switch (array)
+        {
+        case GL_VERTEX_ARRAY:
+            if (clientstate->vertex_array.enabled)
+                {
+                return;
+                }
+            clientstate->vertex_array.enabled = GL_TRUE;
+            clientstate->vertex_array.changed = GL_TRUE;
+            break;
+        case GL_COLOR_ARRAY:
+            if (clientstate->color_array.enabled)
+                {
+                return;
+                }
+            clientstate->color_array.enabled = GL_TRUE;
+            clientstate->color_array.changed = GL_TRUE;
+
+            break;
+        case GL_TEXTURE_COORD_ARRAY:
+            if (clientstate->texture_coord_array.enabled)
+                {
+                return;
+                }
+            clientstate->texture_coord_array.enabled = GL_TRUE;
+            clientstate->texture_coord_array.changed = GL_TRUE;
+            break;
+        default:
+            break;
+        }
+    }
+void glDisableClientState(GLenum  array) 
+    {
+    struct nanotmuState* clientstate = NULL;
+    if (clientactivetmu == GL_TEXTURE0)
+        {
+        clientstate = &tmuState0;
+        }
+    else if (clientactivetmu == GL_TEXTURE1)
+        {
+        clientstate = &tmuState1;
+        }
+    else
+        {
+        return;
+        }
+    switch (array)
+        {
+        case GL_VERTEX_ARRAY:
+            if (!clientstate->vertex_array.enabled)
+                {
+                return;
+                }
+            clientstate->vertex_array.enabled = GL_FALSE;
+            clientstate->vertex_array.changed = GL_TRUE;
+            break;
+        case GL_COLOR_ARRAY:
+            if (!clientstate->color_array.enabled)
+                {
+                return;
+                }
+            clientstate->color_array.enabled = GL_FALSE;
+            clientstate->color_array.changed = GL_TRUE;
+
+            break;
+        case GL_TEXTURE_COORD_ARRAY:
+            if (!clientstate->texture_coord_array.enabled)
+                {
+                return;
+                }
+            clientstate->texture_coord_array.enabled = GL_FALSE;
+            clientstate->texture_coord_array.changed = GL_TRUE;
+            break;
+        default:
+            break;
+        }
+    }
+void glVertexPointer(  GLint size,     GLenum type,GLsizei     stride, const GLvoid *pointer ) 
+    {
+    if (tmuState0.vertex_array.size == size &&
+        tmuState0.vertex_array.stride == stride &&
+        tmuState0.vertex_array.type == type &&
+        tmuState0.vertex_array.ptr == pointer)
+        {
+        return;
+        }
+    tmuState0.vertex_array.size = size;
+    tmuState0.vertex_array.stride = stride;
+    tmuState0.vertex_array.type = type;
+    tmuState0.vertex_array.ptr  = (GLvoid*)pointer;
+    tmuState0.vertex_array.changed = GL_TRUE;
+    }
+void glTexCoordPointer( GLint  size,  GLenum type,  GLsizei stride,  const     GLvoid *pointer ) 
+    {
+    struct nanotmuState* clientstate = NULL;
+    if (clientactivetmu == GL_TEXTURE0)
+        {
+        clientstate = &tmuState0;
+        }
+    else if (clientactivetmu == GL_TEXTURE1)
+        {
+        clientstate = &tmuState1;
+        }
+    if (clientstate->texture_coord_array.size == size &&
+        clientstate->texture_coord_array.stride == stride &&
+        clientstate->texture_coord_array.type == type &&
+        clientstate->texture_coord_array.ptr == pointer)
+        {
+        return;
+        }
+    clientstate->texture_coord_array.size = size;
+    clientstate->texture_coord_array.stride = stride;
+    clientstate->texture_coord_array.type = type;
+    clientstate->texture_coord_array.ptr  = (GLvoid*)pointer;
+    clientstate->texture_coord_array.changed = GL_TRUE;
+    }
+void glColorPointer( GLint size,  GLenum type,  GLsizei stride,  const GLvoid *pointer ) 
+    {
+    if (tmuState0.color_array.size == size &&
+        tmuState0.color_array.stride == stride &&
+        tmuState0.color_array.type == type &&
+        tmuState0.color_array.ptr == pointer)
+        {
+        return;
+        }
+    tmuState0.color_array.size = size;
+    tmuState0.color_array.stride = stride;
+    tmuState0.color_array.type = type;
+    tmuState0.color_array.ptr  = (GLvoid*)pointer;
+    tmuState0.color_array.changed = GL_TRUE;
+    }
+void glPolygonOffset( GLfloat factor, GLfloat units ) 
+    {
+    FlushOnStateChange();
+    glEsImpl->glPolygonOffset(factor, units);
+    }
+void glStencilMask( GLuint mask ) {}
+void glClearStencil( GLint s ) {}
+
+#if defined(__MULTITEXTURE_SUPPORT__)
+
+extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t );
+
+void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t )
+    {
+    if (target == GL_TEXTURE0)
+        {
+        glTexCoord2f(s,t);
+        }
+    else
+        {
+        currentVertexAttrib.s_multi = s;
+        currentVertexAttrib.t_multi = t;
+        }
+    }
+#endif
+
+/* Vladimir  */
+void glDrawArrays( GLenum mode, int first, int count)
+{
+    FlushOnStateChange();
+    glEsImpl->glDrawArrays(mode, first , count);
+}
+void glMultMatrixf (const GLfloat *m)
+{
+    FlushOnStateChange();
+    glEsImpl->glMultMatrixf(m);
+}
+
+void glPixelStorei (GLenum pname, GLint param)
+{
+    FlushOnStateChange();
+    glEsImpl->glPixelStorei(pname, param);
+}
+
+
+void glFogf (GLenum pname, GLfloat param)
+{
+       FlushOnStateChange();
+       glEsImpl->glFogf(pname, param);
+}
+
+void glFogfv (GLenum pname, const GLfloat *params)
+{
+       FlushOnStateChange();
+       glEsImpl->glFogfv(pname, params);
+}
+
+void glGetTexParameteriv (GLenum target, GLenum pname, GLint *params)
+{
+       FlushOnStateChange();
+       glEsImpl->glGetTexParameteriv(target, pname, params);
+}
+
+
+// This gives: called unimplemented OpenGL ES API (Android)
+void glTexParameteri (GLenum target, GLenum pname, GLint param)
+{
+    if (pname == GL_TEXTURE_BORDER_COLOR) {
+               return; // not supported by opengl es
+       }
+    if (    (pname == GL_TEXTURE_WRAP_S ||
+             pname == GL_TEXTURE_WRAP_T) &&
+             param == GL_CLAMP)   {
+               param = 0x812F;
+       }
+
+       FlushOnStateChange();
+       glEsImpl->glTexParameteri(target, pname, param);
+}
+
+void glTexParameterx (GLenum target, GLenum pname, GLfixed param)
+{
+    if (pname == GL_TEXTURE_BORDER_COLOR) {
+               return; // not supported by opengl es
+       }
+    if (    (pname == GL_TEXTURE_WRAP_S ||
+             pname == GL_TEXTURE_WRAP_T) &&
+             param == GL_CLAMP)   {
+               param = 0x812F;
+       }
+       FlushOnStateChange();
+       glEsImpl->glTexParameterx(target, pname, param);
+}
+
+void glGenTextures (GLsizei n, GLuint *textures)
+{
+       FlushOnStateChange();
+       glEsImpl->glGenTextures(n, textures);
+}
+
+void glFrontFace (GLenum mode)
+{
+       FlushOnStateChange();
+       glEsImpl->glFrontFace(mode);
+}
+
+
+
+// End Vladimir
+
+
+
diff --git a/nanogl.cpp b/nanogl.cpp
new file mode 100644 (file)
index 0000000..823851f
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+Copyright (C) 2007-2009 Olli Hinkka
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#define LOG_TAG "nanoGL"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+//#include <cutils/log.h>
+#include <android/log.h>
+
+#include "nanogl.h"
+#include "glesinterface.h"
+#include "gl.h"
+
+#define LOG __android_log_print
+#define DEBUG_NANO 0
+
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define LOGD(...) if (DEBUG_NANO) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,__VA_ARGS__)
+#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG,__VA_ARGS__)
+
+#define GL_ENTRY(_r, _api, ...) #_api,
+
+static char const * const gl_names[] = {
+    #include "gl_entries.in"
+    NULL
+};
+
+//const char * driver;
+
+static void* glesLib = NULL;
+
+GlESInterface* glEsImpl = NULL;
+
+extern void InitGLStructs();
+
+static void gl_unimplemented() { 
+       LOGE ("Called unimplemented OpenGL ES API\n"); 
+}
+
+
+static int CreateGlEsInterface( const char * name, void * lib, void * lib1, void * default_func )
+{
+       // alloc space
+       if ( !glEsImpl )
+               glEsImpl = (GlESInterface *) malloc(sizeof(GlESInterface)); 
+
+       if (!glEsImpl) {
+        return 0;
+    }
+
+       // load GL API calls
+       char const * const * api;
+       api = gl_names;
+
+       // nanoGL interface pointer
+       void ** ptr = (void **)(glEsImpl);
+
+       while (*api) 
+       {
+               void * f;
+               
+               f = dlsym(lib, *api); // ltry ibGLESxx_CM.so
+
+               if (f == NULL) {
+                       LOGW( "<%s> not found in %s. Trying libEGL.so.", *api, name); //driver);
+                       
+                       // try lib1
+                       if ( lib1 ) {
+                               f = dlsym(lib1, *api); // libEGL.so
+                               
+                               if ( f == NULL ) {
+                                       LOGE ( "<%s> not found in libEGL.so", *api);
+                                       f = default_func; //(void*)gl_unimplemented;
+                               }
+                               else {
+                                       LOGD ("<%s> @ 0x%p\n", *api, f);
+                               }
+                       }
+                       else 
+                               f = default_func;
+               }
+               else {
+                       LOGD ("<%s> @ 0x%p\n", *api, f);
+               }
+                       
+           *ptr++ = f;
+        api++;
+    }
+
+       return 1;
+}
+
+// Load using the dynamic loader
+static int loadDriver(const char * name) {
+       glesLib = dlopen(name, RTLD_NOW | RTLD_LOCAL);
+       int rc = (glesLib) ? 1 : 0;
+       return rc;
+}
+
+/**
+ * Init
+ */
+int nanoGL_Init()
+{
+       const char * lib1 = "libGLESv1_CM.so";  // Has both gl* & egl* funcs SDK < 1.5
+       const char * lib2 = "libGLESv2.so";     // Only gl* funcs SDK >= 1.5
+       const char * lib3 = "libEGL.so";                // Only egl* funcs SDK >= 1.5
+       const char * driver;
+       
+       // load lib
+       LOGI("nanoGL: Init loading driver %s\n", lib1);
+       //LOG (ANDROID_LOG_DEBUG, LOG_TAG, "nanoGL: Init loading driver %s\n", lib1);
+
+       if ( ! loadDriver(lib1) ) 
+       {
+               LOGE("Failed to load driver %s. Trying %s\n", lib1, lib2);
+
+               if ( ! loadDriver(lib2) ) {
+                       LOGE ("Failed to load  %s.\n", lib2);
+                       return 0;
+               }
+               else
+                       driver = lib2;
+       }
+       else
+               driver = lib1;
+
+       void * eglLib;
+       
+       //if ( strcmp(driver, lib2) == 0 ) {
+               LOGD ("**** Will Load EGL subs from %s ****", lib3);
+               
+               eglLib = dlopen(lib3, RTLD_NOW | RTLD_LOCAL);
+               
+               if ( ! eglLib ) {
+                       LOGE ( "Failed to load %s", lib3);
+               }
+       //}
+       
+       // Load API gl* for 1.5+  else egl* gl* 
+       //if (CreateGlEsInterface(driver, glesLib, eglLib, NULL) == -1)
+       if ( !CreateGlEsInterface(driver, glesLib, eglLib, (void *) gl_unimplemented) == -1)
+    {
+               // release lib
+               LOGE ( "CreateGlEsInterface failed.");
+
+               dlclose(glesLib);
+           return 0;
+    }
+
+       // Init nanoGL
+       InitGLStructs();
+       return 1;
+}
+
+void nanoGL_Destroy()
+{
+       LOGD ("nanoGL_Destroy");
+       
+       if (glEsImpl) {
+        free( glEsImpl); 
+        glEsImpl = NULL;
+    }
+       
+       // release lib
+       dlclose(glesLib);
+}
+