本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.Clear方法的具体用法?C# GraphicsDevice.Clear怎么用?C# GraphicsDevice.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
using (var form = CreateForm())
{
PresentationParameters presentationParameters = CreatePresentationParameters();
var device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware,
form.Handle, presentationParameters);
Application.Idle +=
delegate
{
device.Clear(Color.Blue);
device.Present();
Application.DoEvents();
};
Application.Run(form);
}
}
示例2: ToneMap
private void ToneMap(Renderer renderer, Vector2 resolution, GraphicsDevice device, Texture2D lightBuffer)
{
var toneMapped = RenderTargetManager.GetTarget(device, (int)resolution.X, (int)resolution.Y, SurfaceFormat.Color, depthFormat: DepthFormat.Depth24Stencil8, name: "tone mapped", usage: RenderTargetUsage.DiscardContents);
device.SetRenderTarget(toneMapped);
device.Clear(Color.Transparent);
device.DepthStencilState = DepthStencilState.None;
device.BlendState = BlendState.Opaque;
_toneMap.Parameters["Texture"].SetValue(lightBuffer);
_toneMap.Parameters["Luminance"].SetValue(_adaptedLuminance[_current]);
_toneMap.Parameters["MinExposure"].SetValue(renderer.Data.GetValue(new TypedName<float>("hdr_minexposure")));
_toneMap.Parameters["MaxExposure"].SetValue(renderer.Data.GetValue(new TypedName<float>("hdr_maxexposure")));
_quad.Draw(_toneMap, renderer.Data);
Output("tonemapped", toneMapped);
}
示例3: CalculateLuminance
private void CalculateLuminance(Renderer renderer, Vector2 resolution, GraphicsDevice device, Texture2D lightBuffer)
{
if (_previous == -1)
{
_previous = 1;
device.SetRenderTarget(_adaptedLuminance[_previous]);
device.Clear(Color.Transparent);
device.SetRenderTarget(null);
}
var tmp = _previous;
_previous = _current;
_current = tmp;
// calculate luminance map
var luminanceMap = RenderTargetManager.GetTarget(device, 1024, 1024, SurfaceFormat.Single, mipMap: true, name: "luminance map", usage: RenderTargetUsage.DiscardContents);
device.SetRenderTarget(luminanceMap);
device.BlendState = BlendState.Opaque;
device.Clear(Color.Transparent);
_calculateLuminance.Parameters["Texture"].SetValue(lightBuffer);
_quad.Draw(_calculateLuminance, renderer.Data);
Output("luminance", luminanceMap);
// read bottom mipmap to find average luminance
_averageLuminance = RenderTargetManager.GetTarget(device, 1, 1, SurfaceFormat.Single, name: "average luminance", usage: RenderTargetUsage.DiscardContents);
device.SetRenderTarget(_averageLuminance);
_readLuminance.Parameters["Texture"].SetValue(luminanceMap);
_quad.Draw(_readLuminance, renderer.Data);
// adapt towards the current luminance
device.SetRenderTarget(_adaptedLuminance[_current]);
_adaptLuminance.Parameters["Texture"].SetValue(_averageLuminance);
_adaptLuminance.Parameters["PreviousAdaption"].SetValue(_adaptedLuminance[_previous]);
_quad.Draw(_adaptLuminance, renderer.Data);
RenderTargetManager.RecycleTarget(_averageLuminance);
}
示例4: Create
public void Create(bool fullscreen, int width, int height, bool audio)
{
GraphicsDevice Device;
Window = new Form();
Window.ClientSize = new System.Drawing.Size(width, height);
Window.Show();
//GraphicsAdapter.DefaultAdapter.
PresentationParameters param=new PresentationParameters();
param.BackBufferCount=1;
//param.BackBufferFormat=SurfaceFormat.Rgba32;
param.BackBufferHeight=height;
param.BackBufferWidth=width;
//param.FullScreenRefreshRateInHz=60;
param.IsFullScreen=fullscreen;
param.PresentFlag=PresentFlag.None;
param.SwapEffect=fullscreen?SwapEffect.Flip:SwapEffect.Discard;
param.PresentationInterval=PresentInterval.One;
param.AutoDepthStencilFormat = DepthFormat.Depth16;
param.BackBufferFormat = SurfaceFormat.Bgr32;
param.EnableAutoDepthStencil = true;
param.PresentationInterval = PresentInterval.Immediate;
try
{
Device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, Window.Handle, CreateOptions.HardwareVertexProcessing, param);
}
catch (InvalidCallException e)
{
System.Console.WriteLine(e.Message);
System.Console.WriteLine(e.ErrorCode);
throw e;
}
Device.Clear(new Color(0, 0, 0, 1));
Device.Present();
renderer = new XnaRenderer(Device);
}