---
title: "render(using:_:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowlevelrenderer/render(using:_:)"
---

# render(using:_:)

Encodes draw calls for the frame into the given command buffer using a caller-controlled render callback.

## Declaration

```swift
final func render(using commandBuffer: any MTLCommandBuffer, _ callback: @_lifetime(0: copy 0) (inout LowLevelRenderer.RenderState) -> ())
```

## Parameters

- `commandBuffer`: The Metal command buffer to encode draw calls into.
- `callback`: A closure that receives a RenderState and issues draw calls.

## Discussion

Discussion Inside the callback, call state.render(meshInstancesArrayIndex:meshInstanceIndex:) or state.render(meshInstancesArrayIndex:range:) to encode draw calls in any order. You control which instances are drawn and in what sequence — use sortMeshInstances(_:indices:configuration:) for built-in depth sorting, cullMeshInstances(_:indices:configuration:) to remove instances outside the view frustum before drawing, or supply your own ordering. You are responsible for committing the command buffer after this call returns.

## See Also

### Rendering a frame

- [LowLevelRenderer.RenderState](realitykit/lowlevelrenderer/renderstate.md)
- [LowLevelRenderer.Resources](realitykit/lowlevelrenderer/resources.md)
