Render targets Setup storage for target texture and bind it to correct framebuffer
507020
function setupFrameBufferTexture ( framebuffer, renderTarget, attachment, textureTarget ) {

		var glFormat = paramThreeToGL( renderTarget.texture.format );
		var glType = paramThreeToGL( renderTarget.texture.type );
		state.texImage2D( textureTarget, 0, glFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
		_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
		_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );
		_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );

	}
25514
function(shader, sampler_name, dimension_name) {
        if (this.unit === null)
            throw "Trying to use texture not set to a texture unit.";
        var gl = this.gl;
        gl.useProgram(shader);
        // Set the texture buffer to use
        gl.uniform1i(gl.getUniformLocation(shader, sampler_name), this.unit);
        // Set the image dimensions
        gl.uniform2f(
            gl.getUniformLocation(shader, dimension_name),
            this.width,
            this.height
        );
    }
1237639
function setupRenderTarget( renderTarget ) {

		var renderTargetProperties = properties.get( renderTarget );
		var textureProperties = properties.get( renderTarget.texture );

		renderTarget.addEventListener( 'dispose', onRenderTargetDispose );

		textureProperties.__webglTexture = _gl.createTexture();

		info.memory.textures ++;

		var isCube = ( renderTarget.isWebGLRenderTargetCube === true );
		var isTargetPowerOfTwo = isPowerOfTwo( renderTarget );

		// Setup framebuffer

		if ( isCube ) {

			renderTargetProperties.__webglFramebuffer = [];

			for ( var i = 0; i < 6; i ++ ) {

				renderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();

			}

		} else {

			renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();

		}

		// Setup color buffer

		if ( isCube ) {

			state.bindTexture( 34067, textureProperties.__webglTexture );
			setTextureParameters( 34067, renderTarget.texture, isTargetPowerOfTwo );

			for ( var i = 0; i < 6; i ++ ) {

				setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, 36064, 34069 + i );

			}

			if ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) {

				generateMipmap( 34067, renderTarget.texture, renderTarget.width, renderTarget.height );

			}

			state.bindTexture( 34067, null );

		} else {

			state.bindTexture( 3553, textureProperties.__webglTexture );
			setTextureParameters( 3553, renderTarget.texture, isTargetPowerOfTwo );
			setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, 36064, 3553 );

			if ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) {

				generateMipmap( 3553, renderTarget.texture, renderTarget.width, renderTarget.height );

			}

			state.bindTexture( 3553, null );

		}

		// Setup depth and stencil buffers

		if ( renderTarget.depthBuffer ) {

			setupDepthRenderbuffer( renderTarget );

		}

	}
495723
function(unit) {
    gl.activeTexture(gl.TEXTURE0 + (unit || 0));
    gl.bindTexture(gl.TEXTURE_2D, this.id);
  }
726871
function setupDepthTexture ( framebuffer, renderTarget ) {

		var isCube = ( renderTarget instanceof THREE.WebGLRenderTargetCube );
		if ( isCube ) throw new Error('Depth Texture with cube render targets is not supported!');

		_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );

		if ( !( renderTarget.depthTexture instanceof THREE.DepthTexture ) ) {

			throw new Error('renderTarget.depthTexture must be an instance of THREE.DepthTexture');

		}

		// upload an empty depth texture with framebuffer size
		if ( !properties.get( renderTarget.depthTexture ).__webglTexture ||
				renderTarget.depthTexture.image.width !== renderTarget.width ||
				renderTarget.depthTexture.image.height !== renderTarget.height ) {
			renderTarget.depthTexture.image.width = renderTarget.width;
			renderTarget.depthTexture.image.height = renderTarget.height;
			renderTarget.depthTexture.needsUpdate = true;
		}

		setTexture2D( renderTarget.depthTexture, 0 );

		var webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
		_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );

	}
871234
def bind_texture(texture):
    """"""
    if not getattr(texture, 'image', None):
        texture.image = load_image(texture.path)

    glEnable(texture.image.target)
    glBindTexture(texture.image.target, texture.image.id)
    gl.glTexParameterf(texture.image.target,
                       gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
    gl.glTexParameterf(texture.image.target,
                       gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
747439
function( renderer, n ) {

			var r = arrayCacheI32[ n ];

			if ( r === undefined ) {

				r = new Int32Array( n );
				arrayCacheI32[ n ] = r;

			}

			for ( var i = 0; i !== n; ++ i )
				r[ i ] = renderer.allocTextureUnit();

			return r;

		}
632272
function getPixels(texture, opts) {
    var gl = texture.gl
    if (!gl)
        throw new Error("must provide gl-texture2d object with a valid 'gl' context")
    
    if (!fbo) {
        var handle = gl.createFramebuffer()
        fbo = {
            handle: handle,
            dispose: dispose,
            gl: gl
        }
    } 

    // make this the current frame buffer
    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo.handle)

    // attach the texture to the framebuffer.
    gl.framebufferTexture2D(
        gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0,
        gl.TEXTURE_2D, texture.handle, 0)

    // check if you can read from this type of texture.
    var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)
    if (status !== gl.FRAMEBUFFER_COMPLETE) 
        throw new Error("cannot read GL framebuffer: " + status)
    
    opts = opts||{}
    opts.x = opts.x|0
    opts.y = opts.y|0
    opts.width = typeof opts.width === 'number' ? opts.width : (texture.shape[0]|0)
    opts.height = typeof opts.height === 'number' ? opts.height : (texture.shape[1]|0)

    var array = new Uint8Array(opts.width * opts.height * 4)
    gl.readPixels(opts.x, opts.y, opts.width, opts.height, gl.RGBA, gl.UNSIGNED_BYTE, array)
    gl.bindFramebuffer(gl.FRAMEBUFFER, null)
    return array
}
781106
function RenderTexture (opts) {
    RenderTexture.superclass.constructor.call(this, opts)

    var width = opts.width,
        height = opts.height

    evt.addPropertyListener(this, 'contentSize', 'change', this._resizeCanvas.bind(this))

    this.canvas = document.createElement('canvas')
    this.context = this.canvas.getContext('2d')

    var atlas = new TextureAtlas({canvas: this.canvas})
    this.sprite = new Sprite({textureAtlas: atlas, rect: {origin: ccp(0, 0), size: {width: width, height: height}}})

    this.contentSize = geo.sizeMake(width, height)
    this.addChild(this.sprite)
    this.anchorPoint = ccp(0, 0)
    this.sprite.anchorPoint = ccp(0, 0)

}
1242126
function( gl, v, renderer ) {

			var unit = renderer.allocTextureUnit();
			gl.uniform1i( this.addr, unit );
			renderer.setTextureCube( v || emptyCubeTexture, unit );

		}
1010850
function (renderer, size) {
        if (!renderer.getGLExtension('EXT_shader_texture_lod')) {
            console.warn('Device not support textureCubeLodEXT');
            return;
        }
        if (!this._brdfLookup) {
            this._normalDistribution = cubemapUtil.generateNormalDistribution();
            this._brdfLookup = cubemapUtil.integrateBRDF(renderer, this._normalDistribution);
        }
        var cubemap = this.cubemap;
        if (cubemap.__prefiltered) {
            return;
        }

        var result = cubemapUtil.prefilterEnvironmentMap(
            renderer, cubemap, {
                encodeRGBM: true,
                width: size,
                height: size
            }, this._normalDistribution, this._brdfLookup
        );
        this.cubemap = result.environmentMap;
        this.cubemap.__prefiltered = true;

        cubemap.dispose(renderer);
    }
252937
function( gl, v, renderer ) {

			var n = v.length,
				units = allocTexUnits( renderer, n );

			gl.uniform1iv( this.addr, units );

			for ( var i = 0; i !== n; ++ i ) {

				renderer.setTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );

			}

		}
682679
def load_texture(renderer, file):
    
    return Texture._from_ptr(check_ptr_err(lib.IMG_LoadTexture(renderer._ptr, file)))
160520
function updateTexture(texture, renderState) {
    if (!texture) {
      return;
    }

    console.log('updateTexture ', m_width);
    console.log('updateTexture ', m_height);

    if (texture.width() !== m_width) {
      texture.setWidth(m_width);
    }

    if (texture.height() !== m_height) {
      texture.setHeight(m_height);
    }

    texture.setup(renderState);
  }
856248
function createGLResources(gl, glConfig) {
  const resources = {
    gl,
    buffers: {},
    textures: {},
    framebuffers: {},
    programs: {},
  };
  const buffers = glConfig.resources.buffers || [];
  const textures = glConfig.resources.textures || [];
  const framebuffers = glConfig.resources.framebuffers || [];

  // Create Buffer
  buffers.forEach((buffer) => {
    const glBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, glBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, buffer.data, gl.STATIC_DRAW);
    resources.buffers[buffer.id] = glBuffer;
  });

  // Create Texture
  textures.forEach((texture) => {
    const glTexture = gl.createTexture();
    const pixelStore = texture.pixelStore || [];
    const texParameter = texture.texParameter || [];

    gl.bindTexture(gl.TEXTURE_2D, glTexture);

    pixelStore.forEach((option) => {
      gl.pixelStorei(gl[option[0]], option[1]);
    });

    texParameter.forEach((option) => {
      gl.texParameteri(gl.TEXTURE_2D, gl[option[0]], gl[option[1]]);
    });

    resources.textures[texture.id] = glTexture;
  });

  // Create Framebuffer
  framebuffers.forEach((framebuffer) => {
    const glFramebuffer = gl.createFramebuffer();
    glFramebuffer.width = framebuffer.width;
    glFramebuffer.height = framebuffer.height;

    resources.framebuffers[framebuffer.id] = glFramebuffer;
  });

  // Create programs
  Object.keys(glConfig.programs).forEach((programName) => {
    buildShaderProgram(gl, programName, glConfig, resources);
  });

  // Add destroy function
  resources.destroy = () => {
    freeGLResources(resources);
  };

  return resources;
}
1198625
function( context, target ) {
    var target   = target || 'ruby'
    var $target  = $.qsa( target, context )

    $.qsa( 'rtc', context )
    .concat( $target ).map( simplifyRubyClass )

    $target
    .forEach(function( $ruby ) {
      var clazz = $ruby.classList
      var $new

      if      ( clazz.contains( 'complex' ))  $new = renderComplexRuby( $ruby )
      else if ( clazz.contains( 'zhuyin' ))   $new = SUPPORT_IC ? renderInterCharRuby( $ruby ) : renderSimpleRuby( $ruby )

      // Finally, replace it
      if ( $new )  $ruby.parentNode.replaceChild( $new, $ruby )
    })
  }
79464
def render
      raise ArgumentError, "Block required" unless block_given?
      raise Error, "Can't nest rendering" if rendering?

      $window.flush # Ensure that any drawing _before_ the render block is drawn to screen, rather than into the buffer.

      render_

      @rendering = true

      # Project onto the texture itself, using Gosu (inverted) coordinates.
      Gl.glPushMatrix
      Gl.glMatrixMode Gl::GL_PROJECTION
      Gl.glLoadIdentity
      Gl.glViewport 0, 0, width, height
      Gl.glOrtho 0, width, height, 0, -1, 1

      begin
        yield self
      ensure
        $window.flush # Force all the drawing to draw now!
        Gl.glBindFramebufferEXT Gl::GL_FRAMEBUFFER_EXT, 0

        @rendering = false

        Gl.glPopMatrix

        cache.refresh # Force lazy reloading of the cache.
      end

      self
    end