MCPcopy Create free account
hub / github.com/nwutils/nw-sample-apps / buildProgram

Function buildProgram

webgl/js/three.min.js:20511–20796  ·  view source on GitHub ↗
( shaderID, fragmentShader, vertexShader, uniforms, attributes, parameters )

Source from the content-addressed store, hash-verified

20509 // Shaders
20510
20511 function buildProgram ( shaderID, fragmentShader, vertexShader, uniforms, attributes, parameters ) {
20512
20513 var p, pl, program, code;
20514 var chunks = [];
20515
20516 // Generate code
20517
20518 if ( shaderID ) {
20519
20520 chunks.push( shaderID );
20521
20522 } else {
20523
20524 chunks.push( fragmentShader );
20525 chunks.push( vertexShader );
20526
20527 }
20528
20529 for ( p in parameters ) {
20530
20531 chunks.push( p );
20532 chunks.push( parameters[ p ] );
20533
20534 }
20535
20536 code = chunks.join();
20537
20538 // Check if code has been already compiled
20539
20540 for ( p = 0, pl = _programs.length; p < pl; p ++ ) {
20541
20542 var programInfo = _programs[ p ];
20543
20544 if ( programInfo.code === code ) {
20545
20546 // console.log( "Code already compiled." /*: \n\n" + code*/ );
20547
20548 programInfo.usedTimes ++;
20549
20550 return programInfo.program;
20551
20552 }
20553
20554 }
20555
20556 //console.log( "building new program " );
20557
20558 //
20559
20560 program = _gl.createProgram();
20561
20562 var prefix_vertex = [
20563
20564 "precision " + _precision + " float;",
20565
20566 _supportsVertexTextures ? "#define VERTEX_TEXTURES" : "",
20567
20568 _this.gammaInput ? "#define GAMMA_INPUT" : "",

Callers 1

three.min.jsFile · 0.85

Calls 3

getShaderFunction · 0.85
cacheUniformLocationsFunction · 0.85
cacheAttributeLocationsFunction · 0.85

Tested by

no test coverage detected