本文整理汇总了C#中GraphicsDevice.SetViewports方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.SetViewports方法的具体用法?C# GraphicsDevice.SetViewports怎么用?C# GraphicsDevice.SetViewports使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.SetViewports方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WarpSceneRenderer
public WarpSceneRenderer(Scene scene, int width, int height)
{
_scene = scene;
_width = width;
_height = height;
_aspectRatio = width / (float)height;
_device = GraphicsDevice.New(DriverType.Warp, DeviceCreationFlags.None, FeatureLevel.Level_10_1);
var serviceProvider = new ServiceProvider();
serviceProvider.AddService<IGraphicsDeviceService>(new GraphicsDeviceService(_device));
_contentManager = new ContentManager(serviceProvider);
_contentManager.Resolvers.Add(new ContentResolver());
var viewport = new Viewport(0, 0, _width, _height);
_device.SetViewports(viewport);
const MSAALevel msaaLevel = MSAALevel.None;
_depthStencilTexture = DepthStencilBuffer.New(_device, _width, _height, msaaLevel, DepthFormat.Depth24Stencil8);
_renderTexture = RenderTarget2D.New(_device, _width, _height, msaaLevel, PixelFormat.R8G8B8A8.UNorm);
Options = new RenderOptions();
_effect = new BasicEffect(_device);
_effect.EnableDefaultLighting();
_inputLayout = VertexInputLayout.New(0, typeof(VertexPositionNormalTexture));
_device.SetVertexInputLayout(_inputLayout);
_meshes = new List<WarpMesh>();
foreach (Mesh mesh in _scene.Meshes)
{
if (!mesh.Positions.Any())
continue;
var warpMesh = new WarpMesh(_device, mesh);
_meshes.Add(warpMesh);
warpMesh.Initialize(_contentManager);
}
}