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); } }
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); } }