Exemplo n.º 1
0
		public void TestMultiamplingTypes(MultisampleType multisampleType)
		{
			var deviceWorkerSettings = new DeviceWorker.DeviceSettings
				{
					AutoDetermineMultisampleType = false,
					MultisampleType = multisampleType
				};
			DirectXScene scene = null;
			OffscreenDirectXDrawer offscreenDrawer = null;
			try
			{
				var deviceWorker = new DeviceWorker(deviceWorkerSettings);
				using(var renderTarget = deviceWorker.Device.GetRenderTarget(0))
					Assert.AreEqual(multisampleType, renderTarget.Description.MultisampleType);
				scene = new DirectXScene(deviceWorker, _rootBody, null);
				offscreenDrawer = new OffscreenDirectXDrawer(scene, Width, Height, ImageFormat);
				_rootBody.Add(RedBox);
				var camera = new TopViewCamera(new Frame3D(0, 0, 200), Width / Height);
				byte[] bitmapBytes;
				offscreenDrawer.TryGetImage(camera, out bitmapBytes);
				var bitmap = new Bitmap(new MemoryStream(bitmapBytes));
				CheckImageSize(Width, Height, bitmap);
				CheckBitmapCenter(bitmap, Color.Red);
			}
			finally
			{
				if(offscreenDrawer != null) offscreenDrawer.Dispose();
				if(scene != null) scene.DeviceWorker.TryDispose();
			}
		}
Exemplo n.º 2
0
        public void TestMultiamplingTypes(MultisampleType multisampleType)
        {
            var deviceWorkerSettings = new DeviceWorker.DeviceSettings
            {
                AutoDetermineMultisampleType = false,
                MultisampleType = multisampleType
            };
            DirectXScene           scene           = null;
            OffscreenDirectXDrawer offscreenDrawer = null;

            try
            {
                var deviceWorker = new DeviceWorker(deviceWorkerSettings);
                using (var renderTarget = deviceWorker.Device.GetRenderTarget(0))
                    Assert.AreEqual(multisampleType, renderTarget.Description.MultisampleType);
                scene           = new DirectXScene(deviceWorker, _rootBody, null);
                offscreenDrawer = new OffscreenDirectXDrawer(scene, Width, Height, ImageFormat);
                _rootBody.Add(RedBox);
                var    camera = new TopViewCamera(new Frame3D(0, 0, 200), Width / Height);
                byte[] bitmapBytes;
                offscreenDrawer.TryGetImage(camera, out bitmapBytes);
                var bitmap = new Bitmap(new MemoryStream(bitmapBytes));
                CheckImageSize(Width, Height, bitmap);
                CheckBitmapCenter(bitmap, Color.Red);
            }
            finally
            {
                if (offscreenDrawer != null)
                {
                    offscreenDrawer.Dispose();
                }
                if (scene != null)
                {
                    scene.DeviceWorker.TryDispose();
                }
            }
        }