binds this mesh's vertex attributes for the given shader
171941
function(shader) {
		var gl = this.gl;

		var offset = 0;
		var stride = this.vertexStride;

		//bind and update our vertex data before binding attributes
		this._updateBuffers();

		//for each attribtue
		for (var i=0; i<this._vertexAttribs.length; i++) {
			var a = this._vertexAttribs[i];

			//location of the attribute
			var loc = a.location === null 
					? shader.getAttributeLocation(a.name)
					: a.location;

			//TODO: We may want to skip unfound attribs
			// if (loc!==0 && !loc)
			// 	console.warn("WARN:", a.name, "is not enabled");

			//first, enable the vertex array
			gl.enableVertexAttribArray(loc);

			//then specify our vertex format
			gl.vertexAttribPointer(loc, a.numComponents, a.type || gl.FLOAT, 
								   a.normalize, stride, offset);

			//and increase the offset...
			offset += a.offsetCount * 4; //in bytes
		}
	}
845981
function (shader) {
            if (this.activeShader !== shader) {
                this.flush();
                this.activeShader = shader;
                this.activeShader.bind();
                this.activeShader.uniforms.uProjectionMatrix = this.projectionMatrix.val;
            }
        }
609958
function makePointsProgram(gl, data) {
  let vertexProgram = vertexProgramCache.get(gl)
  if (!vertexProgram) {
    let vertexShader = gl_utils.compile(gl, gl.VERTEX_SHADER, vertexShaderSrc);
    let fragmentShader = gl_utils.compile(gl, gl.FRAGMENT_SHADER, fragmentShaderSrc);
    vertexProgram = gl_utils.link(gl, vertexShader, fragmentShader);
    vertexProgramCache.set(gl, vertexProgram);
  }

  let locations = gl_utils.getLocations(gl, vertexProgram);

  var buffer = gl.createBuffer();
  if (!buffer) throw new Error('failed to create a nodesBuffer');
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  gl.bufferData(gl.ARRAY_BUFFER, data.byteLength, gl.DYNAMIC_DRAW);

  var pointTexture = createCircleTexture(gl);

  var api = {
    draw,
    updateData,
    dispose
  };
  return api;

  function updateData(newData) {
    data = newData;
  }

  function dispose() {
    // For some reason disposing the buffer results in unbindable
    // buffer for the lines program (that is created after this scene is disposed).
    // gl.deleteBuffer(buffer);
    gl.deleteProgram(vertexProgram);
    gl.deleteTexture(pointTexture);
    vertexProgramCache.delete(gl);
  }

  function draw(transform, screen, count) {
    gl.useProgram(vertexProgram);

    var bpe = data.BYTES_PER_ELEMENT;

    if (transform) {
      gl.uniformMatrix4fv(locations.uniforms.uTransform, false, transform.getArray());
    }
    gl.uniform2f(locations.uniforms.uScreenSize, screen.width, screen.height);
    gl.bindTexture(gl.TEXTURE_2D, pointTexture);

    gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
    gl.bufferData(gl.ARRAY_BUFFER, data, gl.DYNAMIC_DRAW);

    gl.vertexAttribPointer(locations.attributes.aPosition, 2, gl.FLOAT, false, bpe * 6, 0)
    gl.enableVertexAttribArray(locations.attributes.aPosition)

    gl.vertexAttribPointer(locations.attributes.aPointSize, 1, gl.FLOAT, false, bpe * 6, 2 * bpe)
    gl.enableVertexAttribArray(locations.attributes.aPointSize)

    gl.vertexAttribPointer(locations.attributes.aColor, 3, gl.FLOAT, false, bpe * 6, 3 * bpe)
    gl.enableVertexAttribArray(locations.attributes.aColor);
    gl.drawArrays(gl.POINTS, 0, count);
  }
}
571610
def createAllShaders(self):
        ""
        self.m_unSceneProgramID = self.compileGLShader( 
            "Scene",
            # Vertex Shader
            dedent("""\
            #version 410
            uniform mat4 matrix;
            layout(location = 0) in vec4 position;
            layout(location = 1) in vec2 v2UVcoordsIn;
            layout(location = 2) in vec3 v3NormalIn;
            out vec2 v2UVcoords;
            void main()
            {
                v2UVcoords = v2UVcoordsIn;
                gl_Position = matrix * position;
            }
            """),
            # Fragment Shader
            dedent("""\
            #version 410 core
            uniform sampler2D mytexture;
            in vec2 v2UVcoords;
            out vec4 outputColor;
            void main()
            {
               outputColor = texture(mytexture, v2UVcoords);
            }
            """)
            )
        self.m_nSceneMatrixLocation = glGetUniformLocation( self.m_unSceneProgramID, "matrix" )
        if self.m_nSceneMatrixLocation == -1:
            dprintf( "Unable to find matrix uniform in scene shader\n" )
            return False
        self.m_unControllerTransformProgramID = self.compileGLShader(
            "Controller",
            # vertex shader
            dedent("""\
            #version 410
            uniform mat4 matrix;
            layout(location = 0) in vec4 position;
            layout(location = 1) in vec3 v3ColorIn;
            out vec4 v4Color;
            void main()
            {
                v4Color.xyz = v3ColorIn;
                v4Color.a = 1.0;
                gl_Position = matrix * position;
            }
            """),
            # fragment shader
            dedent("""\
            #version 410
            in vec4 v4Color;
            out vec4 outputColor;
            void main()
            {
               outputColor = v4Color;
            }
            """) )
        self.m_nControllerMatrixLocation = glGetUniformLocation( self.m_unControllerTransformProgramID, "matrix" )
        if self.m_nControllerMatrixLocation == -1:
            dprintf( "Unable to find matrix uniform in controller shader\n" )
            return False
        self.m_unRenderModelProgramID = self.compileGLShader( 
            "render model",
            # vertex shader
            dedent("""\
            #version 410
            uniform mat4 matrix;
            layout(location = 0) in vec4 position;
            layout(location = 1) in vec3 v3NormalIn;
            layout(location = 2) in vec2 v2TexCoordsIn;
            out vec2 v2TexCoord;
            void main()
            {
                v2TexCoord = v2TexCoordsIn;
                gl_Position = matrix * vec4(position.xyz, 1);
            }
            """),
            #fragment shader
            dedent("""\
            #version 410 core
            uniform sampler2D diffuse;
            in vec2 v2TexCoord;
            out vec4 outputColor;
            void main()
            {
               outputColor = texture( diffuse, v2TexCoord);
            }
            """) )
        self.m_nRenderModelMatrixLocation = glGetUniformLocation( self.m_unRenderModelProgramID, "matrix" )
        if self.m_nRenderModelMatrixLocation == -1:
            dprintf( "Unable to find matrix uniform in render model shader\n" )
            return False
        self.m_unLensProgramID = self.compileGLShader(
            "Distortion",
            # vertex shader
            dedent("""\
            #version 410 core
            layout(location = 0) in vec4 position;
            layout(location = 1) in vec2 v2UVredIn;
            layout(location = 2) in vec2 v2UVGreenIn;
            layout(location = 3) in vec2 v2UVblueIn;
            noperspective  out vec2 v2UVred;
            noperspective  out vec2 v2UVgreen;
            noperspective  out vec2 v2UVblue;
            void main()
            {
                v2UVred = v2UVredIn;
                v2UVgreen = v2UVGreenIn;
                v2UVblue = v2UVblueIn;
                gl_Position = position;
            }
            """),
            # fragment shader
            dedent("""\
            #version 410 core
            uniform sampler2D mytexture;
    
            noperspective  in vec2 v2UVred;
            noperspective  in vec2 v2UVgreen;
            noperspective  in vec2 v2UVblue;
    
            out vec4 outputColor;
    
            void main()
            {
                float fBoundsCheck = ( 
                    (dot( vec2( lessThan( v2UVgreen.xy, vec2(0.05, 0.05)) ), vec2(1.0, 1.0))
                    + dot( vec2( greaterThan( v2UVgreen.xy, vec2( 0.95, 0.95)) ), vec2(1.0, 1.0))) 
                    );
                if( fBoundsCheck > 1.0 ) {
                    outputColor = vec4( 0, 0, 0, 1.0 ); 
                } 
                else {
                    float red = texture(mytexture, v2UVred).x;
                    float green = texture(mytexture, v2UVgreen).y;
                    float blue = texture(mytexture, v2UVblue).z;
                    outputColor = vec4( red, green, blue, 1.0  ); 
                }
            }
            """) )
        return self.m_unSceneProgramID != 0 and self.m_unControllerTransformProgramID != 0 and self.m_unRenderModelProgramID != 0 and self.m_unLensProgramID != 0
416127
def _insert_glsl(vertex, fragment, to_insert):
    
    # Find the place where to insert the GLSL snippet.
    # This is "gl_Position = transform(data_var_name);" where
    # data_var_name is typically an attribute.
    vs_regex = re.compile(r'gl_Position = transform\(([\S]+)\);')
    r = vs_regex.search(vertex)
    if not r:
        logger.debug("The vertex shader doesn't contain the transform "
                     "placeholder: skipping the transform chain "
                     "GLSL insertion.")
        return vertex, fragment
    assert r
    logger.log(5, "Found transform placeholder in vertex code: `%s`",
               r.group(0))

    # Find the GLSL variable with the data (should be a `vec2`).
    var = r.group(1)
    assert var and var in vertex

    # Headers.
    vertex = to_insert['vert', 'header'] + '\n\n' + vertex
    fragment = to_insert['frag', 'header'] + '\n\n' + fragment

    # Get the pre and post transforms.
    vs_insert = to_insert['vert', 'before_transforms']
    vs_insert += to_insert['vert', 'transforms']
    vs_insert += to_insert['vert', 'after_transforms']

    # Insert the GLSL snippet in the vertex shader.
    vertex = vs_regex.sub(indent(vs_insert), vertex)

    # Now, we make the replacements in the fragment shader.
    fs_regex = re.compile(r'(void main\(\)\s*\{)')
    # NOTE: we add the `void main(){` that was removed by the regex.
    fs_insert = '\\1\n' + to_insert['frag', 'before_transforms']
    fragment = fs_regex.sub(indent(fs_insert), fragment)

    # Replace the transformed variable placeholder by its name.
    vertex = vertex.replace('{{ var }}', var)

    return vertex, fragment
66634
def vertices(self, values):
        
        self._data['vertices'] = np.asanyarray(values,
                                               order='C',
                                               dtype=np.float64)
532271
function update (opt) {
    // remove old shaders
    disposeShaders()

    var quiet = opt.quiet
    var attributeBindings = opt.attributes

    var vertSrc = opt.vertex || defaultVertex
    var fragSrc = opt.fragment || defaultFragment

    // re-compile source
    vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertSrc, quiet, name)
    fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragSrc, quiet, name)

    // re-link
    var shaders = [ vertexShader, fragmentShader ]
    linkShaders(gl, program, shaders, attributeBindings, quiet, name)

    // extract uniforms and attributes
    types = extract(gl, program)

    // allow user to inject some dummy uniforms
    if (opt.uniforms) {
      var inactiveUniforms = []
      opt.uniforms.forEach(function (uniform) {
        if (indexOfName(types.uniforms, uniform.name) === -1) {
          inactiveUniforms.push(uniform)
          types.uniforms.push({ name: uniform.name, type: uniform.type })
        }
      })

      // provide UX for inactive uniforms...? TBD
      if (!quiet && inactiveUniforms.length > 0) {
        var shaderName = name ? (' (' + name + ')') : ''
        console.warn('Inactive uniforms in shader' + shaderName + ': '
          + inactiveUniforms
            .map(function (x) { return x.name })
            .join(', '))
      }
    }

    // normalize sort order by name across Chrome / FF
    types.uniforms.sort(compareString)
    types.attributes.sort(compareString)

    // provide optimized getters/setters
    uniforms = reflect(types.uniforms, function (uniform, index) {
      return makeUniformProp(uniform, index)
    })

    // provide attribute locations and type
    // (GLSL ES does not support array/struct attributes)
    attributes = types.attributes.reduce(function (struct, attrib) {
      var name = attrib.name
      struct[name] = {
        size: dimension(attrib.type),
        type: attrib.type,
        location: gl.getAttribLocation(program, name)
      }
      return struct
    }, {})
  }
1095123
public void onAttach(GVRSceneObject sceneObj)
    {
        super.onAttach(sceneObj);
        GVRComponent comp = getComponent(GVRRenderData.getComponentType());

        if (comp == null)
        {
            throw new IllegalStateException("Cannot attach a morph to a scene object without a base mesh");
        }

        GVRMesh mesh = ((GVRRenderData) comp).getMesh();
        if (mesh == null)
        {
            throw new IllegalStateException("Cannot attach a morph to a scene object without a base mesh");
        }
        GVRShaderData mtl = getMaterial();

        if ((mtl == null) ||
            !mtl.getTextureDescriptor().contains("blendshapeTexture"))
        {
            throw new IllegalStateException("Scene object shader does not support morphing");
        }
        copyBaseShape(mesh.getVertexBuffer());
        mtl.setInt("u_numblendshapes", mNumBlendShapes);
        mtl.setFloatArray("u_blendweights", mWeights);
    }
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 ] );

			}

		}
1300230
function initBuffers() {

  // Create a buffer for the cube's vertices.

  cubeVerticesBuffer = gl.createBuffer();

  // Select the cubeVerticesBuffer as the one to apply vertex
  // operations to from here out.

  gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesBuffer);

  // Now create an array of vertices for the cube.

  var vertices = [
    // Front face
    -1.0, -1.0,  1.0,
     1.0, -1.0,  1.0,
     1.0,  1.0,  1.0,
    -1.0,  1.0,  1.0,

    // Back face
    -1.0, -1.0, -1.0,
    -1.0,  1.0, -1.0,
     1.0,  1.0, -1.0,
     1.0, -1.0, -1.0,

    // Top face
    -1.0,  1.0, -1.0,
    -1.0,  1.0,  1.0,
     1.0,  1.0,  1.0,
     1.0,  1.0, -1.0,

    // Bottom face
    -1.0, -1.0, -1.0,
     1.0, -1.0, -1.0,
     1.0, -1.0,  1.0,
    -1.0, -1.0,  1.0,

    // Right face
     1.0, -1.0, -1.0,
     1.0,  1.0, -1.0,
     1.0,  1.0,  1.0,
     1.0, -1.0,  1.0,

    // Left face
    -1.0, -1.0, -1.0,
    -1.0, -1.0,  1.0,
    -1.0,  1.0,  1.0,
    -1.0,  1.0, -1.0
  ];

  // Now pass the list of vertices into WebGL to build the shape. We
  // do this by creating a Float32Array from the JavaScript array,
  // then use it to fill the current vertex buffer.

  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);

  // Now set up the colors for the faces. We'll use solid colors
  // for each face.

  var colors = [
    [1.0,  1.0,  1.0,  1.0],    // Front face: white
    [1.0,  0.0,  0.0,  1.0],    // Back face: red
    [0.0,  1.0,  0.0,  1.0],    // Top face: green
    [0.0,  0.0,  1.0,  1.0],    // Bottom face: blue
    [1.0,  1.0,  0.0,  1.0],    // Right face: yellow
    [1.0,  0.0,  1.0,  1.0]     // Left face: purple
  ];

  // Convert the array of colors into a table for all the vertices.

  var generatedColors = [];

  for (j=0; j<6; j++) {
    var c = colors[j];

    // Repeat each color four times for the four vertices of the face

    for (var i=0; i<4; i++) {
      generatedColors = generatedColors.concat(c);
    }
  }

  cubeVerticesColorBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesColorBuffer);
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(generatedColors), gl.STATIC_DRAW);

  // Build the element array buffer; this specifies the indices
  // into the vertex array for each face's vertices.

  cubeVerticesIndexBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVerticesIndexBuffer);

  // This array defines each face as two triangles, using the
  // indices into the vertex array to specify each triangle's
  // position.

  var cubeVertexIndices = [
    0,  1,  2,      0,  2,  3,    // front
    4,  5,  6,      4,  6,  7,    // back
    8,  9,  10,     8,  10, 11,   // top
    12, 13, 14,     12, 14, 15,   // bottom
    16, 17, 18,     16, 18, 19,   // right
    20, 21, 22,     20, 22, 23    // left
  ]

  // Now send the element array to GL

  gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,
      new Uint16Array(cubeVertexIndices), gl.STATIC_DRAW);
}
439141
function() {
        var gl = this.context;
        gl.useProgram(this.shader);
        gl.bindBuffer(gl.ARRAY_BUFFER, this._attributeBuffer);
        var a,
            attributes = this.attributes;
        // Process every attribute
        for (var i = 0; i < attributes.length; i++) {
            a = attributes[i];
            gl.vertexAttribPointer(
                a.location,
                a.width,
                a.type,
                false,
                this.stride * a.bytes,
                a.offset * a.bytes
            );
        }

        // For now, special case the need for texture objects
        var t = this.texture_obj;
        if (t && t.unit === null) {
            this.layer.texture_manager.bindTexture(t);
        }

        this.index_pointer = 0;
    }
836627
private void bind() {
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, FBO);
		GL11.glReadBuffer(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT);
	}
1225979
function (data) {
    this.material = new THREE.MeshStandardMaterial(getMaterialData(data));
    utils.material.updateMap(this, data);
    if (data.normalMap) { utils.material.updateDistortionMap('normal', this, data); }
    if (data.displacementMap) { utils.material.updateDistortionMap('displacement', this, data); }
    if (data.ambientOcclusionMap) { utils.material.updateDistortionMap('ambientOcclusion', this, data); }
    if (data.metalnessMap) { utils.material.updateDistortionMap('metalness', this, data); }
    if (data.roughnessMap) { utils.material.updateDistortionMap('roughness', this, data); }
    this.updateEnvMap(data);
	this.material.onBeforeCompile = function ( shader ) {
		shader.uniforms.tileData = State.tileData;
		shader.uniforms.tileTexture = State.tileTexture;
		shader.uniforms.lightTexture = State.lightTexture;
		shader.defines[ 'TILED_FORWARD' ] = 1;  
	}
  }
995093
def bind(self):
        """"""
        # This is called simply to deal with anything that might be currently bound (for example, Pyglet objects),
        gl.glBindTexture(gl.GL_TEXTURE_2D, 0)

        # Store current viewport size for later
        self._old_viewport = get_viewport()

        # Bind the FBO, and change the viewport to fit its texture.
        gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, self.id)  # Rendering off-screen
        gl.glViewport(0, 0, self.texture.width, self.texture.height)
70865
def _init_filled_edges(self, renderer, properties, edge_mapping):
        ""
        glyph_model = Patches if self.filled else Bezier
        allowed_properties = glyph_model.properties()
        for glyph_type in ('', 'selection_', 'nonselection_', 'hover_', 'muted_'):
            glyph = getattr(renderer.edge_renderer, glyph_type+'glyph', None)
            if glyph is None:
                continue
            group_properties = dict(properties)
            props = self._process_properties(self.edge_glyph, group_properties, {})
            filtered = self._filter_properties(props, glyph_type, allowed_properties)
            new_glyph = glyph_model(**dict(filtered, **edge_mapping))
            setattr(renderer.edge_renderer, glyph_type+'glyph', new_glyph)
1173223
function LGraphTextureEdges() {
            this.addInput("Tex.", "Texture");

            this.addOutput("Edges", "Texture");
            this.properties = {
                invert: true,
                threshold: false,
                factor: 1,
                precision: LGraphTexture.DEFAULT
            };

            if (!LGraphTextureEdges._shader) {
                LGraphTextureEdges._shader = new GL.Shader(
                    Shader.SCREEN_VERTEX_SHADER,
                    LGraphTextureEdges.pixel_shader
                );
            }
        }
1370337
function( gl, v, renderer ) {

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

		}