Friends link: exam 70-450 cert 9a0-125 Adobe 9A0-127 exam Apple 9l0-410 Certification a00-202 Exam dumps IBM a2010-570 Exam dumps Pass A2160-669 Exam asc-029 Exam Dumps BCP-240 Actual Exam ISEB bh0-006 exam
GLOW » Hello Clone!
Parajumpers sale Parajumpers sale http://www.unifem.ch canada goose sale http://www.canadagooseoutlets.be https://www.gasinc.nl Canada Goose jas
2011+06+07

Hello Clone!

This is the second GLOW tutorial where we’ll show how to create many rotating cubes.

You can see the result here. Please view the source and have it at hand when reading this tutorial. Also, please read Hello Cube! before continuing.

After we’ve setup our context and the cube information, we send this to the compiler instead of sending it to a GLOW.Shader. Like this…

var compiled = new GLOW.Compiler.compile( cubeShaderInfo );

And then we use the compiled data to create our cubes…

var cube, cubes = [];
for( var i = 0; i < 1000; i++ ) {
  cube = new GLOW.Shader( { use: compiled,
                            except: {
                              transform: new GLOW.Matrix4() } } );
  cube.transform
      .setPosition( Math.random() * 1000 - 500,
                    Math.random() * 1000 - 500,
                    Math.random() * 1000 - 500 );
  cubes.push( cube );
}

Instead of using the cube information object as parameter to the Shader constructor, we use the compiled version by using the use property. More importantly, we also set an except property, which defines data that we should use instead of the data in the compiled information.

This way it's easy to instantiate shaders and create data that is unique for this instance. The compiled data is also available in the Shader or via the clone function...

var shaderA = new GLOW.Shader( info );
var shaderB = new GLOW.Shader( { use: shaderA.compiledData,
                                 except: {
                                   time: new GLOW.Float(); } } );
var shaderC = shaderB.clone( { time: new GLOW.Float() } );

Note that there's a rotation data property in the example, which is shared for all Shaders. In the update loop we update it in one of the Shaders and as it's shared, all cubes rotates. The render loop...

cubes[ 0 ].rotation.addRotation( 0.01, 0.01, 0.01 );

context.cache.clear();
context.clear();

for( var i = 0; i < cubes.length; i++ ) {
  cubes[ i ].draw();
}

Before you start drawing your shaders, it's important to update your uniforms and clear the cache.