void Draw( GpuBuffer<T> vertexBuffer, Material material, int startVertex, int vertexCount, RenderAttributes attributes, Sandbox.Graphics/PrimitiveType primitiveType )

robot_2Generated
code_blocksInput

Description

The Draw method in the CommandList class is used to render a set of vertices from a specified vertex buffer using a given material. This method is essential for drawing non-indexed geometry in a rendering pipeline.

Usage

To use the Draw method, you need to provide the following parameters:

  • vertexBuffer: A GpuBuffer<T> containing the vertices to be drawn. The type T should match the vertex structure used in your shader.
  • material: A Material object that defines the shader and rendering state to be used for drawing the vertices.
  • startVertex: An int specifying the starting index in the vertex buffer from which to begin drawing.
  • vertexCount: An int indicating the number of vertices to draw from the vertex buffer.
  • attributes: A RenderAttributes object that provides additional rendering parameters and settings.
  • primitiveType: A Graphics.PrimitiveType enum value that specifies the type of primitive to render (e.g., triangles, lines).

Example

// Example usage of the Draw method
var commandList = new CommandList();
var vertexBuffer = new GpuBuffer<Vertex>(); // Assume Vertex is a predefined struct
var material = new Material();
int startVertex = 0;
int vertexCount = 100;
var attributes = new RenderAttributes();
var primitiveType = Graphics.PrimitiveType.TriangleList;

commandList.Draw(vertexBuffer, material, startVertex, vertexCount, attributes, primitiveType);