code:
/* $Change: 597344 $ */
#ifndef __glext_h_
#define __glext_h_

/* $Revision: #1 $ on $Date: 2010/07/30 $ */

#ifdef __cplusplus
extern "C" {
#endif

/*
 * This document is licensed under the SGI Free Software B License Version
 * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
 */

#ifndef GL_APIENTRYP
#   define GL_APIENTRYP GL_APIENTRY*
#endif

#define GL_GLEXT_PROTOTYPES

/*------------------------------------------------------------------------*
 * OES extension tokens
 *------------------------------------------------------------------------*/

/* GL_OES_blend_equation_separate */
#ifndef GL_OES_blend_equation_separate
/* BLEND_EQUATION_RGB_OES same as BLEND_EQUATION_OES */
#define GL_BLEND_EQUATION_RGB_OES                               0x8009
#define GL_BLEND_EQUATION_ALPHA_OES                             0x883D
#endif

/* GL_OES_blend_func_separate */
#ifndef GL_OES_blend_func_separate
#define GL_BLEND_DST_RGB_OES                                    0x80C8
#define GL_BLEND_SRC_RGB_OES                                    0x80C9
#define GL_BLEND_DST_ALPHA_OES                                  0x80CA
#define GL_BLEND_SRC_ALPHA_OES                                  0x80CB
#endif

/* GL_OES_blend_subtract */
#ifndef GL_OES_blend_subtract
#define GL_BLEND_EQUATION_OES                                   0x8009
#define GL_FUNC_ADD_OES                                         0x8006
#define GL_FUNC_SUBTRACT_OES                                    0x800A
#define GL_FUNC_REVERSE_SUBTRACT_OES                            0x800B
#endif

/* GL_OES_compressed_ETC1_RGB8_texture */
#ifndef GL_OES_compressed_ETC1_RGB8_texture
#define GL_ETC1_RGB8_OES                                        0x8D64
#endif

/* GL_OES_depth24 */
#ifndef GL_OES_depth24
#define GL_DEPTH_COMPONENT24_OES                                0x81A6
#endif

/* GL_OES_depth32 */
#ifndef GL_OES_depth32
#define GL_DEPTH_COMPONENT32_OES                                0x81A7
#endif

/* GL_OES_draw_texture */
#ifndef GL_OES_draw_texture
#define GL_TEXTURE_CROP_RECT_OES                                0x8B9D
#endif

/* GL_OES_EGL_image */
#ifndef GL_OES_EGL_image
typedef void* GLeglImageOES;
#endif

/* GL_OES_fixed_point */
#ifndef GL_OES_fixed_point
#define GL_FIXED_OES                                            0x140C
#endif

/* GL_OES_framebuffer_object */
#ifndef GL_OES_framebuffer_object
#define GL_NONE_OES                                             0
#define GL_FRAMEBUFFER_OES                                      0x8D40
#define GL_RENDERBUFFER_OES                                     0x8D41
#define GL_RGBA4_OES                                            0x8056
#define GL_RGB5_A1_OES                                          0x8057
#define GL_RGB565_OES                                           0x8D62
#define GL_DEPTH_COMPONENT16_OES                                0x81A5
#define GL_RENDERBUFFER_WIDTH_OES                               0x8D42
#define GL_RENDERBUFFER_HEIGHT_OES                              0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT_OES                     0x8D44
#define GL_RENDERBUFFER_RED_SIZE_OES                            0x8D50
#define GL_RENDERBUFFER_GREEN_SIZE_OES                          0x8D51
#define GL_RENDERBUFFER_BLUE_SIZE_OES                           0x8D52
#define GL_RENDERBUFFER_ALPHA_SIZE_OES                          0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE_OES                          0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE_OES                        0x8D55
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES               0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES               0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES             0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES     0x8CD3
#define GL_COLOR_ATTACHMENT0_OES                                0x8CE0
#define GL_DEPTH_ATTACHMENT_OES                                 0x8D00
#define GL_STENCIL_ATTACHMENT_OES                               0x8D20
#define GL_FRAMEBUFFER_COMPLETE_OES                             0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES                0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES        0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES                0x8CD9
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES                   0x8CDA
#define GL_FRAMEBUFFER_UNSUPPORTED_OES                          0x8CDD
#define GL_FRAMEBUFFER_BINDING_OES                              0x8CA6
#define GL_RENDERBUFFER_BINDING_OES                             0x8CA7
#define GL_MAX_RENDERBUFFER_SIZE_OES                            0x84E8
#define GL_INVALID_FRAMEBUFFER_OPERATION_OES                    0x0506
#endif

/* GL_OES_mapbuffer */
#ifndef GL_OES_mapbuffer
#define GL_WRITE_ONLY_OES                                       0x88B9
#define GL_BUFFER_ACCESS_OES                                    0x88BB
#define GL_BUFFER_MAPPED_OES                                    0x88BC
#define GL_BUFFER_MAP_POINTER_OES                               0x88BD
#endif

/* GL_OES_matrix_get */
#ifndef GL_OES_matrix_get
#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES               0x898D
#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES              0x898E
#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES                 0x898F
#endif

/* GL_OES_matrix_palette */
#ifndef _WIN32//  _WIN32
#ifndef GL_OES_matrix_palette
#define GL_MAX_VERTEX_UNITS_OES                                 0x86A4
#define GL_MAX_PALETTE_MATRICES_OES                             0x8842
#define GL_MATRIX_PALETTE_OES                                   0x8840
#define GL_MATRIX_INDEX_ARRAY_OES                               0x8844
#define GL_WEIGHT_ARRAY_OES                                     0x86AD
#define GL_CURRENT_PALETTE_MATRIX_OES                           0x8843
#define GL_MATRIX_INDEX_ARRAY_SIZE_OES                          0x8846
#define GL_MATRIX_INDEX_ARRAY_TYPE_OES                          0x8847
#define GL_MATRIX_INDEX_ARRAY_STRIDE_OES                        0x8848
#define GL_MATRIX_INDEX_ARRAY_POINTER_OES                       0x8849
#define GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES                0x8B9E
#define GL_WEIGHT_ARRAY_SIZE_OES                                0x86AB
#define GL_WEIGHT_ARRAY_TYPE_OES                                0x86A9
#define GL_WEIGHT_ARRAY_STRIDE_OES                              0x86AA
#define GL_WEIGHT_ARRAY_POINTER_OES                             0x86AC
#define GL_WEIGHT_ARRAY_BUFFER_BINDING_OES                      0x889E
#endif
#endif//_WIN32

/* GL_OES_packed_depth_stencil */
#ifndef GL_OES_packed_depth_stencil
#define GL_DEPTH_STENCIL_OES                                    0x84F9
#define GL_UNSIGNED_INT_24_8_OES                                0x84FA
#define GL_DEPTH24_STENCIL8_OES                                 0x88F0
#endif

/* GL_OES_rgb8_rgba8 */
#ifndef GL_OES_rgb8_rgba8
#define GL_RGB8_OES                                             0x8051
#define GL_RGBA8_OES                                            0x8058
#endif

/* GL_OES_stencil1 */
#ifndef GL_OES_stencil1
#define GL_STENCIL_INDEX1_OES                                   0x8D46
#endif

/* GL_OES_stencil4 */
#ifndef GL_OES_stencil4
#define GL_STENCIL_INDEX4_OES                                   0x8D47
#endif

/* GL_OES_stencil8 */
#ifndef GL_OES_stencil8
#define GL_STENCIL_INDEX8_OES                                   0x8D48
#endif

/* GL_OES_stencil_wrap */
#ifndef GL_OES_stencil_wrap
#define GL_INCR_WRAP_OES                                        0x8507
#define GL_DECR_WRAP_OES                                        0x8508
#endif

/* GL_OES_texture_cube_map */
#ifndef GL_OES_texture_cube_map
#define GL_NORMAL_MAP_OES                                       0x8511
#define GL_REFLECTION_MAP_OES                                   0x8512
#define GL_TEXTURE_CUBE_MAP_OES                                 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP_OES                         0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES                      0x8515
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES                      0x8516
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES                      0x8517
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES                      0x8518
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES                      0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES                      0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES                        0x851C
#define GL_TEXTURE_GEN_MODE_OES                                 0x2500
#define GL_TEXTURE_GEN_STR_OES                                  0x8D60
#endif

/* GL_OES_texture_mirrored_repeat */
#ifndef GL_OES_texture_mirrored_repeat
#define GL_MIRRORED_REPEAT_OES                                  0x8370
#endif

/*------------------------------------------------------------------------*
 * AMD extension tokens
 *------------------------------------------------------------------------*/

/* GL_AMD_compressed_3DC_texture */
#ifndef GL_AMD_compressed_3DC_texture
#define GL_3DC_X_AMD                                            0x87F9
#define GL_3DC_XY_AMD                                           0x87FA
#endif

/* GL_AMD_compressed_ATC_texture */
#ifndef GL_AMD_compressed_ATC_texture
#define GL_ATC_RGB_AMD                                          0x8C92
#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93
#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE
#endif

/*------------------------------------------------------------------------*
 * EXT extension tokens
 *------------------------------------------------------------------------*/

/* GL_EXT_texture_filter_anisotropic */
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_TEXTURE_MAX_ANISOTROPY_EXT                           0x84FE
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                       0x84FF
#endif

/* GL_EXT_texture_format_BGRA8888 */
#ifndef GL_EXT_texture_format_BGRA8888
#define GL_BGRA                                                 0x80E1
#endif

/*------------------------------------------------------------------------*
 * IMG extension tokens
 *------------------------------------------------------------------------*/

/* GL_IMG_read_format */
#ifndef GL_IMG_read_format
#define GL_BGRA                                                 0x80E1
#define GL_UNSIGNED_SHORT_4_4_4_4_REV                           0x8365
#define GL_UNSIGNED_SHORT_1_5_5_5_REV                           0x8366
#endif

/* GL_IMG_texture_compression_pvrtc */
#ifndef GL_IMG_texture_compression_pvrtc
#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
#endif

/* GL_IMG_user_clip_plane */
#ifndef GL_IMG_user_clip_plane
#define GL_CLIP_PLANE0_IMG                                      0x3000
#define GL_CLIP_PLANE1_IMG                                      0x3001
#define GL_CLIP_PLANE2_IMG                                      0x3002
#define GL_CLIP_PLANE3_IMG                                      0x3003
#define GL_CLIP_PLANE4_IMG                                      0x3004
#define GL_CLIP_PLANE5_IMG                                      0x3005
#define GL_MAX_CLIP_PLANES_IMG                                  0x0D32
#endif

/* GL_IMG_texture_env_enhanced_fixed_function */
#ifndef GL_IMG_texture_env_enhanced_fixed_function
#define GL_MODULATE_COLOR_IMG                                   0x8C04
#define GL_RECIP_ADD_SIGNED_ALPHA_IMG                           0x8C05
#define GL_TEXTURE_ALPHA_MODULATE_IMG                           0x8C06
#define GL_FACTOR_ALPHA_MODULATE_IMG                            0x8C07
#define GL_FRAGMENT_ALPHA_MODULATE_IMG                          0x8C08
#define GL_ADD_BLEND_IMG                                        0x8C09
#define GL_DOT3_RGBA_IMG                                        0x86AF
#endif

/*------------------------------------------------------------------------*
 * NV extension tokens
 *------------------------------------------------------------------------*/

/* GL_NV_fence */
#ifndef GL_NV_fence
#define GL_ALL_COMPLETED_NV                                     0x84F2
#define GL_FENCE_STATUS_NV                                      0x84F3
#define GL_FENCE_CONDITION_NV                                   0x84F4
#endif

/*------------------------------------------------------------------------*
 * QCOM extension tokens
 *------------------------------------------------------------------------*/

/* GL_QCOM_driver_control */
/* No new tokens introduced by this extension. */

/* GL_QCOM_perfmon_global_mode */
#ifndef GL_QCOM_perfmon_global_mode
#define GL_PERFMON_GLOBAL_MODE_QCOM                             0x8FA0
#endif

/*------------------------------------------------------------------------*
 * End of extension tokens, start of corresponding extension functions
 *------------------------------------------------------------------------*/

/*------------------------------------------------------------------------*
 * OES extension functions
 *------------------------------------------------------------------------*/

/* GL_OES_blend_equation_separate */
#if 0 // not supported
#ifndef GL_OES_blend_equation_separate
#define GL_OES_blend_equation_separate 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glBlendEquationSeparateOES (GLenum modeRGB, GLenum modeAlpha);
#endif
typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEOESPROC) (GLenum modeRGB, GLenum modeAlpha);
#endif
#endif // not supported

/* GL_OES_blend_func_separate */
#if 0 // not supported
#ifndef GL_OES_blend_func_separate
#define GL_OES_blend_func_separate 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glBlendFuncSeparateOES (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
#endif
typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEOESPROC) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
#endif
#endif // not supported

/* GL_OES_blend_subtract */
#if 0 // not supported
#ifndef GL_OES_blend_subtract
#define GL_OES_blend_subtract 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glBlendEquationOES (GLenum mode);
#endif
typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONOESPROC) (GLenum mode);
#endif
#endif // not supported

/* GL_OES_byte_coordinates */
#ifndef GL_OES_byte_coordinates
#define GL_OES_byte_coordinates 1
#endif

/* GL_OES_compressed_ETC1_RGB8_texture */
#ifndef GL_OES_compressed_ETC1_RGB8_texture
#define GL_OES_compressed_ETC1_RGB8_texture 1
#endif

/* GL_OES_depth24 */
#ifndef GL_OES_depth24
#define GL_OES_depth24 1
#endif

/* GL_OES_depth32 */
#ifndef GL_OES_depth32
#define GL_OES_depth32 1
#endif

/* GL_OES_draw_texture */
#if 0 // not supported
#ifndef GL_OES_draw_texture
#define GL_OES_draw_texture 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height);
GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort *coords);
GL_API void GL_APIENTRY glDrawTexivOES (const GLint *coords);
GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed *coords);
GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat *coords);
#endif
typedef void (GL_APIENTRYP PFNGLDRAWTEXSOESPROC) (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
typedef void (GL_APIENTRYP PFNGLDRAWTEXIOESPROC) (GLint x, GLint y, GLint z, GLint width, GLint height);
typedef void (GL_APIENTRYP PFNGLDRAWTEXXOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
typedef void (GL_APIENTRYP PFNGLDRAWTEXSVOESPROC) (const GLshort *coords);
typedef void (GL_APIENTRYP PFNGLDRAWTEXIVOESPROC) (const GLint *coords);
typedef void (GL_APIENTRYP PFNGLDRAWTEXXVOESPROC) (const GLfixed *coords);
typedef void (GL_APIENTRYP PFNGLDRAWTEXFOESPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
typedef void (GL_APIENTRYP PFNGLDRAWTEXFVOESPROC) (const GLfloat *coords);
#endif

/* GL_OES_EGL_image */
#ifndef GL_OES_EGL_image
#define GL_OES_EGL_image 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
#endif
typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
#endif
#endif // not supported

/* GL_OES_element_index_uint */
#ifndef GL_OES_element_index_uint
#define GL_OES_element_index_uint 1
#endif

/* GL_OES_extended_matrix_palette */
#ifndef GL_OES_extended_matrix_palette
#define GL_OES_extended_matrix_palette 1
#endif

/* GL_OES_fbo_render_mipmap */
#ifndef GL_OES_fbo_render_mipmap
#define GL_OES_fbo_render_mipmap 1
#endif

/* GL_OES_fixed_point */
#if 0 // not supported
#ifndef GL_OES_fixed_point
#define GL_OES_fixed_point 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glAlphaFuncxOES (GLenum func, GLclampx ref);
GL_API void GL_APIENTRY glClearColorxOES (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
GL_API void GL_APIENTRY glClearDepthxOES (GLclampx depth);
GL_API void GL_APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation);
GL_API void GL_APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
GL_API void GL_APIENTRY glDepthRangexOES (GLclampx zNear, GLclampx zFar);
GL_API void GL_APIENTRY glFogxOES (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glFogxvOES (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glFrustumxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
GL_API void GL_APIENTRY glGetClipPlanexOES (GLenum pname, GLfixed eqn[4]);
GL_API void GL_APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetLightxvOES (GLenum light, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetMaterialxvOES (GLenum face, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetTexEnvxvOES (GLenum env, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glLightModelxOES (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glLineWidthxOES (GLfixed width);
GL_API void GL_APIENTRY glLoadMatrixxOES (const GLfixed *m);
GL_API void GL_APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glMultMatrixxOES (const GLfixed *m);
GL_API void GL_APIENTRY glMultiTexCoord4xOES (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
GL_API void GL_APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz);
GL_API void GL_APIENTRY glOrthoxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
GL_API void GL_APIENTRY glPointParameterxOES (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glPointSizexOES (GLfixed size);
GL_API void GL_APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units);
GL_API void GL_APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glSampleCoveragexOES (GLclampx value, GLboolean invert);
GL_API void GL_APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z);
#endif
typedef void (GL_APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLclampx ref);
typedef void (GL_APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
typedef void (GL_APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLclampx depth);
typedef void (GL_APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation);
typedef void (GL_APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
typedef void (GL_APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLclampx zNear, GLclampx zFar);
typedef void (GL_APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param);
typedef void (GL_APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *params);
typedef void (GL_APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum pname, GLfixed eqn[4]);
typedef void (GL_APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params);
typedef void (GL_APIENTRYP PFNGLGETLIGHTXVOESPROC) (GLenum light, GLenum pname, GLfixed *params);
typedef void (GL_APIENTRYP PFNGLGETMATERIALXVOESPROC) (GLenum face, GLenum pname, GLfixed *params);
typedef void (GL_APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum env, GLenum pname, GLfixed *params);
typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);
typedef void (GL_APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param);
typedef void (GL_APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *params);
typedef void (GL_APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param);
typedef void (GL_APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params);
typedef void (GL_APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width);
typedef void (GL_APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m);
typedef void (GL_APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param);
typedef void (GL_APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *params);
typedef void (GL_APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m);
typedef void (GL_APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
typedef void (GL_APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz);
typedef void (GL_APIENTRYP PFNGLORTHOXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXOESPROC) (GLenum pname, GLfixed param);
typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params);
typedef void (GL_APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size);
typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units);
typedef void (GL_APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEXOESPROC) (GLclampx value, GLboolean invert);
typedef void (GL_APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
typedef void (GL_APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param);
typedef void (GL_APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param);
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
typedef void (GL_APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
#endif
#endif // not supported

/* GL_OES_framebuffer_object */
#ifndef GL_OES_framebuffer_object
#define GL_OES_framebuffer_object 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API GLboolean GL_APIENTRY glIsRenderbufferOES (GLuint renderbuffer);
GL_API void GL_APIENTRY glBindRenderbufferOES (GLenum target, GLuint renderbuffer);
GL_API void GL_APIENTRY glDeleteRenderbuffersOES (GLsizei n, const GLuint* renderbuffers);
GL_API void GL_APIENTRY glGenRenderbuffersOES (GLsizei n, GLuint* renderbuffers);
GL_API void GL_APIENTRY glRenderbufferStorageOES (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
GL_API void GL_APIENTRY glGetRenderbufferParameterivOES (GLenum target, GLenum pname, GLint* params);
GL_API GLboolean GL_APIENTRY glIsFramebufferOES (GLuint framebuffer);
GL_API void GL_APIENTRY glBindFramebufferOES (GLenum target, GLuint framebuffer);
GL_API void GL_APIENTRY glDeleteFramebuffersOES (GLsizei n, const GLuint* framebuffers);
GL_API void GL_APIENTRY glGenFramebuffersOES (GLsizei n, GLuint* framebuffers);
GL_API GLenum GL_APIENTRY glCheckFramebufferStatusOES (GLenum target);
GL_API void GL_APIENTRY glFramebufferRenderbufferOES (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
GL_API void GL_APIENTRY glFramebufferTexture2DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GL_API void GL_APIENTRY glGetFramebufferAttachmentParameterivOES (GLenum target, GLenum attachment, GLenum pname, GLint* params);
GL_API void GL_APIENTRY glGenerateMipmapOES (GLenum target);
#endif
typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFEROESPROC) (GLuint renderbuffer);
typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFEROESPROC) (GLenum target, GLuint renderbuffer);
typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSOESPROC) (GLsizei n, const GLuint* renderbuffers);
typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSOESPROC) (GLsizei n, GLuint* renderbuffers);
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) (GLenum target, GLenum pname, GLint* params);
typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFEROESPROC) (GLuint framebuffer);
typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFEROESPROC) (GLenum target, GLuint framebuffer);
typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSOESPROC) (GLsizei n, const GLuint* framebuffers);
typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSOESPROC) (GLsizei n, GLuint* framebuffers);
typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) (GLenum target);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPOESPROC) (GLenum target);
#endif

#if 0 // not supported
/* GL_OES_mapbuffer */
#ifndef GL_OES_mapbuffer
#define GL_OES_mapbuffer 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
GL_API GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
GL_API void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void** params);
#endif
typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void** params);
#endif
#endif // not supported

/* GL_OES_matrix_get */
#ifndef GL_OES_matrix_get
#define GL_OES_matrix_get 1
#endif

/* GL_OES_matrix_palette */
#ifndef _WIN32//  _WIN32
#ifndef GL_OES_matrix_palette
#define GL_OES_matrix_palette 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glCurrentPaletteMatrixOES (GLuint matrixpaletteindex);
GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES (void);
GL_API void GL_APIENTRY glMatrixIndexPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glWeightPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
#endif
typedef void (GL_APIENTRYP PFNGLCURRENTPALETTEMATRIXOESPROC) (GLuint matrixpaletteindex);
typedef void (GL_APIENTRYP PFNGLLOADPALETTEFROMMODELVIEWMATRIXOESPROC) (void);
typedef void (GL_APIENTRYP PFNGLMATRIXINDEXPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
#endif
#endif//_WIN32

/* GL_OES_packed_depth_stencil */
#ifndef GL_OES_packed_depth_stencil
#define GL_OES_packed_depth_stencil 1
#endif

/* GL_OES_query_matrix */
#if 0 // not supported
#ifndef GL_OES_query_matrix
#define GL_OES_query_matrix 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES (GLfixed mantissa[16], GLint exponent[16]);
#endif
typedef GLbitfield (GL_APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed mantissa[16], GLint exponent[16]);
#endif
#endif // not supported

/* GL_OES_rgb8_rgba8 */
#ifndef GL_OES_rgb8_rgba8
#define GL_OES_rgb8_rgba8 1
#endif

/* GL_OES_single_precision */
#if 0 // not supported
#ifndef GL_OES_single_precision
#define GL_OES_single_precision 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar);
GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation);
GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]);
GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth);
#endif
typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf zNear, GLclampf zFar);
typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
typedef void (GL_APIENTRYP PFNGLORTHOFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
typedef void (GL_APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation);
typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum pname, GLfloat eqn[4]);
typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth);
#endif
#endif // not supported

/* GL_OES_stencil1 */
#ifndef GL_OES_stencil1
#define GL_OES_stencil1 1
#endif

/* GL_OES_stencil4 */
#ifndef GL_OES_stencil4
#define GL_OES_stencil4 1
#endif

/* GL_OES_stencil8 */
#ifndef GL_OES_stencil8
#define GL_OES_stencil8 1
#endif

/* GL_OES_stencil_wrap */
#ifndef GL_OES_stencil_wrap
#define GL_OES_stencil_wrap 1
#endif

/* GL_OES_texture_cube_map */
#if 0 // not supported
#ifndef GL_OES_texture_cube_map
#define GL_OES_texture_cube_map 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glTexGenfOES (GLenum coord, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glTexGenfvOES (GLenum coord, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glTexGeniOES (GLenum coord, GLenum pname, GLint param);
GL_API void GL_APIENTRY glTexGenivOES (GLenum coord, GLenum pname, const GLint *params);
GL_API void GL_APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glGetTexGenfvOES (GLenum coord, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetTexGenivOES (GLenum coord, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params);
#endif
typedef void (GL_APIENTRYP PFNGLTEXGENFOESPROC) (GLenum coord, GLenum pname, GLfloat param);
typedef void (GL_APIENTRYP PFNGLTEXGENFVOESPROC) (GLenum coord, GLenum pname, const GLfloat *params);
typedef void (GL_APIENTRYP PFNGLTEXGENIOESPROC) (GLenum coord, GLenum pname, GLint param);
typedef void (GL_APIENTRYP PFNGLTEXGENIVOESPROC) (GLenum coord, GLenum pname, const GLint *params);
typedef void (GL_APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param);
typedef void (GL_APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params);
typedef void (GL_APIENTRYP PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pname, GLfloat *params);
typedef void (GL_APIENTRYP PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);
#endif
#endif // not supported

/* GL_OES_texture_env_crossbar */
#ifndef GL_OES_texture_env_crossbar
#define GL_OES_texture_env_crossbar 1
#endif

/* GL_OES_texture_mirrored_repeat */
#ifndef GL_OES_texture_mirrored_repeat
#define GL_OES_texture_mirrored_repeat 1
#endif

#if 0 // not supported
/*------------------------------------------------------------------------*
 * AMD extension functions
 *------------------------------------------------------------------------*/

/* GL_AMD_compressed_3DC_texture */
#ifndef GL_AMD_compressed_3DC_texture
#define GL_AMD_compressed_3DC_texture 1
#endif

/* GL_AMD_compressed_ATC_texture */
#ifndef GL_AMD_compressed_ATC_texture
#define GL_AMD_compressed_ATC_texture 1
#endif

/*------------------------------------------------------------------------*
 * EXT extension functions
 *------------------------------------------------------------------------*/

/* GL_EXT_texture_filter_anisotropic */
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_EXT_texture_filter_anisotropic 1
#endif

/* GL_EXT_texture_format_BGRA8888 */
#ifndef GL_EXT_texture_format_BGRA8888
#define GL_EXT_texture_format_BGRA8888 1
#endif

/*------------------------------------------------------------------------*
 * IMG extension functions
 *------------------------------------------------------------------------*/

/* GL_IMG_read_format */
#ifndef GL_IMG_read_format
#define GL_IMG_read_format 1
#endif

/* GL_IMG_texture_compression_pvrtc */
#ifndef GL_IMG_texture_compression_pvrtc
#define GL_IMG_texture_compression_pvrtc 1
#endif

/* GL_IMG_user_clip_plane */
#ifndef GL_IMG_user_clip_plane
#define GL_IMG_user_clip_plane 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glClipPlanefIMG (GLenum, const GLfloat *);
GL_API void GL_APIENTRY glClipPlanexIMG (GLenum, const GLfixed *);
#endif
typedef void (GL_APIENTRYP PFNGLCLIPPLANEFIMG) (GLenum p, const GLfloat *eqn);
typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMG) (GLenum p, const GLfixed *eqn);
#endif

/* GL_IMG_texture_env_enhanced_fixed_function */
#ifndef GL_IMG_texture_env_enhanced_fixed_function
#define GL_IMG_texture_env_enhanced_fixed_function 1
#endif

/*------------------------------------------------------------------------*
 * NV extension functions
 *------------------------------------------------------------------------*/

/* NV_fence */
#ifndef GL_NV_fence
#define GL_NV_fence 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
GL_API void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);
GL_API GLboolean GL_APIENTRY glIsFenceNV (GLuint);
GL_API GLboolean GL_APIENTRY glTestFenceNV (GLuint);
GL_API void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
GL_API void GL_APIENTRY glFinishFenceNV (GLuint);
GL_API void GL_APIENTRY glSetFenceNV (GLuint, GLenum);
#endif
typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
#endif

/*------------------------------------------------------------------------*
 * QCOM extension functions
 *------------------------------------------------------------------------*/

/* GL_QCOM_driver_control */
#ifndef GL_QCOM_driver_control
#define GL_QCOM_driver_control 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);
GL_API void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, char *driverControlString);
GL_API void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);
GL_API void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);
#endif
typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, char *driverControlString);
typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
#endif

/* GL_QCOM_perfmon_global_mode */
#ifndef GL_QCOM_perfmon_global_mode
#define GL_QCOM_perfmon_global_mode 1
#endif

#endif // not supported

/*------------------------------------------------------------------------*
 * Samsung extension functions
 *------------------------------------------------------------------------*/

/* PName */
#define GL_MAX_ELEMENTS_VERTICES          0x80E8
#define GL_MAX_ELEMENTS_INDICES           0x80E9

/* PVRTC */
#define GL_PVRTC2_OES				0x1911
#define GL_PVRTC4_OES				0x1912

//
// For sync OpenGLES 2.0 */
//
/* Separate Blend Functions */
#define GL_BLEND_DST_RGB	                0x80C8
#define GL_BLEND_SRC_RGB 					0x80C9

/* Vertex Arrays */
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED        0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE           0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE         0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE           0x8625
#define GL_CURRENT_VERTEX_ATTRIB              0x8626
#define GL_VERTEX_ATTRIB_ARRAY_POINTER        0x8645
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED     0x886A
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F

/* Shaders */
#define GL_FRAGMENT_SHADER                0x8B30
#define GL_VERTEX_SHADER                  0x8B31

/* Framebuffer Object. */
#define GL_INVALID_FRAMEBUFFER_OPERATION	0x0506

/** Texture and Texture Environment as in ShaderInterface.doc  **/
//
// Texture environment modes
//
#define   TEX_ENV_MODE_REPLACE   		1
#define   TEX_ENV_MODE_MODULATE  		2
#define   TEX_ENV_MODE_ADD	   		3
#define   TEX_ENV_MODE_DECAL     		4
#define   TEX_ENV_MODE_BLEND     		5
#define   TEX_ENV_MODE_COMBINE          	6
//
// Combine RGB
//
#define   TEX_COMBINE_RGB_REPLACE 		1
#define   TEX_COMBINE_RGB_MODULATE		2
#define   TEX_COMBINE_RGB_ADD     		3
#define   TEX_COMBINE_RGB_ADD_SIGNED	4
#define   TEX_COMBINE_RGB_INTERPOLATE	5
#define   TEX_COMBINE_RGB_SUBTRACT		6
#define   TEX_COMBINE_RGB_DOT3_RGB		7
#define   TEX_COMBINE_RGB_DOT3_RGBA		8

//
// Combine Alpha
//
#define   TEX_COMBINE_ALPHA_REPLACE 		1
#define   TEX_COMBINE_ALPHA_MODULATE		2
#define   TEX_COMBINE_ALPHA_ADD     		3
#define   TEX_COMBINE_ALPHA_ADD_SIGNED		4
#define   TEX_COMBINE_ALPHA_INTERPOLATE		5
#define   TEX_COMBINE_ALPHA_SUBTRACT		6

//
// Combiner RGB and ALPHA source arguments
//
#define   TEX_ENV_COMBINER_SRC_TEXTURE			1
#define   TEX_ENV_COMBINER_SRC_CONSTANT			2
#define   TEX_ENV_COMBINER_SRC_PRIMARY_COLOR  	3
#define   TEX_ENV_COMBINER_SRC_PREVIOUS 		4

//
// Combiner RGB operands
//
#define   TEX_ENV_COMBINER_RGB_OP_SRC_COLOR     			1
#define   TEX_ENV_COMBINER_RGB_OP_ONE_MINUS_SRC_COLOR     	2
#define   TEX_ENV_COMBINER_RGB_OP_SRC_ALPHA     			3
#define   TEX_ENV_COMBINER_RGB_OP_ONE_MINUS_SRC_ALPHA     	4

//
// Combiner ALPHA operands
//
#define   TEX_ENV_COMBINER_ALPHA_OP_SRC_ALPHA     			1
#define   TEX_ENV_COMBINER_ALPHA_OP_ONE_MINUS_SRC_ALPHA    	2

//
//  Fog mode
//
#define  FOGMODE_LINEAR 	1
#define  FOGMODE_EXP    	2
#define  FOGMODE_EXP2	 	3

#ifdef __cplusplus
}
#endif

#endif /* __glext_h_ */

license: mit


code:
/* $Change: 597344 $ */
#ifndef _gl_macro_h_
#define _gl_macro_h_

// redefine gl function
#ifdef glAlphaFunc
#undef glAlphaFunc
#endif
#define		glAlphaFunc		glAlphaFunc_1
#define		glClearColor		glClearColor_1
#define		glClearDepthf		glClearDepthf_1
#define		glClipPlanef		glClipPlanef_1
#define		glColor4f		glColor4f_1
#define		glDepthRangef		glDepthRangef_1
#define		glFogf		glFogf_1
#define		glFogfv		glFogfv_1
#define		glFrustumf		glFrustumf_1
#define		glGetClipPlanef		glGetClipPlanef_1
#define		glGetFloatv		glGetFloatv_1
#define		glGetLightfv		glGetLightfv_1
#define		glGetMaterialfv		glGetMaterialfv_1
#define		glGetTexEnvfv		glGetTexEnvfv_1
#define		glGetTexParameterfv		glGetTexParameterfv_1
#define		glLightModelf		glLightModelf_1
#define		glLightModelfv		glLightModelfv_1
#define		glLightf		glLightf_1
#define		glLightfv		glLightfv_1
#define		glLineWidth		glLineWidth_1
#define		glLoadMatrixf		glLoadMatrixf_1
#define		glMaterialf		glMaterialf_1
#define		glMaterialfv		glMaterialfv_1
#define		glMultMatrixf		glMultMatrixf_1
#define		glMultiTexCoord4f		glMultiTexCoord4f_1
#define		glNormal3f		glNormal3f_1
#define		glOrthof		glOrthof_1
#define		glPointParameterf		glPointParameterf_1
#define		glPointParameterfv		glPointParameterfv_1
#define		glPointSize		glPointSize_1
#define		glPolygonOffset		glPolygonOffset_1
#define		glRotatef		glRotatef_1
#define		glScalef		glScalef_1
#define		glTexEnvf		glTexEnvf_1
#define		glTexEnvfv		glTexEnvfv_1
#define		glTexParameterf		glTexParameterf_1
#define		glTexParameterfv		glTexParameterfv_1
#define		glTranslatef		glTranslatef_1
#define		glActiveTexture		glActiveTexture_1
#define		glAlphaFuncx		glAlphaFuncx_1
#define		glBindBuffer		glBindBuffer_1
#define		glBindTexture		glBindTexture_1
#define		glBlendFunc		glBlendFunc_1
#define		glBufferData		glBufferData_1
#define		glBufferSubData		glBufferSubData_1
#define		glClear		glClear_1
#define		glClearColorx		glClearColorx_1
#define		glClearDepthx		glClearDepthx_1
#define		glClearStencil		glClearStencil_1
#define		glClientActiveTexture		glClientActiveTexture_1
#define		glClipPlanex		glClipPlanex_1
#define		glColor4ub		glColor4ub_1
#define		glColor4x		glColor4x_1
#define		glColorMask		glColorMask_1
#define		glColorPointer		glColorPointer_1
#define		glCompressedTexImage2D		glCompressedTexImage2D_1
#define		glCompressedTexSubImage2D		glCompressedTexSubImage2D_1
#define		glCopyTexImage2D		glCopyTexImage2D_1
#define		glCopyTexSubImage2D		glCopyTexSubImage2D_1
#define		glCullFace		glCullFace_1
#define		glDeleteBuffers		glDeleteBuffers_1
#define		glDeleteTextures		glDeleteTextures_1
#define		glDepthFunc		glDepthFunc_1
#define		glDepthMask		glDepthMask_1
#define		glDepthRangex		glDepthRangex_1
#define		glDisable		glDisable_1
#define		glDisableClientState		glDisableClientState_1
#define		glDrawArrays		glDrawArrays_1
#define		glDrawElements		glDrawElements_1
#define		glEnable		glEnable_1
#define		glEnableClientState		glEnableClientState_1
#define		glFinish		glFinish_1
#define		glFlush		glFlush_1
#define		glFogx		glFogx_1
#define		glFogxv		glFogxv_1
#define		glFrontFace		glFrontFace_1
#define		glFrustumx		glFrustumx_1
#define		glGetBooleanv		glGetBooleanv_1
#define		glGetBufferParameteriv		glGetBufferParameteriv_1
#define		glGetClipPlanex		glGetClipPlanex_1
#define		glGenBuffers		glGenBuffers_1
#define		glGenTextures		glGenTextures_1
#define		glGetError		glGetError_1
#define		glGetFixedv		glGetFixedv_1
#define		glGetIntegerv		glGetIntegerv_1
#define		glGetLightxv		glGetLightxv_1
#define		glGetMaterialxv		glGetMaterialxv_1
#define		glGetPointerv		glGetPointerv_1
#define		glGetString		glGetString_1
#define		glGetTexEnviv		glGetTexEnviv_1
#define		glGetTexEnvxv		glGetTexEnvxv_1
#define		glGetTexParameteriv		glGetTexParameteriv_1
#define		glGetTexParameterxv		glGetTexParameterxv_1
#define		glHint		glHint_1
#define		glIsBuffer		glIsBuffer_1
#define		glIsEnabled		glIsEnabled_1
#define		glIsTexture		glIsTexture_1
#define		glLightModelx		glLightModelx_1
#define		glLightModelxv		glLightModelxv_1
#define		glLightx		glLightx_1
#define		glLightxv		glLightxv_1
#define		glLineWidthx		glLineWidthx_1
#define		glLoadIdentity		glLoadIdentity_1
#define		glLoadMatrixx		glLoadMatrixx_1
#define		glLogicOp		glLogicOp_1
#define		glMaterialx		glMaterialx_1
#define		glMaterialxv		glMaterialxv_1
#define		glMatrixMode		glMatrixMode_1
#define		glMultMatrixx		glMultMatrixx_1
#define		glMultiTexCoord4x		glMultiTexCoord4x_1
#define		glNormal3x		glNormal3x_1
#define		glNormalPointer		glNormalPointer_1
#define		glOrthox		glOrthox_1
#define		glPixelStorei		glPixelStorei_1
#define		glPointParameterx		glPointParameterx_1
#define		glPointParameterxv		glPointParameterxv_1
#define		glPointSizex		glPointSizex_1
#define		glPolygonOffsetx		glPolygonOffsetx_1
#define		glPopMatrix		glPopMatrix_1
#define		glPushMatrix		glPushMatrix_1
#define		glReadPixels		glReadPixels_1
#define		glRotatex 		glRotatex_1
#define		glSampleCoverage		glSampleCoverage_1
#define		glSampleCoveragex		glSampleCoveragex_1
#define		glScalex		glScalex_1
#define		glScissor		glScissor_1
#define		glShadeModel		glShadeModel_1
#define		glStencilFunc		glStencilFunc_1
#define		glStencilMask		glStencilMask_1
#define		glStencilOp		glStencilOp_1
#define		glTexCoordPointer		glTexCoordPointer_1
#define		glTexEnvi		glTexEnvi_1
#define		glTexEnvx		glTexEnvx_1
#define		glTexEnviv		glTexEnviv_1
#define		glTexEnvxv		glTexEnvxv_1
#define		glTexImage2D		glTexImage2D_1
#define		glTexParameteri		glTexParameteri_1
#define		glTexParameterx		glTexParameterx_1
#define		glTexParameteriv		glTexParameteriv_1
#define		glTexParameterxv		glTexParameterxv_1
#define		glTexSubImage2D		glTexSubImage2D_1
#define		glTranslatex		glTranslatex_1
#define		glVertexPointer		glVertexPointer_1
#define		glViewport		glViewport_1
#define		glPointSizePointerOES glPointSizePointerOES_1
#define		glCurrentPaletteMatrixOES glCurrentPaletteMatrixOES_1
#define		glLoadPaletteFromModelViewMatrixOES glLoadPaletteFromModelViewMatrixOES_1
#define		glMatrixIndexPointerOES glMatrixIndexPointerOES_1
#define		glWeightPointerOES glWeightPointerOES_1

//Start of FBO Functions
#define		glIsRenderbufferOES glIsRenderbufferOES_1
#define		glBindRenderbufferOES glBindRenderbufferOES_1
#define		glDeleteRenderbuffersOES glDeleteRenderbuffersOES_1
#define		glGenRenderbuffersOES glGenRenderbuffersOES_1
#define		glRenderbufferStorageOES glRenderbufferStorageOES_1
#define		glGetRenderbufferParameterivOES glGetRenderbufferParameterivOES_1
#define		glIsFramebufferOES glIsFramebufferOES_1
#define		glBindFramebufferOES glBindFramebufferOES_1
#define		glDeleteFramebuffersOES glDeleteFramebuffersOES_1
#define		glGenFramebuffersOES glGenFramebuffersOES_1
#define		glCheckFramebufferStatusOES glCheckFramebufferStatusOES_1
#define		glFramebufferRenderbufferOES glFramebufferRenderbufferOES_1
#define		glFramebufferTexture2DOES glFramebufferTexture2DOES_1
#define		glGetFramebufferAttachmentParameterivOES glGetFramebufferAttachmentParameterivOES_1
#define		glGenerateMipmapOES glGenerateMipmapOES_1
//End of FBO Functions

#endif // _egl_macro_h_


code:
/* $Change: 597344 $ */
#ifndef __glplatform_h_
#define __glplatform_h_

/* $Revision: #1 $ on $Date: 2010/07/30 $ */

/*
 * This document is licensed under the SGI Free Software B License Version
 * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
 */

/* Platform-specific types and definitions for OpenGL ES 1.X  gl.h
 * Last modified on 2008/12/19
 *
 * Adopters may modify khrplatform.h and this file to suit their platform.
 * You are encouraged to submit all modifications to the Khronos group so that
 * they can be included in future versions of this file.  Please submit changes
 * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
 * by filing a bug against product "OpenGL-ES" component "Registry".
 */

#include "khrplatform.h"

#ifndef GL_API
#define GL_API      KHRONOS_APICALL
#endif

#define GL_APIENTRY //KHRONOS_APIENTRY

#endif /* __glplatform_h_ */


code:
/* $Change: 608281 $ */
#ifndef __khrplatform_h_
#define __khrplatform_h_

/*! \file Khrplatform.h
    \brief Khrplatform header file.

    Khrplatform header file.
*/

/*
** Copyright (c) 2008-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/

/* Khronos platform-specific types and definitions.
 *
 * $Revision: #3 $ on $Date: 2010/08/05 $
 *
 * Adopters may modify this file to suit their platform. Adopters are
 * encouraged to submit platform specific modifications to the Khronos
 * group so that they can be included in future versions of this file.
 * Please submit changes by sending them to the public Khronos Bugzilla
 * (http://khronos.org/bugzilla) by filing a bug against product
 * "Khronos (general)" component "Registry".
 *
 * A predefined template which fills in some of the bug fields can be
 * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
 * must create a Bugzilla login first.
 *
 *
 * See the Implementer's Guidelines for information about where this file
 * should be located on your system and for more details of its use:
 *    http://www.khronos.org/registry/implementers_guide.pdf
 *
 * This file should be included as
 *        #include <KHR/khrplatform.h>
 * by Khronos client API header files that use its types and defines.
 *
 * The types in khrplatform.h should only be used to define API-specific types.
 *
 * Types defined in khrplatform.h:
 *    khronos_int8_t              signed   8  bit
 *    khronos_uint8_t             unsigned 8  bit
 *    khronos_int16_t             signed   16 bit
 *    khronos_uint16_t            unsigned 16 bit
 *    khronos_int32_t             signed   32 bit
 *    khronos_uint32_t            unsigned 32 bit
 *    khronos_int64_t             signed   64 bit
 *    khronos_uint64_t            unsigned 64 bit
 *    khronos_intptr_t            signed   same number of bits as a pointer
 *    khronos_uintptr_t           unsigned same number of bits as a pointer
 *    khronos_ssize_t             signed   size
 *    khronos_usize_t             unsigned size
 *    khronos_float_t             signed   32 bit floating point
 *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds
 *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in
 *                                         nanoseconds
 *    khronos_stime_nanoseconds_t signed time interval in nanoseconds
 *    khronos_boolean_enum_t      enumerated boolean type. This should
 *      only be used as a base type when a client API's boolean type is
 *      an enum. Client APIs which use an integer or other type for
 *      booleans cannot use this as the base type for their boolean.
 *
 * Tokens defined in khrplatform.h:
 *
 *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
 *
 *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
 *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
 *
 * Calling convention macros defined in this file:
 *    KHRONOS_APICALL
 *    KHRONOS_APIENTRY
 *    KHRONOS_APIATTRIBUTES
 *
 * These may be used in function prototypes as:
 *
 *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
 *                                  int arg1,
 *                                  int arg2) KHRONOS_APIATTRIBUTES;
 */

/**
 * @addtogroup opengles
 *
 * @{
 */

/*-------------------------------------------------------------------------
 * Definition of KHRONOS_APICALL
 *-------------------------------------------------------------------------
 * This precedes the return type of the function in the function prototype.
 */
#if defined (_WIN32)
#ifdef __KHRONOS_EXPORTS
#    define KHRONOS_APICALL __declspec(dllexport)
#else
#    define KHRONOS_APICALL __declspec(dllimport)
#endif
//#define KHRONOS_APICALL extern
#elif defined (__SYMBIAN32__)
#   define KHRONOS_APICALL IMPORT_C
#else
#   define KHRONOS_APICALL extern
#endif

/*-------------------------------------------------------------------------
 * Definition of KHRONOS_APIENTRY
 *-------------------------------------------------------------------------
 * This follows the return type of the function  and precedes the function
 * name in the function prototype.
 */
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
    /* Win32 but not WinCE */
#   define KHRONOS_APIENTRY __stdcall
#else
#   define KHRONOS_APIENTRY
#endif

/*-------------------------------------------------------------------------
 * Definition of KHRONOS_APIATTRIBUTES
 *-------------------------------------------------------------------------
 * This follows the closing parenthesis of the function prototype arguments.
 */
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif

/*-------------------------------------------------------------------------
 * basic type definitions
 *-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)

/*
 * Using <stdint.h>
 */
#include <stdint.h>
typedef int32_t                 khronos_int32_t;
typedef uint32_t                khronos_uint32_t;
typedef int64_t                 khronos_int64_t;
typedef uint64_t                khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64   1
#define KHRONOS_SUPPORT_FLOAT   1

#elif defined(__VMS ) || defined(__sgi)

/*
 * Using <inttypes.h>
 */
#include <inttypes.h>
typedef int32_t                 khronos_int32_t;
typedef uint32_t                khronos_uint32_t;
typedef int64_t                 khronos_int64_t;
typedef uint64_t                khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64   1
#define KHRONOS_SUPPORT_FLOAT   1

#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)

/*
 * Win32
 */
typedef __int32                 khronos_int32_t;
typedef unsigned __int32        khronos_uint32_t;
typedef __int64                 khronos_int64_t;
typedef unsigned __int64        khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64   1
#define KHRONOS_SUPPORT_FLOAT   1

#elif defined(__sun__) || defined(__digital__)

/*
 * Sun or Digital
 */
typedef int                     khronos_int32_t;
typedef unsigned int            khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int                khronos_int64_t;
typedef unsigned long int       khronos_uint64_t;
#else
typedef long long int           khronos_int64_t;
typedef unsigned long long int  khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64   1
#define KHRONOS_SUPPORT_FLOAT   1

#elif 0

/*
 * Hypothetical platform with no float or int64 support
 */
typedef int                     khronos_int32_t;
typedef unsigned int            khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64   0
#define KHRONOS_SUPPORT_FLOAT   0

#else

/*
 * Generic fallback
 */
#include <stdint.h>
typedef int32_t                 khronos_int32_t;
typedef uint32_t                khronos_uint32_t;
typedef int64_t                 khronos_int64_t;
typedef uint64_t                khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64   1
#define KHRONOS_SUPPORT_FLOAT   1

#endif

/*
 * Types that are (so far) the same on all platforms
 */
/*! \var typedef signed char khronos_int8_t
    \brief A type definition for khronos_int8_t.
*/
typedef signed   char          khronos_int8_t;

/*! \var typedef unsigned char khronos_uint8_t
    \brief A type definition for khronos_uint8_t.
*/
typedef unsigned char          khronos_uint8_t;

/*! \var typedef signed   short int     khronos_int16_t
    \brief A type definition for khronos_int16_t.
*/
typedef signed   short int     khronos_int16_t;

/*! \var typedef unsigned short int     khronos_uint16_t
    \brief A type definition for khronos_uint16_t.
*/
typedef unsigned short int     khronos_uint16_t;

/*! \var typedef signed   long  int     khronos_intptr_t
    \brief A type definition for khronos_intptr_t.
*/
typedef signed   long  int     khronos_intptr_t;

/*! \var typedef unsigned long  int     khronos_uintptr_t
    \brief A type definition for khronos_uintptr_t.
*/
typedef unsigned long  int     khronos_uintptr_t;

/*! \var typedef signed   long  int     khronos_ssize_t
    \brief A type definition for khronos_ssize_t.
*/
typedef signed   long  int     khronos_ssize_t;

/*! \var typedef unsigned long  int     khronos_usize_t
    \brief A type definition for khronos_usize_t.
*/
typedef unsigned long  int     khronos_usize_t;

#if KHRONOS_SUPPORT_FLOAT
/*
 * Float type
 */
typedef          float         khronos_float_t;
#endif

#if KHRONOS_SUPPORT_INT64
/* Time types
 *
 * These types can be used to represent a time interval in nanoseconds or
 * an absolute Unadjusted System Time.  Unadjusted System Time is the number
 * of nanoseconds since some arbitrary system event (e.g. since the last
 * time the system booted).  The Unadjusted System Time is an unsigned
 * 64 bit value that wraps back to 0 every 584 years.  Time intervals
 * may be either signed or unsigned.
 */
typedef khronos_uint64_t       khronos_utime_nanoseconds_t;
typedef khronos_int64_t        khronos_stime_nanoseconds_t;
#endif

/*
 * Dummy value used to pad enum types to 32 bits.
 */
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif

/*
 * Enumerated boolean type
 *
 * Values other than zero should be considered to be true.  Therefore
 * comparisons should not be made against KHRONOS_TRUE.
 */
typedef enum {
    KHRONOS_FALSE = 0,
    KHRONOS_TRUE  = 1,
    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;

/*-------------------------------------------------------------------------
 * Data type definitions for GL APIs
 *-----------------------------------------------------------------------*/

/*! \var typedef void GLvoid
    \brief A type definition for GLvoid.
*/
typedef void             	GLvoid;

/*! \var typedef unsigned int GLenum
    \brief A type definition for GLenum.
*/
typedef unsigned int    	GLenum;

/*! \var typedef unsigned char GLboolean
    \brief A type definition for GLboolean.
*/
typedef unsigned char   	GLboolean;

/*! \var typedef unsigned int GLbitfield
    \brief A type definition for GLbitfield.
*/
typedef unsigned int    	GLbitfield;

/*! \var typedef signed char GLbyte
    \brief A type definition for GLbyte.
*/
typedef khronos_int8_t   	GLbyte;

/*! \var typedef short GLshort
    \brief A type definition for GLshort.
*/
typedef short           	GLshort;

/*! \var typedef int GLint
    \brief A type definition for GLint.
*/
typedef int             	GLint;

/*! \var typedef int GLsizei
    \brief A type definition for GLsizei.
*/
typedef int             	GLsizei;

/*! \var typedef khronos_uint8_t GLubyte
    \brief A type definition for GLubyte.
*/
typedef khronos_uint8_t  	GLubyte;

/*! \var typedef unsigned short GLushort
    \brief A type definition for GLushort.
*/
typedef unsigned short  	GLushort;

/*! \var unsigned int    	GLuint
    \brief A type definition for GLuint.
*/
typedef unsigned int    	GLuint;

/*! \var typedef khronos_float_t GLfloat
    \brief A type definition for GLfloat.
*/
typedef khronos_float_t  	GLfloat;

/*! \var typedef khronos_float_t GLclampf
    \brief A type definition for GLclampf.
*/
typedef khronos_float_t  	GLclampf;

/*! \var typedef khronos_int32_t GLfixed
    \brief A type definition for GLfixed.
*/
typedef khronos_int32_t  	GLfixed;

/*! \var typedef khronos_int32_t GLclampx
    \brief A type definition for GLclampx.
*/
typedef khronos_int32_t  	GLclampx;

/*! \var typedef khronos_intptr_t GLintptr
    \brief A type definition for GLintptr.
*/
typedef khronos_intptr_t 	GLintptr;

/*! \var typedef khronos_ssize_t GLsizeiptr
    \brief A type definition for GLsizeiptr.
*/
typedef khronos_ssize_t  	GLsizeiptr;

/**
 * @}
 */

#endif /* __khrplatform_h_ */


code:
/*
 Bada pthread
 Copyright (c) 2010 Markovtsev Vadim

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/

#ifndef CC_BADA_2_0

#include "pthread.h"
#include <FApp.h>
#include <FBaseRtThread.h>

using namespace Osp::Base;
using namespace Osp::Base::Runtime;

extern "C" {

typedef void*(*pthread_func)(void *);

//struct _pthread_fastlock
//{
//	int __spinlock;
//};

//typedef struct _pthread_descr_struct*_pthread_descr;
/* Mutexes */
struct pthread_mutex{
  Osp::Base::Runtime::Mutex *lock;
//  _pthread_descr owner;
  int kind;
  unsigned int count;
  bool acquired;
};

struct sched_param {
  int sched_priority;           /* Process execution scheduling priority */

#if defined(_POSIX_SPORADIC_SERVER)
  int ss_low_priority;          /* Low scheduling priority for sporadic */
                                /*   server */
  struct timespec ss_replenish_period;
                                /* Replenishment period for sporadic server */
  struct timespec ss_initial_budget;   /* Initial budget for sporadic server */
#endif
};

/* Attributes for threads.  */
struct pthread_attr{
  int		__detachstate;
  int		__schedpolicy;
  struct sched_param	__schedparam;
  int		__inheritsched;
  int		__scope;
  void *	__stackaddr;
  unsigned long __stacksize;
};

struct pthread_mutexattr{
  int __mutexkind;
};

struct pthread_cond{
  Osp::Base::Runtime::Monitor *lock;
//  _pthread_descr wait_chain;
};

class RunnableProxy :
		public Object,
  		public virtual IRunnable
{
private:
	pthread_func _func;
	void * _parameter;

public:
	void SetFunc(pthread_func func)
	{
		_func = func;
	}

	pthread_func GetFunc()
	{
		return _func;
	}

	void SetParameter(void *parameter)
	{
		_parameter = parameter;
	}

	void *GetParameter()
	{
		return _parameter;
	}

	Object* Run(void)
	{
		void *result = _func(_parameter);
		return (Object *)result;
	}
};

pthread_t pthread_self(void)
{
	return Thread::GetCurrentThread();
}

int pthread_create(pthread_t*__threadarg,
			const pthread_attr_t*__attr,
			void*(*__start_routine)(void *),
			void*__arg)
{
	if (NULL == __threadarg)
	{
		return -1;
	}
	Thread *thread = new Thread();
	RunnableProxy *proxy = new RunnableProxy();
	proxy->SetFunc(__start_routine);
	proxy->SetParameter(__arg);
	thread->Construct(*proxy);
	*__threadarg = thread;
	return (int)thread->Start();
}

void pthread_exit(void*__retval)
{
	Thread::Exit(-1);
}

int pthread_join(pthread_t __th,void**__thread_return)
{
	if (!__th)
	{
		return -1;
	}
	return ((Thread*)__th)->Join();
}

int pthread_cancel(pthread_t thread)
{
	if (!thread)
	{
		return -1;
	}
	return ((Thread*)thread)->Exit();
}

int pthread_detach(pthread_t __th)
{
	if (__th)
	{
		((Thread*)__th)->Exit();
		delete __th;
	}
	return 0;
}

int pthread_equal(pthread_t __thread1,pthread_t __thread2)
{
	if (!__thread1 || !__thread2)
	{
		return (void *)__thread1 == (void *)__thread2;
	}
	return ((Thread*)__thread1)->Equals(*((Thread*)__thread2));
}

int pthread_kill(pthread_t thread,int sig)
{
	if (!thread)
	{
		return -1;
	}
	return ((Thread*)thread)->Exit(sig);
}

int pthread_attr_init(pthread_attr_t*attr)
{
	*attr = new pthread_attr();
	(*attr)->__stacksize = Thread::DEFAULT_STACK_SIZE;
	struct sched_param param;
	param.sched_priority = THREAD_PRIORITY_MID;
	(*attr)->__schedparam = param;
	return 0;
}

int pthread_attr_destroy(pthread_attr_t*attr)
{
	return 0;
}

int pthread_attr_setdetachstate(pthread_attr_t*attr,const int detachstate)
{
	(*attr)->__detachstate = detachstate;
	return 0;
}

int pthread_attr_getdetachstate(const pthread_attr_t*attr,int*detachstate)
{
	*detachstate = (*attr)->__detachstate;
	return 0;
}

int pthread_mutexattr_init(pthread_mutexattr_t*attr)
{
	*attr = new pthread_mutexattr();
	return 0;
}

int pthread_mutexattr_destroy(pthread_mutexattr_t*attr)
{
	return 0;
}

int pthread_mutex_init(pthread_mutex_t*mutex,
		const pthread_mutexattr_t*mutexattr)
{
	if (!mutex)
	{
		return -1;
	}
	*mutex = new pthread_mutex();
	(*mutex)->lock = new Mutex();
	(*mutex)->acquired = false;
	return (*mutex)->lock->Create();
}

int pthread_mutex_lock(pthread_mutex_t*mutex)
{
	if (!mutex || !(*mutex)->lock)
	{
		return -1;
	}
	int res = (*mutex)->lock->Acquire();
	if (res == E_SUCCESS)
	{
		(*mutex)->acquired = true;
	}
	return res;
}

int pthread_mutex_unlock(pthread_mutex_t*mutex)
{
	if (!mutex || !(*mutex)->lock)
	{
		return -1;
	}
	int res = (*mutex)->lock->Release();
	if (res == E_SUCCESS)
	{
		(*mutex)->acquired = false;
	}
	return res;
}

int pthread_mutex_trylock(pthread_mutex_t*mutex)
{
	if (!mutex || !(*mutex)->lock)
	{
		return -1;
	}
	if (!(*mutex)->acquired)
	{
		int res = (*mutex)->lock->Acquire();
		if (res == E_SUCCESS)
		{
			(*mutex)->acquired = true;
		}
		return res;
	}
	return -1;
}

int pthread_mutex_destroy(pthread_mutex_t*mutex)
{
	delete (*mutex)->lock;
	(*mutex)->acquired = false;
	delete (*mutex);
	return 0;
}

int pthread_cond_init(pthread_cond_t*cond,pthread_condattr_t*cond_attr)
{
	if (!cond)
	{
		return -1;
	}
	*cond = new pthread_cond();
	(*cond)->lock = new Monitor();
	(*cond)->lock->Construct();
	return 0;
}

int pthread_cond_destroy(pthread_cond_t*cond)
{
	if (cond != NULL)
	{
		delete (*cond)->lock;
		delete (*cond);
		return 1;
	}
	return 0;
}

int pthread_cond_signal(pthread_cond_t*cond)
{
	if (!cond)
	{
		return -1;
	}
	return (*cond)->lock->Notify();
}

int pthread_cond_broadcast(pthread_cond_t*cond)
{
	if (!cond)
	{
		return -1;
	}
	return (*cond)->lock->NotifyAll();
}

int pthread_cond_timedwait(pthread_cond_t*cond,pthread_mutex_t*mutex,
			   const struct timespec*abstime)
{
	if (!cond)
	{
		return -1;
	}
	(*cond)->lock->Enter();
	(*cond)->lock->Wait();
	(*cond)->lock->Exit();
	return 1;
}

int pthread_cond_wait(pthread_cond_t*cond,pthread_mutex_t*mutex)
{
	if (!cond)
	{
		return -1;
	}
	(*cond)->lock->Enter();
	(*cond)->lock->Wait();
	(*cond)->lock->Exit();
	return 1;
}

int pthread_condattr_init(pthread_condattr_t*attr)
{
	return 0;
}

int pthread_condattr_destroy(pthread_condattr_t*attr)
{
	return 0;
}

int pthread_condattr_getpshared(const pthread_condattr_t*attr,int*pshared)
{
	return 0;
}

int pthread_condattr_setpshared(pthread_condattr_t*attr,int pshared)
{
	return 0;
}

}

#endif


code:
/*
 Bada pthread
 Copyright (c) 2010 Markovtsev Vadim

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/

#ifndef __BADA_PTHREAD_H__
#define __BADA_PTHREAD_H__

#ifdef CC_BADA_2_0
#include <libxml/../pthread.h>
#else

#ifdef __cplusplus
extern "C" {
#endif

#define PTHREAD_STACK_SIZE (64*1024)
#define PTHREAD_STACK_MINSIZE	16384
#define PTHREAD_THREADS_MAX	1024

#define MAX_SPIN_COUNT		50
#define SPIN_SLEEP_DURATION	2000001
#define PTHREAD_DESTRUCTOR_ITERATIONS 1

#define PTHREAD_KEYS_MAX	32

typedef void* pthread_t;
struct pthread_mutex;
typedef struct pthread_mutex* pthread_mutex_t;
struct pthread_attr;
typedef struct pthread_attr* pthread_attr_t;
struct pthread_mutexattr;
typedef struct pthread_mutexattr* pthread_mutexattr_t;
struct pthread_cond;
typedef struct pthread_cond* pthread_cond_t;

#define PTHREAD_SPIN_LOCKED 1
#define PTHREAD_SPIN_UNLOCKED 0

enum {
  PTHREAD_MUTEX_FAST_NP,
#define PTHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_FAST_NP
  PTHREAD_MUTEX_RECURSIVE_NP,
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE_NP
  PTHREAD_MUTEX_ERRORCHECK_NP,
#define PTHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK_NP
};

enum {
  PTHREAD_PROCESS_PRIVATE,
#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
  PTHREAD_PROCESS_SHARED
#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
};

#define PTHREAD_MUTEX_INITIALIZER \
{{PTHREAD_SPIN_UNLOCKED},0,PTHREAD_MUTEX_FAST_NP,0}

#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
{{PTHREAD_SPIN_UNLOCKED},0,PTHREAD_MUTEX_RECURSIVE_NP,0}

#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
{{PTHREAD_SPIN_UNLOCKED},0,PTHREAD_MUTEX_ERRORCHECK_NP,0}

int pthread_mutexattr_init(pthread_mutexattr_t*attr);
int pthread_mutexattr_destroy(pthread_mutexattr_t*attr);

//int pthread_mutexattr_getkind_np(const pthread_mutexattr_t*attr,int*kind);
//int pthread_mutexattr_setkind_np(pthread_mutexattr_t*attr,int kind);

int pthread_mutex_init(pthread_mutex_t*mutex,
		const pthread_mutexattr_t*mutexattr);
int pthread_mutex_lock(pthread_mutex_t*mutex);
int pthread_mutex_unlock(pthread_mutex_t*mutex);
int pthread_mutex_trylock(pthread_mutex_t*mutex);
int pthread_mutex_destroy(pthread_mutex_t*mutex);

/* Conditions */
typedef void* pthread_condattr_t;

#define PTHREAD_COND_INITIALIZER \
{{PTHREAD_SPIN_UNLOCKED},0}

int pthread_cond_init(pthread_cond_t*cond,pthread_condattr_t*cond_attr);
int pthread_cond_destroy(pthread_cond_t*cond);
int pthread_cond_signal(pthread_cond_t*cond);
int pthread_cond_broadcast(pthread_cond_t*cond);
int pthread_cond_timedwait(pthread_cond_t*cond,pthread_mutex_t*mutex,
			   const struct timespec*abstime);
int pthread_cond_wait(pthread_cond_t*cond,pthread_mutex_t*mutex);

// These two functions are not described in the standard. Use them as follows:
// [thread #1]
//   pthread_cond_enter(cond);
//   pthread_cond_wait(cond, null);
//   pthread_cond_exit(cond);
//
// [thread #2]
//   pthread_cond_enter(cond);
//   pthread_cond_broadcast(cond);
//   pthread_cond_exit(cond);
//
// The mutex style locking will result in a dead lock.
int pthread_cond_enter(pthread_cond_t*cond);
int pthread_cond_exit(pthread_cond_t*cond);

/* only for completeness (always return NULL) */
int pthread_condattr_init(pthread_condattr_t*attr);
int pthread_condattr_destroy(pthread_condattr_t*attr);
int pthread_condattr_getpshared(const pthread_condattr_t*attr,int*pshared);
int pthread_condattr_setpshared(pthread_condattr_t*attr,int pshared);

/* thread specific variables */
typedef unsigned int pthread_key_t;
/*
int pthread_key_create(pthread_key_t*key,void(*destructor)(const void*));
int pthread_key_delete(pthread_key_t key);
int pthread_setspecific(pthread_key_t key,const void*value);
const void*pthread_getspecific(pthread_key_t key);
*/

enum {
  PTHREAD_CREATE_JOINABLE,
#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
  PTHREAD_CREATE_DETACHED
#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
};

enum {
  PTHREAD_EXPLICIT_SCHED,
#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
  PTHREAD_INHERIT_SCHED
#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
};

enum {	/* for completeness */
  PTHREAD_SCOPE_SYSTEM,
#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
  PTHREAD_SCOPE_PROCESS
#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
};

int pthread_attr_init(pthread_attr_t*attr);
int pthread_attr_destroy(pthread_attr_t*attr);

int pthread_attr_setdetachstate(pthread_attr_t*attr,const int detachstate);
int pthread_attr_getdetachstate(const pthread_attr_t*attr,int*detachstate);
/*
int pthread_attr_setschedpolicy(pthread_attr_t*attr,const int policy);
int pthread_attr_getschedpolicy(const pthread_attr_t*attr,int*policy);

int pthread_attr_setschedparam(pthread_attr_t*attr,
				const struct sched_param*param);
int pthread_attr_getschedparam(const pthread_attr_t*attr,
				struct sched_param*param);

int pthread_attr_setinheritsched(pthread_attr_t*attr,const int inherit);
int pthread_attr_getinheritsched(const pthread_attr_t*attr,int*inherit);

int pthread_attr_setscope(pthread_attr_t*attr,const int scope);
int pthread_attr_getscope(const pthread_attr_t*attr,int*scope);

int pthread_attr_setstackaddr(pthread_attr_t*attr,void*stack);
int pthread_attr_getstackaddr(const pthread_attr_t*attr,void**stack);

int pthread_attr_setstacksize(pthread_attr_t*attr,const size_t stacksize);
int pthread_attr_getstacksize(const pthread_attr_t*attr,size_t*stacksize);

int pthread_setschedparam(const pthread_t target_thread,const int policy,
			  const struct sched_param*param);
int pthread_getschedparam(const pthread_t target_thread,int*policy,
			  struct sched_param*param);
*/
/* ONCE */
typedef int pthread_once_t;
#define PTHREAD_ONCE_INIT	PTHREAD_SPIN_UNLOCKED

//int pthread_once(pthread_once_t*once_control,void(*init_routine)(void));

/* CANCEL */

enum {
  PTHREAD_CANCEL_ENABLE,
#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
  PTHREAD_CANCEL_DISABLE,
#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
};

enum {
  PTHREAD_CANCEL_DEFERRED,
#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
  PTHREAD_CANCEL_ASYNCHRONOUS,
#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
};

#define PTHREAD_CANCELED ((void *) -1)

int pthread_kill(pthread_t thread,int sig);
int pthread_cancel(pthread_t thread);
/*int pthread_setcancelstate(int state,int*oldstate);

int pthread_setcanceltype(int type,int*oldtype);

void pthread_testcancel(void);
*/
/* CLEANUP */
/*
void pthread_cleanup_push(void(*routine)(void*),void*arg);
void pthread_cleanup_pop(int execute);

void pthread_cleanup_push_defer_np(void(*routine)(void*),void*arg);
void pthread_cleanup_pop_restore_np(int execute);
*/
/* FORK */
/*
pid_t pthread_atfork(void(*prepare)(void),void(*parent)(void),
		     void(*child)(void));
*/
/* THREADS */
pthread_t pthread_self(void);

int pthread_create(pthread_t*__threadarg,
		const pthread_attr_t*__attr,
		void*(*__start_routine)(void *),
		void*__arg);

void pthread_exit(void*__retval);

int pthread_join(pthread_t __th,void**__thread_return);

int pthread_detach(pthread_t __th);
int pthread_equal(pthread_t __thread1,pthread_t __thread2);

//int pthread_sigmask(int how,const sigset_t*newset,sigset_t*oldset);

#ifdef __cplusplus
}
#endif

#endif /* CC_BADA_2_0 */

#endif /* __BADA_PTHREAD_H__ */


code:
/*
 Bada pthread
 Copyright (c) 2010 Markovtsev Vadim

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/

#include "semaphore.h"
#include <map>
#include <string>

static std::map<std::string, sem_t *> _semaphores;

int sem_destroy(sem_t*sem)
{
	if (sem)
	{
		if (sem->id)
		{
			delete sem->id;
			sem->id = null;
		}
		if (sem->mutex)
		{
			delete sem->mutex;
			sem->mutex = null;
		}
	}
	return 0;
}

static int atomic_add(int *number, int value, Osp::Base::Runtime::Mutex *mutex)
{
	if (!mutex || !number)
	{
		return -1;
	}
	mutex->Acquire();
	*number += value;
	mutex->Release();
	return 0;
}

int sem_getvalue(sem_t*sem,int*sval)
{
	if (!sem || !sval || sem->mutex)
	{
		return -1;
	}
	sem->mutex->Acquire();
	*sval =	sem->value;
	sem->mutex->Release();
	return 0;
}

int sem_init(sem_t*sem,int pshared,unsigned int value)
{
	if (!sem)
	{
		return -1;
	}
	sem->id = new Osp::Base::Runtime::Semaphore();
	sem->mutex = new Osp::Base::Runtime::Mutex();
	sem->id->Create(value);
	sem->mutex->Create();
	sem->value = value;
	return 0;
}
int sem_post(sem_t*sem)
{
	if (!sem || !sem->id)
	{
		return -1;
	}
	atomic_add(&sem->value, 1, sem->mutex);
	sem->id->Release();
	return 0;
}

int sem_trywait(sem_t*sem)
{
	if (!sem || !sem->id)
	{
		return -1;
	}
	sem->mutex->Acquire();
	int sval =	sem->value;
	sem->mutex->Release();
	if (sval > 0)
	{
		atomic_add(&sem->value, -1, sem->mutex);
		sem->id->Acquire();
		return 0;
	}
	return -1;
}

int sem_wait(sem_t*sem)
{
	if (!sem || !sem->id)
	{
		return -1;
	}
	atomic_add(&sem->value, -1, sem->mutex);
	sem->id->Acquire();
	return 0;
}

sem_t*sem_open(const char*name,int oflag,...)
{
	sem_t *sem = new sem_t();
	sem->id = new Osp::Base::Runtime::Semaphore();
	sem->mutex = new Osp::Base::Runtime::Mutex();
	sem->id->Create(name);
	sem->mutex->Create();
	sem->value = 1;
	_semaphores.insert(std::pair<std::string, sem_t *>(name, sem));
	return sem;
}

int sem_close(sem_t*sem)
{
	return sem_destroy(sem);
}

int sem_unlink(const char*name)
{
	std::map<std::string, sem_t *>::iterator I = _semaphores.find(name);
	if (I == _semaphores.end())
	{
		return -1;
	}
	sem_destroy(I->second);
	_semaphores.erase(name);
	return 0;
}

int sem_timedwait(sem_t*sem,const struct timespec*abstime)
{
	if (!sem || !sem->id || !abstime)
	{
		return -1;
	}
	sem->id->Acquire(abstime->tv_sec * 1000 + abstime->tv_nsec / 1000000);
	return 0;
}


code:
/*
 Bada pthread
 Copyright (c) 2010 Markovtsev Vadim

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/

#ifndef SEMAPHORE_H_
#define SEMAPHORE_H_

#include <FBaseRtThread.h>
#include <time.h>

typedef struct sem{
  Osp::Base::Runtime::Semaphore *id;
  int value;
  Osp::Base::Runtime::Mutex *mutex;
}sem_t;

#define SEM_FAILED	((sem_t*)0)
#define SEM_VALUE_MAX	((int)((~0u)>>1))
#define SEM_MAGIC	0x35d108f2

int sem_destroy(sem_t*sem);
int sem_getvalue(sem_t*sem,int*sval);
int sem_init(sem_t*sem,int pshared,unsigned int value);
int sem_post(sem_t*sem);
int sem_trywait(sem_t*sem);
int sem_wait(sem_t*sem);

sem_t*sem_open(const char*name,int oflag,...);
int sem_close(sem_t*sem);
int sem_unlink(const char*name);

int sem_timedwait(sem_t*sem,const struct timespec*abstime);

#endif /* SEMAPHORE_H_ */


code:
/****************************************************************************
 Copyright (c) 2010 cocos2d-x.org

 http://www.cocos2d-x.org

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/

#import <Foundation/Foundation.h>
#import "CCAccelerometerDelegate.h"
#import <UIKit/UIKit.h>

@interface AccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
{
	cocos2d::CCAccelerometerDelegate *delegate_;
	cocos2d::CCAcceleration *acceleration_;
}

@property(readwrite) cocos2d::CCAccelerometerDelegate *delegate_;
@property(readwrite) cocos2d::CCAcceleration *acceleration_;

+ (id) sharedAccelerometerDispather;
- (id) init;
- (void) addDelegate: (cocos2d::CCAccelerometerDelegate *) delegate;

@end


code:
/****************************************************************************
 Copyright (c) 2010 cocos2d-x.org

 http://www.cocos2d-x.org

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/

#import "AccelerometerDelegateWrapper.h"

@implementation AccelerometerDispatcher

static AccelerometerDispatcher* s_pAccelerometerDispatcher;

@synthesize delegate_;
@synthesize acceleration_;

+ (id) sharedAccelerometerDispather
{
    if (s_pAccelerometerDispatcher == nil) {
        s_pAccelerometerDispatcher = [[self alloc] init];
    }

    return s_pAccelerometerDispatcher;
}

- (id) init
{
    acceleration_ = new cocos2d::CCAcceleration();
    return self;
}

- (void) dealloc
{
    s_pAccelerometerDispatcher = 0;
    delegate_ = 0;
    delete acceleration_;
    [super dealloc];
}

- (void) addDelegate: (cocos2d::CCAccelerometerDelegate *) delegate
{
    delegate_ = delegate;

    if (delegate_)
    {
        [[UIAccelerometer sharedAccelerometer] setDelegate:self];
    }
    else
    {
        [[UIAccelerometer sharedAccelerometer] setDelegate:nil];
    }
}

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
    if (! delegate_)
    {
        return;
    }

    acceleration_->x = acceleration.x;
    acceleration_->y = acceleration.y;
    acceleration_->z = acceleration.z;
    acceleration_->timestamp = acceleration.timestamp;

    double tmp = acceleration_->x;

    switch ([[UIApplication sharedApplication] statusBarOrientation])
    {
    case UIInterfaceOrientationLandscapeRight:
        acceleration_->x = -acceleration_->y;
        acceleration_->y = tmp;
        break;

    case UIInterfaceOrientationLandscapeLeft:
        acceleration_->x = acceleration_->y;
        acceleration_->y = -tmp;
        break;

    case UIInterfaceOrientationPortraitUpsideDown:
        acceleration_->x = -acceleration_->y;
        acceleration_->y = -tmp;
        break;

    case UIInterfaceOrientationPortrait:
        break;
    }

    delegate_->didAccelerate(acceleration_);
}

@end


code:
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org

http://www.cocos2d-x.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

#ifndef __PLATFORM_IPHONE_CCACCELEROMETER_H__
#define __PLATFORM_IPHONE_CCACCELEROMETER_H__

#include "CCAccelerometerDelegate.h"

namespace   cocos2d {

class CC_DLL CCAccelerometer
{
public:
    CCAccelerometer();
    ~CCAccelerometer();

    static CCAccelerometer* sharedAccelerometer();

    void setDelegate(CCAccelerometerDelegate* pDelegate);

private:
    static CCAccelerometer* m_spUIAccelerometer;
};

}//namespace   cocos2d

#endif


code:
/****************************************************************************
 Copyright (c) 2010 cocos2d-x.org

 http://www.cocos2d-x.org

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/

#include "CCAccelerometer.h"
#include "AccelerometerDelegateWrapper.h"

namespace cocos2d {

    CCAccelerometer* CCAccelerometer::m_spUIAccelerometer = NULL;

    CCAccelerometer::CCAccelerometer()
    {
    }

    CCAccelerometer::~CCAccelerometer()
    {
    }

    CCAccelerometer* CCAccelerometer::sharedAccelerometer()
    {
        if (m_spUIAccelerometer == NULL) {
            m_spUIAccelerometer = new CCAccelerometer();
        }

        return m_spUIAccelerometer;
    }

    void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
    {
        [[AccelerometerDispatcher sharedAccelerometerDispather] addDelegate:pDelegate];
    }
}


code:
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org

http://www.cocos2d-x.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

#ifndef __CC_APPLICATION_IOS_H__
#define __CC_APPLICATION_IOS_H__

#include "CCCommon.h"

NS_CC_BEGIN;

class CCRect;

class CC_DLL CCApplication
{
public:
        CCApplication();
        virtual ~CCApplication();

        /**
         @brief	Implement for initialize OpenGL instance, set source path, etc...
         */
        virtual bool initInstance() = 0;

        /**
         @brief	Implement CCDirector and CCScene init code here.
         @return true    Initialize success, app continue.
         @return false   Initialize failed, app terminate.
         */
        virtual bool applicationDidFinishLaunching() = 0;

        /**
         @brief  The function be called when the application enter background
         @param  the pointer of the application
         */
        virtual void applicationDidEnterBackground() = 0;

        /**
         @brief  The function be called when the application enter foreground
         @param  the pointer of the application
         */
        virtual void applicationWillEnterForeground() = 0;

        /**
         @brief	Callback by CCDirector for limit FPS.
         @interval       The time, which expressed in second in second, between current frame and next.
         */
        void setAnimationInterval(double interval);

        typedef enum
        {
                        /// Device oriented vertically, home button on the bottom
                kOrientationPortrait = 0,
                        /// Device oriented vertically, home button on the top
                kOrientationPortraitUpsideDown = 1,
                        /// Device oriented horizontally, home button on the right
                kOrientationLandscapeLeft = 2,
                        /// Device oriented horizontally, home button on the left
                kOrientationLandscapeRight = 3,
        } Orientation;

        /**
         @brief	Callback by CCDirector for change device orientation.
         @orientation    The defination of orientation which CCDirector want change to.
         @return         The actual orientation of the application.
         */
        Orientation setOrientation(Orientation orientation);

        /**
         @brief	Get status bar rectangle in EGLView window.
         */
        void    statusBarFrame(CCRect * rect);

        /**
         @brief	Run the message loop.
         */
        int run();

        /**
         @brief	Get current applicaiton instance.
         @return Current application instance pointer.
         */
        static CCApplication& sharedApplication();

        /**
        @brief Get current language config
        @return Current language config
        */
        static ccLanguageType getCurrentLanguage();

protected:
        static CCApplication * sm_pSharedApplication;
};

NS_CC_END;

#endif	// end of __CC_APPLICATION_IOS_H__


code:
/****************************************************************************
 Copyright (c) 2010 cocos2d-x.org

 http://www.cocos2d-x.org

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 ****************************************************************************/

#import "CCApplication_ios.h"

#import <UIKit/UIKit.h>

#import "CCGeometry.h"
#import "CCDirectorCaller.h"

NS_CC_BEGIN;

CCApplication* CCApplication::sm_pSharedApplication = 0;

CCApplication::CCApplication()
{
    CC_ASSERT(! sm_pSharedApplication);
    sm_pSharedApplication = this;
}

CCApplication::~CCApplication()
{
    CC_ASSERT(this == sm_pSharedApplication);
    sm_pSharedApplication = 0;
}

int CCApplication::run()
{
    if (initInstance() && applicationDidFinishLaunching())
    {
        [[CCDirectorCaller sharedDirectorCaller] startMainLoop];
    }
    return 0;
}

void CCApplication::setAnimationInterval(double interval)
{
    [[CCDirectorCaller sharedDirectorCaller] setAnimationInterval: interval ];
}

CCApplication::Orientation CCApplication::setOrientation(Orientation eOritation)
{
    UIApplication * app = [UIApplication sharedApplication];
    UIInterfaceOrientation newOrientation;
    switch (eOritation)
    {
    case kOrientationPortrait:
        newOrientation = UIInterfaceOrientationPortrait;
        break;
    case kOrientationPortraitUpsideDown:
        newOrientation = UIInterfaceOrientationPortraitUpsideDown;
        break;
    case kOrientationLandscapeLeft:
        newOrientation = UIInterfaceOrientationLandscapeRight;
        break;
    case kOrientationLandscapeRight:
        newOrientation = UIInterfaceOrientationLandscapeLeft;
        break;
    default:
        newOrientation = UIInterfaceOrientationPortrait;
        break;
    }
    if (newOrientation != [app statusBarOrientation])
    {
        [app setStatusBarOrientation: newOrientation];
    }
    return eOritation;
}

void CCApplication::statusBarFrame(cocos2d::CCRect * rect)
{
    rect->origin.x = [[UIApplication sharedApplication] statusBarFrame].origin.x;
    rect->origin.y = [[UIApplication sharedApplication] statusBarFrame].origin.y;
    rect->size.width = [[UIApplication sharedApplication] statusBarFrame].size.width;
    rect->size.height = [[UIApplication sharedApplication] statusBarFrame].size.height;
}

/////////////////////////////////////////////////////////////////////////////////////////////////
// static member function
//////////////////////////////////////////////////////////////////////////////////////////////////

CCApplication& CCApplication::sharedApplication()
{
    CC_ASSERT(sm_pSharedApplication);
    return *sm_pSharedApplication;
}

ccLanguageType CCApplication::getCurrentLanguage()
{
    // get the current language and country config
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
    NSString *currentLanguage = [languages objectAtIndex:0];

    // get the current language code.(such as English is "en", Chinese is "zh" and so on)
    NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage];
    NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode];

    ccLanguageType ret = kLanguageEnglish;
    if ([languageCode isEqualToString:@"zh"])
    {
        ret = kLanguageChinese;
    }
    else if ([languageCode isEqualToString:@"en"])
    {
        ret = kLanguageEnglish;
    }
    else if ([languageCode isEqualToString:@"fr"]){
        ret = kLanguageFrench;
    }
    else if ([languageCode isEqualToString:@"it"]){
        ret = kLanguageItalian;
    }
    else if ([languageCode isEqualToString:@"de"]){
        ret = kLanguageGerman;
    }
    else if ([languageCode isEqualToString:@"es"]){
        ret = kLanguageSpanish;
    }
	else if ([languageCode isEqualToString:@"ru"]){
        ret = kLanguageRussian;
    }

    return ret;
}

NS_CC_END;