Exemple #1
0
		public void Configure (ImageView renderView)
		{
			renderView.DepthPixelFormat = depthPixelFormat;
			renderView.StencilPixelFormat = stencilPixelFormat;
			renderView.SampleCount = sampleCount;

			// we need to set the framebuffer only property of the layer to NO so we
			// can perform compute on the drawable's texture
			var metalLayer = (CAMetalLayer)renderView.Layer;
			metalLayer.FramebufferOnly = false;

			if (!PreparePipelineState ())
				throw new ApplicationException ("ERROR: Failed creating a depth stencil state descriptor!");

			if (!PrepareTexturedQuad ("Default", "jpg"))
				throw new ApplicationException ("ERROR: Failed creating a textured quad!");

			if (!PrepareDepthStencilState ())
				throw new ApplicationException ("ERROR: Failed creating a depth stencil state!");

			if (!PrepareTransformBuffer ())
				throw new ApplicationException ("ERROR: Failed creating a transform buffer!");

			// Default orientation is unknown
			mnOrientation = UIInterfaceOrientation.Unknown;

			// Create linear transformation matrices
			PrepareTransforms ();
		}
Exemple #2
0
		public void Reshape (ImageView view)
		{
			// To correctly compute the aspect ration determine the device
			// interface orientation.
			UIInterfaceOrientation orientation = UIApplication.SharedApplication.StatusBarOrientation;

			// Update the quad and linear _transformation matrices, if and
			// only if, the device orientation is changed.
			if (mnOrientation == orientation)
				return;

			float angleInDegrees = GetActualAngle (orientation, view.Layer.Bounds);
			CreateMatrix (angleInDegrees);
			UpdateBuffer ();
		}
Exemple #3
0
		public void Render (ImageView view)
		{
			inflightSemaphore.WaitOne ();
			IMTLCommandBuffer commandBuffer = commandQueue.CommandBuffer ();

			// compute image processing on the (same) drawable texture
			ICAMetalDrawable drawable = view.GetNextDrawable ();

			// create a render command encoder so we can render into something
			MTLRenderPassDescriptor renderPassDescriptor = view.GetRenderPassDescriptor (drawable);

			if (renderPassDescriptor == null) {
				inflightSemaphore.Release ();
				return;
			}

			// Get a render encoder
			IMTLRenderCommandEncoder renderEncoder = commandBuffer.CreateRenderCommandEncoder (renderPassDescriptor);

			// render textured quad
			Encode (renderEncoder);

			commandBuffer.AddCompletedHandler ((IMTLCommandBuffer buffer) => {
				inflightSemaphore.Release ();
				drawable.Dispose ();
			});

			commandBuffer.PresentDrawable (drawable);
			commandBuffer.Commit ();
		}