Engine API Reference - v2.17.0
    Preparing search index...

    Class QuadRender

    An object that renders a quad using a Shader.

    Note: QuadRender does not modify render states. Before calling QuadRender#render, you should set up the required states using GraphicsDevice#setDrawStates, or the individual setters (GraphicsDevice#setBlendState, GraphicsDevice#setCullMode, GraphicsDevice#setFrontFace, GraphicsDevice#setDepthState, GraphicsDevice#setStencilState). Otherwise previously set states will be used.

    Example:

    const shader = pc.ShaderUtils.createShader(app.graphicsDevice, {
    uniqueName: 'MyShader',
    attributes: { aPosition: SEMANTIC_POSITION },
    vertexGLSL: '// vertex shader code',
    fragmentGLSL: '// fragment shader code'
    });
    const quad = new QuadRender(shader);

    // Set up render states before rendering (defaults are suitable for full-screen quads)
    app.graphicsDevice.setDrawStates();

    quad.render();
    quad.destroy();
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Renders the quad. If the viewport is provided, the original viewport and scissor is restored after the rendering.

      Parameters

      • Optionalviewport: Vec4

        The viewport rectangle of the quad, in pixels. The viewport is not changed if not provided.

      • Optionalscissor: Vec4

        The scissor rectangle of the quad, in pixels. Used only if the viewport is provided.

      • OptionalnumInstances: number

        Number of instances to draw. When provided, renders multiple quads using instanced drawing. Each instance can use the instance index (gl_InstanceID in GLSL, pcInstanceIndex in WGSL) to fetch per-quad data from a texture or buffer, allowing each quad to be parameterized independently.

      Returns void