本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.GraphicsDevice.Present方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.Present方法的具体用法?C# GraphicsDevice.Present怎么用?C# GraphicsDevice.Present使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.Present方法的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: Run
public void Run()
{
using (var form = EmptyWindow.CreateForm())
{
PresentationParameters presentationParameters = EmptyWindow.CreatePresentationParameters();
var device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware,
form.Handle, presentationParameters);
Vertex[] vertices = CreateVertices();
var vertexBuffer = new VertexBuffer(device,
typeof(Vertex), vertices.Length, BufferUsage.None);
vertexBuffer.SetData(vertices, 0, vertices.Length);
var indices = CreateIndices();
var indexBuffer = new IndexBuffer(device,
sizeof (int) * indices.Length, BufferUsage.None,
IndexElementSize.ThirtyTwoBits);
indexBuffer.SetData(indices);
VertexDeclaration vertexDeclaration = TriangleWithVertexBuffer.CreateVertexDeclaration(device);
var basicEffect = new BasicEffect(device, new EffectPool())
{
LightingEnabled = false,
TextureEnabled = false,
VertexColorEnabled = true
};
Application.Idle +=
delegate
{
device.Clear(Color.Blue);
device.VertexDeclaration = vertexDeclaration;
device.Vertices[0].SetSource(vertexBuffer, 0, 24);
device.Indices = indexBuffer;
device.RenderState.CullMode = CullMode.None;
basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(
(float)(System.Math.PI / 3), 800f / 600.0f, 0.01f, 100f);
basicEffect.View = Matrix.CreateLookAt(
new Vector3(0, 0, -3), new Vector3(), new Vector3(0, 1, 0));
basicEffect.World = Matrix.Identity;
basicEffect.Begin();
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Begin();
device.DrawIndexedPrimitives(PrimitiveType.TriangleList,
0, 0, vertices.Length, 0, 2);
pass.End();
}
basicEffect.End();
device.Present();
Application.DoEvents();
};
Application.Run(form);
}
}
示例3: DrawRightEye
private void DrawRightEye(GameTime time, Vector3 eyePosition, RenderModes mode, GraphicsDevice device,
SpriteBatch sb)
{
switch (mode)
{
case RenderModes.StereoCrossConverged:
device.SetRenderTarget(0, (_takeScreenshot ? _screenshotTargetRight : _rightEyeRender));
break;
case RenderModes.Stereo:
// Draw on the extra created window
device.Present(_stereoRightHandle);
break;
}
device.Clear(ClearColor);
// Setup camera for right eye
// Translate look at direction to new eye position
const float focusDistance = 10.0f;
Vector3 lookAtVector = Vector3.Normalize(Camera.LookAt - Camera.Position);
Camera.LookAt = Camera.Position + focusDistance*lookAtVector;
Camera.Position = eyePosition;
Camera.UpdateMatrices();
_basicEffect.View = Camera.View;
base.Draw(time);
// Print FPS
if (ShowFPS)
{
string fpsText = "FPS: " + _fpsUtil.Value;
PrintInfo(sb, new Vector2(0.9f*_screenWidth, 0), fpsText);
}
}
示例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);
}