本文整理汇总了C#中DeviceContext.ClearDepthStencilView方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceContext.ClearDepthStencilView方法的具体用法?C# DeviceContext.ClearDepthStencilView怎么用?C# DeviceContext.ClearDepthStencilView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceContext
的用法示例。
在下文中一共展示了DeviceContext.ClearDepthStencilView方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindDsvAndSetNullRenderTarget
public void BindDsvAndSetNullRenderTarget(DeviceContext dc) {
dc.Rasterizer.SetViewports(_viewport);
dc.OutputMerger.SetTargets(_depthMapDSV, (RenderTargetView)null);
dc.ClearDepthStencilView(_depthMapDSV, DepthStencilClearFlags.Depth|DepthStencilClearFlags.Stencil, 1.0f, 0);
}
示例2: ClearRenderTarget
public void ClearRenderTarget(DeviceContext context, DepthStencilView depthStencilView, float red, float green, float blue, float alpha)
{
// Setup the color the buffer to.
var color = new Color4(red, green, blue, alpha);
// Clear the back buffer.
context.ClearRenderTargetView(RenderTargetView, color);
// Clear the depth buffer.
context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);
}
示例3: Render
public void Render( DeviceContext deviceContext, Viewport viewport, RenderTargetView renderTargetView, DepthStencilView depthStencilView )
{
deviceContext.ClearRenderTargetView( renderTargetView, Constants.CLEAR_COLOR );
deviceContext.ClearDepthStencilView( depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0x00 );
//mTinyTextContext.Print( viewport, "Frame Time: " + FrameTimeString, 10, 10 );
//mTinyTextContext.Render();
mStopwatch.Reset();
mStopwatch.Start();
}
示例4: Clear
/// <summary>
/// Clears the instance
/// </summary>
/// <param name="context"></param>
public virtual void Clear(DeviceContext context)
{
if (!IsDepthStencilUsed || (!DepthStencilClearSettings.IsClearDepth && !DepthStencilClearSettings.IsClearStencil)) return;
var dsFlags = (DepthStencilClearFlags) 0;
if (DepthStencilClearSettings.IsClearDepth)
dsFlags |= DepthStencilClearFlags.Depth;
if (DepthStencilClearSettings.IsClearStencil)
dsFlags |= DepthStencilClearFlags.Stencil;
context.ClearDepthStencilView(DepthStencilView, dsFlags, DepthStencilClearSettings.DepthClearValue, DepthStencilClearSettings.StencilClearValue);
}
示例5: Render
public void Render(DeviceContext deviceContext, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix, Light light)
{
Light newLight = new Light(light.Direction, light.Color, new Vector4(1), light.SpecularPower, light.SpecularColor);
_skydome.Render(deviceContext);
_renderer.LightShader.Render(deviceContext, _skydome.IndexCount, Matrix.Scaling(10000) * Matrix.RotationY(MathUtil.PiOverTwo-WaveTranslation.X/8), viewMatrix, projectionMatrix, _skydome.Texture, newLight, _renderer.Camera);
deviceContext.ClearDepthStencilView(_renderer.DirectX.RenderToTextureDepthStencilView, DepthStencilClearFlags.Depth, 1, 0);
_refractionTexture.SetRenderTarget(deviceContext, _renderer.DirectX.RenderToTextureDepthStencilView);
_refractionTexture.ClearRenderTarget(deviceContext, _renderer.DirectX.RenderToTextureDepthStencilView, 0.0f, 0.0f, 0.0f, 1.0f);
deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(TerrainVertexBuffer, Utilities.SizeOf<VertexDefinition.PositionTextureNormal4Weights>(), 0));
deviceContext.InputAssembler.SetIndexBuffer(TerrainIndexBuffer, Format.R32_UInt, 0);
deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
TerrainShader.Render(deviceContext, TerrainIndexCount, worldMatrix, viewMatrix, projectionMatrix, light, _terrainTextures, _refractionClippingPlane);
deviceContext.ClearDepthStencilView(_renderer.DirectX.RenderToTextureDepthStencilView, DepthStencilClearFlags.Depth, 1, 0);
_reflectionTexture.SetRenderTarget(deviceContext, _renderer.DirectX.RenderToTextureDepthStencilView);
_reflectionTexture.ClearRenderTarget(deviceContext, _renderer.DirectX.RenderToTextureDepthStencilView, 0.0f, 0.0f, 0.0f, 1.0f);
_skydome.Render(deviceContext);
_renderer.LightShader.Render(deviceContext, _skydome.IndexCount, Matrix.Scaling(10000) * Matrix.RotationY(MathUtil.PiOverTwo - WaveTranslation.X/8), viewMatrix, projectionMatrix, _skydome.Texture, newLight, _renderer.Camera);
deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(TerrainVertexBuffer, Utilities.SizeOf<VertexDefinition.PositionTextureNormal4Weights>(), 0));
deviceContext.InputAssembler.SetIndexBuffer(TerrainIndexBuffer, Format.R32_UInt, 0);
deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
TerrainShader.Render(deviceContext, TerrainIndexCount, worldMatrix, _renderer.Camera.ReflectionMatrix, projectionMatrix, light, _terrainTextures, _reflectionClippingPlane);
_renderer.DirectX.SetBackBufferAsRenderTarget();
//Render water
deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(WaterVertexBuffer, Utilities.SizeOf<VertexDefinition.PositionTexture>(), 0));
deviceContext.InputAssembler.SetIndexBuffer(WaterIndexBuffer, Format.R32_UInt, 0);
deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
WaterShader.Render(deviceContext, WaterIndexCount, worldMatrix, viewMatrix, projectionMatrix, _renderer.Camera.ReflectionMatrix, _reflectionTexture.ShaderResourceView, _refractionTexture.ShaderResourceView, _bumpMap.TextureResource, WaveTranslation, _renderer.Camera.Position);
//Render terrain
deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(TerrainVertexBuffer, Utilities.SizeOf<VertexDefinition.PositionTextureNormal4Weights>(), 0));
deviceContext.InputAssembler.SetIndexBuffer(TerrainIndexBuffer, Format.R32_UInt, 0);
deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
TerrainShader.Render(deviceContext, TerrainIndexCount, worldMatrix, viewMatrix, projectionMatrix, light, _terrainTextures, _noClippingPlane);
_bitmap.Render(deviceContext);
_renderer.TextureShader.Render(deviceContext, _bitmap.IndexCount, Matrix.Identity, _renderer.Camera.UiMatrix, _renderer.DirectX.OrthoMatrix, _refractionTexture.ShaderResourceView);
_bitmap2.Render(deviceContext);
_renderer.TextureShader.Render(deviceContext, _bitmap.IndexCount, Matrix.Identity, _renderer.Camera.UiMatrix, _renderer.DirectX.OrthoMatrix, _reflectionTexture.ShaderResourceView);
}
示例6: Render
public void Render(RenderTargetView renderTargetView, DeviceContext context, SurfacePass pass)
{
// TODO: generate sky envmap here, with custom params
pass.Pass(context, @"
struct PS_IN
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD;
};
float3 main(PS_IN input) : SV_Target
{
float phi = 2 * 3.14159265 * input.tex.x;
float theta = 3.14159265 * input.tex.y;
float3 p = float3(sin(theta) * cos(phi), cos(theta), sin(theta) * sin(phi));
float brightness = 500;
if (p.y < 0) return lerp(float3(1, 1, 1), float3(0, 0, 0), -p.y) * brightness;
/* TEMPORARY */
float sunBrightness = (dot(p, normalize(float3(-0.5f, 0.8f, 0.9f))) > 0.9995f) ? 1 : 0;
return lerp(float3(1, 1, 1), float3(0.7f, 0.7f, 1), p.y) * brightness + sunBrightness * 50000;
}
", skyEnvMap.Dimensions, skyEnvMap.RTV, null, null);
context.OutputMerger.SetRenderTargets((RenderTargetView)null);
context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);
context.ClearRenderTargetView(renderTargetView, new Color4(0.5f, 0, 1, 1));
context.Rasterizer.State = rasterizerState;
context.OutputMerger.DepthStencilState = depthStencilState;
context.OutputMerger.SetTargets(depthStencilView, renderTargetView);
context.Rasterizer.SetViewports(new[] { new ViewportF(0, 0, RenderDimensions.Width, RenderDimensions.Height) });
context.Rasterizer.SetScissorRectangles(new[] { new SharpDX.Rectangle(0, 0, RenderDimensions.Width, RenderDimensions.Height) });
context.VertexShader.Set(vertexShader);
context.InputAssembler.InputLayout = inputLayout;
context.PixelShader.SetShaderResource(0, skyEnvMap.SRV);
context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
{
DataStream cameraStream;
context.MapSubresource(cameraBuffer, MapMode.WriteDiscard, MapFlags.None, out cameraStream);
camera.WriteTo(cameraStream);
context.UnmapSubresource(cameraBuffer, 0);
cameraStream.Dispose();
}
context.VertexShader.SetConstantBuffer(0, cameraBuffer);
context.PixelShader.SetConstantBuffer(0, cameraBuffer);
foreach (Model model in models.Values)
model.Render(context, camera, materials, proxy);
}
示例7: SetRenderTarget
public void SetRenderTarget(DeviceContext context, DepthStencilView depthStencilView)
{
// Bind the render target view and depth stencil buffer to the output pipeline.
context.OutputMerger.SetTargets(depthStencilView, texRenderTargetView);
// Setup the color the buffer to.
var color = new Color4(0.0f, 0.0f, 1.0f, 1.0f);
// Clear the render to texture buffer.
context.ClearRenderTargetView(texRenderTargetView, color);
// Clear the depth buffer.
context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);
}
示例8: Render
public void Render( DeviceContext deviceContext, Viewport viewport, RenderTargetView renderTargetView, DepthStencilView depthStencilView )
{
deviceContext.ClearRenderTargetView( renderTargetView, Constants.CLEAR_COLOR );
deviceContext.ClearDepthStencilView( depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0x00 );
var centerDataSpace = mTileManager.TiledDatasetView.CenterDataSpace;
var extentDataSpace = mTileManager.TiledDatasetView.ExtentDataSpace;
var camera = new Camera(
new Vector3( 0, 0, 0 ),
new Vector3( 0, 0, 1 ),
new Vector3( 0, 1, 0 ),
Matrix.OrthoOffCenterLH(
centerDataSpace.X - ( extentDataSpace.X / 2f ),
centerDataSpace.X + ( extentDataSpace.X / 2f ),
centerDataSpace.Y + ( extentDataSpace.Y / 2f ),
centerDataSpace.Y - ( extentDataSpace.Y / 2f ),
0.1f,
100f ) );
var datasetExtentDataSpaceX = mTileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get( "SourceMap" ).NumTilesX * Constants.ConstParameters.GetInt( "TILE_SIZE_X" );
var datasetExtentDataSpaceY = mTileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get( "SourceMap" ).NumTilesY * Constants.ConstParameters.GetInt( "TILE_SIZE_Y" );
mTileManager.GetTileCache().ToList().ForEach( tileCacheEntry => RenderTileCacheEntry( deviceContext, camera, datasetExtentDataSpaceX, datasetExtentDataSpaceY, tileCacheEntry, viewport ) );
//mTinyTextContext.Print( viewport, "Frame Time: " + FrameTimeString, 10, 10 );
//mTinyTextContext.Print( viewport, "Number of Active Cache Entries: " + mTileManager.GetTileCache().Count, 10, 30 );
//mTinyTextContext.Render();
mStopwatch.Reset();
mStopwatch.Start();
}
示例9: ClearRenderTarget
public void ClearRenderTarget(DeviceContext context, DepthStencilView depthStencilView, float red, float green, float blue, float alpha)
{
context.ClearRenderTargetView(_renderTargetView, new Color4(red, green, blue, alpha));
context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);
}
示例10: BindDsvAndSetNullRenderTarget
public void BindDsvAndSetNullRenderTarget(DeviceContext context) {
context.Rasterizer.SetViewports(new RawViewportF[] { _viewport });
context.OutputMerger.SetTargets(_depthMapDSV, (RenderTargetView)null);
context.ClearDepthStencilView(_depthMapDSV, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0);
}
示例11: Draw
public void Draw(float TimeMili, Device device, DeviceContext context)
{
if (RebderCube)
{
RebderCube = false;
SkyBox.RenderCubemap();
}
Random R = new Random(2);
for (int i = 0; i < 0; i+=2)
{
DVector3 t = new DVector3(R.NextDouble(-500, 500), R.NextDouble(-500, 500), R.NextDouble(-500, 500));
LensBatching.DrawLens(t, new Vector2(5, 5), new Vector2(0, 0), new Vector2(1, 1), new Vector4(1, 0, 0, 1), TC1);
t = new DVector3(R.NextDouble(-500, 500), R.NextDouble(-500, 500), R.NextDouble(-500, 500));
LensBatching.DrawLens(t, new Vector2(5, 5), new Vector2(0, 0), new Vector2(1, 1), new Vector4(0, 0, 1, 1), TC2);
}
LensBatching.DrawLens(Camera.position + Conversion.ToDoubleVector(-LightDirection)*Camera.farClip*0.95f, new Vector2(1000, 1000), new Vector2(0, 0), new Vector2(1, 1), new Vector4(1, 0, 0, 1), TC1);
KDtree KDT = new KDtree(20, AllObjects);
List<GameObject> InCam = KDT.GetBodyInCamera(Camera.position, Camera.LcameraFrustum);
DebugDraw.ResetLine();
//Depth
device.ImmediateContext.OutputMerger.SetTargets(DepthMapStencilView, DepthTarget);
device.ImmediateContext.ClearDepthStencilView(DepthMapStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);
context.ClearRenderTargetView(DepthTarget, new Color4(1.0f, 0.0f, 0.0f, 1.0f));
for (int i = 0; i < InCam.Count; i++) if (InCam[i] != null) InCam[i].DrawDepth(device, Camera);
PSSMsHelper.RenderAllSplits(device, Camera, Conversion.ToDoubleVector(LightDirection), KDT, InCam);
//
DrawHelper.OcclusionTest(device, Camera, DepthSRV);
//
context.Rasterizer.SetViewports(Program.viewport);
context.OutputMerger.SetTargets(DepthStencilView, HDRTarget);
context.ClearRenderTargetView(HDRTarget, new Color4(0.5f, 0.5f, 1.0f, 1.0f));
context.ClearDepthStencilView(DepthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);
//DebugDraw.AddLine(new DebugLine(KDT.Root.AA, KDT.Root.BB, new Vector3(1, 0, 0)));
//DebugDraw.DrawAABB(KDT.Root.AA, KDT.Root.BB, new Vector3(1, 0, 0));
//DebugDraw.DrawKDTree(KDT, new Vector3(1, 0, 0));
//DebugDraw.DrawLocator(new DVector3(50, 50, 0), 5, new Vector3(0, 1, 0));
SkyBox.Draw(TimeMili, device, context, Camera);
/*
for (int i = 0; i < InCam.Count; i++)
if (InCam[i] != null)
InCam[i].Draw(device, Camera, Light, LightDirection);
*/
PSSMsHelper.RenderObj(TimeMili, device, Camera, LightDirection, Light.Color, InCam);
for (int i = 0; i < InCam.Count; i++)
if (InCam[i] != null)
InCam[i].DrawEffects(device, Camera);
LensBatching.BatchingDrawLens(device, Camera, DepthSRV);
DebugDraw.Draw(device, Camera);
/*
foreach (GSSprite TS_ in TS)
{
TS_.Render(device, Camera, DepthSRV);
}
*/
//context.OutputMerger.SetTargets(renderTarget);
//HDRSRV
//DepthSRV
QuadScreen.FinalRender(device, TimeMili, context, HDRSRV, DepthSRV, renderTarget);
/*
Int64 TStart = Program.HiTimer.Value;
Int64 TStop = Program.HiTimer.Value;
float Time = Program.HiTimer.Tick2Mili(TStop - TStart);
Program.form.Text = Time.ToString();*/
}
示例12: EnableViewport
/// <summary>
/// Enable the rendering in this viewport
/// </summary>
public void EnableViewport(DeviceContext devCont)
{
// Set the render target to the specific viewport
devCont.OutputMerger.SetTargets( m_DepthStencilView, m_RenderTarget );
/// Clear or fill the Render target with a single color
devCont.ClearRenderTargetView(
m_RenderTarget, new Color4( 0.0f, 0.0f, 0.0f, 1.0f ) );
//m_RenderTarget, new Color4( 0.0f, 0.125f, 0.3f, 1.0f ) );
/// clear the depth buffer to 1.0 (max depth)
devCont.ClearDepthStencilView(
m_DepthStencilView, DepthStencilClearFlags.Depth,
1.0f, 0 );
/// Set the selected camera to the
/// camera of the selected viewport
Engine.g_RenderCamera = m_Camera;
/// Apply the viewport the rasterizer
/// (the thing that actually draws the triangle)
devCont.Rasterizer.SetViewport( m_Viewport.X, m_Viewport.Y,
m_Viewport.Width, m_Viewport.Height, m_Viewport.MinZ, m_Viewport.MaxZ);
if ( m_RasterizerState.Description.FillMode != Settings.FillMode || m_RasterizerState.Description.CullMode != Settings.CullMode) {
m_RasterizerStateDesc = new RasterizerStateDescription();
m_RasterizerStateDesc.CullMode = Settings.CullMode;
m_RasterizerStateDesc.FillMode = Settings.FillMode;
m_RasterizerStateDesc.IsDepthClipEnabled = true;
m_RasterizerStateDesc.IsScissorEnabled = false;
m_RasterizerStateDesc.IsMultisampleEnabled = false;
m_RasterizerStateDesc.IsAntialiasedLineEnabled = false;
m_RasterizerStateDesc.SlopeScaledDepthBias = 0.0f;
m_RasterizerStateDesc.DepthBiasClamp = 0.0f;
m_RasterizerStateDesc.DepthBias = 0;
m_RasterizerState = new RasterizerState( Engine.g_device, m_RasterizerStateDesc );
}
/// set the rasterizer state
devCont.Rasterizer.State = m_RasterizerState;
}
示例13: RenderCubemap
public static void RenderCubemap(DeviceContext context, TextureObject targetTexture, TextureObject targetDepth, SimpleSceneWrapper sceneWrapper, Vector3 position, float range, bool depthOnly = false, Color4 clearColor = new Color4())
{
//using (new GpuProfilePoint(context, "CubemapRendering"))
{
// some hardcoded near plane
Matrix projectionMatrix = Matrix.PerspectiveFovLH((float)Math.PI / 2.0f, 1.0f, 0.05f, range);
ContextHelper.SetDepthStencilState(context, ContextHelper.DepthConfigurationType.DepthCompare);
// set the shaders
context.VertexShader.Set(ShaderManager.GetVertexShader("VertexScene"));
context.PixelShader.Set(depthOnly ? null : ShaderManager.GetPixelShader("PixelSceneSimple"));
dynamic cvpb = m_CurrentViewportBuffer;
for (int i = 0; i < 6; ++i)
{
Vector3 lookAt = new Vector3();
Vector3 upVec = new Vector3();
switch (i)
{
case 0:
lookAt = new Vector3(1.0f, 0.0f, 0.0f);
upVec = new Vector3(0.0f, 1.0f, 0.0f);
break;
case 1:
lookAt = new Vector3(-1.0f, 0.0f, 0.0f);
upVec = new Vector3(0.0f, 1.0f, 0.0f);
break;
case 2:
lookAt = new Vector3(0.0f, 1.0f, 0.0f);
upVec = new Vector3(0.0f, 0.0f, -1.0f);
break;
case 3:
lookAt = new Vector3(0.0f, -1.0f, 0.0f);
upVec = new Vector3(0.0f, 0.0f, 1.0f);
break;
case 4:
lookAt = new Vector3(0.0f, 0.0f, 1.0f);
upVec = new Vector3(0.0f, 1.0f, 0.0f);
break;
case 5:
lookAt = new Vector3(0.0f, 0.0f, -1.0f);
upVec = new Vector3(0.0f, 1.0f, 0.0f);
break;
}
Matrix viewMatrix = Matrix.LookAtLH(position, position + lookAt, upVec);
cvpb.g_ProjMatrix = projectionMatrix;
cvpb.g_ViewMatrix = viewMatrix;
cvpb.g_ViewProjMatrix = viewMatrix * projectionMatrix;
{
context.ClearRenderTargetView(targetTexture.m_ArrayRenderTargetViews[i], clearColor);
context.ClearDepthStencilView(targetDepth.m_ArrayDepthStencilViews[i], DepthStencilClearFlags.Depth, 1.0f, 0);
RenderTargetSet.BindTextureAsRenderTarget(context, targetTexture.m_ArrayRenderTargetViews[i], targetDepth.m_ArrayDepthStencilViews[i], targetTexture.m_Width, targetTexture.m_Height);
m_CurrentViewportBuffer.CompileAndBind(context);
// render triangles
sceneWrapper.Render(context);
RenderTargetSet.BindNull(context);
}
}
ContextHelper.SetDepthStencilState(context, ContextHelper.DepthConfigurationType.NoDepth);
}
}
示例14: Clear
public void Clear(DeviceContext context, Color4 color, bool depth = false)
{
for (int i = 0; i < m_NumRTs; ++i)
{
context.ClearRenderTargetView(m_RenderTargets[i].m_RenderTargetView, color);
}
if (depth && m_DepthStencil.m_DepthStencilView != null)
{
context.ClearDepthStencilView(m_DepthStencil.m_DepthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);
}
}