             ColourPipelineDescriptor.fragmentFunction = fragmentProgram
             ColourPipelineDescriptor.vertexDescriptor = RectDescriptor
 
+		var pipeline_err:NSError?
         self.colourPipeline = device!.newRenderPipelineStateWithDescriptor(
-            ColourPipelineDescriptor, error: nil)
+            ColourPipelineDescriptor, error: &pipeline_err)
 
         if (colourPipeline == nil)
         {
             println("colourPipeline")
         }
+        if (pipeline_err != nil)
+        {
+            println("pipeline_err = \(pipeline_err)")
+        }
         //-----------------------------------------------------------
         // compute pipeline state.
         //-----------------------------------------------------------
+        var pipeline_error:NSError?
         let computeFunction = defaultLibrary!.newFunctionWithName("CheckerKernel")
         self.checkerPipeline = device!.newComputePipelineStateWithFunction(
-              computeFunction!, error:nil)
+              computeFunction!, error:&pipeline_error)
 
         if (checkerPipeline == nil)
         {
             println("checkerPipeline")
+        }
+        if (pipeline_error != nil)
+        {
+            println("pipeline_error = \(pipeline_error)")
         }
         //-----------------------------------------------------------
         // fill in BufferData.

        //-----------------------------------------------------------
        let TexCoordDescriptor = MTLVertexAttributeDescriptor()
        TexCoordDescriptor.format = MTLVertexFormat.Float2
        TexCoordDescriptor.offset = sizeof(V2f)  // offsetof(VertexData, texCoord)
        TexCoordDescriptor.bufferIndex = 0
        //
        //-----------------------------------------------------------
        // Layout descriptor for Vertex Data.
        //-----------------------------------------------------------
        let LayoutDescriptor = MTLVertexBufferLayoutDescriptor()
        LayoutDescriptor.stride = sizeof(VertexData)
        LayoutDescriptor.stepFunction = MTLVertexStepFunction.PerVertex
        LayoutDescriptor.stepRate = 1
        //

        //-----------------------------------------------------------
        // vertex descriptor for Rect.
        //-----------------------------------------------------------
        let RectDescriptor = MTLVertexDescriptor()
        RectDescriptor.attributes[0] = PositionDescriptor

        self.data = device.newBufferWithLength(sizeof(BufferDataB),
                    options:MTLResourceOptions.OptionCPUCacheModeDefault)

        println("sizeof(PointData) = \(sizeof(PointData))")
        println("sizeof(BufferDataB) = \(sizeof(BufferDataB))")

        let bufferPointer = data?.contents()
