本文整理汇总了C#中TerraViewer.RenderContext11.SetupBasicEffect方法的典型用法代码示例。如果您正苦于以下问题:C# RenderContext11.SetupBasicEffect方法的具体用法?C# RenderContext11.SetupBasicEffect怎么用?C# RenderContext11.SetupBasicEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TerraViewer.RenderContext11
的用法示例。
在下文中一共展示了RenderContext11.SetupBasicEffect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupGroundOverlays
// Set up render context state required for drawing ground overlays when shaders
// are enabled.
public void SetupGroundOverlays(RenderContext11 renderContext)
{
// A shader should be set up already
if (renderContext.Shader == null)
{
renderContext.SetupBasicEffect(BasicEffect.TextureOnly, 1.0f, Color.White);
}
// Count the number of overlays so that we can choose the appropriate shader
var overlayCount = 0;
foreach (var overlay in GroundOverlays)
{
if (overlay.Icon.Texture != null)
{
++overlayCount;
}
}
overlayCount = Math.Min(PlanetShader11.MaxOverlayTextures, overlayCount);
if (overlayCount == 0)
{
// No work to do
return;
}
// Get a shader identical to the one currently in use, but which supports
// the required number of overlays.
var key = renderContext.Shader.Key;
key.overlayTextureCount = overlayCount;
var overlayShader = PlanetShader11.GetPlanetShader(renderContext.Device, key);
renderContext.Shader = overlayShader;
renderContext.Shader.DiffuseColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
var devContext = renderContext.Device.ImmediateContext;
var overlayIndex = 0;
foreach (var overlay in GroundOverlays)
{
var texture = overlay.Icon.Texture;
if ( texture != null)
{
if (overlayIndex < PlanetShader11.MaxOverlayTextures)
{
renderContext.Shader.SetOverlayTextureMatrix(overlayIndex, overlay.GetMatrix().Matrix11);
renderContext.Shader.SetOverlayTextureColor(overlayIndex, overlay.color);
renderContext.Shader.SetOverlayTexture(overlayIndex, texture.ResourceView);
}
++overlayIndex;
}
}
}
示例2: Draw
public void Draw(RenderContext11 renderContext, float Opacity, Color drawColor)
{
if (glyphCache == null || glyphCache.Version > glyphVersion)
{
PrepareBatch();
}
//todo11 Use Shader
renderContext.SetupBasicEffect(BasicEffect.TextureColorOpacity, Opacity, drawColor);
renderContext.MainTexture = glyphCache.Texture;
renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
renderContext.PreDraw();
if (layout == null)
{
layout = new SharpDX.Direct3D11.InputLayout(renderContext.Device, renderContext.Shader.InputSignature, new[]
{
new SharpDX.Direct3D11.InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float, 0, 0),
new SharpDX.Direct3D11.InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float, 12, 0),
});
}
renderContext.Device.ImmediateContext.InputAssembler.InputLayout = layout;
renderContext.SetVertexBuffer(vertexBuffer);
renderContext.devContext.Draw(vertexBuffer.Count, 0);
}
示例3: Draw
public void Draw(RenderContext11 renderContext)
{
renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
renderContext.devContext.InputAssembler.SetVertexBuffers(0, vertexBufferBinding);
renderContext.devContext.InputAssembler.SetIndexBuffer(indexBuffer, SharpDX.DXGI.Format.R32_UInt, 0);
renderContext.SunPosition = new Vector3d(500, 500, 0.0);
renderContext.SunlightColor = System.Drawing.Color.White;
renderContext.AmbientLightColor = System.Drawing.Color.DarkGray;
renderContext.SetupBasicEffect(BasicEffect.TextureOnly, 1.0f, System.Drawing.Color.White);
renderContext.MainTexture = texture;
renderContext.PreDraw();
if (layout == null)
{
layout = new SharpDX.Direct3D11.InputLayout(renderContext.Device, renderContext.Shader.InputSignature, new[]
{
new SharpDX.Direct3D11.InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float, 0, 0),
new SharpDX.Direct3D11.InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float, 16, 0),
});
renderContext.Device.ImmediateContext.InputAssembler.InputLayout = layout;
}
// Draw the cube
renderContext.devContext.DrawIndexed(triangleCount * 3, 0, 0);
}