本文整理汇总了C#中Device类的典型用法代码示例。如果您正苦于以下问题:C# Device类的具体用法?C# Device怎么用?C# Device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Device类属于命名空间,在下文中一共展示了Device类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例6: 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
示例7: ImageSprite
public ImageSprite(Bitmap bitmap, Device device, Color color)
{
_color = color;
_bitmap = bitmap;
Rebuild(device);
}
开发者ID:TomNZ,项目名称:Console-Wrapper,代码行数:7,代码来源:ImageSprite.cs
示例8: 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
示例9: 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
示例10: 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
示例11: BufferedGeometryData
public BufferedGeometryData(Device device, int numItems)
{
this.device = device;
this.numItems = numItems;
dataValidity = DataValidityType.Source;
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:IAtomRenderer.cs
示例12: 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
示例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
示例16: DrawBox
public static void DrawBox(int ulx, int uly, int width, int height, float z, int color, Device device)
{
CustomVertex.TransformedColored[] verts = new CustomVertex.TransformedColored[4];
verts[0].X = (float) ulx;
verts[0].Y = (float) uly;
verts[0].Z = z;
verts[0].Color = color;
verts[1].X = (float) ulx;
verts[1].Y = (float) uly + height;
verts[1].Z = z;
verts[1].Color = color;
verts[2].X = (float) ulx + width;
verts[2].Y = (float) uly;
verts[2].Z = z;
verts[2].Color = color;
verts[3].X = (float) ulx + width;
verts[3].Y = (float) uly + height;
verts[3].Z = z;
verts[3].Color = color;
device.VertexFormat = CustomVertex.TransformedColored.Format;
device.TextureState[0].ColorOperation = TextureOperation.Disable;
device.DrawUserPrimitives(PrimitiveType.TriangleStrip, verts.Length - 2, verts);
}
开发者ID:beginor,项目名称:WorldWind,代码行数:27,代码来源:WidgetUtil.cs
示例17: EnumerateDevices
/* Queries the number of available devices and creates a list with device data. */
public static List<Device> EnumerateDevices()
{
/* Create a list for the device data. */
List<Device> list = new List<Device>();
/* Enumerate all camera devices. You must call
PylonEnumerateDevices() before creating a device. */
uint count = Pylon.EnumerateDevices();
/* Get device data from all devices. */
for( uint i = 0; i < count; ++i)
{
/* Create a new data packet. */
Device device = new Device();
/* Get the device info handle of the device. */
PYLON_DEVICE_INFO_HANDLE hDi = Pylon.GetDeviceInfoHandle(i);
/* Get the name. */
device.Name = Pylon.DeviceInfoGetPropertyValueByName(hDi, Pylon.cPylonDeviceInfoFriendlyNameKey);
/* Set the index. */
device.Index = i;
/* Add to the list. */
list.Add(device);
}
return list;
}
开发者ID:artemisvision,项目名称:PylonVideoCapture,代码行数:26,代码来源:DeviceEnumerator.cs
示例18: Render
public int vertexStartIndex; // Start offset for VB
#endregion Fields
#region Methods
public void Render(Effect effect, Device device, bool setMaterial)
{
// Set material
if (setMaterial)
material.ApplyMaterial(device);
// Calculate number of primitives to draw.
int primCount = 0;
switch (Type)
{
case PrimitiveType.TriangleList:
primCount = nIndices / 3;
break;
case PrimitiveType.TriangleFan:
case PrimitiveType.TriangleStrip:
primCount = nIndices - 2;
break;
}
// Draw
if (primCount > 0)
{
device.DrawIndexedPrimitives(Type, vertexStartIndex, lowestIndiceValue, nVerts, IndiceStartIndex, primCount);
}
}
开发者ID:maesse,项目名称:CubeHags,代码行数:31,代码来源:DynamicItem.cs
示例19: TestTurretHead
/// <summary>
/// Creates a simple twin barreled TurretHead at the given location
/// facing the given rotation and controlled by the given kayboard
/// Device.
/// </summary>
/// <param name="location">Location of the TurretHead</param>
/// <param name="rotation">Rotation the TurretHead is facing</param>
/// <param name="scale">Scale of the TurretHead</param>
/// <param name="keyboard">
/// Keyboard Device used to controll the Turret
/// </param>
public TestTurretHead(Vector3 location, Vector3 rotation, Vector3 scale, Device keyboard)
: base(location + Settings.TEST_TURRET_HEAD_OFFSET, rotation, scale, Settings.TEST_TURRET_HEAD_ROTATION_SPEED, Settings.TEST_TURRET_BARREL_ROTATION_SPEED, keyboard)
{
this.models.Add(ContentLoader.TestTurretHeadModel);
addChild(new TurretBarrel(
new Vector3(this.location.X, this.location.Y, this.location.Z) + Settings.TEST_TURRET_BARREL_ONE_OFFSET,
new Vector3(this.rotation.X, this.rotation.Y, this.rotation.Z) + Settings.TEST_TURRET_BARREL_DEFAULT_ROTATION,
scale,
ContentLoader.TestTurretBarrelModel,
Settings.TEST_TURRET_BARREL_MAX_PITCH,
Settings.TEST_TURRET_BARREL_MIN_PITCH,
Settings.TEST_TURRET_BARREL_SHOOT_DELAY,
Settings.TEST_TURRET_BARREL_PUSH_SPEED,
Settings.TEST_TURRET_BARREL_PULL_SPEED,
keyboard
));
addChild(new TurretBarrel(
new Vector3(this.location.X, this.location.Y, this.location.Z) + Settings.TEST_TURRET_BARREL_TWO_OFFSET,
new Vector3(this.rotation.X, this.rotation.Y, this.rotation.Z) + Settings.TEST_TURRET_BARREL_DEFAULT_ROTATION,
scale,
ContentLoader.TestTurretBarrelModel,
Settings.TEST_TURRET_BARREL_MAX_PITCH,
Settings.TEST_TURRET_BARREL_MIN_PITCH,
Settings.TEST_TURRET_BARREL_SHOOT_DELAY,
Settings.TEST_TURRET_BARREL_PUSH_SPEED,
Settings.TEST_TURRET_BARREL_PULL_SPEED,
keyboard
));
}
开发者ID:newgrounds,项目名称:Clear-Skies,代码行数:42,代码来源:TestTurretHead.cs
示例20: TextureCache
public TextureCache(Device device)
{
_device = device;
_cache = new Dictionary<string, CachedTexture>();
_textureCache = new Dictionary<int, CachedTexture>();
_nextTextureId = 1;
}
开发者ID:HaKDMoDz,项目名称:Psy,代码行数:7,代码来源:TextureCache.cs
注:本文中的Device类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论