Guest User

Untitled

a guest
Oct 27th, 2015
21
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Unit TERRA_OpenGLES;
  2. {$I terra.inc}
  3.  
  4. {$IFDEF FPC}
  5. {$PACKRECORDS C}
  6. {$ENDIF}
  7.  
  8. Interface
  9. Uses TERRA_String, TERRA_Utils, TERRA_Log, Math,
  10. {$IFDEF FPC}DynLibs {$ELSE} Windows{$ENDIF};
  11.  
  12. Const
  13.   {$IFDEF WINDOWS} OpenGLLibName = 'libGLESv2.dll'; {$ENDIF}
  14.   {$IFDEF ANDROID} OpenGLLibName = 'libGLESv2.so'; {$ENDIF}
  15.  
  16.   {$IFDEF IOS}
  17.   {$DEFINE STATIC_LINKING}
  18.   {$LINKLIB GL}
  19.   OpenGLLibName = '/System/Library/Frameworks/OpenGLES.framework/OpenGLES';
  20.   {$ENDIF}
  21.  
  22.  
  23. // OpenGL ES core versions
  24.   GL_ES_VERSION_2_0 = 1;
  25.  
  26. // ClearBufferMask
  27.   GL_DEPTH_BUFFER_BIT  = $00000100;
  28.   GL_STENCIL_BUFFER_BIT = $00000400;
  29.   GL_COLOR_BUFFER_BIT = $00004000;
  30.  
  31. // BeginMode
  32.   GL_POINTS           = $0000;
  33.   GL_LINES            = $0001;
  34.   GL_LINE_LOOP        = $0002;
  35.   GL_LINE_STRIP       = $0003;
  36.   GL_TRIANGLES        = $0004;
  37.   GL_TRIANGLE_STRIP   = $0005;
  38.   GL_TRIANGLE_FAN     = $0006;
  39.  
  40.   GL_PERSPECTIVE_CORRECTION_HINT = $0C50;
  41.   GL_POINT_SMOOTH_HINT = $0C51;
  42.   GL_LINE_SMOOTH_HINT = $0C52;
  43.   GL_FOG_HINT = $0C54;
  44.   GL_GENERATE_MIPMAP_HINT = $8192;
  45.  
  46. // AlphaFunction
  47. //(not supported in ES20)
  48.  
  49. // BlendingFactorDest
  50.   GL_ZERO                         =  0;
  51.   GL_ONE                          =  1;
  52.   GL_SRC_COLOR                    =  $0300;
  53.   GL_ONE_MINUS_SRC_COLOR          =  $0301;
  54.   GL_SRC_ALPHA                    =  $0302;
  55.   GL_ONE_MINUS_SRC_ALPHA          =  $0303;
  56.   GL_DST_ALPHA                    =  $0304;
  57.   GL_ONE_MINUS_DST_ALPHA          =  $0305;
  58.  
  59. // BlendingFactorSrc
  60. //      GL_ZERO
  61. //      GL_ONE
  62.   GL_DST_COLOR                    =  $0306;
  63.   GL_ONE_MINUS_DST_COLOR          =  $0307;
  64.   GL_SRC_ALPHA_SATURATE           =  $0308;
  65. //      GL_SRC_ALPHA
  66. //      GL_ONE_MINUS_SRC_ALPHA
  67. //      GL_DST_ALPHA
  68. //      GL_ONE_MINUS_DST_ALPHA
  69.  
  70. // BlendEquationSeparate
  71.   GL_FUNC_ADD                     =  $8006;
  72.   GL_BLEND_EQUATION               =  $8009;
  73.   GL_BLEND_EQUATION_RGB           =  $8009;    // same as BLEND_EQUATION
  74.   GL_BLEND_EQUATION_ALPHA         =  $883D;
  75.  
  76. // BlendSubtract
  77.   GL_FUNC_SUBTRACT                =  $800A;
  78.   GL_FUNC_REVERSE_SUBTRACT        =  $800B;
  79.  
  80. // Separate Blend Functions
  81.   GL_BLEND_DST_RGB                =  $80C8;
  82.   GL_BLEND_SRC_RGB                =  $80C9;
  83.   GL_BLEND_DST_ALPHA              =  $80CA;
  84.   GL_BLEND_SRC_ALPHA              =  $80CB;
  85.   GL_CONSTANT_COLOR               =  $8001;
  86.   GL_ONE_MINUS_CONSTANT_COLOR     =  $8002;
  87.   GL_CONSTANT_ALPHA               =  $8003;
  88.   GL_ONE_MINUS_CONSTANT_ALPHA     =  $8004;
  89.   GL_BLEND_COLOR                  =  $8005;
  90.  
  91. // Buffer Objects
  92.   GL_ARRAY_BUFFER                  = $8892;
  93.   GL_ELEMENT_ARRAY_BUFFER          = $8893;
  94.   GL_ARRAY_BUFFER_BINDING          = $8894;
  95.   GL_ELEMENT_ARRAY_BUFFER_BINDING  = $8895;
  96.  
  97.   GL_STREAM_DRAW                   = $88E0;
  98.   GL_STATIC_DRAW                   = $88E4;
  99.   GL_DYNAMIC_DRAW                  = $88E8;
  100.  
  101.   GL_BUFFER_SIZE                   = $8764;
  102.   GL_BUFFER_USAGE                  = $8765;
  103.  
  104.   GL_CURRENT_VERTEX_ATTRIB         = $8626;
  105.  
  106. // CullFaceMode
  107.   GL_FRONT                         = $0404;
  108.   GL_BACK                          = $0405;
  109.   GL_FRONT_AND_BACK                = $0408;
  110.  
  111. // DepthFunction
  112. {      GL_NEVER */
  113. /*      GL_LESS */
  114. /*      GL_EQUAL */
  115. /*      GL_LEQUAL */
  116. /*      GL_GREATER */
  117. /*      GL_NOTEQUAL */
  118. /*      GL_GEQUAL */
  119. /*      GL_ALWAYS */
  120. }
  121.  
  122. // EnableCap
  123.   GL_TEXTURE_2D                    = $0DE1;
  124.   GL_CULL_FACE                     = $0B44;
  125.   GL_BLEND                         = $0BE2;
  126.   GL_DITHER                        = $0BD0;
  127.   GL_STENCIL_TEST                  = $0B90;
  128.   GL_DEPTH_TEST                    = $0B71;
  129.   GL_SCISSOR_TEST                  = $0C11;
  130.   GL_POLYGON_OFFSET_FILL           = $8037;
  131.   GL_SAMPLE_ALPHA_TO_COVERAGE      = $809E;
  132.   GL_SAMPLE_COVERAGE               = $80A0;
  133.  
  134. // ErrorCode
  135.   GL_NO_ERROR                      = 0;
  136.   GL_INVALID_ENUM                  = $0500;
  137.   GL_INVALID_VALUE                 = $0501;
  138.   GL_INVALID_OPERATION             = $0502;
  139.   GL_OUT_OF_MEMORY                 = $0505;
  140.  
  141. // FrontFaceDirection
  142.   GL_CW                            = $0900;
  143.   GL_CCW                           = $0901;
  144.  
  145. // GetPName
  146.   GL_LINE_WIDTH                     = $0B21;
  147.   GL_ALIASED_POINT_SIZE_RANGE       = $846D;
  148.   GL_ALIASED_LINE_WIDTH_RANGE       = $846E;
  149.   GL_CULL_FACE_MODE                 = $0B45;
  150.   GL_FRONT_FACE                     = $0B46;
  151.   GL_DEPTH_RANGE                    = $0B70;
  152.   GL_DEPTH_WRITEMASK                = $0B72;
  153.   GL_DEPTH_CLEAR_VALUE              = $0B73;
  154.   GL_DEPTH_FUNC                     = $0B74;
  155.   GL_STENCIL_CLEAR_VALUE            = $0B91;
  156.   GL_STENCIL_FUNC                   = $0B92;
  157.   GL_STENCIL_FAIL                   = $0B94;
  158.   GL_STENCIL_PASS_DEPTH_FAIL        = $0B95;
  159.   GL_STENCIL_PASS_DEPTH_PASS        = $0B96;
  160.   GL_STENCIL_REF                    = $0B97;
  161.   GL_STENCIL_VALUE_MASK             = $0B93;
  162.   GL_STENCIL_WRITEMASK              = $0B98;
  163.   GL_STENCIL_BACK_FUNC              = $8800;
  164.   GL_STENCIL_BACK_FAIL              = $8801;
  165.   GL_STENCIL_BACK_PASS_DEPTH_FAIL   = $8802;
  166.   GL_STENCIL_BACK_PASS_DEPTH_PASS   = $8803;
  167.   GL_STENCIL_BACK_REF               = $8CA3;
  168.   GL_STENCIL_BACK_VALUE_MASK        = $8CA4;
  169.   GL_STENCIL_BACK_WRITEMASK         = $8CA5;
  170.   GL_VIEWPORT                       = $0BA2;
  171.   GL_SCISSOR_BOX                    = $0C10;
  172. //      GL_SCISSOR_TEST
  173.   GL_COLOR_CLEAR_VALUE              = $0C22;
  174.   GL_COLOR_WRITEMASK                = $0C23;
  175.   GL_UNPACK_ALIGNMENT               = $0CF5;
  176.   GL_PACK_ALIGNMENT                 = $0D05;
  177.   GL_MAX_TEXTURE_SIZE               = $0D33;
  178.   GL_MAX_VIEWPORT_DIMS              = $0D3A;
  179.   GL_SUBPIXEL_BITS                  = $0D50;
  180.   GL_RED_BITS                       = $0D52;
  181.   GL_GREEN_BITS                     = $0D53;
  182.   GL_BLUE_BITS                      = $0D54;
  183.   GL_ALPHA_BITS                     = $0D55;
  184.   GL_DEPTH_BITS                     = $0D56;
  185.   GL_STENCIL_BITS                   = $0D57;
  186.   GL_POLYGON_OFFSET_UNITS           = $2A00;
  187. //      GL_POLYGON_OFFSET_FILL
  188.   GL_POLYGON_OFFSET_FACTOR          = $8038;
  189.   GL_TEXTURE_BINDING_2D             = $8069;
  190.   GL_SAMPLE_BUFFERS                 = $80A8;
  191.   GL_SAMPLES                        = $80A9;
  192.   GL_SAMPLE_COVERAGE_VALUE          = $80AA;
  193.   GL_SAMPLE_COVERAGE_INVERT         = $80AB;
  194.  
  195. // GetTextureParameter
  196. {      GL_TEXTURE_MAG_FILTER */
  197. /*      GL_TEXTURE_MIN_FILTER */
  198. /*      GL_TEXTURE_WRAP_S */
  199. /*      GL_TEXTURE_WRAP_T }
  200.  
  201.   GL_NUM_COMPRESSED_TEXTURE_FORMATS = $86A2;
  202.   GL_COMPRESSED_TEXTURE_FORMATS     = $86A3;
  203.  
  204. // HintMode
  205.   GL_DONT_CARE                      = $1100;
  206.   GL_FASTEST                        = $1101;
  207.   GL_NICEST                         = $1102;
  208.  
  209.  
  210. // DataType
  211.   GL_BYTE                           = $1400;
  212.   GL_UNSIGNED_BYTE                  = $1401;
  213.   GL_SHORT                          = $1402;
  214.   GL_UNSIGNED_SHORT                 = $1403;
  215.   GL_INT                            = $1404;
  216.   GL_UNSIGNED_INT                   = $1405;
  217.   GL_FLOAT                          = $1406;
  218.   GL_FIXED                          = $140C;
  219.  
  220. // PixelFormat
  221.   GL_DEPTH_COMPONENT                = $1902;
  222.   GL_ALPHA                          = $1906;
  223.   GL_RGB                            = $1907;
  224.   GL_RGBA                           = $1908;
  225.   GL_LUMINANCE                      = $1909;
  226.   GL_LUMINANCE_ALPHA                = $190A;
  227.   GL_RGBA8 = GL_RGBA;
  228.  
  229. // PixelType
  230. //     GL_UNSIGNED_BYTE
  231.   GL_UNSIGNED_SHORT_4_4_4_4         = $8033;
  232.   GL_UNSIGNED_SHORT_5_5_5_1         = $8034;
  233.   GL_UNSIGNED_SHORT_5_6_5           = $8363;
  234.  
  235. // Shaders
  236.  GL_FRAGMENT_SHADER                  = $8B30;
  237.  GL_VERTEX_SHADER                    = $8B31;
  238.  GL_MAX_VERTEX_ATTRIBS               = $8869;
  239.  GL_MAX_VERTEX_UNIFORM_VECTORS       = $8DFB;
  240.  GL_MAX_VARYING_VECTORS              = $8DFC;
  241.  GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = $8B4D;
  242.  GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS   = $8B4C;
  243.  GL_MAX_TEXTURE_IMAGE_UNITS          = $8872;
  244.  GL_MAX_FRAGMENT_UNIFORM_VECTORS     = $8DFD;
  245.  GL_SHADER_TYPE                      = $8B4F;
  246.  GL_DELETE_STATUS                    = $8B80;
  247.  GL_LINK_STATUS                      = $8B82;
  248.  GL_VALIDATE_STATUS                  = $8B83;
  249.  GL_ATTACHED_SHADERS                 = $8B85;
  250.  GL_ACTIVE_UNIFORMS                  = $8B86;
  251.  GL_ACTIVE_UNIFORM_MAX_LENGTH        = $8B87;
  252.  GL_ACTIVE_ATTRIBUTES                = $8B89;
  253.  GL_ACTIVE_ATTRIBUTE_MAX_LENGTH      = $8B8A;
  254.  GL_SHADING_LANGUAGE_VERSION         = $8B8C;
  255.  GL_CURRENT_PROGRAM                  = $8B8D;
  256.  
  257. // StencilFunction
  258.  GL_NEVER                          = $0200;
  259.  GL_LESS                           = $0201;
  260.  GL_EQUAL                          = $0202;
  261.  GL_LEQUAL                         = $0203;
  262.  GL_GREATER                        = $0204;
  263.  GL_NOTEQUAL                       = $0205;
  264.  GL_GEQUAL                         = $0206;
  265.  GL_ALWAYS                         = $0207;
  266.  
  267. // StencilOp
  268. //      GL_ZERO
  269.   GL_KEEP                           = $1E00;
  270.   GL_REPLACE                        = $1E01;
  271.   GL_INCR                           = $1E02;
  272.   GL_DECR                           = $1E03;
  273.   GL_INVERT                         = $150A;
  274.   GL_INCR_WRAP                      = $8507;
  275.   GL_DECR_WRAP                      = $8508;
  276.  
  277. // StringName
  278.   GL_VENDOR                         = $1F00;
  279.   GL_RENDERER                       = $1F01;
  280.   GL_VERSION                        = $1F02;
  281.   GL_EXTENSIONS                     = $1F03;
  282.  
  283. // TextureMagFilter
  284.   GL_NEAREST                        = $2600;
  285.   GL_LINEAR                         = $2601;
  286.  
  287.   GL_DEPTH24_STENCIL8 = $88F0;
  288.  
  289. // TextureMinFilter
  290. //      GL_NEAREST
  291. //      GL_LINEAR
  292.   GL_NEAREST_MIPMAP_NEAREST         = $2700;
  293.   GL_LINEAR_MIPMAP_NEAREST          = $2701;
  294.   GL_NEAREST_MIPMAP_LINEAR          = $2702;
  295.   GL_LINEAR_MIPMAP_LINEAR           = $2703;
  296.  
  297. // TextureParameterName
  298.   GL_TEXTURE_MAG_FILTER             = $2800;
  299.   GL_TEXTURE_MIN_FILTER             = $2801;
  300.   GL_TEXTURE_WRAP_S                 = $2802;
  301.   GL_TEXTURE_WRAP_T                 = $2803;
  302.  
  303. // TextureTarget
  304. //      GL_TEXTURE_2D
  305.   GL_TEXTURE                        = $1702;
  306.  
  307.   GL_TEXTURE_CUBE_MAP               = $8513;
  308.   GL_TEXTURE_BINDING_CUBE_MAP       = $8514;
  309.   GL_TEXTURE_CUBE_MAP_POSITIVE_X    = $8515;
  310.   GL_TEXTURE_CUBE_MAP_NEGATIVE_X    = $8516;
  311.   GL_TEXTURE_CUBE_MAP_POSITIVE_Y    = $8517;
  312.   GL_TEXTURE_CUBE_MAP_NEGATIVE_Y    = $8518;
  313.   GL_TEXTURE_CUBE_MAP_POSITIVE_Z    = $8519;
  314.   GL_TEXTURE_CUBE_MAP_NEGATIVE_Z    = $851A;
  315.   GL_MAX_CUBE_MAP_TEXTURE_SIZE      = $851C;
  316.  
  317. // TextureUnit
  318.   GL_TEXTURE0                       = $84C0;
  319.   GL_TEXTURE1                       = $84C1;
  320.   GL_TEXTURE2                       = $84C2;
  321.   GL_TEXTURE3                       = $84C3;
  322.   GL_TEXTURE4                       = $84C4;
  323.   GL_TEXTURE5                       = $84C5;
  324.   GL_TEXTURE6                       = $84C6;
  325.   GL_TEXTURE7                       = $84C7;
  326.   GL_TEXTURE8                       = $84C8;
  327.   GL_TEXTURE9                       = $84C9;
  328.   GL_TEXTURE10                      = $84CA;
  329.   GL_TEXTURE11                      = $84CB;
  330.   GL_TEXTURE12                      = $84CC;
  331.   GL_TEXTURE13                      = $84CD;
  332.   GL_TEXTURE14                      = $84CE;
  333.   GL_TEXTURE15                      = $84CF;
  334.   GL_TEXTURE16                      = $84D0;
  335.   GL_TEXTURE17                      = $84D1;
  336.   GL_TEXTURE18                      = $84D2;
  337.   GL_TEXTURE19                      = $84D3;
  338.   GL_TEXTURE20                      = $84D4;
  339.   GL_TEXTURE21                      = $84D5;
  340.   GL_TEXTURE22                      = $84D6;
  341.   GL_TEXTURE23                      = $84D7;
  342.   GL_TEXTURE24                      = $84D8;
  343.   GL_TEXTURE25                      = $84D9;
  344.   GL_TEXTURE26                      = $84DA;
  345.   GL_TEXTURE27                      = $84DB;
  346.   GL_TEXTURE28                      = $84DC;
  347.   GL_TEXTURE29                      = $84DD;
  348.   GL_TEXTURE30                      = $84DE;
  349.   GL_TEXTURE31                      = $84DF;
  350.   GL_ACTIVE_TEXTURE                 = $84E0;
  351.  
  352. // TextureWrapMode
  353.   GL_REPEAT                         = $2901;
  354.   GL_CLAMP_TO_EDGE                  = $812F;
  355.   GL_MIRRORED_REPEAT                = $8370;
  356.  
  357. // Uniform Types
  358.  GL_FLOAT_VEC2                     = $8B50;
  359.  GL_FLOAT_VEC3                     = $8B51;
  360.  GL_FLOAT_VEC4                     = $8B52;
  361.  GL_INT_VEC2                       = $8B53;
  362.  GL_INT_VEC3                       = $8B54;
  363.  GL_INT_VEC4                       = $8B55;
  364.  GL_BOOL                           = $8B56;
  365.  GL_BOOL_VEC2                      = $8B57;
  366.  GL_BOOL_VEC3                      = $8B58;
  367.  GL_BOOL_VEC4                      = $8B59;
  368.  GL_FLOAT_MAT2                     = $8B5A;
  369.  GL_FLOAT_MAT3                     = $8B5B;
  370.  GL_FLOAT_MAT4                     = $8B5C;
  371.  GL_SAMPLER_2D                     = $8B5E;
  372.  GL_SAMPLER_CUBE                   = $8B60;
  373.  
  374. // Vertex Arrays
  375.   GL_VERTEX_ATTRIB_ARRAY_ENABLED        = $8622;
  376.   GL_VERTEX_ATTRIB_ARRAY_SIZE           = $8623;
  377.   GL_VERTEX_ATTRIB_ARRAY_STRIDE         = $8624;
  378.   GL_VERTEX_ATTRIB_ARRAY_TYPE           = $8625;
  379.   GL_VERTEX_ATTRIB_ARRAY_NORMALIZED     = $886A;
  380.   GL_VERTEX_ATTRIB_ARRAY_POINTER        = $8645;
  381.   GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = $889F;
  382.  
  383. // Read Format
  384.   GL_IMPLEMENTATION_COLOR_READ_TYPE   = $8B9A;
  385.   GL_IMPLEMENTATION_COLOR_READ_FORMAT = $8B9B;
  386.  
  387. // Shader Source
  388.   GL_COMPILE_STATUS                 = $8B81;
  389.   GL_INFO_LOG_LENGTH                = $8B84;
  390.   GL_SHADER_SOURCE_LENGTH           = $8B88;
  391.   GL_SHADER_COMPILER                = $8DFA;
  392.  
  393. // Shader Binary
  394.   GL_SHADER_BINARY_FORMATS          = $8DF8;
  395.   GL_NUM_SHADER_BINARY_FORMATS      = $8DF9;
  396.  
  397. // Shader Precision-Specified Types
  398.   GL_LOW_FLOAT                      = $8DF0;
  399.   GL_MEDIUM_FLOAT                   = $8DF1;
  400.   GL_HIGH_FLOAT                     = $8DF2;
  401.   GL_LOW_INT                        = $8DF3;
  402.   GL_MEDIUM_INT                     = $8DF4;
  403.   GL_HIGH_INT                       = $8DF5;
  404.  
  405. // Framebuffer Object.
  406.   GL_FRAMEBUFFER                    = $8D40;
  407.   GL_RENDERBUFFER                   = $8D41;
  408.  
  409.   GL_RGBA4                          = $8056;
  410.   GL_RGB5_A1                        = $8057;
  411.   GL_RGB565                         = $8D62;
  412.   GL_DEPTH_COMPONENT16              = $81A5;
  413.   GL_STENCIL_INDEX                  = $1901;
  414.   GL_STENCIL_INDEX8                 = $8D48;
  415.  
  416.   GL_RENDERBUFFER_WIDTH             = $8D42;
  417.   GL_RENDERBUFFER_HEIGHT            = $8D43;
  418.   GL_RENDERBUFFER_INTERNAL_FORMAT   = $8D44;
  419.   GL_RENDERBUFFER_RED_SIZE          = $8D50;
  420.   GL_RENDERBUFFER_GREEN_SIZE        = $8D51;
  421.   GL_RENDERBUFFER_BLUE_SIZE         = $8D52;
  422.   GL_RENDERBUFFER_ALPHA_SIZE        = $8D53;
  423.   GL_RENDERBUFFER_DEPTH_SIZE        = $8D54;
  424.   GL_RENDERBUFFER_STENCIL_SIZE      = $8D55;
  425.  
  426.   GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE           = $8CD0;
  427.   GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME           = $8CD1;
  428.   GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL         = $8CD2;
  429.   GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = $8CD3;
  430.  
  431.   GL_COLOR_ATTACHMENT0              = $8CE0;
  432.   GL_DEPTH_ATTACHMENT               = $8D00;
  433.   GL_STENCIL_ATTACHMENT             = $8D20;
  434.  
  435.   GL_NONE                           = 0;
  436.  
  437.   GL_FRAMEBUFFER_COMPLETE                      = $8CD5;
  438.   GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT         = $8CD6;
  439.   GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = $8CD7;
  440.   GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS         = $8CD9;
  441.   GL_FRAMEBUFFER_UNSUPPORTED                   = $8CDD;
  442.   GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT = $8CD8;
  443.   GL_FRAMEBUFFER_INCOMPLETE_FORMATS = $8CDA;
  444.   GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = $8CDB;
  445.   GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = $8CDC;
  446.   GL_FRAMEBUFFER_STATUS_ERROR = $8CDE;
  447.  
  448.   GL_FRAMEBUFFER_BINDING            = $8CA6;
  449.   GL_RENDERBUFFER_BINDING           = $8CA7;
  450.   GL_MAX_RENDERBUFFER_SIZE          = $84E8;
  451.  
  452.   GL_INVALID_FRAMEBUFFER_OPERATION  = $0506;
  453.  
  454.   //Extensions
  455.   GL_DEPTH_COMPONENT24_OES          = $81A6;
  456.   GL_DEPTH_COMPONENT32_OES          = $81A7;
  457.  
  458.   // GL_OES_packed_depth_stencil
  459.   GL_DEPTH_STENCIL_OES              = $84F9;
  460.   GL_UNSIGNED_INT_24_8_OES          = $84FA;
  461.   GL_DEPTH24_STENCIL8_OES           = $88F0;
  462.  
  463.     GL_STENCIL_INDEX8_OES           = $8D48;
  464.  
  465.   // GL_OES_rgb8_rgba8
  466.   GL_RGB8_OES                        = $8051;
  467.   GL_RGBA8_OES                       = $8058;
  468.  
  469. // APPLE extension tokens
  470.  
  471. // GL_APPLE_framebuffer_multisample
  472.   GL_RENDERBUFFER_SAMPLES_APPLE                          = $8CAB;
  473.   GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE            = $8D56;
  474.   GL_MAX_SAMPLES_APPLE                                   = $8D57;
  475.   GL_READ_FRAMEBUFFER_APPLE                              = $8CA8;
  476.   GL_DRAW_FRAMEBUFFER_APPLE                              = $8CA9;
  477.   GL_DRAW_FRAMEBUFFER_BINDING_APPLE                      = $8CA6;
  478.   GL_READ_FRAMEBUFFER_BINDING_APPLE                      = $8CAA;
  479.  
  480. // GL_APPLE_texture_format_BGRA8888
  481.   GL_BGRA_EXT                                            = $80E1;
  482.   GL_BGRA = GL_BGRA_EXT;
  483.  
  484. // GL core functions.
  485. {$IFNDEF STATIC_LINKING}
  486. Var
  487. {$ENDIF}
  488.  
  489.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glActiveTexture{$IFNDEF STATIC_LINKING}:Procedure{$ENDIF}(texture:Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  490.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glAttachShader{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(programname, shader:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  491.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBindAttribLocation{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program:Integer; index:Integer; name:PAnsiChar); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  492.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBindBuffer{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, buffer:Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  493.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBindFramebuffer{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, framebuffer:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  494.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBindRenderbuffer{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, renderbuffer:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  495.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBindTexture{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, texture:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  496.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBlendColor{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(red, green, blue, alpha:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  497.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBlendEquation{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}( mode:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  498.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBlendEquationSeparate{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(modeRGB, modeAlpha:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  499.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBlendFunc{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(sfactor, dfactor:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  500.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBlendFuncSeparate{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(srcRGB, dstRGB, srcAlpha, dstAlpha:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  501.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBufferData {$IFNDEF STATIC_LINKING}:Procedure{$ENDIF}(target, size:Cardinal; data:Pointer; usage:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  502.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glBufferSubData{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, offset, size:Cardinal; data:Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  503.   {$IFDEF STATIC_LINKING}Function{$ENDIF} glCheckFramebufferStatus{$IFNDEF STATIC_LINKING}:Function{$ENDIF} (target:Integer):Integer; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  504.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glClear{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(mask:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  505.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glClearColor{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(red, green, blue, alpha:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  506.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glClearDepthf{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(depth:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  507.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glClearStencil{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(s:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  508.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glColorMask{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(red, green, blue, alpha:Boolean); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  509.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glCompileShader{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(shader:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  510.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glCompressedTexImage2D{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, level, internalformat, width, height, border, imageSize:Cardinal; data:Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  511.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glCompressedTexSubImage2D{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, level, xoffset, yoffset, width, height, format, imageSize:Cardinal; data:Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  512.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glCopyTexImage2D{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, level, internalformat, x, y, width, height, border:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  513.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glCopyTexSubImage2D{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, level, xoffset, yoffset, x, y, width,height:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  514.   {$IFDEF STATIC_LINKING}Function{$ENDIF} glCreateProgram{$IFNDEF STATIC_LINKING}:Function{$ENDIF}():Integer; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  515.   {$IFDEF STATIC_LINKING}Function{$ENDIF} glCreateShader{$IFNDEF STATIC_LINKING}:Function{$ENDIF} (shadertype:Integer):Integer; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  516.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glCullFace{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(mode:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  517.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDeleteBuffers{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal;  buffers:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  518.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDeleteFramebuffers{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal; framebuffers:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  519.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDeleteProgram{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  520.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDeleteRenderbuffers{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal; renderbuffers:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  521.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDeleteShader{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(shader:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  522.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDeleteTextures{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal; textures:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  523.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDepthFunc{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(func:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  524.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDepthMask{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(flag:Boolean); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  525.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDepthRange{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(zNear, zFar:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  526.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDetachShader{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program, shader:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  527.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDisable{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(cap:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  528.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDisableVertexAttribArray{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(index:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  529.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDrawArrays{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(mode, first, count:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  530.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glDrawElements{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(mode, count, _type:Cardinal; indices:Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  531.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glEnable{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(cap:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  532.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glEnableVertexAttribArray{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(index:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  533.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glFinish{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  534.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glFlush{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  535.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glFramebufferRenderbuffer{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, attachment, renderbuffertarget, renderbuffer:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  536.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glFramebufferTexture2D{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, attachment, textarget, texture, level:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  537.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glFrontFace{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(mode:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  538.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGenBuffers{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal; buffers:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  539.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGenerateMipmap{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  540.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGenFramebuffers{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal; framebuffers:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  541.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGenRenderbuffers{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal; renderbuffers:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  542.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGenTextures{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal; textures:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  543.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetActiveAttrib{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program, index, bufsize:Cardinal; Var length, size, _type:Integer; name:PAnsiChar); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  544.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetActiveUniform{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program, index, bufsize:Cardinal; Var length, size, _type:Integer; name:PAnsiChar); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  545.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetAttachedShaders{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program, maxcount:Cardinal; Var count:Integer; shaders:PCardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  546.   {$IFDEF STATIC_LINKING}Function{$ENDIF} glGetAttribLocation{$IFNDEF STATIC_LINKING}:Function{$ENDIF} (_program:Cardinal; name:PAnsiChar):Integer; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  547.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetBooleanv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(pname:Cardinal; params:PBoolean); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  548.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetBufferParameteriv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  549.   {$IFDEF STATIC_LINKING}Function{$ENDIF} glGetError{$IFNDEF STATIC_LINKING}:Function{$ENDIF} ():Integer; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  550.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetFloatv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(pname:Cardinal; params:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  551.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetFramebufferAttachmentParameteriv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, attachment, pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  552.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetIntegerv {$IFNDEF STATIC_LINKING}:Procedure{$ENDIF}(pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  553.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetProgramiv {$IFNDEF STATIC_LINKING}:Procedure{$ENDIF}(_program,pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  554.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetProgramInfoLog{$IFNDEF STATIC_LINKING}:procedure{$ENDIF}(_program: Cardinal; bufSize: Integer; length: PInteger; infoLog: PAnsiChar); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  555.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetRenderbufferParameteriv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  556.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetShaderiv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(shader, pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  557.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetShaderInfoLog{$IFNDEF STATIC_LINKING}: procedure{$ENDIF}(shader: Cardinal; bufSize: Integer; length: PInteger; infoLog: PAnsiChar); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  558.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetShaderPrecisionFormat{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(shadertype, precisiontype:Cardinal; Var range, precision:Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  559.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF} glGetShaderSource{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(shader, bufsize:Cardinal; Var length:Integer; source:PAnsiChar); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  560.   {$IFDEF STATIC_LINKING}Function{$ENDIF} glGetString{$IFNDEF STATIC_LINKING}:Function{$ENDIF} (name:Cardinal):PAnsiChar; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  561.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glGetTexParameterfv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, pname:Cardinal; params:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  562.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glGetTexParameteriv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  563.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glGetUniformfv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program, location:Cardinal;  params:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  564.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glGetUniformiv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program, location:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  565.   {$IFDEF STATIC_LINKING}Function{$ENDIF}glGetUniformLocation{$IFNDEF STATIC_LINKING}:Function{$ENDIF}(_program:Cardinal; name:PAnsiChar):Integer; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  566.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glGetVertexAttribfv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(index, pname:Cardinal; params:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  567.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glGetVertexAttribiv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(index, pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  568.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glGetVertexAttribPointerv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(index, pname:Cardinal; pointer:PPointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  569.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glHint{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, mode:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  570.   {$IFDEF STATIC_LINKING}Function{$ENDIF}glIsBuffer{$IFNDEF STATIC_LINKING}:Function{$ENDIF} (buffer:Cardinal):Boolean; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  571.   {$IFDEF STATIC_LINKING}Function{$ENDIF}glIsEnabled{$IFNDEF STATIC_LINKING}:Function{$ENDIF} (cap:Cardinal):Boolean; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  572.   {$IFDEF STATIC_LINKING}Function{$ENDIF}glIsFramebuffer{$IFNDEF STATIC_LINKING}:Function{$ENDIF} (framebuffer:Cardinal):Boolean; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  573.   {$IFDEF STATIC_LINKING}Function{$ENDIF}glIsProgram{$IFNDEF STATIC_LINKING}:Function{$ENDIF} (_program:Cardinal):Boolean; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  574.   {$IFDEF STATIC_LINKING}Function{$ENDIF}glIsRenderbuffer{$IFNDEF STATIC_LINKING}:Function {$ENDIF}(renderbuffer:Cardinal):Boolean; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  575.   {$IFDEF STATIC_LINKING}Function{$ENDIF}glIsShader{$IFNDEF STATIC_LINKING}:Function {$ENDIF} (shader:Cardinal):Boolean; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  576.   {$IFDEF STATIC_LINKING}Function{$ENDIF}glIsTexture{$IFNDEF STATIC_LINKING}:Function {$ENDIF}(texture:Cardinal):Boolean; cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  577.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glLineWidth{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(width:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  578.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glLinkProgram{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  579.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glPixelStorei{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(pname:Cardinal; param:Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  580.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glPolygonOffset{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(factor, units:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  581.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glReadPixels{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(x, y, width, height, format, _type:Cardinal; pixels:Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  582.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glReleaseShaderCompiler {$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  583.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glRenderbufferStorage{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, internalformat, width, height:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  584.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glSampleCoverage{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(value:Single; invert:Boolean); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  585.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glScissor{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(x, y, width, height:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  586.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glShaderBinary{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(n:Cardinal; shaders:PCardinal; binaryformat:Cardinal; binary:Pointer; length:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  587.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glShaderSource{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(shader: Cardinal; count: Integer; const _string: PAnsiChar; const length: PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  588.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glStencilFunc{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(func, ref, mask:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  589.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glStencilFuncSeparate{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(face, func, ref, mask:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  590.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glStencilMask {$IFNDEF STATIC_LINKING}:Procedure{$ENDIF}(mask:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  591.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glStencilMaskSeparate{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(face, mask:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  592.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glStencilOp{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(fail, zfail, zpass:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  593.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glStencilOpSeparate{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(face, fail, zfail, zpass:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  594.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glTexImage2D {$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, level, internalformat, width, height, border, format, _type:Cardinal; pixels:Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  595.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glTexParameterf{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, pname:Cardinal; param:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  596.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glTexParameterfv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, pname:Cardinal; params:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  597.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glTexParameteri{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, pname:Cardinal; param:Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  598.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glTexParameteriv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, pname:Cardinal; params:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  599.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glTexSubImage2D{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, level, xoffset, yoffset, width, height, format, _type:Cardinal; pixels:Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  600.  
  601.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform1f{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; v0: Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  602.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform2f{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; v0: Single; v1: Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  603.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform3f{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; v0: Single; v1: Single; v2: Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  604.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform4f{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; v0: Single; v1: Single; v2: Single; v3: Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  605.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform1i{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; v0: Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  606.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform2i{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; v0: Integer; v1: Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  607.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform3i{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; v0: Integer; v1: Integer; v2: Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  608.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform4i{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; v0: Integer; v1: Integer; v2: Integer; v3: Integer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  609.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform1fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; const value: PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  610.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform2fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; const value: PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  611.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform3fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; const value: PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  612.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform4fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; const value: PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  613.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform1iv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; const value: PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  614.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform2iv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; const value: PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  615.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform3iv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; const value: PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  616.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniform4iv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; const value: PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  617.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniformMatrix2fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; transpose: Boolean; const value: PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  618.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniformMatrix3fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; transpose: Boolean; const value: PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  619.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUniformMatrix4fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(location: Integer; count: Integer; transpose: Boolean; const value: PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  620.  
  621.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glUseProgram{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  622.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glValidateProgram{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(_program:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  623.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glVertexAttrib1f{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(indx:Cardinal; x:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  624.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glVertexAttrib1fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(indx:Cardinal; values:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  625.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glVertexAttrib2f{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(indx:Cardinal; x, y:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  626.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glVertexAttrib2fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(indx:Cardinal; values:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  627.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glVertexAttrib3f{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(indx:Cardinal; x, y, z:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  628.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}  glVertexAttrib3fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(indx:Cardinal; values:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  629.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glVertexAttrib4f{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(indx:Cardinal; x, y, z, w:Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  630.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glVertexAttrib4fv{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(indx:Cardinal; values:PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  631.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glVertexAttribPointer{$IFNDEF STATIC_LINKING}:procedure{$ENDIF}(index: Cardinal; size: Integer; _type: Cardinal; normalized: Boolean; stride: Integer; const pointer: Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  632.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glViewport{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(x, y, width, height:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  633.  
  634.   // Extensions
  635.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glRenderbufferStorageMultisample{$IFNDEF STATIC_LINKING}:Procedure {$ENDIF}(target, samples, internalformat, width, height:Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  636.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glResolveMultisampleFramebuffer{$IFNDEF STATIC_LINKING}:Procedure{$ENDIF}(); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  637.   {$IFDEF STATIC_LINKING}Procedure{$ENDIF}glDiscardFramebuffer{$IFNDEF STATIC_LINKING}:Procedure{$ENDIF}(target, count:Integer; attachments:PInteger); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  638.  
  639.   // GL ES1
  640.   {$IFDEF LEGACY_GLES}
  641.   glAlphaFunc:Procedure (func: Cardinal; ref: Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  642.   glEnableClientState: Procedure(aarray: Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  643.   glDisableClientState: Procedure(aarray: Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  644.   glVertexPointer:Procedure (size: Integer; atype: Cardinal; stride: Integer; const pointer: Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  645.   glTexCoordPointer:Procedure (size: Integer; atype: Cardinal; stride: Integer; const pointer: Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  646.   glColorPointer:Procedure (size: Integer; atype: Cardinal; stride: Integer; const pointer: Pointer); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  647.   glColor4f:Procedure (red, green, blue, alpha: Single); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  648.   glMatrixMode:Procedure (mode: Cardinal); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  649.   glLoadMatrixf:Procedure (const m: PSingle); cdecl; {$IFDEF STATIC_LINKING}External; {$ENDIF}
  650.   {$ENDIF}
  651.  
  652. Procedure glClearDepth(depth:Single);
  653.  
  654. Function glExtensionSupported(Extension:TERRAString):Boolean;
  655. Function glGetExtensionString():TERRAString;
  656.  
  657. Procedure LoadOpenGL();
  658.  
  659. Implementation
  660. Uses TERRA_Error, TERRA_Application;
  661.  
  662. {$IFNDEF STATIC_LINKING}
  663. Type
  664.   TLibHandle = Cardinal;
  665.  
  666. Var
  667.   OpenGLHandle:TLibHandle;
  668. {$ENDIF}
  669.  
  670. Var
  671.   ExtensionsList:TERRAString='';
  672.  
  673.  
  674. Procedure glClearDepth(depth:Single);
  675. Begin
  676.   glClearDepthf(depth);
  677. End;
  678.  
  679. Function glGetExtensionString():TERRAString;
  680. Begin
  681.   Result := ExtensionsList;
  682. End;
  683.  
  684. {$IFNDEF STATIC_LINKING}
  685. Function glGetProcAddress(Proc:TERRAString):Pointer;
  686. Begin
  687.   Result := GetProcAddress(OpenGLHandle, PAnsiChar(Proc));
  688.   If Not Assigned(Result) Then
  689.     Result := GetProcAddress(OpenGLHandle, PAnsiChar(Proc+'OES'));
  690.  
  691.   If Not Assigned(Result) Then
  692.     Result := GetProcAddress(OpenGLHandle, PAnsiChar(Proc+'APPLE'));
  693.  
  694.   If Not Assigned(Result) Then
  695.     Result := GetProcAddress(OpenGLHandle, PAnsiChar(Proc+'EXT'));
  696.  
  697.   If Not Assigned(Result) Then
  698.     Log(logWarning,'GL', 'Function '+Proc+' not avaliable.');
  699. End;
  700. {$ENDIF}
  701.  
  702. Procedure LoadOpenGL();
  703. Begin
  704. {$IFNDEF STATIC_LINKING}
  705.     TERRA_Log.Log(logDebug, 'GL', 'loading openGL');
  706.   Log(logDebug, 'OpenGL', 'Loading library');
  707.  
  708.   OpenGLHandle := LoadLibrary(PAnsiChar(OpenGLLibName));
  709.   If OpenGLHandle=0 Then
  710.   Begin
  711.     RaiseError('Error loading OpenGL from '+OpenGLLibName);
  712.     Exit;
  713.   End;
  714.  
  715.   glActiveTexture := glGetProcAddress('glActiveTexture');
  716.   glAttachShader := glGetProcAddress('glAttachShader');
  717.   glBindAttribLocation := glGetProcAddress('glBindAttribLocation');
  718.   glBindBuffer := glGetProcAddress('glBindBuffer');
  719.   glBindFramebuffer := glGetProcAddress('glBindFramebuffer');
  720.   glBindRenderbuffer := glGetProcAddress('glBindRenderbuffer');
  721.   glBindTexture := glGetProcAddress('glBindTexture');
  722.   glBlendColor := glGetProcAddress('glBlendColor');
  723.   glBlendEquation := glGetProcAddress('glBlendEquation');
  724.   glBlendEquationSeparate := glGetProcAddress('glBlendEquationSeparate');
  725.   glBlendFunc := glGetProcAddress('glBlendFunc');
  726.   glBlendFuncSeparate := glGetProcAddress('glBlendFuncSeparate ');
  727.   glBufferData := glGetProcAddress('glBufferData');
  728.   glBufferSubData := glGetProcAddress('glBufferSubData');
  729.   glCheckFramebufferStatus := glGetProcAddress('glCheckFramebufferStatus');
  730.   glClear := glGetProcAddress('glClear');
  731.   glClearColor := glGetProcAddress('glClearColor');
  732.   glClearDepthf := glGetProcAddress('glClearDepthf');
  733.   glClearStencil := glGetProcAddress('glClearStencil');
  734.   glColorMask := glGetProcAddress('glColorMask');
  735.   glCompileShader := glGetProcAddress('glCompileShader');
  736.   glCompressedTexImage2D := glGetProcAddress('glCompressedTexImage2D');
  737.   glCompressedTexSubImage2D := glGetProcAddress('glCompressedTexSubImage2D');
  738.   glCopyTexImage2D := glGetProcAddress('glCopyTexImage2D');
  739.   glCopyTexSubImage2D := glGetProcAddress('glCopyTexSubImage2D');
  740.   glCreateProgram := glGetProcAddress('glCreateProgram');
  741.   glCreateShader := glGetProcAddress('glCreateShader');
  742.   glCullFace := glGetProcAddress('glCullFace');
  743.   glDeleteBuffers := glGetProcAddress('glDeleteBuffers');
  744.   glDeleteFramebuffers := glGetProcAddress('glDeleteFramebuffers');
  745.   glDeleteProgram := glGetProcAddress('glDeleteProgram');
  746.   glDeleteRenderbuffers := glGetProcAddress('glDeleteRenderbuffers');
  747.   glDeleteShader := glGetProcAddress('glDeleteShader');
  748.   glDeleteTextures := glGetProcAddress('glDeleteTextures');
  749.   glDepthFunc := glGetProcAddress('glDepthFunc');
  750.   glDepthMask := glGetProcAddress('glDepthMask');
  751.   glDepthRange := glGetProcAddress('glDepthRangef');
  752.   glDetachShader := glGetProcAddress('glDetachShader');
  753.   glDisable := glGetProcAddress('glDisable');
  754.   glDisableVertexAttribArray := glGetProcAddress('glDisableVertexAttribArray');
  755.   glDrawArrays := glGetProcAddress('glDrawArrays');
  756.   glDrawElements := glGetProcAddress('glDrawElements');
  757.   glEnable := glGetProcAddress('glEnable');
  758.   glEnableVertexAttribArray := glGetProcAddress('glEnableVertexAttribArray');
  759.   glFinish := glGetProcAddress('glFinish');
  760.   glFlush := glGetProcAddress('glFlush');
  761.   glFramebufferRenderbuffer := glGetProcAddress('glFramebufferRenderbuffer');
  762.   glFramebufferTexture2D := glGetProcAddress('glFramebufferTexture2D');
  763.   glFrontFace := glGetProcAddress('glFrontFace');
  764.   glGenBuffers := glGetProcAddress('glGenBuffers');
  765.   glGenerateMipmap := glGetProcAddress('glGenerateMipmap');
  766.   glGenFramebuffers := glGetProcAddress('glGenFramebuffers');
  767.   glGenRenderbuffers := glGetProcAddress('glGenRenderbuffers');
  768.   glGenTextures := glGetProcAddress('glGenTextures');
  769.   glGetActiveAttrib := glGetProcAddress('glGetActiveAttrib');
  770.   glGetActiveUniform := glGetProcAddress('glGetActiveUniform');
  771.   glGetAttachedShaders := glGetProcAddress('glGetAttachedShaders');
  772.   glGetAttribLocation := glGetProcAddress('glGetAttribLocation');
  773.   glGetBooleanv := glGetProcAddress('glGetBooleanv');
  774.   glGetBufferParameteriv := glGetProcAddress('glGetBufferParameteriv');
  775.   glGetError := glGetProcAddress('glGetError');
  776.   glGetFloatv := glGetProcAddress('glGetFloatv');
  777.   glGetFramebufferAttachmentParameteriv := glGetProcAddress('glGetFramebufferAttachmentParameteriv');
  778.   glGetIntegerv := glGetProcAddress('glGetIntegerv');
  779.   glGetProgramiv := glGetProcAddress('glGetProgramiv');
  780.   glGetProgramInfoLog := glGetProcAddress('glGetProgramInfoLog');
  781.   glGetRenderbufferParameteriv := glGetProcAddress('glGetRenderbufferParameteriv');
  782.   glGetShaderiv := glGetProcAddress('glGetShaderiv');
  783.   glGetShaderInfoLog := glGetProcAddress('glGetShaderInfoLog');
  784.   glGetShaderPrecisionFormat := glGetProcAddress('glGetShaderPrecisionFormat');
  785.   glGetShaderSource := glGetProcAddress('glGetShaderSource');
  786.   glGetString := glGetProcAddress('glGetString');
  787.   glGetTexParameterfv := glGetProcAddress('glGetTexParameterfv');
  788.   glGetTexParameteriv := glGetProcAddress('glGetTexParameteriv');
  789.   glGetUniformfv := glGetProcAddress('glGetUniformfv');
  790.   glGetUniformiv := glGetProcAddress('glGetUniformiv');
  791.   glGetUniformLocation := glGetProcAddress('glGetUniformLocation');
  792.   glGetVertexAttribfv := glGetProcAddress('glGetVertexAttribfv');
  793.   glGetVertexAttribiv := glGetProcAddress('glGetVertexAttribiv');
  794.   glGetVertexAttribPointerv := glGetProcAddress('glGetVertexAttribPointerv');
  795.   glHint := glGetProcAddress('glHint');
  796.   glIsBuffer := glGetProcAddress('glIsBuffer');
  797.   glIsEnabled := glGetProcAddress('glIsFramebuffer');
  798.   glIsFramebuffer := glGetProcAddress('glIsFramebuffer');
  799.   glIsProgram := glGetProcAddress('glIsProgram');
  800.   glIsRenderbuffer := glGetProcAddress('glIsRenderbuffer');
  801.   glIsShader := glGetProcAddress('glIsShader');
  802.   glIsTexture := glGetProcAddress('glIsTexture');
  803.   glLineWidth := glGetProcAddress('glLineWidth');
  804.   glLinkProgram := glGetProcAddress('glLinkProgram');
  805.   glPixelStorei := glGetProcAddress('glPixelStorei');
  806.   glPolygonOffset := glGetProcAddress('glPolygonOffset');
  807.   glReadPixels := glGetProcAddress('glReadPixels');
  808.   glReleaseShaderCompiler := glGetProcAddress('glReleaseShaderCompiler');
  809.   glRenderbufferStorage := glGetProcAddress('glRenderbufferStorage');
  810.   glSampleCoverage := glGetProcAddress('glSampleCoverage');
  811.   glScissor := glGetProcAddress('glScissor');
  812.   glShaderBinary := glGetProcAddress('glShaderBinary');
  813.   glShaderSource := glGetProcAddress('glShaderSource');
  814.   glStencilFunc := glGetProcAddress('glStencilFunc');
  815.   glStencilFuncSeparate := glGetProcAddress('glStencilFuncSeparate');
  816.   glStencilMask := glGetProcAddress('glStencilMask');
  817.   glStencilMaskSeparate := glGetProcAddress('glStencilMaskSeparate');
  818.   glStencilOp := glGetProcAddress('glStencilOp');
  819.   glStencilOpSeparate := glGetProcAddress('glStencilOpSeparate');
  820.   glTexImage2D := glGetProcAddress('glTexImage2D');
  821.   glTexParameterf := glGetProcAddress('glTexParameterf');
  822.   glTexParameterfv := glGetProcAddress('glTexParameterfv');
  823.   glTexParameteri := glGetProcAddress('glTexParameteri');
  824.   glTexParameteriv := glGetProcAddress('glTexParameteriv');
  825.   glTexSubImage2D := glGetProcAddress('glTexSubImage2D');
  826.   glUniform1f := glGetProcAddress('glUniform1f');
  827.   glUniform1fv := glGetProcAddress('glUniform1fv');
  828.   glUniform1i := glGetProcAddress('glUniform1i');
  829.   glUniform1iv := glGetProcAddress('glUniform1iv');
  830.   glUniform2f := glGetProcAddress('glUniform2f');
  831.   glUniform2fv := glGetProcAddress('glUniform2fv');
  832.   glUniform2i := glGetProcAddress('glUniform2i');
  833.   glUniform2iv := glGetProcAddress('glUniform2iv');
  834.   glUniform3f := glGetProcAddress('glUniform3f');
  835.   glUniform3fv := glGetProcAddress('glUniform3fv');
  836.   glUniform3i := glGetProcAddress('glUniform3i');
  837.   glUniform3iv := glGetProcAddress('glUniform3iv');
  838.   glUniform4f := glGetProcAddress('glUniform4f');
  839.   glUniform4fv := glGetProcAddress('glUniform4fv');
  840.   glUniform4i := glGetProcAddress('glUniform4i');
  841.   glUniform4iv := glGetProcAddress('glUniform4iv');
  842.   glUniformMatrix2fv := glGetProcAddress('glUniformMatrix2fv');
  843.   glUniformMatrix3fv := glGetProcAddress('glUniformMatrix3fv');
  844.   glUniformMatrix4fv := glGetProcAddress('glUniformMatrix4fv');
  845.   glUseProgram := glGetProcAddress('glUseProgram');
  846.   glValidateProgram := glGetProcAddress('glValidateProgram');
  847.   glVertexAttrib1f := glGetProcAddress('glVertexAttrib1f');
  848.   glVertexAttrib1fv := glGetProcAddress('glVertexAttrib1fv');
  849.   glVertexAttrib2f := glGetProcAddress('glVertexAttrib2f');
  850.   glVertexAttrib2fv := glGetProcAddress('glVertexAttrib2fv');
  851.   glVertexAttrib3f := glGetProcAddress('glVertexAttrib3f');
  852.   glVertexAttrib3fv := glGetProcAddress('glVertexAttrib3fv');
  853.   glVertexAttrib4f := glGetProcAddress('glVertexAttrib4f');
  854.   glVertexAttrib4fv := glGetProcAddress('glVertexAttrib4fv');
  855.   glVertexAttribPointer := glGetProcAddress('glVertexAttribPointer');
  856.  
  857.   glDiscardFramebuffer := glGetProcAddress('glDiscardFramebuffer');
  858.  
  859.   glRenderbufferStorageMultisample := glGetProcAddress('glRenderbufferStorageMultisample');
  860.   glResolveMultisampleFramebuffer := glGetProcAddress('glResolveMultisampleFramebuffer');
  861.  
  862.   glViewport := glGetProcAddress('glViewport');
  863.  
  864.   {$IFDEF LEGACY_GLES}
  865.   glAlphaFunc := glGetProcAddress('glAlphaFunc');
  866.   glEnableClientState := glGetProcAddress('glEnableClientState');
  867.   glDisableClientState := glGetProcAddress('glDisableClientState');
  868.   glVertexPointer := glGetProcAddress('glVertexPointer');
  869.   glTexCoordPointer := glGetProcAddress('glTexCoordPointer');
  870.   glColorPointer := glGetProcAddress('glColorPointer');
  871.   glColor4f := glGetProcAddress('glColor4f');
  872.  
  873.   glMatrixMode := glGetProcAddress('glMatrixMode');
  874.   glLoadMatrixf := glGetProcAddress('glLoadMatrixf');
  875.   {$ENDIF}
  876.  
  877. {$ENDIF}
  878. End;
  879.  
  880. {$IFNDEF STATIC_LINKING}
  881. Procedure FreeOpenGL;
  882. Begin
  883.   If OpenGLHandle<>0 Then
  884.     FreeLibrary(OpenGLHandle);
  885. End;
  886. {$ENDIF}
  887.  
  888. Function glExtensionSupported(Extension:TERRAString):Boolean;
  889. Begin
  890.   If (Extension='') Then
  891.   Begin
  892.     Result := False;
  893.     Exit;
  894.   End;
  895.  
  896.   If (ExtensionsList='') Then
  897.   Begin
  898.     ExtensionsList := PAnsiChar(glGetString(GL_EXTENSIONS));
  899.   End;
  900.  
  901.   Result := Pos(Extension,ExtensionsList)>0;
  902. End;
  903.  
  904. Procedure VFP_SetCW(cw : dword); nostackframe; assembler;
  905. Asm
  906.   fmxr fpscr,r0
  907. End;
  908.  
  909. Initialization
  910.   SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);
  911.   VFP_SetCW($1F00);
  912. Finalization
  913. {$IFNDEF STATIC_LINKING}
  914.   FreeOpenGL;
  915. {$ENDIF}
  916. End.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×