public void Update(CommandBucket commandBucket) { var cube = commandBucket.AddCommand(2); cube.SetShaderProgram(program); cube.SetVertexBuffer(_vb); cube.SetIndexBuffer(_ib); cube.SetSharedUniforms(_ub); cube.SetRasteriserState(rasteriserState); cube.SetTexture(0, texture, colourMapUniform, textureSampler); cube.SetTransform((Nml.Matrix4x4.Translate(new Nml.Vector3(z: -1.0f)) * Nml.Matrix4x4.RotateY(-0.5f)).ToArray()); }
public void Update(CommandBucket commandBucket) { // Draw a single triangle var tri = commandBucket.AddCommand(0); tri.SetShaderProgram(program); tri.SetVertexBuffer(_vb); tri.SetPrimitiveType(PrimitiveType.Triangles); tri.SetTransform(Nml.Matrix4x4.Translate(new Nml.Vector3(x: -2.0f)).ToArray()); tri.SetSharedUniforms(defaultUniforms); // Draw a square using triangle strips var triStrip = commandBucket.AddCommand(0); triStrip.SetShaderProgram(program); triStrip.SetVertexBuffer(_vb); triStrip.SetPrimitiveType(PrimitiveType.TriangleStrip); triStrip.SetTransform(Nml.Matrix4x4.Translate(new Nml.Vector3(x: -0.9f)).ToArray()); triStrip.SetSharedUniforms(defaultUniforms); // Draw 2 vertical lines var lines = commandBucket.AddCommand(0); lines.SetShaderProgram(program); lines.SetVertexBuffer(_vb); lines.SetPrimitiveType(PrimitiveType.Lines); lines.SetTransform(Nml.Matrix4x4.Translate(new Nml.Vector3(x: 0.2f)).ToArray()); lines.SetSharedUniforms(defaultUniforms); // Draw connected lines var lineStrip = commandBucket.AddCommand(0); lineStrip.SetShaderProgram(program); lineStrip.SetVertexBuffer(_vb); lineStrip.SetPrimitiveType(PrimitiveType.LineStrip); lineStrip.SetTransform(Nml.Matrix4x4.Translate(new Nml.Vector3(y: -1.1f)).ToArray()); lineStrip.SetSharedUniforms(defaultUniforms); // Draw points var points = commandBucket.AddCommand(0); points.SetShaderProgram(program); points.SetVertexBuffer(_vb); points.SetPrimitiveType(PrimitiveType.Points); points.SetTransform(Nml.Matrix4x4.Translate(new Nml.Vector3(x: -1.2f, y: -1.1f)).ToArray()); points.SetSharedUniforms(defaultUniforms); }
public void Update(CommandBucket commandBucket) { // Draw the translucent cube second var transluscentCube = commandBucket.AddCommand(2); transluscentCube.SetShaderProgram(program); transluscentCube.SetBlendState(_bs); transluscentCube.SetVertexBuffer(_vb); transluscentCube.SetIndexBuffer(_ib); transluscentCube.SetSharedUniforms(_translucent); transluscentCube.SetTransform(Nml.Matrix4x4.Translate(new Nml.Vector3(z: 1.0f)).ToArray()); // Draw the opaque cube first var opaqueCube = commandBucket.AddCommand(1); opaqueCube.SetShaderProgram(program); opaqueCube.SetVertexBuffer(_vb); opaqueCube.SetIndexBuffer(_ib); opaqueCube.SetSharedUniforms(_opaque); opaqueCube.SetTransform(Nml.Matrix4x4.Translate(new Nml.Vector3(x: -0.4f)).ToArray()); }