本文整理汇总了C#中SharpDX类的典型用法代码示例。如果您正苦于以下问题:C# SharpDX类的具体用法?C# SharpDX怎么用?C# SharpDX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SharpDX类属于命名空间,在下文中一共展示了SharpDX类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TileLoader
public TileLoader(string filePath, SharpDX.Direct3D11.SubResourceTiling[] tilingInfo, bool border)
{
_filePath = filePath;
_tilingInfo = tilingInfo;
_border = border;
var fileInfo = new FileInfo(_filePath);
// precompute the tile offsets in the file for each cube face
var numTilesPerFace = (fileInfo.Length / SampleSettings.TileSizeInBytes / 6);
var tilesForSingleFaceMostDetailedMip = tilingInfo[1].StartTileIndexInOverallResource;
_subresourcesPerFaceInResource = tilingInfo.Length / 6;
for (var face = 0; face < 6; face++)
{
var tileIndexInFace = 0;
var tilesInSubresource = tilesForSingleFaceMostDetailedMip;
_subresourcesPerFaceInFile = 0;
while (tileIndexInFace < numTilesPerFace)
{
var offset = (face * numTilesPerFace) + tileIndexInFace;
_subresourceTileOffsets.Add(offset);
tileIndexInFace += tilesInSubresource;
tilesInSubresource = Math.Max(1, tilesInSubresource / 4);
_subresourcesPerFaceInFile++;
}
}
}
开发者ID:nhowells,项目名称:SharpDX-Samples,代码行数:28,代码来源:TileLoader.cs
示例2: FormatInfo
public static IFormatInfo FormatInfo(SharpDX.DXGI.Format dxgiFormat)
{
int numColors;
int colorBits;
FormatElementType colorFormatType;
int alphaBits;
FormatElementType alphaFormatType;
int totalBits;
ColorAlphaFormatFlags flags;
Utility.Helpers.FormatHelper.GetExplicitColorAlphaFormatInfo((ExplicitFormat)dxgiFormat,
out numColors, out colorBits, out colorFormatType, out alphaBits, out alphaFormatType, out totalBits, out flags);
return new FormatInfo
{
ID = (int)dxgiFormat,
Description = dxgiFormat.ToString(),
ExplicitFormat = (ExplicitFormat)dxgiFormat,
NumColors = numColors,
ColorBits = colorBits,
ColorFormatType = colorFormatType,
AlphaBits = alphaBits,
AlphaFormatType = alphaFormatType,
TotalBits = totalBits,
Flags = flags
};
}
开发者ID:Zulkir,项目名称:Beholder,代码行数:27,代码来源:CtBeholder.cs
示例3: Draw
public static void Draw(RenderContext11 renderContext, PositionColoredTextured[] points, int count, Texture11 texture, SharpDX.Direct3D.PrimitiveTopology primitiveType, float opacity = 1.0f)
{
if (VertexBuffer == null)
{
VertexBuffer = new Buffer(renderContext.Device, System.Runtime.InteropServices.Marshal.SizeOf(points[0]) * 2500, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, System.Runtime.InteropServices.Marshal.SizeOf(points[0]));
VertexBufferBinding = new VertexBufferBinding(VertexBuffer, System.Runtime.InteropServices.Marshal.SizeOf((points[0])), 0);
}
renderContext.devContext.InputAssembler.PrimitiveTopology = primitiveType;
renderContext.BlendMode = BlendMode.Alpha;
renderContext.setRasterizerState(TriangleCullMode.Off);
SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
mat.Transpose();
WarpOutputShader.MatWVP = mat;
WarpOutputShader.Use(renderContext.devContext, texture != null, opacity);
renderContext.SetVertexBuffer(VertexBufferBinding);
DataBox box = renderContext.devContext.MapSubresource(VertexBuffer, 0, MapMode.WriteDiscard, MapFlags.None);
Utilities.Write(box.DataPointer, points, 0, count);
renderContext.devContext.UnmapSubresource(VertexBuffer, 0);
if (texture != null)
{
renderContext.devContext.PixelShader.SetShaderResource(0, texture.ResourceView);
}
else
{
renderContext.devContext.PixelShader.SetShaderResource(0, null);
}
renderContext.devContext.Draw(count, 0);
}
开发者ID:china-vo,项目名称:wwt-windows-client,代码行数:33,代码来源:Sprite2d.cs
示例4: Render
internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Line line)
{
var rect = line.GetBoundingRect(rootElement).ToSharpDX();
//var fill = line.Fill.ToSharpDX(renderTarget, rect);
var stroke = await line.Stroke.ToSharpDX(renderTarget, rect);
if (stroke == null ||
line.StrokeThickness <= 0)
{
return;
}
//var layer = new Layer(renderTarget);
//var layerParameters = new LayerParameters();
//layerParameters.ContentBounds = rect;
//renderTarget.PushLayer(ref layerParameters, layer);
renderTarget.DrawLine(
new DrawingPointF(
rect.Left + (float)line.X1,
rect.Top + (float)line.Y1),
new DrawingPointF(
rect.Left + (float)line.X2,
rect.Top + (float)line.Y2),
stroke,
(float)line.StrokeThickness,
line.GetStrokeStyle(compositionEngine.D2DFactory));
//renderTarget.PopLayer();
}
开发者ID:prabaprakash,项目名称:Visual-Studio-2013,代码行数:30,代码来源:LineRenderer.cs
示例5: MyBackbuffer
internal MyBackbuffer(SharpDX.Direct3D11.Resource swapChainBB)
{
m_resource = swapChainBB;
m_resource.DebugName = m_debugName;
m_rtv = new RenderTargetView(MyRender11.Device, swapChainBB);
m_rtv.DebugName = m_debugName;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyBackbuffer.cs
示例6: GetTexture
public override void GetTexture(SharpDX.Size2F surfaceSize, out DrawingSurfaceSynchronizedTexture synchronizedTexture, out SharpDX.RectangleF textureSubRectangle)
{
if (_synchronizedTexture == null)
{
_synchronizedTexture = _host.CreateSynchronizedTexture(_controller.GetTexture());
}
// Set output parameters.
_textureSubRectangle.Left = 0.0f;
_textureSubRectangle.Top = 0.0f;
_textureSubRectangle.Right = surfaceSize.Width;
_textureSubRectangle.Bottom = surfaceSize.Height;
//HOW DO YOU DO A Microsoft::WRL::ComPtr<T> CopyTo ?????
//m_synchronizedTexture.CopyTo(synchronizedTexture);
synchronizedTexture = _synchronizedTexture;
textureSubRectangle = _textureSubRectangle;
//something is going wrong here as the second time thru the BeginDraw consumes
//the call and controlnever returns back to this method, thus GetTexture
//(the call after begindraw) never fires again... ??????
synchronizedTexture.BeginDraw();
_controller.GetTexture(surfaceSize, synchronizedTexture, textureSubRectangle);
synchronizedTexture.EndDraw();
}
开发者ID:numo16,项目名称:SharpDX,代码行数:29,代码来源:SharpDXContentProvider.cs
示例7: VertexBuffer
/// <summary>
/// Initializes a new instance of <see cref="VertexBuffer"/> class.
/// </summary>
/// <param name="context">Instance of an effect context</param>
/// <param name="resourceId"></param>
/// <param name="vertexBufferProperties"></param>
/// <param name="customVertexBufferProperties"></param>
public VertexBuffer(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.VertexBufferProperties vertexBufferProperties, CustomVertexBufferProperties customVertexBufferProperties) : base(IntPtr.Zero)
{
unsafe {
var customVertexBufferPropertiesNative = new CustomVertexBufferProperties.__Native();
customVertexBufferProperties.__MarshalTo(ref customVertexBufferPropertiesNative);
var inputElementsNative = new InputElement.__Native[customVertexBufferProperties.InputElements.Length];
try
{
for (int i = 0; i < customVertexBufferProperties.InputElements.Length; i++)
customVertexBufferProperties.InputElements[i].__MarshalTo(ref inputElementsNative[i]);
fixed (void* pInputElements = inputElementsNative)
{
customVertexBufferPropertiesNative.InputElementsPointer = (IntPtr)pInputElements;
customVertexBufferPropertiesNative.ElementCount = customVertexBufferProperties.InputElements.Length;
fixed (void* pInputSignature = customVertexBufferProperties.InputSignature)
{
customVertexBufferPropertiesNative.ShaderBufferSize = customVertexBufferProperties.InputSignature.Length;
customVertexBufferPropertiesNative.ShaderBufferWithInputSignature = (IntPtr)pInputSignature;
context.CreateVertexBuffer(vertexBufferProperties, resourceId, new IntPtr(&customVertexBufferPropertiesNative), this);
}
}
}
finally
{
for (int i = 0; i < inputElementsNative.Length; i++)
inputElementsNative[i].__MarshalFree();
}
}
}
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:39,代码来源:VertexBuffer.cs
示例8: Draw
public override void Draw(SharpDX.Toolkit.GameTime gameTime)
{
Vector2 p1=new Vector2(RodeData.Node1.Position.Item1,RodeData.Node1.Position.Item2),
p2=new Vector2(RodeData.Node2.Position.Item1,RodeData.Node2.Position.Item2);
DrawLine(p1, p2, line, Game, Color, RodeData.RoadDisplayMode);
base.Draw(gameTime);
}
开发者ID:TPDT,项目名称:TPDT.LogicGraph,代码行数:7,代码来源:Road.cs
示例9: CreateSwapChain
protected override SharpDX.DXGI.SwapChain2 CreateSwapChain(SharpDX.DXGI.Factory2 factory, SharpDX.Direct3D11.Device1 device, SharpDX.DXGI.SwapChainDescription1 desc)
{
// Creates a SwapChain from a CoreWindow pointer
using (var comWindow = new ComObject(window))
using (var swapChain1 = new SwapChain1(factory, device, comWindow, ref desc))
return swapChain1.QueryInterface<SwapChain2>();
}
开发者ID:SickheadGames,项目名称:SharpDX,代码行数:7,代码来源:CoreWindowTarget.cs
示例10: Joy_JoystickStateChanged
void Joy_JoystickStateChanged(object sender, SharpDX.DirectInput.JoystickState state)
{
if (buttonPanel != null && buttonPanel.Controls.Count > 0)
{
for (int i = 0; i < buttonPanel.Controls.Count; i++)
{
bool[] buttons = state.Buttons;
var b = (JoyButton)buttonPanel.Controls[i];
b.State = buttons[i];
}
}
if (povsPanel != null && povsPanel.Controls.Count > 0)
{
int[] povs = state.PointOfViewControllers;
for (int i = 0; i < povsPanel.Controls.Count; i++)
{
var p = (JoyPov)povsPanel.Controls[i];
p.State = povs[i];
}
}
if (sliderPanel != null && sliderPanel.Controls.Count > 0)
{
for(int i=0; i<sliderPanel.Controls.Count; i++){
var c = (JoySlider)sliderPanel.Controls[i];
c.State = state.Sliders[i];
}
}
}
开发者ID:kmpm,项目名称:MoJ,代码行数:29,代码来源:MainForm.cs
示例11: Form1
public Form1(Factory factory, SharpDX.Direct3D11.Device device, Object renderLock)
{
InitializeComponent();
this.factory = factory;
this.device = device;
this.renderLock = renderLock;
}
开发者ID:Dallemanden,项目名称:RoomAliveToolkit,代码行数:7,代码来源:Form1.cs
示例12: Update
public override void Update(double secondsElapsed, ExternalUtilsCSharp.KeyUtils keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false)
{
base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
Framework fw = WithOverlay.Framework;
if (fw.LocalPlayer == null)
return;
if (!fw.LocalPlayer.IsValid())
return;
if(fw.LocalPlayer.m_iTeamNum == (int)Team.Terrorists)
{
this.AlliesColor = Color.Red;
this.EnemiesColor = Color.LightBlue;
}
else
{
this.AlliesColor = Color.LightBlue;
this.EnemiesColor = Color.Red;
}
this.RotationDegrees = fw.ViewAngles.Y + 90;
this.CenterCoordinate = new SharpDX.Vector2(fw.LocalPlayer.m_vecOrigin.X, fw.LocalPlayer.m_vecOrigin.Y);
var enemies = fw.Players.Where(x => x.Item2.IsValid() && x.Item2.m_iHealth > 0 && x.Item2.m_iTeamNum != fw.LocalPlayer.m_iTeamNum);
this.Enemies = enemies.Select(x => new Vector2(x.Item2.m_vecOrigin.X, x.Item2.m_vecOrigin.Y)).ToArray();
var allies = fw.Players.Where(x => x.Item2.IsValid() && x.Item2.m_iHealth > 0 && x.Item2.m_iTeamNum == fw.LocalPlayer.m_iTeamNum);
this.Allies = allies.Select(x => new Vector2(x.Item2.m_vecOrigin.X, x.Item2.m_vecOrigin.Y)).ToArray();
}
开发者ID:Healios,项目名称:ExternalUtilsCSharp,代码行数:29,代码来源:PlayerRadar.cs
示例13: OnDraw
protected override void OnDraw(SharpDX.Direct2D1.WindowRenderTarget device)
{
if (Theme.ShadowColor != Color.Transparent)
FillRectangle(device, Theme.ShadowColor, X, Y, Width, Height);
if (Theme.BackColor != Color.Transparent)
FillRectangle(device, Theme.BackColor, X, Y, Width, Height);
}
开发者ID:nkarpey,项目名称:Zat-s-External-CSGO-Multihack,代码行数:7,代码来源:Panel.cs
示例14: LinearGradientBrushImpl
public LinearGradientBrushImpl(
Perspex.Media.LinearGradientBrush brush,
SharpDX.Direct2D1.RenderTarget target,
Size destinationSize)
{
if (brush != null)
{
var gradientStops = brush.GradientStops.Select(s => new SharpDX.Direct2D1.GradientStop { Color = s.Color.ToDirect2D(), Position = (float)s.Offset }).ToArray();
Point startPoint = new Point(0, 0);
Point endPoint = new Point(0, 0);
switch (brush.MappingMode)
{
case Perspex.Media.BrushMappingMode.Absolute:
// TODO:
break;
case Perspex.Media.BrushMappingMode.RelativeToBoundingBox:
startPoint = new Point(brush.StartPoint.X * destinationSize.Width, brush.StartPoint.Y * destinationSize.Height);
endPoint = new Point(brush.EndPoint.X * destinationSize.Width, brush.EndPoint.Y * destinationSize.Height);
break;
}
PlatformBrush = new SharpDX.Direct2D1.LinearGradientBrush(
target,
new SharpDX.Direct2D1.LinearGradientBrushProperties { StartPoint = startPoint.ToSharpDX(), EndPoint = endPoint.ToSharpDX() },
new SharpDX.Direct2D1.BrushProperties { Opacity = (float)brush.Opacity, Transform = target.Transform },
new SharpDX.Direct2D1.GradientStopCollection(target, gradientStops, brush.SpreadMethod.ToDirect2D())
);
}
}
开发者ID:healtech,项目名称:Perspex,代码行数:33,代码来源:LinearGradientBrushImpl.cs
示例15: CreateBufferUAV
public static UnorderedAccessView CreateBufferUAV(SharpDX.Direct3D11.Device device, Buffer buffer, UnorderedAccessViewBufferFlags flags = UnorderedAccessViewBufferFlags.None)
{
UnorderedAccessViewDescription uavDesc = new UnorderedAccessViewDescription
{
Dimension = UnorderedAccessViewDimension.Buffer,
Buffer = new UnorderedAccessViewDescription.BufferResource { FirstElement = 0 }
};
if ((buffer.Description.OptionFlags & ResourceOptionFlags.BufferAllowRawViews) == ResourceOptionFlags.BufferAllowRawViews)
{
// A raw buffer requires R32_Typeless
uavDesc.Format = Format.R32_Typeless;
uavDesc.Buffer.Flags = UnorderedAccessViewBufferFlags.Raw | flags;
uavDesc.Buffer.ElementCount = buffer.Description.SizeInBytes / 4;
}
else if ((buffer.Description.OptionFlags & ResourceOptionFlags.BufferStructured) == ResourceOptionFlags.BufferStructured)
{
uavDesc.Format = Format.Unknown;
uavDesc.Buffer.Flags = flags;
uavDesc.Buffer.ElementCount = buffer.Description.SizeInBytes / buffer.Description.StructureByteStride;
}
else
{
throw new ArgumentException("Buffer must be raw or structured", "buffer");
}
return new UnorderedAccessView(device, buffer, uavDesc);
}
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:27,代码来源:ParticleRenderer.cs
示例16: SetButtonStateTo
private void SetButtonStateTo(MouseButton button, SharpDX.Toolkit.Input.ButtonState state)
{
switch (button)
{
case MouseButton.None:
break;
case MouseButton.Left:
left = state;
break;
case MouseButton.Middle:
middle = state;
break;
case MouseButton.Right:
right = state;
break;
case MouseButton.XButton1:
xButton1 = state;
break;
case MouseButton.XButton2:
xButton2 = state;
break;
default:
throw new ArgumentOutOfRangeException("button");
}
}
开发者ID:ukitake,项目名称:Stratum,代码行数:25,代码来源:StratumMouseManager.cs
示例17: CreateObjectFromURL
/// <summary>
/// <p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p> Creates a media source or a byte stream from a URL. This method is synchronous. </p>
/// </summary>
/// <param name="url"><dd> <p> Null-terminated string that contains the URL to resolve. </p> </dd></param>
/// <param name="flags"><dd> <p> Bitwise OR of one or more flags. See <strong>Source Resolver Flags</strong>. </p> </dd></param>
/// <param name="objectType"><dd> <p> Receives a member of the <strong><see cref="SharpDX.MediaFoundation.ObjectType"/></strong> enumeration, specifying the type of object that was created. </p> </dd></param>
/// <returns>A reference to the object's <strong><see cref="SharpDX.ComObject"/></strong> interface. The caller must release the interface.</returns>
/// <remarks>
/// <p>The <em>dwFlags</em> parameter must contain either the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.MediaSource"/></strong> flag or the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.ByteStream"/></strong> flag, but should not contain both.</p><p>For local files, you can pass the file name in the <em>pwszURL</em> parameter; the <code>file:</code> scheme is not required.</p><p><strong>Note</strong>??This method cannot be called remotely.</p>
/// </remarks>
/// <msdn-id>ms702279</msdn-id>
/// <unmanaged>HRESULT IMFSourceResolver::CreateObjectFromURL([In] const wchar_t* pwszURL,[In] unsigned int dwFlags,[In] IPropertyStore* pProps,[Out] MF_OBJECT_TYPE* pObjectType,[Out] IUnknown** ppObject)</unmanaged>
/// <unmanaged-short>IMFSourceResolver::CreateObjectFromURL</unmanaged-short>
public SharpDX.ComObject CreateObjectFromURL(string url,
SourceResolverFlags flags,
out SharpDX.MediaFoundation.ObjectType objectType
)
{
return CreateObjectFromURL(url, flags, null, out objectType);
}
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:20,代码来源:SourceResolver.cs
示例18: CreateEffectFromMemory
/// <summary>
/// <p>Creates an effect from a binary effect or file.</p>
/// </summary>
/// <param name="dataRef"><dd> <p>Blob of compiled effect data.</p> </dd></param>
/// <param name="dataLength"><dd> <p>Length of the data blob.</p> </dd></param>
/// <param name="fXFlags"><dd> <p>No effect flags exist. Set to zero.</p> </dd></param>
/// <param name="deviceRef"><dd> <p>Pointer to the <strong><see cref="SharpDX.Direct3D11.Device"/></strong> on which to create Effect resources.</p> </dd></param>
/// <param name="effectOut"><dd> <p>Address of the newly created <strong><see cref="SharpDX.Direct3D11.Effect"/></strong> interface.</p> </dd></param>
/// <param name="srcName">No documentation.</param>
/// <returns><p>The return value is one of the values listed in Direct3D 11 Return Codes.</p></returns>
/// <remarks>
/// <p><strong>Note</strong>??You must use Effects 11 source to build your effects-type application. For more info about using Effects 11 source, see Differences Between Effects 10 and Effects 11.</p>
/// </remarks>
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='D3DX11CreateEffectFromMemory']/*"/>
/// <msdn-id>ff476273</msdn-id>
/// <unmanaged>HRESULT D3DX11CreateEffectFromMemory([In, Buffer] const void* pData,[In] SIZE_T DataLength,[In] unsigned int FXFlags,[In] ID3D11Device* pDevice,[Out, Fast] ID3DX11Effect** ppEffect,[In, Optional] const char* srcName)</unmanaged>
/// <unmanaged-short>D3DX11CreateEffectFromMemory</unmanaged-short>
public static void CreateEffectFromMemory(System.IntPtr dataRef,
SharpDX.PointerSize dataLength,
int fXFlags,
SharpDX.Direct3D11.Device deviceRef,
SharpDX.Direct3D11.Effect effectOut,
string srcName)
{
unsafe
{
IntPtr effectOut_ = IntPtr.Zero;
IntPtr srcName_ = Utilities.StringToHGlobalAnsi(srcName);
SharpDX.Result __result__;
if(IntPtr.Size == 4)
{
__result__ = D3DX11CreateEffectFromMemory_11_1_x86(dataRef, dataLength, fXFlags, deviceRef.NativePointer, out effectOut_, srcName_);
}
else
{
__result__ = D3DX11CreateEffectFromMemory_11_1_x64(dataRef, dataLength, fXFlags, deviceRef.NativePointer, out effectOut_, srcName_);
}
((SharpDX.Direct3D11.Effect)effectOut).NativePointer = effectOut_;
Marshal.FreeHGlobal(srcName_);
__result__.CheckError();
}
}
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:42,代码来源:D3DX11Effects.cs
示例19: VertexShader
public static SharpDX.Direct3D11.VertexShader VertexShader(SharpDX.Direct3D11.Device device, string hlslFile, string entryPoint, ShaderMacro[] defines = null, string profile = "vs_5_0")
{
using (var bytecode = CompileFromFile(hlslFile, entryPoint, profile, defines))
{
return new SharpDX.Direct3D11.VertexShader(device, bytecode);
}
}
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:7,代码来源:HLSLCompiler.cs
示例20: Vector3SDXtoEUC
public static MathObjects.Vector3[] Vector3SDXtoEUC(SharpDX.Vector3[] vec)
{
MathObjects.Vector3[] vecs = new MathObjects.Vector3[vec.Length];
for (int i = 0; i < vecs.Length; i++)
vecs[i] = Vector3SDXtoEUC(vec[i]);
return vecs;
}
开发者ID:Healios,项目名称:ExternalUtilsCSharp,代码行数:7,代码来源:SharpDXConverter.cs
注:本文中的SharpDX类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论