跳到正文

Shader

使用有限数量的数值着色器参数绘制经过验证的 WGSL。

正在加载交互演示…

#导入

从 quickgui 导入 CustomShader。

use quickgui::*;

#用法

custom_shader(
    CustomShader::new(
        "fn quickgui_fragment(input: QuickGuiShaderInput) -> vec4<f32> { return vec4<f32>(input.uv.x, 0.3, input.uv.y, 1.0); }",
    )
    .expect("shader"),
)
.size(260.0, 150.0)

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

CustomShader

查看源码
pub fn new(source: impl AsRef<str>) -> Result<Self, CustomShaderError>
source_bytespub fn source_bytes(&self) -> usize—

Configures source bytes for this part.

pub fn source_bytes(&self) -> usize
查看源码

custom_shader

查看源码
pub fn custom_shader(shader: impl Into<CustomShader>) -> Element

Create a retained rectangle painted by validated application WGSL. Like the web canvas default, its initial size is 300 by 150 logical pixels. The shader remains still until application state invalidates the view or explicitly requests another frame.