Exemplo n.º 1
0
		public void SetOverlayGeometry(D3D10OverlayContext overlayGeometry)
		{
			_overlayGeometry = overlayGeometry;
			BringOverlayGeometryIntoDeviceBuffers(overlayGeometry);
		}
Exemplo n.º 2
0
		private void BringOverlayGeometryIntoDeviceBuffers(D3D10OverlayContext overlayGeometry)
		{
			Device device = _hostDevice;
			if (device == null)
				return;

			// ------------------  Triangle buffer ------------------------------------
			{
				var buf = (PositionColorIndexedTriangleBuffer)overlayGeometry.PositionColorIndexedTriangleBuffers;

				var vertexBuffer = Buffer.Create<float>(device, buf.VertexStream, new BufferDescription()
				{
					BindFlags = BindFlags.VertexBuffer,
					CpuAccessFlags = CpuAccessFlags.None,
					OptionFlags = ResourceOptionFlags.None,
					SizeInBytes = buf.VertexStreamLength,
					Usage = ResourceUsage.Default
				});

				var indexBuffer = Buffer.Create<int>(device, buf.IndexStream, new BufferDescription()
				{
					BindFlags = BindFlags.IndexBuffer,
					CpuAccessFlags = CpuAccessFlags.None,
					OptionFlags = ResourceOptionFlags.None,
					SizeInBytes = buf.IndexStreamLength,
					Usage = ResourceUsage.Default
				});
				var indexCount = buf.TriangleCount * 3;

				var devBuffer = new VertexAndIndexDeviceBufferNoMaterial { VertexBuffer = vertexBuffer, VertexCount = buf.VertexCount, IndexBuffer = indexBuffer, IndexCount = indexCount };

				var oldBuffer = System.Threading.Interlocked.Exchange(ref _overlayGeometryTriangleDeviceBuffer, devBuffer);

				oldBuffer?.RemoveAndDispose();
			}

			// ------------------  Line list buffer ------------------------------------
			{
				var buf = (PositionColorLineListBuffer)overlayGeometry.PositionColorLineListBuffer;

				var vertexBuffer = Buffer.Create<float>(device, buf.VertexStream, new BufferDescription()
				{
					BindFlags = BindFlags.VertexBuffer,
					CpuAccessFlags = CpuAccessFlags.None,
					OptionFlags = ResourceOptionFlags.None,
					SizeInBytes = buf.VertexStreamLength,
					Usage = ResourceUsage.Default
				});

				var devBuffer = new VertexBufferNoMaterial { VertexBuffer = vertexBuffer, VertexCount = buf.VertexCount };

				var oldBuffer = System.Threading.Interlocked.Exchange(ref _overlayGeometryLineListBuffer, devBuffer);

				oldBuffer?.RemoveAndDispose();
			}
		}
Exemplo n.º 3
0
		internal void SetMarkerGeometry(D3D10OverlayContext markerGeometry)
		{
			_markerGeometry = markerGeometry;
			BringMarkerGeometryIntoDeviceBuffers(markerGeometry);
		}