本文整理汇总了C#中SlimDX类的典型用法代码示例。如果您正苦于以下问题:C# SlimDX类的具体用法?C# SlimDX怎么用?C# SlimDX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SlimDX类属于命名空间,在下文中一共展示了SlimDX类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup(SlimDX.Direct3D10.Device device, SlimDX.Direct3D10.InputLayout layout)
{
device.InputAssembler.SetVertexBuffers(0,
new SlimDX.Direct3D10.VertexBufferBinding(VertexBuffer, VertexStreamLayout.Size, 0));
SetupCommon(device, layout);
}
示例2: Apply
public void Apply(DX11Texture2D texture, int w, int h, int d, SlimDX.DXGI.Format format, int slice)
{
format = format == SlimDX.DXGI.Format.Unknown ? texture.Format : format;
if (this.rtarr != null)
{
if (this.rtarr.ElemCnt != d || this.rtarr.Width != w || this.rtarr.Height != h
|| this.rtarr.Format != format)
{
this.rtarr.Dispose(); this.rtarr = null;
}
}
if (this.rtarr == null)
{
this.rtarr = new DX11RenderTextureArray(this.context, w, h, d, format);
}
this.shader.SelectTechnique("Render");
this.quad.Bind(this.layout);
int idx = VMath.Zmod(slice, d);
//Push specific slice as render target
this.context.RenderTargetStack.Push(this.rtarr.SliceRTV[idx]);
//Call simple shader (could use full screen triangle instead)
this.shader.SetBySemantic("TEXTURE", texture.SRV);
this.shader.ApplyPass(0);
this.quad.Draw();
this.context.RenderTargetStack.Pop();
}
示例3: D3D11RenderingPane
public D3D11RenderingPane( Factory dxgiFactory, SlimDX.Direct3D11.Device d3D11Device, DeviceContext d3D11DeviceContext, D3D11HwndDescription d3D11HwndDescription )
{
mDxgiFactory = dxgiFactory;
mD3D11Device = d3D11Device;
mD3D11DeviceContext = d3D11DeviceContext;
var swapChainDescription = new SwapChainDescription
{
BufferCount = 1,
ModeDescription =
new ModeDescription( d3D11HwndDescription.Width,
d3D11HwndDescription.Height,
new Rational( 60, 1 ),
Format.R8G8B8A8_UNorm ),
IsWindowed = true,
OutputHandle = d3D11HwndDescription.Handle,
SampleDescription = new SampleDescription( 1, 0 ),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
mSwapChain = new SwapChain( mDxgiFactory, mD3D11Device, swapChainDescription );
mDxgiFactory.SetWindowAssociation( d3D11HwndDescription.Handle, WindowAssociationFlags.IgnoreAll );
CreateD3D11Resources( d3D11HwndDescription.Width, d3D11HwndDescription.Height );
PauseRendering = false;
}
示例4: WriteVisibleElements
public override void WriteVisibleElements(View3D view, RectangleF ClientBounds, ref RectangleF RemainingBounds, SlimDX.DataStream LineVerts, ref int LineVertsCount, SlimDX.DataStream LinesIndices, ref int LinesIndicesCount, SlimDX.DataStream TriangleVerts, ref int TriangleVertsCount, SlimDX.DataStream TriangleIndices, ref int TriangleIndicesCount)
{
SizeF stringSize = TextRenderHelper.MessureString(m_Text, m_FontType, view, 1f);
if (m_FixedSize == false)
{
this.Size = new System.Drawing.Size(m_Padding.Horizontal + (int)stringSize.Width, m_Padding.Vertical + (int)stringSize.Height);
}
m_Bounds = UiStyleHelper.LayoutControlBounds(RemainingBounds, Location, Size, Anchor, Docking, out RemainingBounds);
float x, y;
float px = view.PixelSize.X;
float py = view.PixelSize.Y;
PointF textLocation = UiStyleHelper.LayoutTextBounds(Bounds, stringSize, TextAlign, Padding);
UiStyleHelper.CovertToVertCoords_Relitive(textLocation, view.PixelSize, out x, out y);
Color4 textColor;
if (TextColorOverride == true)
{
textColor = m_TextColor;
}
else
{
textColor = UiStyleHelper.GetControlTextColor(this, DisplayMode.Auto);
}
TextRenderHelper.WriteString(view, Bounds,
m_Text, m_FontType, new Vector3(x, y, ZIndexForLines_Float), 1f, textColor,
TriangleVerts, ref TriangleVertsCount,
TriangleIndices, ref TriangleIndicesCount);
}
示例5: Initialize
public static void Initialize( out Factory dxgiFactory, out SlimDX.Direct3D11.Device d3d11Device )
{
dxgiFactory = new Factory();
Adapter adapter = null;
long videoMemory = 0;
for ( var i = 0; i < dxgiFactory.GetAdapterCount(); i++ )
{
var tmpAdapter = dxgiFactory.GetAdapter( i );
if ( tmpAdapter.Description.DedicatedVideoMemory > videoMemory )
{
adapter = tmpAdapter;
videoMemory = tmpAdapter.Description.DedicatedVideoMemory;
}
}
d3d11Device = null;
try
{
d3d11Device = Constants.DEBUG_D3D11_DEVICE
? new SlimDX.Direct3D11.Device( adapter,
DeviceCreationFlags.Debug,
new[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 } )
: new SlimDX.Direct3D11.Device( adapter,
DeviceCreationFlags.None,
new[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 } );
}
catch ( Exception e )
{
Console.WriteLine( "\nError: Couldn't create Direct3D 11 device (exception: " + e.Source + ", " + e.Message + ").\n" );
}
}
示例6: ChainPull
public static Map.Map ChainPull(SlimDX.Direct3D9.Device device)
{
var m = Medium(device);
m.DynamicsRoot.AddChild(new Map.Units.Grunt { Position = new SlimDX.Vector3(36, 36, 0) });
m.DynamicsRoot.AddChild(new Map.Units.Grunt { Position = new SlimDX.Vector3(31, 31, 0) });
return m;
}
示例7: AddFreeShadowTexture
public static void AddFreeShadowTexture(SlimDX.Direct3D9.Texture texture)
{
lock (mLockObj)
{
mFreeShadowTextures.Add(texture);
}
}
示例8: ChainPullRaisable
public static Map.Map ChainPullRaisable(SlimDX.Direct3D9.Device device)
{
var m = Medium(device);
m.DynamicsRoot.AddChild(new Map.Units.Grunt { Position = new SlimDX.Vector3(36, 36, 0), State = Client.Game.Map.UnitState.RaisableCorpse });
m.DynamicsRoot.AddChild(new Map.Units.Grunt { Position = new SlimDX.Vector3(31, 31, 0), State = Client.Game.Map.UnitState.RaisableCorpse });
return m;
}
示例9: RenderModel
void RenderModel(Graphics.Content.Model10 model, SlimDX.Matrix entityWorld, Effect effect)
{
throw new NotImplementedException();
//if (model == null || !model.Visible || model.Mesh == null) return;
Matrix world = model.World * entityWorld;
world.M41 = (float)((int)world.M41);
world.M42 = (float)((int)world.M42);
world *= Matrix.Scaling(2f / (float)view.Viewport.Width, 2f / (float)view.Viewport.Height, 1) * Matrix.Translation(-1, -1, 0) * Matrix.Scaling(1, -1, 1);
world.M43 = 0.5f;
effect.GetVariableByName("World").AsMatrix().SetMatrix(world);
effect.GetVariableByName("Texture").AsResource().SetResource(model.TextureShaderView);
effect.GetTechniqueByName("Render").GetPassByIndex(0).Apply();
if (model.Mesh != null)
{
model.Mesh.Setup(view.Device10, view.Content.Acquire<InputLayout>(
new Content.VertexStreamLayoutFromEffect
{
Signature10 = effect.GetTechniqueByIndex(0).GetPassByIndex(0).Description.Signature,
Layout = model.Mesh.VertexStreamLayout
}));
model.Mesh.Draw(device);
}
}
示例10: HitModels
public void HitModels(SlimDX.Ray camRay, out MdxIntersectionResult result)
{
result = new MdxIntersectionResult();
result.Distance = -1;
renderLock.WaitOne();
foreach (var couple in BatchRenderers)
{
float curDist = 0.0f;
uint instanceId;
SlimDX.Vector3 hitPoint;
if (couple.Value.Intersector.Intersect(camRay, out curDist, out instanceId, out hitPoint))
{
if (curDist < result.Distance || result.Distance < 0)
{
result.InstanceID = instanceId;
result.Distance = curDist;
result.Model = couple.Value.mModelInfo;
result.Renderer = couple.Value;
result.InstanceData = result.Renderer.InstanceLoader.GetInstanceById(instanceId);
result.HitPoint = hitPoint;
result.HasHit = true;
}
}
}
renderLock.ReleaseMutex();
}
示例11: WriteVisibleElements
public override void WriteVisibleElements(View3D view,
RectangleF ClientBounds, ref RectangleF RemainingBounds,
SlimDX.DataStream LineVerts, ref int LineVertsCount,
SlimDX.DataStream LinesIndices, ref int LinesIndicesCount,
SlimDX.DataStream TriangleVerts, ref int TriangleVertsCount,
SlimDX.DataStream TriangleIndices, ref int TriangleIndicesCount)
{
base.WriteVisibleElements(view, ClientBounds, ref RemainingBounds,
LineVerts, ref LineVertsCount,
LinesIndices, ref LinesIndicesCount,
TriangleVerts, ref TriangleVertsCount,
TriangleIndices, ref TriangleIndicesCount);
RectangleF innerBounds = Bounds;
foreach (UiControl ctrl in Controls)
{
if (ctrl.IsVisible == false)
{
continue;
}
ctrl.WriteVisibleElements(view, ClientBounds, ref innerBounds,
LineVerts, ref LineVertsCount,
LinesIndices, ref LinesIndicesCount,
TriangleVerts, ref TriangleVertsCount,
TriangleIndices, ref TriangleIndicesCount);
}
}
示例12: Draw
public void Draw(SlimDX.Matrix transform, bool noShader = false)
{
lock (mGroups)
{
foreach (var group in mGroups)
group.RenderGroup(transform, noShader);
}
}
示例13: NullRenderingStrategy
public NullRenderingStrategy( SlimDX.Direct3D11.Device device, DeviceContext deviceContext )
{
//bool result;
//mTinyTextContext = new Context( device, deviceContext, Constants.MAX_NUM_TINY_TEXT_CHARACTERS, out result );
//Release.Assert( result );
mStopwatch.Start();
}
示例14: WriteVisibleElements
public override void WriteVisibleElements(View3D view, RectangleF ClientBounds, ref RectangleF RemainingBounds, SlimDX.DataStream LineVerts, ref int LineVertsCount, SlimDX.DataStream LinesIndices, ref int LinesIndicesCount, SlimDX.DataStream TriangleVerts, ref int TriangleVertsCount, SlimDX.DataStream TriangleIndices, ref int TriangleIndicesCount)
{
base.WriteVisibleElements(view, ClientBounds, ref RemainingBounds,
LineVerts, ref LineVertsCount,
LinesIndices, ref LinesIndicesCount,
TriangleVerts, ref TriangleVertsCount,
TriangleIndices, ref TriangleIndicesCount);
}
示例15: Camera
// Constructor
public Camera(SlimDX.Direct3D9.Device device)
{
this.device = device;
//worldMatrix[0, 2] = -1f;
//worldMatrix[1, 0] = -1f;
//worldMatrix[2, 1] = 1f;
//worldMatrix[3, 3] = 1f;
}