本文整理汇总了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();
}
示例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;
}
示例3: IsSupported
public static bool IsSupported(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
return device.Extensions.Contains(ExtensionName);
}
示例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);
}
示例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();
}
示例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();
}
}
示例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));
}
示例8: ImageSprite
public ImageSprite(Bitmap bitmap, Device device, Color color)
{
_color = color;
_bitmap = bitmap;
Rebuild(device);
}
示例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;
}
}
示例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();
}
示例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();
}
示例12: BufferedGeometryData
public BufferedGeometryData(Device device, int numItems)
{
this.device = device;
this.numItems = numItems;
dataValidity = DataValidityType.Source;
}
示例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;
}
示例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);
}
示例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;
}