当前位置: 首页>>代码示例>>C#>>正文


C# Device类代码示例

本文整理汇总了C#中Device的典型用法代码示例。如果您正苦于以下问题:C# Device类的具体用法?C# Device怎么用?C# Device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Device类属于命名空间,在下文中一共展示了Device类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateInputDevices

        protected void CreateInputDevices(Control target)
        {
            // create keyboard device.
            keyboard = new Device(SystemGuid.Keyboard);
            if (keyboard == null)
            {
                throw new Exception("No keyboard found.");
            }

            // create mouse device.
            mouse = new Device(SystemGuid.Mouse);
            if (mouse == null)
            {
                throw new Exception("No mouse found.");
            }

            // set cooperative level.
            keyboard.SetCooperativeLevel(target, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);

            mouse.SetCooperativeLevel(target, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);

            // Acquire devices for capturing.
            keyboard.Acquire();
            mouse.Acquire();
        }
开发者ID:sakseichek,项目名称:homm,代码行数:25,代码来源:Poller.cs

示例2: Load

		public Model Load(string file, Device device)
		{
			XmlDocument document = new XmlDocument();
			document.Load(file);

			XmlNamespaceManager ns = new XmlNamespaceManager(document.NameTable);
			ns.AddNamespace("c", "http://www.collada.org/2005/11/COLLADASchema");

			// Read vertex positions
			var positionsNode = document.SelectSingleNode("/c:COLLADA/c:library_geometries/c:geometry/c:mesh/c:source/c:float_array", ns);
			var indicesNode = document.SelectSingleNode("/c:COLLADA/c:library_geometries/c:geometry/c:mesh/c:triangles/c:p", ns);

			var positions = ParseVector3s(positionsNode.InnerText).ToArray();
			var indices = ParseInts(indicesNode.InnerText).ToArray();

			// Mixing concerns here, but oh well
			var model = new Model()
			{
				VertexBuffer = Buffer.Create(device, BindFlags.VertexBuffer, positions),
				IndexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, indices),
				IndexCount = indices.Length,
				VertexPositions = positions,
				Indices = indices
			};

			return model;
		}
开发者ID:flair2005,项目名称:PhysX.Net,代码行数:27,代码来源:ColladaLoader.cs

示例3: IsSupported

        public static bool IsSupported(Device device)
        {
            if (device == null)
                throw new ArgumentNullException("device");

            return device.Extensions.Contains(ExtensionName);
        }
开发者ID:JamesLinus,项目名称:NOpenCL,代码行数:7,代码来源:KhrD3D11Sharing.cs

示例4: DX11DynamicStructuredBuffer

 public DX11DynamicStructuredBuffer(Device dev, Buffer buffer, int cnt) //Dynamic default buffer
 {
     this.Size = cnt;
     this.Buffer = buffer;
     this.Stride = buffer.Description.StructureByteStride;
     this.SRV = new ShaderResourceView(dev, this.Buffer);
 }
开发者ID:arturoc,项目名称:FeralTic,代码行数:7,代码来源:NonGenericStructuredBuffer.cs

示例5: Draw

        public void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView)
        {
            var deviceChanged = _device != device || _context != context;
            _device = device;
            _context = context;

            if (deviceChanged)
            {
                DrawingSurfaceState.Device = _device;
                DrawingSurfaceState.Context = _context;
                DrawingSurfaceState.RenderTargetView = renderTargetView;
            }

            if (!_game.Initialized)
            {
                // Start running the game.
                _game.Run(GameRunBehavior.Asynchronous);
            }
            else if (deviceChanged)
            {
                _game.GraphicsDevice.Initialize();

                Microsoft.Xna.Framework.Content.ContentManager.ReloadGraphicsContent();

                // DeviceReset events
                _game.graphicsDeviceManager.OnDeviceReset(EventArgs.Empty);
                _game.GraphicsDevice.OnDeviceReset();
            }

            _game.GraphicsDevice.UpdateTarget(renderTargetView);
            _game.GraphicsDevice.ResetRenderTargets();
            _game.Tick();

            _host.RequestAdditionalFrame();
        }
开发者ID:GhostTap,项目名称:MonoGame,代码行数:35,代码来源:SurfaceUpdateHandler.cs

示例6: ShowDialog

        public override void ShowDialog(object sender, EventArgs e)
        {
            if (d3d == null)
            {
                d3d = new Direct3D();
                var pm = new SlimDX.Direct3D9.PresentParameters();
                pm.Windowed = true;
                device = new Device(d3d, 0, DeviceType.Reference, IntPtr.Zero, CreateFlags.FpuPreserve, pm);
            }

            string[] files;
            string path;
            if (ConvDlg.Show(Name, GetOpenFilter(), out files, out path) == DialogResult.OK)
            {
                ProgressDlg pd = new ProgressDlg(DevStringTable.Instance["GUI:Converting"]);

                pd.MinVal = 0;
                pd.Value = 0;
                pd.MaxVal = files.Length;

                pd.Show();
                for (int i = 0; i < files.Length; i++)
                {
                    string dest = Path.Combine(path, Path.GetFileNameWithoutExtension(files[i]) + ".x");

                    Convert(new DevFileLocation(files[i]), new DevFileLocation(dest));
                    pd.Value = i;
                }
                pd.Close();
                pd.Dispose();
            }
        }
开发者ID:yuri410,项目名称:lrvbsvnicg,代码行数:32,代码来源:Model2XConverter.cs

示例7: EndToEndTest

		public void EndToEndTest()
		{	
			// Arrange.
		    var device = new Device();
            var logger = new TracefileBuilder(device);
            var expectedData = RenderScene(device);

            var stringWriter = new StringWriter();
			logger.WriteTo(stringWriter);

			var loggedJson = stringWriter.ToString();
			var logReader = new StringReader(loggedJson);
			var tracefile = Tracefile.FromTextReader(logReader);

			// Act.
			var swapChainPresenter = new RawSwapChainPresenter();
			var replayer = new Replayer(
                tracefile.Frames[0], tracefile.Frames[0].Events.Last(),
                swapChainPresenter);
			replayer.Replay();
            var actualData = swapChainPresenter.Data;

			// Assert.
			Assert.That(actualData, Is.EqualTo(expectedData));
		}
开发者ID:modulexcite,项目名称:rasterizr,代码行数:25,代码来源:ReplayerTests.cs

示例8: ImageSprite

        public ImageSprite(Bitmap bitmap, Device device, Color color)
        {
            _color = color;
            _bitmap = bitmap;

            Rebuild(device);
        }
开发者ID:TomNZ,项目名称:Console-Wrapper,代码行数:7,代码来源:ImageSprite.cs

示例9: InitializeGraphics

 public static bool InitializeGraphics(Control handle)
 {
     try
     {
         presentParams.Windowed = true;
         presentParams.SwapEffect = SwapEffect.Discard;
         presentParams.EnableAutoDepthStencil = true;
         presentParams.AutoDepthStencilFormat = DepthFormat.D16;
         device = new Device(0, DeviceType.Hardware, handle, CreateFlags.SoftwareVertexProcessing, presentParams);
         CamDistance = 10;
         Mat = new Material();
         Mat.Diffuse = Color.White;
         Mat.Specular = Color.LightGray;
         Mat.SpecularSharpness = 15.0F;
         device.Material = Mat;
         string loc = Path.GetDirectoryName(Application.ExecutablePath);
         DefaultTex = TextureLoader.FromFile(device, loc + "\\exec\\Default.bmp");
         CreateCoordLines();
         init = true;
         return true;
     }
     catch (DirectXException)
     {
         return false;
     }
 }
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:26,代码来源:Renderer.cs

示例10: MonoGameNoesisGUIWrapper

		/// <summary>
		///     Initializes a new instance of the <see cref="MonoGameNoesisGUIWrapper" /> class.
		/// </summary>
		/// <param name="game">The MonoGame game instance.</param>
		/// <param name="graphics">Graphics device manager of the game instance.</param>
		/// <param name="rootXamlPath">Local XAML file path - will be used as the UI root element</param>
		/// <param name="stylePath">(optional) Local XAML file path - will be used as global ResourceDictionary (UI style)</param>
		/// <param name="dataLocalPath">(optional) Local path to the folder which will be used as root for other paths</param>
		/// <remarks>
		///     PLEASE NOTE: .XAML-files should be prebuilt to .NSB-files by NoesisGUI Build Tool).
		/// </remarks>
		public MonoGameNoesisGUIWrapper(
			Game game,
			GraphicsDeviceManager graphics,
			string rootXamlPath,
			string stylePath = null,
			string dataLocalPath = "Data")
		{
			this.game = game;
			this.graphics = graphics;

			this.graphicsDevice = graphics.GraphicsDevice;
			var device = ((Device)this.graphicsDevice.Handle);
			this.DeviceDX11 = device;

			GUI.InitDirectX11(device.NativePointer);

			GUI.AddResourceProvider(dataLocalPath);

			this.uiRenderer = this.CreateRenderer(rootXamlPath, stylePath);

			this.inputManager = new MonoGameNoesisGUIWrapperInputManager(this.uiRenderer);
			game.Window.TextInput += (sender, args) => this.inputManager.OnTextInput(args);
			game.Window.ClientSizeChanged += this.WindowClientSizeChangedHandler;
			this.graphicsDevice.DeviceReset += this.DeviceResetHandler;
			this.graphicsDevice.DeviceLost += this.DeviceLostHandler;
			this.UpdateSize();
		}
开发者ID:aienabled,项目名称:NoesisGUI.MonoGameWrapper,代码行数:38,代码来源:MonoGameNoesisGUIWrapper.cs

示例11: loop

 public override void loop(Device i_d3d)
 {
     lock (this._ss)
     {
         this._ms.update(this._ss);
         this._rs.drawBackground(i_d3d, this._ss.getSourceImage());
         i_d3d.BeginScene();
         i_d3d.Clear(ClearFlags.ZBuffer, Color.DarkBlue, 1.0f, 0);
         if (this._ms.isExistMarker(this.mid))
         {
             //get marker plane pos from Mouse X,Y
             Point p=this.form.PointToClient(Cursor.Position);
             Vector3 mp = new Vector3();
             this._ms.getMarkerPlanePos(this.mid, p.X,p.Y,ref mp);
             mp.Z = 20.0f;
             //立方体の平面状の位置を計算
             Matrix transform_mat2 = Matrix.Translation(mp);
             //変換行列を掛ける
             transform_mat2 *= this._ms.getD3dMarkerMatrix(this.mid);
             // 計算したマトリックスで座標変換
             i_d3d.SetTransform(TransformType.World, transform_mat2);
             // レンダリング(描画)
             this._rs.colorCube(i_d3d, 40);
         }
         i_d3d.EndScene();
     }
     i_d3d.Present();
 }
开发者ID:whztt07,项目名称:NyARToolkitCS,代码行数:28,代码来源:Program.cs

示例12: BufferedGeometryData

        public BufferedGeometryData(Device device, int numItems)
        {
            this.device = device;
            this.numItems = numItems;

            dataValidity = DataValidityType.Source;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:IAtomRenderer.cs

示例13: start

        public bool start(string name)
        {
            self.name = name;
            DeviceList joysticklist = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);

            bool found = false;

            foreach (DeviceInstance device in joysticklist)
            {
                if (device.ProductName == name)
                {
                    joystick = new Device(device.InstanceGuid);
                    found = true;
                    break;
                }
            }
            if (!found)
                return false;

            joystick.SetDataFormat(DeviceDataFormat.Joystick);

            joystick.Acquire();

            enabled = true;

            System.Threading.Thread t11 = new System.Threading.Thread(new System.Threading.ThreadStart(mainloop)) {
            Name = "Joystick loop",
            Priority = System.Threading.ThreadPriority.AboveNormal,
            IsBackground = true
        };
            t11.Start();

            return true;
        }
开发者ID:RodrigoVarasLopez,项目名称:ardupilot-mega,代码行数:34,代码来源:Joystick.cs

示例14: CreateDrawModel

        /// <summary>
        /// Create DrawModel
        /// </summary>
        public void CreateDrawModel(Device DXDevice , int Name , string TextureFileName)
        {
            ModelForDraw CreateModel = new ModelForDraw(DXDevice , Name);
            CreateModel.TextureLoad(TextureFileName);

            DrawModelList.Add(CreateModel);
        }
开发者ID:Se2015HardCording,项目名称:Mobile-Robot-Controller,代码行数:10,代码来源:ModelManager.cs

示例15: FromScene

        public static Model FromScene(Scene scene, Device device)
        {
            VertexDeclaration vertexDeclaration = new VertexDeclaration(device,
                VertexPositionNormalTexture.VertexElements);
            Model result = new Model(scene, device, vertexDeclaration);
            foreach (Mesh mesh in scene.Meshes)
            {
                VertexBuffer vertexBuffer = new VertexBuffer(device,
                    mesh.Positions.Count * VertexPositionNormalTexture.SizeInBytes,
                    Usage.WriteOnly, VertexFormat.None, Pool.Default);
                DataStream vertexDataStream = vertexBuffer.Lock(0,
                    mesh.Positions.Count * VertexPositionNormalTexture.SizeInBytes,
                    LockFlags.None);
                VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[mesh.Positions.Count];
                for (int i = 0; i < vertices.Length; ++i)
                    vertices[i] = new VertexPositionNormalTexture(mesh.Positions[i], (mesh.Normals.Count > i) ? mesh.Normals[i] : Vector3D.Zero, Point2D.Zero);
                vertexDataStream.WriteRange(vertices);
                vertexBuffer.Unlock();

                IndexBuffer indexBuffer = new IndexBuffer(device, mesh.Indices.Count * sizeof(int),
                    Usage.WriteOnly, Pool.Default, false);
                DataStream indexDataStream = indexBuffer.Lock(0, mesh.Indices.Count * sizeof(int), LockFlags.None);
                indexDataStream.WriteRange(mesh.Indices.ToArray());
                indexBuffer.Unlock();

                ModelMesh modelMesh = new ModelMesh(mesh, device, vertexBuffer,
                    mesh.Positions.Count, indexBuffer, mesh.PrimitiveCount,
                    Matrix3D.Identity, mesh.Material);
                result.Meshes.Add(modelMesh);
            }
            return result;
        }
开发者ID:bondehagen,项目名称:meshellator,代码行数:32,代码来源:ModelConverter.cs


注:本文中的Device类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。