This function takes care of setting the shading code and
        compiling+linking it into a working program object that is ready
        to use.
172196
def set_shaders(self, vert, frag):
        
        self._linked = False
        # Create temporary shader objects
        vert_handle = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        frag_handle = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
        # For both vertex and fragment shader: set source, compile, check
        for code, handle, type_ in [(vert, vert_handle, 'vertex'),
                                    (frag, frag_handle, 'fragment')]:
            gl.glShaderSource(handle, code)
            gl.glCompileShader(handle)
            status = gl.glGetShaderParameter(handle, gl.GL_COMPILE_STATUS)
            if not status:
                errors = gl.glGetShaderInfoLog(handle)
                errormsg = self._get_error(code, errors, 4)
                raise RuntimeError("Shader compilation error in %s:\n%s" %
                                   (type_ + ' shader', errormsg))
        # Attach shaders
        gl.glAttachShader(self._handle, vert_handle)
        gl.glAttachShader(self._handle, frag_handle)
        # Link the program and check
        gl.glLinkProgram(self._handle)
        if not gl.glGetProgramParameter(self._handle, gl.GL_LINK_STATUS):
            raise RuntimeError('Program linking error:\n%s'
                               % gl.glGetProgramInfoLog(self._handle))
        # Now we can remove the shaders. We no longer need them and it
        # frees up precious GPU memory:
        # http://gamedev.stackexchange.com/questions/47910
        gl.glDetachShader(self._handle, vert_handle)
        gl.glDetachShader(self._handle, frag_handle)
        gl.glDeleteShader(vert_handle)
        gl.glDeleteShader(frag_handle)
        # Now we know what variables will be used by the program
        self._unset_variables = self._get_active_attributes_and_uniforms()
        self._handles = {}
        self._known_invalid = set()
        self._linked = True
1117682
function shadedRectangle( $x1, $y1, $width, $height, $options )
    {
        $this->numObj++;
        $shadingLabel = $this->o_shading( $this->numObj, 'new', $options );

        $this->saveState();

        $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F',$x1).' '.sprintf('%.3F',$y1).' '.sprintf('%.3F',$width).' '.sprintf('%.3F',$height).' re';

        $this->objects[$this->currentContents]['c'].="\nW n";

        $this->objects[$this->currentContents]['c'].="\n/".$shadingLabel.' sh';

        $this->restoreState();
    }
1047364
public void bind() {
        program.use();
        if (textures != null) {
            final TIntObjectIterator<Texture> iterator = textures.iterator();
            while (iterator.hasNext()) {
                iterator.advance();
                // Bind the texture to the unit
                final int unit = iterator.key();
                iterator.value().bind(unit);
                // Bind the shader sampler uniform to the unit
                program.bindSampler(unit);
            }
        }
    }
1023256
def _compilecode(function, name, impl, args, varargs, kwargs):
    

    newcodestr, generatedname, impl_name = _generatecode(
        function=function, name=name, impl=impl,
        args=args, varargs=varargs, kwargs=kwargs
    )

    try:
        __file__ = getfile(function)
    except TypeError:
        __file__ = '<string>'

    # compile newcodestr
    code = compile(newcodestr, __file__, 'single')

    # define the code with the new function
    _globals = {}
    exec_(code, _globals)

    # get new code
    _var = _globals[generatedname]
    newco = get_function_code(_var)

    # get new consts list
    newconsts = list(newco.co_consts)

    if PY3:
        newcode = list(newco.co_code)
    else:
        newcode = [ord(co) for co in newco.co_code]

    consts_values = {impl_name: impl}

    # change LOAD_GLOBAL to LOAD_CONST
    index = 0
    newcodelen = len(newcode)
    while index < newcodelen:
        if newcode[index] == LOAD_GLOBAL:
            oparg = newcode[index + 1] + (newcode[index + 2] << 8)
            name = newco.co_names[oparg]
            if name in consts_values:
                const_value = consts_values[name]
                if const_value in newconsts:
                    pos = newconsts.index(const_value)
                else:
                    pos = len(newconsts)
                    newconsts.append(consts_values[name])
                newcode[index] = LOAD_CONST
                newcode[index + 1] = pos & 0xFF
                newcode[index + 2] = pos >> 8
        index += 1

    codeobj = getcodeobj(newconsts, newcode, newco, get_function_code(function))
    # instanciate a new function
    if function is None or isbuiltin(function):
        result = FunctionType(codeobj, {})

    else:
        result = type(function)(
            codeobj,
            get_function_globals(function),
            function.__name__,
            get_function_defaults(function),
            get_function_closure(function)
        )

    return result
341524
function compile(code, filename, options) {
  options = defaults(options || {}, {
    embedSourceMaps: true,
    bareModule: false,
    color: false
  });
  if (arguments.length !== compile.length) {
    throw new Error("incorrect argument count to compile");
  }
  var result = parse(ensureNewline(code));
  if (!result.status) {
    var expectations = uniq(result.expected);
    var data = "expected one of " + expectations.join(", ");
    var index = Math.min(result.index, code.length - 1);
    var oopsyInput = {index: index, data: data};
    var oopsies =
      OopsyData.fromIndices(code, [oopsyInput], {color: options.color});
    return {
      parsed: false,
      result: {
        expectations: expectations,
        oopsy: oopsies[0]
      }
    };
  }
  var squiggleAst = result.value;
  squiggleAst.bareModule = options.bareModule;
  var warnings = lint(squiggleAst);
  var contextualWarnings =
    OopsyData.fromLocations(code, warnings, {color: options.color});
  var esAst = transformAst(squiggleAst);
  var mangledAst = SHOULD_MANGLE ?
    esmangle.optimize(esAst) :
    esAst;
  var optimizedAst = SHOULD_OPTIMIZE ?
    optimize(mangledAst) :
    mangledAst;
  var stuff = generateCodeAndSourceMap(
    optimizedAst, filename, code);
  var js = ensureNewline(stuff.code);
  var sourceMap = stuff.map.toString();
  if (options.embedSourceMaps) {
    js = addSourceMapUrl(js, sourceMap);
  }
  return {
    parsed: true,
    warnings: contextualWarnings,
    sourceMap: sourceMap,
    code: js
  };
}
514252
def _patch():
    
    import sys
    from OpenGL import GL
    if sys.version_info > (3,):
        buffersubdatafunc = GL.glBufferSubData
        if hasattr(buffersubdatafunc, 'wrapperFunction'):
            buffersubdatafunc = buffersubdatafunc.wrapperFunction
        _m = sys.modules[buffersubdatafunc.__module__]
        _m.long = int
    
    # Fix missing enum
    try:
        from OpenGL.GL.VERSION import GL_2_0
        GL_2_0.GL_OBJECT_SHADER_SOURCE_LENGTH = GL_2_0.GL_SHADER_SOURCE_LENGTH
    except Exception:
        pass
1290547
function compileShader(gl, src, type) {
  const shader = gl.createShader(type);

  gl.shaderSource(shader, src);

  // Compile and check status
  gl.compileShader(shader);
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
    // Something went wrong during compilation; get the error
    const lastError = gl.getShaderInfoLog(shader);
    console.error(`Error compiling shader '${shader}': ${lastError}`);
    gl.deleteShader(shader);

    return null;
  }

  return shader;
}
36167
def makefig(code, code_path, output_dir, output_base, config):
    

    # -- Parse format list
    default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 50}
    formats = []
    for fmt in config.plot_formats:
        if isinstance(fmt, str):
            formats.append((fmt, default_dpi.get(fmt, 80)))
        elif type(fmt) in (tuple, list) and len(fmt)==2:
            formats.append((str(fmt[0]), int(fmt[1])))
        else:
            raise PlotError('invalid image format "%r" in plot_formats' % fmt)

    # -- Try to determine if all images already exist

    code_pieces = split_code_at_show(code)

    # Look for single-figure output files first
    all_exists = True
    img = ImageFile(output_base, output_dir)
    for format, dpi in formats:
        if out_of_date(code_path, img.filename(format)):
            all_exists = False
            break
        img.formats.append(format)

    if all_exists:
        return [(code, [img])]

    # Then look for multi-figure output files
    results = []
    all_exists = True
    for i, code_piece in enumerate(code_pieces):
        images = []
        for j in range(1000):
            img = ImageFile('%s_%02d_%02d' % (output_base, i, j), output_dir)
            for format, dpi in formats:
                if out_of_date(code_path, img.filename(format)):
                    all_exists = False
                    break
                img.formats.append(format)

            # assume that if we have one, we have them all
            if not all_exists:
                all_exists = (j > 0)
                break
            images.append(img)
        if not all_exists:
            break
        results.append((code_piece, images))

    if all_exists:
        return results

    # -- We didn't find the files, so build them

    results = []
    ns = {}

    for i, code_piece in enumerate(code_pieces):
        # Clear between runs
        plt.close('all')

        # Run code
        run_code(code_piece, code_path, ns)

        # Collect images
        images = []
        fig_managers = _pylab_helpers.Gcf.get_all_fig_managers()
        for j, figman in enumerate(fig_managers):
            if len(fig_managers) == 1 and len(code_pieces) == 1:
                img = ImageFile(output_base, output_dir)
            else:
                img = ImageFile("%s_%02d_%02d" % (output_base, i, j),
                                output_dir)
            images.append(img)
            for format, dpi in formats:
                try:
                    figman.canvas.figure.savefig(img.filename(format), dpi=dpi)
                except exceptions.BaseException as err:
                    raise PlotError(traceback.format_exc())
                img.formats.append(format)

        # Results
        results.append((code_piece, images))

    return results
886616
function( program ){
    var gl = this.gl;
    gl.bindBuffer( TGT, this.buffer );

    for (var i = 0; i < this.attribs.length; i++) {
      var attrib = this.attribs[i];

      if( program[attrib.name] !== undefined ){
        var aLocation = program[attrib.name]();
        gl.enableVertexAttribArray( aLocation );
        gl.vertexAttribPointer( aLocation,
                                attrib.size,
                                attrib.type,
                                attrib.normalize,
                                this.stride,
                                attrib.offset
                              );
      }

    }
  }
343489
function compile(code, options) {
        var output;
        options = options || {};
        options.requireModule = options.requireModule || requireModule;
        var ast = parse(code, options.modules || [], options);
        if (options.readableNames) {
            ast = optimizeHygiene(ast);
        }
        if (options.ast) {
            return ast;
        }
        if (options.sourceMap) {
            output = codegen.generate(ast, _.extend({
                comment: true,
                sourceMap: options.filename,
                sourceMapWithCode: true
            }, options.escodegen));
            return {
                code: output.code,
                sourceMap: output.map.toString()
            };
        }
        return { code: codegen.generate(ast, _.extend({ comment: true }, options.escodegen)) };
    }
842535
function compileProgram(gl, vertex, fragment) {
       var vertShader = compileShader(gl, gl.VERTEX_SHADER, vertex);
       var fragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragment);
       var program = gl.createProgram();
       gl.attachShader(program, vertShader);
       gl.attachShader(program, fragShader);
       gl.linkProgram(program);

       if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
         throw new Error("Error initializing Shader " + this + "\n" + "gl.VALIDATE_STATUS: " + gl.getProgramParameter(program, gl.VALIDATE_STATUS) + "\n" + "gl.getError()" + gl.getError() + "\n" + "gl.getProgramInfoLog()" + gl.getProgramInfoLog(program));
       }

       gl.useProgram(program); // clean-up

       gl.deleteShader(vertShader);
       gl.deleteShader(fragShader);
       return program;
     }
762272
function Renderer(opts) {
  this.entities = []
  this.root = this.entity()

  // check if we passed gl context or options object
  opts = opts.texture2D ? { ctx: opts } : opts

  const ctx = (this._ctx = opts.ctx)

  const gl = opts.ctx.gl
  gl.getExtension('OES_standard_derivatives')

  this._dummyTexture2D = ctx.texture2D({ width: 4, height: 4 })
  this._dummyTextureCube = ctx.textureCube({ width: 4, height: 4 })

  this._debug = false
  this._programCacheMap = {
    values: [],
    getValue: function(flags, vert, frag) {
      for (var i = 0; i < this.values.length; i++) {
        var v = this.values[i]
        if (v.frag === frag && v.vert === vert) {
          if (v.flags.length === flags.length) {
            var found = true
            for (var j = 0; j < flags.length; j++) {
              if (v.flags[j] !== flags[j]) {
                found = false
                break
              }
            }
            if (found) {
              return v.program
            }
          }
        }
      }
      return false
    },
    setValue: function(flags, vert, frag, program) {
      this.values.push({ flags, vert, frag, program })
    }
  }

  if (opts.profile) {
    State.profiler = createProfiler(opts.ctx, this)
    State.profiler.flush = opts.profileFlush
  }

  if (opts.pauseOnBlur && isBrowser) {
    window.addEventListener('focus', () => {
      State.paused = false
    })
    window.addEventListener('blur', () => {
      State.paused = true
    })
  }

  // TODO: move from State object to internal probs and renderer({ opts }) setter?
  Object.assign(State, opts)
  this._state = State

  this.shaders = {
    chunks: SHADERS_CHUNKS,
    pipeline: {
      material: {
        vert: PBR_VERT,
        frag: PBR_FRAG
      }
    }
  }
}
594876
function start(CB, env) {

    var app = this;

    /*
     |--------------------------------------------------------------------------
     | Register The Environment Variables
     |--------------------------------------------------------------------------
     |
     | Here we will register all of the ENV variables into the
     | process so that they're globally available configuration options so
     | sensitive configuration information can be swept out of the code.
     |
     */
    (new EnvironmentVariables(app.getEnvironmentVariablesLoader())).load(env);

    /*
     |--------------------------------------------------------------------------
     | Register The Configuration Repository
     |--------------------------------------------------------------------------
     |
     | The configuration repository is used to lazily load in the options for
     | this application from the configuration files. The files are easily
     | separated by their concerns so they do not become really crowded.
     |
     */
    app.config = new Config(
        app.getConfigLoader(), env
    );

    // Set additional configurations
    app.config.set('cache.etagFn', utils.compileETag(app.config.get('cache').etag));
    app.config.set('middleware.queryParserFn', utils.compileQueryParser(app.config.get('middleware').queryParser));
    app.config.set('request.trustProxyFn', utils.compileTrust(app.config.get('request').trustProxy));

    // Expose use method globally
    global.use = app.use.bind(app);

    // Register user aliases for Positron modules
    app.alias(app.config.get('app.aliases', {}));

    /*
     |--------------------------------------------------------------------------
     | Register Booted Start Files & Expose Globals
     |--------------------------------------------------------------------------
     |
     | Once the application has been booted we will expose app globals as per
     | user configuration. Also there are several "start" files
     | we will want to include. We'll register our "booted" handler here
     | so the files are included after the application gets booted up.
     |
     */
    app.booted(function() {
        // expose app globals
        app.exposeGlobals();

        /*
         |--------------------------------------------------------------------------
         | Load The Application Start Script
         |--------------------------------------------------------------------------
         |
         | The start scripts gives this application the opportunity to do things
         | that should be done right after application has booted like configure
         | application logger, load filters etc. We'll load it here.
         |
         */
        var appStartScript = app.path.app + "/start/global.js";


        /*
         |--------------------------------------------------------------------------
         | Load The Environment Start Script
         |--------------------------------------------------------------------------
         |
         | The environment start script is only loaded if it exists for the app
         | environment currently active, which allows some actions to happen
         | in one environment while not in the other, keeping things clean.
         |
         */
        var envStartScript = app.path.app + "/start/" + env + ".js";


        /*
         |--------------------------------------------------------------------------
         | Load The Application Routes
         |--------------------------------------------------------------------------
         |
         | The Application routes are kept separate from the application starting
         | just to keep the file a little cleaner. We'll go ahead and load in
         | all of the routes now and return the application to the callers.
         |
         */
        var routes = app.path.app + "/routes.js";

        async.filter([appStartScript, envStartScript, routes], fs.exists, function (results) {
            results.forEach(function (path) {
                require(path);
            });

            CB(app);
        });
    });

    /*
     |--------------------------------------------------------------------------
     | Register The Core Service Providers
     |--------------------------------------------------------------------------
     |
     | The Positron core service providers register all of the core pieces
     | of the Positron framework including session, auth, encryption
     | and more. It's simply a convenient wrapper for the registration.
     |
     */
    var providers = app.config.get('app').providers;

    app.getProviderRepository().load(providers, function() {

        /*
         |--------------------------------------------------------------------------
         | Boot The Application
         |--------------------------------------------------------------------------
         |
         | Once all service providers are loaded we will  call the boot method on
         | application which will boot all service provider's and eventually boot the
         | positron application.
         |
         */
        app.boot();
    });

}
493169
function createProgram(shaderArray) {
			var newProgram = glContext.createProgram();

			for (var shaderIndex = 0; shaderIndex < shaderArray.length; ++shaderIndex) {
					glContext.attachShader(newProgram, shaderArray[shaderIndex]);
			}
			glContext.linkProgram(newProgram);

			// Check for errors during linking
			var status = glContext.getProgramParameter(newProgram, glContext.LINK_STATUS);
			if (!status) {
					var infoLog = glContext.getProgramInfoLog(newProgram);
					console.log("Unable to link Kinect WebGL program. Error:" + infoLog);
					glContext.deleteProgram(newProgram);
					return null;
			}

			return newProgram;
	}
607200
function postprocessProgram(program) {
      var body = program.body;

      if (body.length === 0) {
        return;
      }

      if (usesMorph(body[0])) {
        body.unshift(buildText(''));
      }

      if (usesMorph(body[body.length-1])) {
        body.push(buildText(''));
      }
    }
1082074
def main():
    """"""
    util.create_dir(os.path.join(CONF_DIR, "templates"))
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/light/"))
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/dark/"))

    util.setup_logging()
    parser = get_args()

    parse_args_exit(parser)
    parse_args(parser)
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;
    }