public override void Update(ApplicationTimer timer) { var elapsed = (float)timer.ElapsedSeconds; var movement = elapsed; if (KeyboardHandler.Key(ConsoleKey.W).IsDown()) { _camera.TranslateZ(movement); } if (KeyboardHandler.Key(ConsoleKey.S).IsDown()) { _camera.TranslateZ(-movement); } if (KeyboardHandler.Key(ConsoleKey.A).IsDown()) { _camera.TranslateX(movement); } if (KeyboardHandler.Key(ConsoleKey.D).IsDown()) { _camera.TranslateX(-movement); } if (KeyboardHandler.Key(ConsoleKey.Spacebar).IsDown()) { _camera.TranslateY(-movement); } if (KeyboardHandler.Modifier(ConsoleModifiers.Shift).IsDown()) { _camera.TranslateY(movement); } if (KeyboardHandler.Key(ConsoleKey.UpArrow).IsDown()) { _camera.RotateX(movement); } if (KeyboardHandler.Key(ConsoleKey.DownArrow).IsDown()) { _camera.RotateX(-movement); } if (KeyboardHandler.Key(ConsoleKey.RightArrow).IsDown()) { _camera.RotateY(movement); } if (KeyboardHandler.Key(ConsoleKey.LeftArrow).IsDown()) { _camera.RotateY(-movement); } if (KeyboardHandler.Key(ConsoleKey.M).IsDown()) { _msaa = _msaa.IsMultiSampled ? MsaaDesc.None : MsaaDesc.X8; } }
/// <summary> /// Creates a new <see cref="TextureDesc"/> representing a 2D render target /// </summary> /// <param name="format">The <see cref="DataFormat"/> for the render target</param> /// <param name="width">The width, in texels, of the target</param> /// <param name="height">The height, in texels, of the target</param> /// <param name="clearColor">The <see cref="Rgba128"/> to set to be the optimized clear value</param> /// <param name="msaa">Optionally, the <see cref="MsaaDesc"/> for the render target</param> /// <returns>A new <see cref="TextureDesc"/> representing a render target</returns> public static TextureDesc CreateRenderTargetDesc(DataFormat format, uint width, uint height, Rgba128 clearColor, MsaaDesc msaa = default) { return(new TextureDesc { Height = height, Width = width, DepthOrArraySize = 1, MipCount = 1, Dimension = TextureDimension.Tex2D, Format = format, ClearValue = TextureClearValue.CreateForRenderTarget(clearColor), Msaa = msaa, ResourceFlags = ResourceFlags.AllowRenderTarget, Layout = TextureLayout.Optimal }); }
/// <summary> /// Creates a new <see cref="TextureDesc"/> representing a 2D render target, with no height or width, for unspecified size targets /// </summary> /// <param name="format">The <see cref="BackBufferFormat"/> for the render target</param> /// <param name="clearColor">The <see cref="Rgba128"/> to set to be the optimized clear value</param> /// <param name="msaa">Optionally, the <see cref="MsaaDesc"/> for the render target</param> /// <returns>A new <see cref="TextureDesc"/> representing a render target</returns> public static TextureDesc CreateRenderTargetDesc(DataFormat format, Rgba128 clearColor, MsaaDesc msaa = default) => CreateRenderTargetDesc(format, 0, 0, clearColor, msaa);
/// <summary> /// Creates a new <see cref="TextureDesc"/> representing a 2D render target /// </summary> /// <param name="format">The <see cref="BackBufferFormat"/> for the render target</param> /// <param name="width">The width, in texels, of the target</param> /// <param name="height">The height, in texels, of the target</param> /// <param name="clearColor">The <see cref="Rgba128"/> to set to be the optimized clear value</param> /// <param name="msaa">Optionally, the <see cref="MsaaDesc"/> for the render target</param> /// <returns>A new <see cref="TextureDesc"/> representing a render target</returns> public static TextureDesc CreateRenderTargetDesc(BackBufferFormat format, uint width, uint height, Rgba128 clearColor, MsaaDesc msaa = default) => CreateRenderTargetDesc((DataFormat)format, width, height, clearColor, msaa);
/// <summary> /// Creates a new <see cref="TextureDesc"/> representing a 2D depth stencil /// </summary> /// <param name="format">The <see cref="DataFormat"/> for the depth stencil</param> /// <param name="width">The width, in texels, of the depth stencil</param> /// <param name="height">The height, in texels, of the depth stencil</param> /// <param name="clearDepth">The <see cref="float"/> to set to be the optimized clear value for the depth element</param> /// <param name="clearStencil">The <see cref="byte"/> to set to be the optimized clear value for the stencil element</param> /// <param name="shaderVisible">Whether the <see cref="Texture"/> is shader visible. <see langword="true"/> by default</param> /// <param name="msaa">Optionally, the <see cref="MsaaDesc"/> for the depth stencil</param> /// <returns>A new <see cref="TextureDesc"/> representing a depth stencil</returns> public static TextureDesc CreateDepthStencilDesc(DataFormat format, uint width, uint height, float clearDepth, byte clearStencil, bool shaderVisible = true, MsaaDesc msaa = default) { return(new TextureDesc { Height = height, Width = width, DepthOrArraySize = 1, MipCount = 1, Dimension = TextureDimension.Tex2D, Format = format, ClearValue = TextureClearValue.CreateForDepthStencil(clearDepth, clearStencil), Msaa = msaa, ResourceFlags = ResourceFlags.AllowDepthStencil | (shaderVisible ? 0 : ResourceFlags.DenyShaderResource), Layout = TextureLayout.Optimal }); }
/// <summary> /// Creates a new <see cref="TextureDesc"/> representing a 2D depth stencil, with no height or width, for unspecified size targets /// </summary> /// <param name="format">The <see cref="DataFormat"/> for the depth stencil</param>s /// <param name="clearDepth">The <see cref="float"/> to set to be the optimized clear value for the depth element</param> /// <param name="clearStencil">The <see cref="byte"/> to set to be the optimized clear value for the stencil element</param> /// <param name="shaderVisible">Whether the <see cref="Texture"/> is shader visible. <see langword="true"/> by default</param> /// <param name="msaa">Optionally, the <see cref="MsaaDesc"/> for the depth stencil</param> /// <returns>A new <see cref="TextureDesc"/> representing a depth stencil</returns> public static TextureDesc CreateDepthStencilDesc(DataFormat format, float clearDepth, byte clearStencil, bool shaderVisible = true, MsaaDesc msaa = default) => CreateDepthStencilDesc(format, 0, 0, clearDepth, clearStencil, shaderVisible, msaa);