import { TNSWebGLRenderingContextBase , WebGLActiveInfo , WebGLBuffer , WebGLFramebuffer , WebGLProgram , WebGLRenderbuffer , WebGLShader , WebGLShaderPrecisionFormat , WebGLTexture , WebGLUniformLocation } from './canvas-plugin.common' ; import { fromFile , ImageSource } from '@nativescript/core/image-source' ; import { ANGLE_instanced_arrays , EXT_blend_minmax , EXT_color_buffer_float , EXT_color_buffer_half_float , EXT_shader_texture_lod , EXT_sRGB , EXT_texture_filter_anisotropic , OES_element_index_uint , OES_fbo_render_mipmap , OES_standard_derivatives , OES_texture_float , OES_texture_float_linear , OES_texture_half_float , OES_texture_half_float_linear , OES_vertex_array_object , WEBGL_color_buffer_float , WEBGL_compressed_texture_etc , WEBGL_compressed_texture_etc1 , WEBGL_compressed_texture_pvrtc , WEBGL_depth_texture , WEBGL_draw_buffers , WEBGL_lose_context } from './TNSWebGLExtensions' ; import { TNSImageAsset } from './TNSImageAsset' ; import { TNSCanvas } from './TNSCanvas' ; declare const Canvas_EXT_blend_minmax , Canvas_EXT_color_buffer_float , Canvas_EXT_color_buffer_half_float , Canvas_EXT_sRGB , Canvas_EXT_shader_texture_lod , Canvas_EXT_texture_filter_anisotropic , Canvas_OES_element_index_uint , Canvas_OES_fbo_render_mipmap , Canvas_OES_standard_derivatives , Canvas_OES_texture_float , Canvas_OES_texture_float_linear , Canvas_OES_texture_half_float , Canvas_OES_texture_half_float_linear , Canvas_OES_vertex_array_object , Canvas_WEBGL_color_buffer_float , Canvas_WEBGL_compressed_texture_etc , Canvas_WEBGL_compressed_texture_etc1 , Canvas_WEBGL_compressed_texture_pvrtc , Canvas_WEBGL_depth_texture , Canvas_WEBGL_lose_context , Canvas_ANGLE_instanced_arrays , Canvas_WEBGL_draw_buffers ; export * from './TNSWebGLExtensions' ; export class TNSWebGLRenderingContext extends TNSWebGLRenderingContextBase { public static isDebug = false ; public static filter : 'both' | 'error' | 'args' = 'both' ; private context ; constructor ( context ) { super ( context ) ; this . context = context ; } get native ( ) { return this . context ; } get drawingBufferHeight ( ) { return this . context . drawingBufferHeight ; } get drawingBufferWidth ( ) { return this . context . drawingBufferWidth ; } activeTexture ( texture ) { this . _glCheckError ( 'activeTexture' ) ; this . _checkArgs ( 'activeTexture' , arguments ) ; this . context . activeTextureWithTexture ( texture ) ; } attachShader ( program , shader ) { const value = program ? program . native : 0 ; const value2 = shader ? shader . native : 0 ; this . _glCheckError ( 'attachShader' ) ; this . _checkArgs ( 'attachShader' , arguments ) ; this . context . attachShaderWithProgramShader ( value , value2 ) ; } bindAttribLocation ( program , index , name ) { this . _glCheckError ( 'bindAttribLocation' ) ; this . _checkArgs ( 'bindAttribLocation' , arguments ) ; const value = program ? program . native : 0 ; this . context . bindAttribLocationWithProgramIndexName ( value , index , name ) ; } bindBuffer ( target , buffer ) { this . _glCheckError ( 'bindBuffer' ) ; this . _checkArgs ( 'bindBuffer' , arguments ) ; const value = buffer ? buffer . native : 0 ; this . context . bindBufferWithTargetBuffer ( target , value ) ; } bindFramebuffer ( target , framebuffer ) { this . _glCheckError ( 'bindFramebuffer' ) ; this . _checkArgs ( 'bindFramebuffer' , arguments ) ; const value = framebuffer ? framebuffer . native : 0 ; this . context . bindFramebufferWithTargetFramebuffer ( target , value ) ; } bindRenderbuffer ( target , renderbuffer ) { this . _glCheckError ( 'bindRenderbuffer' ) ; this . _checkArgs ( 'bindRenderbuffer' , arguments ) ; const value = renderbuffer ? renderbuffer . native : 0 ; this . context . bindRenderbufferWithTargetRenderbuffer ( target , value ) ; } bindTexture ( target , texture ) { this . _glCheckError ( 'bindTexture' ) ; this . _checkArgs ( 'bindTexture' , arguments ) ; const value = texture ? texture . native : 0 ; this . context . bindTextureWithTargetTexture ( target , value ) ; } blendColor ( red , green , blue , alpha ) { this . _glCheckError ( 'blendColor' ) ; this . _checkArgs ( 'blendColor' , arguments ) ; this . context . blendColorWithRedGreenBlueAlpha ( red , green , blue , alpha ) ; } blendEquationSeparate ( modeRGB , modeAlpha ) { this . _glCheckError ( 'blendEquationSeparate' ) ; this . _checkArgs ( 'blendEquationSeparate' , arguments ) ; this . context . blendEquationSeparateWithModeRGBModeAlpha ( modeRGB , modeAlpha ) ; } blendEquation ( mode ) { this . _glCheckError ( 'blendEquation' ) ; this . _checkArgs ( 'blendEquation' , arguments ) ; this . context . blendEquationWithMode ( mode ) ; } blendFuncSeparate ( srcRGB = this . ONE , dstRGB = this . ZERO , srcAlpha = this . ONE , dstAlpha = this . ZERO ) { this . _glCheckError ( 'blendFuncSeparate' ) ; this . _checkArgs ( 'blendFuncSeparate' , arguments ) ; this . context . blendFuncSeparateWithSrcRGBDstRGBSrcAlphaDstAlpha ( srcRGB , dstRGB , srcAlpha , dstAlpha ) ; } blendFunc ( sfactor = this . ONE , dfactor = this . ZERO ) { this . _glCheckError ( 'blendFunc' ) ; this . _checkArgs ( 'blendFunc' , arguments ) ; this . context . blendFuncWithSfactorDfactor ( sfactor , dfactor ) ; } bufferData ( target , size , usage ) ; bufferData ( target , srcData , usage ) ; bufferData ( target , srcData , usage ) { this . _glCheckError ( 'bufferData' ) ; this . _checkArgs ( 'bufferData' , arguments ) ; if ( typeof srcData === 'number' ) { this . context . bufferDataWithTargetSizeUsage ( target , srcData , usage ) ; } else if ( srcData instanceof ArrayBuffer ) { this . context . bufferDataWithTargetByteArrayUsage ( target , new Uint8Array ( srcData . slice ( 0 ) as any ) as any , usage ) ; } else if ( srcData && srcData . buffer instanceof ArrayBuffer ) { if ( srcData instanceof Float32Array || srcData instanceof Float64Array ) { this . context . bufferDataWithTargetFloatArrayUsage ( target , srcData as any , usage ) ; } else if ( srcData instanceof Uint32Array || srcData instanceof Int32Array ) { this . context . bufferDataWithTargetIntArrayUsage ( target , srcData as any , usage ) ; } else if ( srcData instanceof Uint16Array || srcData instanceof Int16Array ) { this . context . bufferDataWithTargetShortArrayUsage ( target , srcData as any , usage ) ; } else if ( srcData instanceof Uint8Array ) { this . context . bufferDataWithTargetByteArrayUsage ( target , srcData as any , usage ) ; } } else { this . context . bufferDataWithTargetSrcDataUsage ( target , srcData , usage ) ; } } bufferSubData ( target , offset , srcData ) { this . _glCheckError ( 'bufferSubData' ) ; this . _checkArgs ( 'bufferSubData' , arguments ) ; if ( srcData instanceof ArrayBuffer ) { this . context . bufferSubDataWithTargetOffsetByteArray ( target , offset , new Uint8Array ( srcData . slice ( 0 ) as any ) as any ) ; } else if ( srcData && srcData . buffer instanceof ArrayBuffer ) { if ( srcData instanceof Float32Array || srcData instanceof Float64Array ) { this . context . bufferSubDataWithTargetOffsetFloatArray ( target , offset , srcData as any ) ; } else if ( srcData instanceof Uint32Array || srcData instanceof Int32Array ) { this . context . bufferSubDataWithTargetOffsetIntArray ( target , offset , srcData as any ) ; } else if ( srcData instanceof Uint16Array || srcData instanceof Int16Array ) { this . context . bufferSubDataWithTargetOffsetShortArray ( target , offset , srcData as any ) ; } else if ( srcData instanceof Uint8Array ) { this . context . bufferSubDataWithTargetOffsetByteArray ( target , offset , srcData as any ) ; } } } checkFramebufferStatus ( target ) { this . _glCheckError ( 'checkFramebufferStatus' ) ; this . _checkArgs ( 'checkFramebufferStatus' , arguments ) ; return this . context . checkFramebufferStatusWithTarget ( target ) ; } clearColor ( red , green , blue , alpha ) { this . _glCheckError ( 'clearColor' ) ; this . _checkArgs ( 'clearColor' , arguments ) ; this . context . clearColorWithRedGreenBlueAlpha ( red , green , blue , alpha ) ; } clearDepth ( depth ) { this . _glCheckError ( 'clearDepth' ) ; this . _checkArgs ( 'clearDepth' , arguments ) ; this . context . clearDepthWithDepth ( depth ) ; } clearStencil ( stencil ) { this . _glCheckError ( 'clearStencil' ) ; this . _checkArgs ( 'clearStencil' , arguments ) ; this . context . clearStencilWithStencil ( stencil ) ; } clear ( mask ) { this . _glCheckError ( 'clear' ) ; this . _checkArgs ( 'clear' , arguments ) ; this . context . clearWithMask ( mask ) ; this . _glCheckError ( 'after clear' ) ; } colorMask ( red , green , blue , alpha ) { this . _glCheckError ( 'colorMask' ) ; this . _checkArgs ( 'colorMask' , arguments ) ; this . context . colorMaskWithRedGreenBlueAlpha ( red , green , blue , alpha ) ; } commit ( ) { this . context . commit ( ) ; } compileShader ( shader ) { this . _glCheckError ( 'compileShader' ) ; this . _checkArgs ( 'compileShader' , arguments ) ; const value = shader ? shader . native : 0 ; this . context . compileShaderWithShader ( value ) ; } compressedTexImage2D ( target , level , internalformat , width , height , border , pixels ? ) { this . _glCheckError ( 'compressedTexImage2D' ) ; this . _checkArgs ( 'compressedTexImage2D' , arguments ) ; if ( pixels && pixels . buffer instanceof ArrayBuffer ) { if ( pixels instanceof Float32Array || pixels instanceof Float64Array ) { this . context . compressedTexImage2DWithTargetLevelInternalformatWidthHeightBorderFloatArray ( target , level , internalformat , width , height , border , pixels as any ) ; } else if ( pixels instanceof Uint32Array || pixels instanceof Int32Array ) { this . context . compressedTexImage2DWithTargetLevelInternalformatWidthHeightBorderIntArray ( target , level , internalformat , width , height , border , pixels as any ) ; } else if ( pixels instanceof Uint16Array || pixels instanceof Int16Array ) { this . context . compressedTexImage2DWithTargetLevelInternalformatWidthHeightBorderShortArray ( target , level , internalformat , width , height , border , pixels as any ) ; } else if ( pixels instanceof Uint8Array ) { this . context . compressedTexImage2DWithTargetLevelInternalformatWidthHeightBorderByteArray ( target , level , internalformat , width , height , border , pixels as any ) ; } } else if ( pixels instanceof ArrayBuffer ) { this . context . compressedTexImage2DWithTargetLevelInternalformatWidthHeightBorderByteArray ( target , level , internalformat , width , height , border , new Uint8Array ( pixels . slice ( 0 ) as any ) as any ) ; } else { this . context . compressedTexImage2DWithTargetLevelInternalformatWidthHeightBorderPixels ( target , level , internalformat , width , height , border , pixels as any ) ; } } compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , pixels ) { this . _glCheckError ( 'compressedTexSubImage2D' ) ; this . _checkArgs ( 'compressedTexSubImage2D' , arguments ) ; if ( pixels && pixels . buffer instanceof ArrayBuffer ) { if ( pixels instanceof Float32Array || pixels instanceof Float64Array ) { this . context . compressedTexSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatFloatArray ( target , level , xoffset , yoffset , width , height , format , pixels as any ) ; } else if ( pixels instanceof Uint32Array || pixels instanceof Int32Array ) { this . context . compressedTexSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatIntArray ( target , level , xoffset , yoffset , width , height , format , pixels as any ) ; } else if ( pixels instanceof Uint16Array || pixels instanceof Int16Array ) { this . context . compressedTexSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatShortArray ( target , level , xoffset , yoffset , width , height , format , pixels as any ) ; } else if ( pixels instanceof Uint8Array ) { this . context . compressedTexSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatByteArray ( target , level , xoffset , yoffset , width , height , format , pixels as any ) ; } } else if ( pixels instanceof ArrayBuffer ) { this . context . compressedTexSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatByteArray ( target , level , xoffset , yoffset , width , height , format , new Uint8Array ( pixels . slice ( 0 ) as any ) as any ) ; } } copyTexImage2D ( target , level , internalformat , x , y , width , height , border ) { this . _glCheckError ( 'copyTexImage2D' ) ; this . _checkArgs ( 'copyTexImage2D' , arguments ) ; this . context . copyTexImage2DWithTargetLevelInternalformatXYWidthHeightBorder ( target , level , internalformat , x , y , width , height , border ) ; } copyTexSubImage2D ( target , level , xoffset , yoffset , x , y , width , height ) { this . _glCheckError ( 'copyTexSubImage2D' ) ; this . _checkArgs ( 'copyTexSubImage2D' , arguments ) ; this . context . copyTexSubImage2DWithTargetLevelXoffsetYoffsetXYWidthHeight ( target , level , xoffset , yoffset , x , y , width , height ) ; } createBuffer ( ) { this . _glCheckError ( 'createBuffer' ) ; this . _checkArgs ( 'createBuffer' , arguments ) ; const id = this . context . createBuffer ( ) ; return new WebGLBuffer ( id ) ; } createFramebuffer ( ) { this . _glCheckError ( 'createFramebuffer' ) ; this . _checkArgs ( 'createFramebuffer' , arguments ) ; return new WebGLFramebuffer ( this . context . createFramebuffer ( ) ) ; } createProgram ( ) { this . _glCheckError ( 'createProgram' ) ; this . _checkArgs ( 'createProgram' , arguments ) ; return new WebGLProgram ( this . context . createProgram ( ) ) ; } createRenderbuffer ( ) { this . _glCheckError ( 'bindBuffer' ) ; this . _checkArgs ( 'bindBuffer' , arguments ) ; return new WebGLRenderbuffer ( this . context . createRenderbuffer ( ) ) ; } createShader ( type ) { this . _glCheckError ( 'createRenderbuffer' ) ; this . _checkArgs ( 'createRenderbuffer' , arguments ) ; return new WebGLShader ( this . context . createShaderWithType ( type ) ) ; } createTexture ( ) { this . _glCheckError ( 'createTexture' ) ; this . _checkArgs ( 'createTexture' , arguments ) ; const id = this . context . createTexture ( ) ; return new WebGLTexture ( id ) ; } cullFace ( mode ) { this . _glCheckError ( 'cullFace' ) ; this . _checkArgs ( 'cullFace' , arguments ) ; this . context . cullFaceWithMode ( mode ) ; } deleteBuffer ( buffer ) { this . _glCheckError ( 'deleteBuffer' ) ; this . _checkArgs ( 'deleteBuffer' , arguments ) ; const value = buffer ? buffer . native : 0 ; this . context . deleteBufferWithBuffer ( value ) ; } deleteFramebuffer ( frameBuffer ) { this . _glCheckError ( 'deleteFramebuffer' ) ; this . _checkArgs ( 'deleteFramebuffer' , arguments ) ; const value = frameBuffer ? frameBuffer . native : 0 ; this . context . deleteFramebufferWithFrameBuffer ( value ) ; } deleteProgram ( program ) { this . _glCheckError ( 'deleteProgram' ) ; this . _checkArgs ( 'deleteProgram' , arguments ) ; const value = program ? program . native : 0 ; this . context . deleteProgramWithProgram ( value ) ; } deleteRenderbuffer ( renderBuffer ) { this . _glCheckError ( 'deleteRenderbuffer' ) ; this . _checkArgs ( 'deleteRenderbuffer' , arguments ) ; const value = renderBuffer ? renderBuffer . native : 0 ; this . context . deleteRenderbufferWithRenderbuffer ( value ) ; } deleteShader ( shader ) { this . _glCheckError ( 'deleteShader' ) ; this . _checkArgs ( 'deleteShader' , arguments ) ; const value = shader ? shader . native : 0 ; this . context . deleteShaderWithShader ( value ) ; } deleteTexture ( texture ) { this . _glCheckError ( 'deleteTexture' ) ; this . _checkArgs ( 'deleteTexture' , arguments ) ; const value = texture ? texture . native : 0 ; this . context . deleteTextureWithTexture ( value ) ; } depthFunc ( func ) { this . _glCheckError ( 'depthFunc' ) ; this . _checkArgs ( 'depthFunc' , arguments ) ; this . context . depthFuncWithFn ( func ) ; } depthMask ( flag ) { this . _glCheckError ( 'depthMask' ) ; this . _checkArgs ( 'depthMask' , arguments ) ; this . context . depthMaskWithFlag ( flag ) ; } depthRange ( zNear , zFar ) { this . _glCheckError ( 'depthRange' ) ; this . _checkArgs ( 'depthRange' , arguments ) ; this . context . depthRangeWithZNearZFar ( zNear , zFar ) ; } detachShader ( program , shader ) { this . _glCheckError ( 'detachShader' ) ; this . _checkArgs ( 'detachShader' , arguments ) ; const value = program ? program . native : 0 ; const value2 = shader ? shader . native : 0 ; this . context . detachShaderWithProgramShader ( value , value2 ) ; } disableVertexAttribArray ( index ) { this . _checkArgs ( 'disableVertexAttribArray' , arguments ) ; this . _glCheckError ( 'disableVertexAttribArray' ) ; this . context . disableVertexAttribArrayWithIndex ( index ) ; } disable ( cap ) { this . _glCheckError ( 'disable' ) ; this . _checkArgs ( 'disable' , arguments ) ; this . context . disableWithCap ( cap ) ; } drawArrays ( mode , first , count ) { this . _glCheckError ( 'drawArrays' ) ; this . _checkArgs ( 'drawArrays' , arguments ) ; this . context . drawArraysWithModeFirstCount ( mode , first , count ) ; } drawElements ( mode , count , type , offset ) { this . _glCheckError ( 'drawElements' ) ; this . _checkArgs ( 'drawElements' , arguments ) ; this . context . drawElementsWithModeCountTypeOffset ( mode , count , type , offset ) ; } enableVertexAttribArray ( index ) { this . _glCheckError ( 'enableVertexAttribArray' ) ; this . _checkArgs ( 'enableVertexAttribArray' , arguments ) ; this . context . enableVertexAttribArrayWithIndex ( index ) ; } enable ( cap ) { this . _glCheckError ( 'enable' ) ; this . _checkArgs ( 'enable' , arguments ) ; this . context . enableWithCap ( cap ) ; } finish ( ) { this . _glCheckError ( 'finish' ) ; this . _checkArgs ( 'finish' , arguments ) ; this . context . finish ( ) ; } flush ( ) { this . _glCheckError ( 'flush' ) ; this . _checkArgs ( 'flush' , arguments ) ; this . context . flush ( ) ; } framebufferRenderbuffer ( target , attachment , renderbuffertarget , renderbuffer ) { this . _glCheckError ( 'framebufferRenderbuffer' ) ; this . _checkArgs ( 'framebufferRenderbuffer' , arguments ) ; const value = renderbuffer ? renderbuffer . native : 0 ; this . context . framebufferRenderbufferWithTargetAttachmentRenderbuffertargetRenderbuffer ( target , attachment , renderbuffertarget , value ) ; } framebufferTexture2D ( target , attachment , textarget , texture , level ) { this . _glCheckError ( 'framebufferTexture2D' ) ; this . _checkArgs ( 'framebufferTexture2D' , arguments ) ; const value = texture ? texture . native : 0 ; this . context . framebufferTexture2DWithTargetAttachmentTextargetTextureLevel ( target , attachment , textarget , value , level ) ; } frontFace ( mode ) { this . _glCheckError ( 'frontFace' ) ; this . _checkArgs ( 'frontFace' , arguments ) ; this . context . frontFaceWithMode ( mode ) ; } generateMipmap ( target ) { this . _glCheckError ( 'generateMipmap' ) ; this . _checkArgs ( 'generateMipmap' , arguments ) ; this . context . generateMipmapWithTarget ( target ) ; } getActiveAttrib ( program , index ) { this . _glCheckError ( 'getActiveAttrib' ) ; this . _checkArgs ( 'getActiveAttrib' , arguments ) ; const value = program ? program . native : 0 ; const attrib = this . context . getActiveAttribWithProgramIndex ( value , index ) ; return new WebGLActiveInfo ( attrib . name , attrib . size , attrib . type ) ; } getActiveUniform ( program , index ) { this . _glCheckError ( 'getActiveUniform' ) ; this . _checkArgs ( 'getActiveUniform' , arguments ) ; const value = program ? program . native : 0 ; const uniform = this . context . getActiveUniformWithProgramIndex ( value , index ) ; return new WebGLActiveInfo ( uniform . name , uniform . size , uniform . type ) ; } getAttachedShaders ( program ) { this . _glCheckError ( 'getAttachedShaders' ) ; this . _checkArgs ( 'getAttachedShaders' , arguments ) ; const value = program ? program . native : 0 ; const shaders = this . context . getAttachedShadersWithProgram ( value ) ; const length = shaders . count ; const attachedShaders = [ ] ; for ( let i = 0 ; i < length ; i ++ ) { attachedShaders . push ( new WebGLShader ( shaders . objectAtIndex ( i ) ) ) ; } return attachedShaders ; } getAttribLocation ( program , name ) { this . _glCheckError ( 'getAttribLocation' ) ; this . _checkArgs ( 'getAttribLocation' , arguments ) ; const value = program ? program . native : 0 ; return this . context . getAttribLocationWithProgramName ( value , name ) ; } getBufferParameter ( target , pname ) { this . _glCheckError ( 'getBufferParameter' ) ; this . _checkArgs ( 'getBufferParameter' , arguments ) ; return this . context . getBufferParameterWithTargetPname ( target , pname ) ; } getContextAttributes ( ) { this . _glCheckError ( 'getContextAttributes' ) ; this . _checkArgs ( 'getContextAttributes' , arguments ) ; const attributes = this . context . getContextAttributes ( ) ; if ( ! attributes ) { return null ; } const keys = attributes . allKeys ; const length = keys . count ; const contextAttributes = { } ; for ( let i = 0 ; i < length ; i ++ ) { const key = keys . objectAtIndex ( i ) ; contextAttributes [ key ] = attributes . objectForKey ( key ) ; } contextAttributes [ 'stencil' ] = true ; return contextAttributes ; } getError ( ) { return this . context . getError ( ) ; } getExtension ( name ) { this . _checkArgs ( 'activattachShadereTexture' , arguments ) ; this . _glCheckError ( 'activattachShadereTexture' ) ; const ext = this . context . getExtensionWithName ( name ) ; if ( ext instanceof Canvas_ANGLE_instanced_arrays ) { return new ANGLE_instanced_arrays ( ext ) ; } else if ( ext instanceof Canvas_EXT_blend_minmax ) { return new EXT_blend_minmax ( ext ) ; } else if ( ext instanceof Canvas_EXT_color_buffer_float ) { return new EXT_color_buffer_float ( ext ) ; } else if ( ext instanceof Canvas_EXT_color_buffer_half_float ) { return new EXT_color_buffer_half_float ( ext ) ; } else if ( ext instanceof Canvas_EXT_sRGB ) { return new EXT_sRGB ( ext ) ; } else if ( ext instanceof Canvas_EXT_shader_texture_lod ) { return new EXT_shader_texture_lod ( ext ) ; } else if ( ext instanceof Canvas_EXT_texture_filter_anisotropic ) { return new EXT_texture_filter_anisotropic ( ext ) ; } else if ( ext instanceof Canvas_OES_element_index_uint ) { return new OES_element_index_uint ( ext ) ; } else if ( ext instanceof Canvas_OES_fbo_render_mipmap ) { return new OES_fbo_render_mipmap ( ext ) ; } else if ( ext instanceof Canvas_OES_standard_derivatives ) { return new OES_standard_derivatives ( ext ) ; } else if ( ext instanceof Canvas_OES_texture_float ) { return new OES_texture_float ( ext ) ; } else if ( ext instanceof Canvas_OES_texture_float_linear ) { return new OES_texture_float_linear ( ext ) ; } else if ( ext instanceof Canvas_OES_texture_half_float ) { return new OES_texture_half_float ( ext ) ; } else if ( ext instanceof Canvas_OES_texture_half_float_linear ) { return new OES_texture_half_float_linear ( ext ) ; } else if ( ext instanceof Canvas_OES_vertex_array_object ) { return new OES_vertex_array_object ( ext ) ; } else if ( ext instanceof Canvas_WEBGL_color_buffer_float ) { return new WEBGL_color_buffer_float ( ext ) ; } else if ( ext instanceof Canvas_WEBGL_compressed_texture_etc ) { return new WEBGL_compressed_texture_etc ( ext ) ; } else if ( ext instanceof Canvas_WEBGL_compressed_texture_etc1 ) { return new WEBGL_compressed_texture_etc1 ( ext ) ; } else if ( ext instanceof Canvas_WEBGL_compressed_texture_pvrtc ) { return new WEBGL_compressed_texture_pvrtc ( ext ) ; } else if ( ext instanceof Canvas_WEBGL_depth_texture ) { return new WEBGL_depth_texture ( ext ) ; } else if ( ext instanceof Canvas_WEBGL_lose_context ) { return new WEBGL_lose_context ( ext ) ; } else if ( ext instanceof Canvas_WEBGL_draw_buffers ) { return new WEBGL_draw_buffers ( ext ) ; } return null ; } getFramebufferAttachmentParameter ( target , attachment , pname ) { this . _glCheckError ( 'getFramebufferAttachmentParameter' ) ; this . _checkArgs ( 'getFramebufferAttachmentParameter' , arguments ) ; const param = this . context . getFramebufferAttachmentParameterWithTargetAttachmentPname ( target , attachment , pname ) ; if ( param . isRenderbuffer ) { return new WebGLRenderbuffer ( param . value ) ; } else if ( param . isTexture ) { return new WebGLTexture ( param . value ) ; } return param . value ; } getParameter ( pname ) { this . _glCheckError ( 'getParameter' ) ; this . _checkArgs ( 'getParameter' , arguments ) ; const value = this . context . getParameterWithPname ( pname ) ; switch ( pname ) { case this . COLOR_WRITEMASK : case this . COLOR_CLEAR_VALUE : case this . BLEND_COLOR : case this . ALIASED_LINE_WIDTH_RANGE : case this . ALIASED_POINT_SIZE_RANGE : case this . DEPTH_RANGE : if ( value instanceof NSArray ) { const count = value . count ; const array = [ ] ; for ( let i = 0 ; i < count ; i ++ ) { array . push ( value . objectAtIndex ( i ) ) ; } return array ; } return value ; case this . ARRAY_BUFFER_BINDING : case this . ELEMENT_ARRAY_BUFFER_BINDING : return new WebGLBuffer ( value ) ; case this . CURRENT_PROGRAM : return new WebGLProgram ( value ) ; case this . COMPRESSED_TEXTURE_FORMATS : const size = value . count ; const result = [ ] ; for ( let i = 0 ; i < size ; i ++ ) { result . push ( value . objectAtIndex ( i ) ) ; } return new Uint32Array ( result ) ; case this . RENDERBUFFER_BINDING : return new WebGLRenderbuffer ( value ) ; case this . FRAMEBUFFER_BINDING : if ( value ) { return new WebGLFramebuffer ( value ) ; } return null ; case this . VIEWPORT : case this . SCISSOR_BOX : case this . MAX_VIEWPORT_DIMS : const len = value . count ; const arr = [ ] ; for ( let i = 0 ; i < len ; i ++ ) { arr . push ( value . objectAtIndex ( i ) ) ; } return new Int32Array ( arr ) ; case this . TEXTURE_BINDING_CUBE_MAP : case this . TEXTURE_BINDING_2D : if ( value ) { return new WebGLTexture ( value ) ; } return null ; case this . VERSION : let isMetal = false ; if ( this . _canvas && this . _canvas . useMetal ) { isMetal = true ; } if ( this . _type === 'webgl2' ) { return `WebGL 2.0 (${ isMetal ? 'Metal' : 'OpenGL ES 3.0' } NativeScript)` ; } else { return `WebGL 1.0 (${ isMetal ? 'Metal' : 'OpenGL ES 3.0' } NativeScript)` ; } default : return value ; } } getProgramInfoLog ( program ) { this . _glCheckError ( 'getProgramInfoLog' ) ; this . _checkArgs ( 'getProgramInfoLog' , arguments ) ; const value = program ? program . native : 0 ; return this . context . getProgramInfoLogWithProgram ( value ) ; } getProgramParameter ( program , pname ) { this . _glCheckError ( 'getProgramParameter' ) ; this . _checkArgs ( 'getProgramParameter' , arguments ) ; const value = program ? program . native : 0 ; return this . context . getProgramParameterWithProgramPname ( value , pname ) ; } getRenderbufferParameter ( target , pname ) { this . _glCheckError ( 'getRenderbufferParameter' ) ; this . _checkArgs ( 'getRenderbufferParameter' , arguments ) ; return this . context . getBufferParameterWithTargetPname ( target , pname ) ; } getShaderInfoLog ( shader ) { this . _glCheckError ( 'getShaderInfoLog' ) ; this . _checkArgs ( 'getShaderInfoLog' , arguments ) ; const value = shader ? shader . native : 0 ; return this . context . getShaderInfoLogWithShader ( value ) ; } getShaderParameter ( shader , pname ) { this . _glCheckError ( 'getShaderParameter' ) ; this . _checkArgs ( 'getShaderParameter' , arguments ) ; const value = shader ? shader . native : 0 ; return this . context . getShaderParameterWithShaderPname ( value , pname ) ; } getShaderPrecisionFormat ( shaderType , precisionType ) { this . _glCheckError ( 'getShaderPrecisionFormat' ) ; this . _checkArgs ( 'getShaderPrecisionFormat' , arguments ) ; const precision = this . context . getShaderPrecisionFormatWithShaderTypePrecisionType ( shaderType , precisionType ) ; return new WebGLShaderPrecisionFormat ( precision . rangeMin , precision . rangeMax , precision . precision ) ; } getShaderSource ( shader ) { this . _glCheckError ( 'getShaderSource' ) ; this . _checkArgs ( 'getShaderSource' , arguments ) ; const value = shader ? shader . native : 0 ; return this . context . getShaderSourceWithShader ( value ) ; } getSupportedExtensions ( ) { this . _glCheckError ( 'getSupportedExtensions' ) ; this . _checkArgs ( 'getSupportedExtensions' , arguments ) ; const extensions = this . context . getSupportedExtensions ( ) ; const array = [ ] ; const length = extensions . count ; for ( let i = 0 ; i < length ; i ++ ) { array . push ( extensions . objectAtIndex ( i ) ) ; } return array ; } getTexParameter ( target , pname ) { this . _glCheckError ( 'getTexParameter' ) ; this . _checkArgs ( 'getTexParameter' , arguments ) ; return this . context . getTexParameterWithTargetPname ( target , pname ) ; } getUniformLocation ( program , name ) { this . _glCheckError ( 'getUniformLocation' ) ; this . _checkArgs ( 'getUniformLocation' , arguments ) ; const value = program ? program . native : 0 ; const id = this . context . getUniformLocationWithProgramName ( value , name ) ; if ( id === - 1 ) { return null ; } return new WebGLUniformLocation ( id ) ; } getUniform ( program , location ) { this . _glCheckError ( 'getUniform' ) ; this . _checkArgs ( 'getUniform' , arguments ) ; const value = program ? program . native : 0 ; const value2 = location ? location . native : 0 ; const result = this . context . getUniformWithProgramLocation ( value , value2 ) ; if ( result instanceof NSArray ) { const array = [ ] ; const length = result . count ; for ( let i = 0 ; i < length ; i ++ ) { array . push ( result . objectAtIndex ( i ) ) ; } return array ; } return result ; } getVertexAttribOffset ( index , pname ) { this . _glCheckError ( 'getVertexAttribOffset' ) ; this . _checkArgs ( 'getVertexAttribOffset' , arguments ) ; return this . context . getVertexAttribOffsetWithIndexPname ( index , pname ) ; } getVertexAttrib ( index , pname ) { this . _glCheckError ( 'getVertexAttrib' ) ; this . _checkArgs ( 'getVertexAttrib' , arguments ) ; const value = this . context . getVertexAttribWithIndexPname ( index , pname ) ; if ( pname === this . CURRENT_VERTEX_ATTRIB && value instanceof NSArray ) { const count = value . count ; const array = [ ] ; for ( let i = 0 ; i < count ; i ++ ) { array . push ( value . objectAtIndex ( i ) ) ; } return array ; } return value ; } hint ( target , mode ) { this . _glCheckError ( 'hint' ) ; this . _checkArgs ( 'hint' , arguments ) ; this . context . hintWithTargetMode ( target , mode ) ; } isBuffer ( buffer ) { this . _glCheckError ( 'isBuffer' ) ; this . _checkArgs ( 'isBuffer' , arguments ) ; const value = buffer ? buffer . native : 0 ; return this . context . isBufferWithBuffer ( value ) ; } isContextLost ( ) { this . _glCheckError ( 'isContextLost' ) ; this . _checkArgs ( 'isContextLost' , arguments ) ; return this . context . isContextLost ( ) ; } isEnabled ( cap ) { this . _glCheckError ( 'isEnabled' ) ; this . _checkArgs ( 'isEnabled' , arguments ) ; return this . context . isEnabledWithCap ( cap ) ; } isFramebuffer ( framebuffer ) { this . _glCheckError ( 'isFramebuffer' ) ; this . _checkArgs ( 'isFramebuffer' , arguments ) ; const value = framebuffer ? framebuffer . native : 0 ; return this . context . isFramebufferWithFramebuffer ( value ) ; } isProgram ( program ) { this . _glCheckError ( 'isProgram' ) ; this . _checkArgs ( 'isProgram' , arguments ) ; const value = program ? program . native : 0 ; return this . context . isProgramWithProgram ( value ) ; } isRenderbuffer ( renderbuffer ) { this . _glCheckError ( 'isRenderbuffer' ) ; this . _checkArgs ( 'isRenderbuffer' , arguments ) ; const value = renderbuffer ? renderbuffer . native : 0 ; return this . context . isRenderbufferWithRenderbuffer ( value ) ; } isShader ( shader ) { this . _glCheckError ( 'isShader' ) ; this . _checkArgs ( 'isShader' , arguments ) ; const value = shader ? shader . native : 0 ; return this . context . isShaderWithShader ( value ) ; } isTexture ( texture ) { this . _glCheckError ( 'isTexture' ) ; this . _checkArgs ( 'isTexture' , arguments ) ; const value = texture ? texture . native : 0 ; return this . context . isTextureWithTexture ( value ) ; } lineWidth ( width ) { this . _glCheckError ( 'lineWidth' ) ; this . _checkArgs ( 'lineWidth' , arguments ) ; this . context . lineWidthWithWidth ( width ) ; } linkProgram ( program ) { this . _glCheckError ( 'linkProgram' ) ; this . _checkArgs ( 'linkProgram' , arguments ) ; const value = program ? program . native : 0 ; this . context . linkProgramWithProgram ( value ) ; } pixelStorei ( pname , param ) { this . _glCheckError ( 'pixelStorei' ) ; this . _checkArgs ( 'pixelStorei' , arguments ) ; if ( pname === this . UNPACK_FLIP_Y_WEBGL || pname === this . UNPACK_PREMULTIPLY_ALPHA_WEBGL ) { this . context . pixelStoreiWithPnameParam ( pname , ! ! param ) ; } else if ( pname === this . PACK_ALIGNMENT || pname === this . UNPACK_ALIGNMENT || pname === this . UNPACK_COLORSPACE_CONVERSION_WEBGL ) { if ( pname === this . UNPACK_COLORSPACE_CONVERSION_WEBGL ) { param = 0x9244 ; } else if ( pname === this . PACK_ALIGNMENT || pname === this . UNPACK_ALIGNMENT ) { param = 4 ; } this . context . pixelStoreiWithPnameParam ( pname , Number ( param ) ) ; } else { this . context . pixelStoreiWithPnameParam ( pname , param ) ; } } polygonOffset ( factor , units ) { this . _glCheckError ( 'polygonOffset' ) ; this . _checkArgs ( 'polygonOffset' , arguments ) ; this . context . polygonOffsetWithFactorUnits ( factor , units ) ; } readPixels ( x , y , width , height , format , type , pixels ) { this . _glCheckError ( 'readPixels' ) ; this . _checkArgs ( 'readPixels' , arguments ) ; if ( pixels && pixels . buffer instanceof ArrayBuffer ) { if ( pixels instanceof Float32Array || pixels instanceof Float64Array ) { this . context . readPixelsWithXYWidthHeightFormatTypeFloatArray ( x , y , width , height , format , type , pixels as any ) ; } else if ( pixels instanceof Uint16Array || pixels instanceof Int16Array ) { this . context . readPixelsWithXYWidthHeightFormatTypeShortArray ( x , y , width , height , format , type , pixels as any ) ; } else if ( pixels instanceof Uint8Array ) { this . context . readPixelsWithXYWidthHeightFormatTypeByteArray ( x , y , width , height , format , type , pixels as any ) ; } } else if ( pixels instanceof ArrayBuffer ) { this . context . readPixelsWithXYWidthHeightFormatTypeByteArray ( x , y , width , height , format , type , new Uint8Array ( pixels . slice ( 0 ) as any ) as any ) ; } } renderbufferStorage ( target , internalFormat , width , height ) { this . _glCheckError ( 'renderbufferStorage' ) ; this . _checkArgs ( 'renderbufferStorage' , arguments ) ; if ( internalFormat === this . DEPTH_STENCIL ) { internalFormat = 0x88F0 ; } this . context . renderbufferStorageWithTargetInternalFormatWidthHeight ( target , internalFormat , width , height ) ; } sampleCoverage ( value , invert ) { this . _glCheckError ( 'sampleCoverage' ) ; this . _checkArgs ( 'sampleCoverage' , arguments ) ; this . context . sampleCoverageWithValueInvert ( value , invert ) ; } scissor ( x , y , width , height ) { this . _glCheckError ( 'scissor' ) ; this . _checkArgs ( 'scissor' , arguments ) ; this . context . scissorWithXYWidthHeight ( x , y , width , height ) ; } shaderSource ( shader , source ) { this . _glCheckError ( 'shaderSource' ) ; this . _checkArgs ( 'shaderSource' , arguments ) ; const value = shader ? shader . native : 0 ; this . context . shaderSourceWithShaderSource ( value , source ) ; } stencilFuncSeparate ( face , func , ref , mask ) { this . _glCheckError ( 'stencilFuncSeparate' ) ; this . _checkArgs ( 'stencilFuncSeparate' , arguments ) ; this . context . stencilFuncSeparateWithFaceFnRefMask ( face , func , ref , mask ) ; } stencilFunc ( func , ref , mask ) { this . _glCheckError ( 'stencilFunc' ) ; this . _checkArgs ( 'stencilFunc' , arguments ) ; this . context . stencilFuncWithFnRefMask ( func , ref , mask ) ; } stencilMaskSeparate ( face , mask ) { this . _glCheckError ( 'stencilMaskSeparate' ) ; this . _checkArgs ( 'stencilMaskSeparate' , arguments ) ; this . context . stencilMaskSeparateWithFaceMask ( face , mask ) ; } stencilMask ( mask ) { this . _glCheckError ( 'stencilMask' ) ; this . _checkArgs ( 'stencilMask' , arguments ) ; this . context . stencilMaskWithMask ( mask ) ; } stencilOpSeparate ( face , fail , zfail , zpass ) { this . _glCheckError ( 'stencilOpSeparate' ) ; this . _checkArgs ( 'stencilOpSeparate' , arguments ) ; this . context . stencilOpSeparateWithFaceFailZfailZpass ( face , fail , zfail , zpass ) ; } stencilOp ( fail , zfail , zpass ) { this . _glCheckError ( 'stencilOp' ) ; this . _checkArgs ( 'stencilOp' , arguments ) ; this . context . stencilOpWithFailZfailZpass ( fail , zfail , zpass ) ; } texImage2D ( target , level , internalformat , format , type , pixels ? ) ; texImage2D ( target , level , internalformat , width , height , border , format , type , pixels ? ) ; texImage2D ( target , level , internalformat , width , height , border , format ? , type ? , pixels ? ) { this . _glCheckError ( 'texImage2D' ) ; this . _checkArgs ( 'texImage2D' , arguments ) ; if ( arguments . length === 9 ) { if ( pixels && pixels . buffer ) { if ( pixels instanceof Float32Array || pixels instanceof Float64Array ) { this . context . texImage2DWithTargetLevelInternalformatWidthHeightBorderFormatTypeFloatArray ( target , level , internalformat , width , height , border , format , type , pixels as any ) ; } else if ( pixels instanceof Uint32Array || pixels instanceof Int32Array ) { this . context . texImage2DWithTargetLevelInternalformatWidthHeightBorderFormatTypeIntArray ( target , level , internalformat , width , height , border , format , type , pixels as any ) ; } else if ( pixels instanceof Uint16Array || pixels instanceof Int16Array ) { this . context . texImage2DWithTargetLevelInternalformatWidthHeightBorderFormatTypeShortArray ( target , level , internalformat , width , height , border , format , type , pixels as any ) ; } else if ( pixels instanceof Uint8Array ) { this . context . texImage2DWithTargetLevelInternalformatWidthHeightBorderFormatTypeByteArray ( target , level , internalformat , width , height , border , format , type , pixels as any ) ; } } else if ( pixels instanceof ArrayBuffer ) { this . context . texImage2DWithTargetLevelInternalformatWidthHeightBorderFormatTypeByteArray ( target , level , internalformat , width , height , border , format , type , new Uint8Array ( pixels . slice ( 0 ) as any ) as any ) ; } else { this . context . texImage2DWithTargetLevelInternalformatWidthHeightBorderFormatTypePixels ( target , level , internalformat , width , height , border , format , type , pixels as any ) ; } } else if ( arguments . length === 6 ) { if ( border instanceof TNSImageAsset ) { this . context . texImage2DWithTargetLevelInternalformatFormatTypeAsset ( target , level , internalformat , width , height , border . native ) ; } else if ( border instanceof ImageSource ) { this . context . texImage2DWithTargetLevelInternalformatFormatTypePixels ( target , level , internalformat , width , height , border . ios ) ; } else if ( border instanceof UIImage ) { this . context . texImage2DWithTargetLevelInternalformatFormatTypePixels ( target , level , internalformat , width , height , border ) ; } else if ( border && typeof border . tagName === 'string' && border . tagName === 'IMG' ) { if ( border . _asset instanceof TNSImageAsset ) { this . context . texImage2DWithTargetLevelInternalformatFormatTypeAsset ( target , level , internalformat , width , height , border . _asset . native ) ; } else if ( border . _imageSource instanceof ImageSource ) { this . context . texImage2DWithTargetLevelInternalformatFormatTypePixels ( target , level , internalformat , width , height , border . _imageSource . ios ) ; } else if ( border . _image instanceof UIImage ) { this . context . texImage2DWithTargetLevelInternalformatFormatTypePixels ( target , level , internalformat , width , height , border . _image ) ; } else if ( typeof border . src === 'string' ) { const asset = fromFile ( border . src ) ; this . context . texImage2DWithTargetLevelInternalformatFormatTypePixels ( target , level , internalformat , width , height , asset . ios ) ; } } else if ( border && typeof border . tagName === 'string' && border . tagName === 'CANVAS' && border . _canvas instanceof TNSCanvas ) { this . context . texImage2DWithTargetLevelInternalformatFormatTypeCanvas ( target , level , internalformat , width , height , border . _canvas . ios ) ; } else { this . context . texImage2DWithTargetLevelInternalformatFormatTypeNone ( target , level , internalformat , width , height , border as any ) ; } } } texParameterf ( target , pname , param ) { this . _glCheckError ( 'texParameterf' ) ; this . _checkArgs ( 'texParameterf' , arguments ) ; this . context . texParameterfWithTargetPnameParam ( target , pname , param ) ; } texParameteri ( target , pname , param ) { this . _glCheckError ( 'texParameteri' ) ; this . _checkArgs ( 'texParameteri' , arguments ) ; this . context . texParameteriWithTargetPnameParam ( target , pname , param ) ; } texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type , pixels ) ; texSubImage2D ( target , level , xoffset , yoffset , format , type , pixels ) ; texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type ? , pixels ? ) { this . _glCheckError ( 'texSubImage2D' ) ; this . _checkArgs ( 'texSubImage2D' , arguments ) ; if ( arguments . length === 9 ) { if ( pixels && pixels . buffer ) { if ( pixels instanceof Float32Array || pixels instanceof Float64Array ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatTypeFloatArray ( target , level , xoffset , yoffset , width , height , format , type , pixels as any ) ; } else if ( pixels instanceof Uint16Array || pixels instanceof Int16Array ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatTypeShortArray ( target , level , xoffset , yoffset , width , height , format , type , pixels as any ) ; } else if ( pixels instanceof Uint8Array ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatTypeByteArray ( target , level , xoffset , yoffset , width , height , format , type , pixels as any ) ; } } else if ( pixels instanceof ArrayBuffer ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatTypeByteArray ( target , level , xoffset , yoffset , width , height , format , type , new Uint8Array ( pixels . slice ( 0 ) as any ) as any ) ; } else { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetWidthHeightFormatTypePixels ( target , level , xoffset , yoffset , width , height , format , type , pixels as any ) ; } } else if ( arguments . length === 7 ) { if ( format instanceof TNSImageAsset ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypeAsset ( target , level , xoffset , yoffset , width , height , format . native ) ; } else if ( format instanceof UIImage ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypePixels ( target , level , xoffset , yoffset , width , height , format ) ; } else if ( format instanceof ImageSource ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypePixels ( target , level , xoffset , yoffset , width , height , format . ios ) ; } else if ( format && typeof format . tagName === 'string' && format . tagName === 'IMG' ) { if ( format . _imageSource instanceof ImageSource ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypePixels ( target , level , xoffset , yoffset , width , height , format . _imageSource . ios ) ; } else if ( format . _image instanceof UIImage ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypePixels ( target , level , xoffset , yoffset , width , height , format . _image ) ; } else if ( format . _asset instanceof TNSImageAsset ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypeAsset ( target , level , xoffset , yoffset , width , height , format . _asset . native ) ; } else if ( typeof format . src === 'string' ) { const result = fromFile ( format . src ) ; this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypePixels ( target , level , xoffset , yoffset , width , height , result ? result . ios : null ) ; } } else if ( format && typeof format . tagName === 'string' && format . tagName === 'CANVAS' && format . _canvas instanceof TNSCanvas ) { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypeCanvas ( target , level , xoffset , yoffset , width , height , format . _canvas . ios ) ; } else { this . context . texSubImage2DWithTargetLevelXoffsetYoffsetFormatTypeNone ( target , level , xoffset , yoffset , width , height , format as any ) ; } } } uniform1f ( location , v0 ) { this . _glCheckError ( 'uniform1f' ) ; this . _checkArgs ( 'uniform1f' , arguments ) ; this . context . uniform1fWithLocationV0 ( location . native , v0 ) ; } uniform1iv ( location , value ) { this . _glCheckError ( 'uniform1iv' ) ; this . _checkArgs ( 'uniform1iv' , arguments ) ; this . context . uniform1ivWithLocationValue ( location . native , value ) ; } uniform1fv ( location , value ) { this . _glCheckError ( 'uniform1fv' ) ; this . _checkArgs ( 'uniform1fv' , arguments ) ; if ( ! ( value instanceof Float32Array ) ) { value = new Float32Array ( value ) as any ; } this . context . uniform1fvWithLocationValue ( location . native , value ) ; } uniform1i ( location , v0 ) { this . _glCheckError ( 'uniform1i' ) ; this . _checkArgs ( 'uniform1i' , arguments ) ; this . context . uniform1iWithLocationV0 ( location . native , v0 ) ; } uniform2f ( location , v0 , v1 ) { this . _glCheckError ( 'uniform2f' ) ; this . _checkArgs ( 'uniform2f' , arguments ) ; this . context . uniform2fWithLocationV0V1 ( location . native , v0 , v1 ) ; } uniform2iv ( location , value ) { this . _glCheckError ( 'uniform2iv' ) ; this . _checkArgs ( 'activattachShadereTexture' , arguments ) ; this . context . uniform2ivWithLocationValue ( location . native , value ) ; } uniform2fv ( location , value ) { this . _glCheckError ( 'uniform2fv' ) ; this . _checkArgs ( 'uniform2fv' , arguments ) ; if ( ! ( value instanceof Float32Array ) ) { value = new Float32Array ( value ) as any ; } this . context . uniform2fvWithLocationValue ( location . native , value ) ; } uniform2i ( location , v0 , v1 ) { this . _glCheckError ( 'uniform2i' ) ; this . _checkArgs ( 'uniform2i' , arguments ) ; this . context . uniform2iWithLocationV0V1 ( location . native , v0 , v1 ) ; } uniform3f ( location , v0 , v1 , v2 ) { this . _glCheckError ( 'uniform3f' ) ; this . _checkArgs ( 'uniform3f' , arguments ) ; this . context . uniform3fWithLocationV0V1V2 ( location . native , v0 , v1 , v2 ) ; } uniform3iv ( location , value ) { this . _glCheckError ( 'uniform3iv' ) ; this . _checkArgs ( 'uniform3iv' , arguments ) ; this . context . uniform3ivWithLocationValue ( location . native , value ) ; } uniform3fv ( location , value ) { this . _glCheckError ( 'uniform3fv' ) ; this . _checkArgs ( 'uniform3fv' , arguments ) ; if ( ! ( value instanceof Float32Array ) ) { value = new Float32Array ( value ) as any ; } this . context . uniform3fvWithLocationValue ( location . native , value ) ; } uniform3i ( location , v0 , v1 , v2 ) { this . _glCheckError ( 'uniform3i' ) ; this . _checkArgs ( 'uniform3i' , arguments ) ; this . context . uniform3iWithLocationV0V1V2 ( location . native , v0 , v1 , v2 ) ; } uniform4f ( location , v0 , v1 , v2 , v3 ) { this . _glCheckError ( 'uniform4f' ) ; this . _checkArgs ( 'uniform4f' , arguments ) ; this . context . uniform4fWithLocationV0V1V2V3 ( location . native , v0 , v1 , v2 , v3 ) ; } uniform4iv ( location , value ) { this . _glCheckError ( 'uniform4iv' ) ; this . _checkArgs ( 'uniform4iv' , arguments ) ; this . context . uniform4ivWithLocationValue ( location . native , value ) ; } uniform4fv ( location , value ) { this . _glCheckError ( 'uniform4fv' ) ; this . _checkArgs ( 'uniform4fv' , arguments ) ; if ( ! ( value instanceof Float32Array ) ) { value = new Float32Array ( value ) as any ; } this . context . uniform4fvWithLocationValue ( location . native , value ) ; } uniform4i ( location , v0 , v1 , v2 , v3 ) { this . _glCheckError ( 'uniform4i' ) ; this . _checkArgs ( 'uniform4i' , arguments ) ; this . context . uniform4iWithLocationV0V1V2V3 ( location . native , v0 , v1 , v2 , v3 ) ; } uniformMatrix2fv ( location , transpose , value ) { this . _glCheckError ( 'uniformMatrix2fv' ) ; this . _checkArgs ( 'uniformMatrix2fv' , arguments ) ; if ( ! ( value instanceof Float32Array ) ) { value = new Float32Array ( value ) as any ; } this . context . uniformMatrix2fvWithLocationTransposeValue ( location . native , transpose , value ) ; } uniformMatrix3fv ( location , transpose , value ) { this . _glCheckError ( 'uniformMatrix3fv' ) ; this . _checkArgs ( 'uniformMatrix3fv' , arguments ) ; if ( ! ( value instanceof Float32Array ) ) { value = new Float32Array ( value ) as any ; } this . context . uniformMatrix3fvWithLocationTransposeValue ( location . native , transpose , value ) ; } uniformMatrix4fv ( location , transpose , value ) { this . _glCheckError ( 'uniformMatrix4fv' ) ; this . _checkArgs ( 'uniformMatrix4fv' , arguments ) ; if ( ! ( value instanceof Float32Array ) ) { value = new Float32Array ( value ) as any ; } this . context . uniformMatrix4fvWithLocationTransposeValue ( location . native , transpose , value ) ; } useProgram ( program ) { this . _glCheckError ( 'useProgram' ) ; this . _checkArgs ( 'useProgram' , arguments ) ; const value = program ? program . native : 0 ; this . context . useProgramWithProgram ( value ) ; } validateProgram ( program ) { this . _glCheckError ( 'validateProgram' ) ; this . _checkArgs ( 'validateProgram' , arguments ) ; const value = program ? program . native : 0 ; this . context . validateProgramWithProgram ( value ) ; } vertexAttrib1f ( index , v0 ) { this . _glCheckError ( 'vertexAttrib1f' ) ; this . _checkArgs ( 'vertexAttrib1f' , arguments ) ; this . context . vertexAttrib1fWithIndexV0 ( index , v0 ) ; } vertexAttrib1fv ( index , value ) { this . _glCheckError ( 'vertexAttrib1fv' ) ; this . _checkArgs ( 'vertexAttrib1fv' , arguments ) ; this . context . vertexAttrib1fvWithIndexValue ( index , value ) ; } vertexAttrib2f ( index , v0 , v1 ) { this . _glCheckError ( 'vertexAttrib2f' ) ; this . _checkArgs ( 'vertexAttrib2f' , arguments ) ; this . context . vertexAttrib2fWithIndexV0V1 ( index , v0 , v1 ) ; } vertexAttrib2fv ( index , value ) { this . _glCheckError ( 'vertexAttrib2fv' ) ; this . _checkArgs ( 'vertexAttrib2fv' , arguments ) ; this . context . vertexAttrib2fvWithIndexValue ( index , value ) ; } vertexAttrib3f ( index , v0 , v1 , v2 ) { this . _glCheckError ( 'vertexAttrib3f' ) ; this . _checkArgs ( 'vertexAttrib3f' , arguments ) ; this . context . vertexAttrib3fWithIndexV0V1V2 ( index , v0 , v1 , v2 ) ; } vertexAttrib3fv ( index , value ) { this . _glCheckError ( 'vertexAttrib3fv' ) ; this . _checkArgs ( 'vertexAttrib3fv' , arguments ) ; this . context . vertexAttrib3fvWithIndexValue ( index , value ) ; } vertexAttrib4f ( index , v0 , v1 , v2 , v3 ) { this . _glCheckError ( 'vertexAttrib4f' ) ; this . _checkArgs ( 'vertexAttrib4f' , arguments ) ; this . context . vertexAttrib4fWithIndexV0V1V2V3 ( index , v0 , v1 , v2 , v3 ) ; } vertexAttrib4fv ( index , value ) { this . _glCheckError ( 'vertexAttrib4fv' ) ; this . _checkArgs ( 'vertexAttrib4fv' , arguments ) ; this . context . vertexAttrib4fvWithIndexValue ( index , value ) ; } vertexAttribPointer ( index , size , type , normalized , stride , offset ) { this . _glCheckError ( 'vertexAttribPointer' ) ; this . _checkArgs ( 'vertexAttribPointer' , arguments ) ; this . context . vertexAttribPointerWithIndexSizeTypeNormalizedStrideOffset ( index , size , type , normalized , stride , offset ) ; } viewport ( x , y , width , height ) { this . _glCheckError ( 'viewport' ) ; this . _checkArgs ( 'viewport' , arguments ) ; this . context . viewportWithXYWidthHeight ( x , y , width , height ) ; } protected getJSArray ( value ) { const count = value . count ; const array = [ ] ; for ( let i = 0 ; i < count ; i ++ ) { array . push ( value . objectAtIndex ( i ) ) ; } return array ; } protected _glCheckError ( message ) { if ( ! TNSWebGLRenderingContext . isDebug ) { return ; } if ( TNSWebGLRenderingContext . filter === 'both' || TNSWebGLRenderingContext . filter === 'error' ) { console . log ( message , this . getError ( ) ) ; } } protected _checkArgs ( message , args ) { if ( ! TNSWebGLRenderingContext . isDebug ) { return ; } if ( TNSWebGLRenderingContext . filter === 'both' || TNSWebGLRenderingContext . filter === 'args' ) { console . log ( '\/**** ' , message , ' ****\/' ) ; console . dir ( args ) ; console . log ( '\/**** ' , message , ' ****\/' ) ; } } }