Files
XCEngine/docs/api/rhi/opengl/command-list/draw.md

38 lines
1.0 KiB
Markdown
Raw Normal View History

# OpenGLCommandList::Draw
```cpp
void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t startVertex, uint32_t startInstance)
```
2026-03-20 02:35:45 +08:00
绘制非索引图元(实例化绘制)。
**参数:**
2026-03-20 02:35:45 +08:00
- `vertexCount` - 每个实例的顶点数量
- `instanceCount` - 要绘制的实例数量
- `startVertex` - 第一个顶点的索引
- `startInstance` - 第一个实例的 ID
**返回值**:无
**详细描述**
此方法使用 `glDrawArraysInstanced` 执行实例化绘制。当 `instanceCount` 为 1 时,等同于普通的非实例化绘制。
**示例:**
```cpp
2026-03-20 02:35:45 +08:00
// 绘制单个实例(相当于 glDrawArrays
commandList->Draw(3, 1, 0, 0);
2026-03-20 02:35:45 +08:00
// 绘制 100 个实例
commandList->Draw(3, 100, 0, 0);
// 绘制多个实例,从实例 ID 10 开始
commandList->Draw(3, 50, 0, 10);
```
## 相关文档
2026-03-20 02:35:45 +08:00
- [OpenGLCommandList 总览](command-list.md) - 返回类总览
- [DrawIndexed](draw-indexed.md) - 索引绘制
- [OpenGL 特有 Draw 方法](opengl-methods.md#draw-primitivetype) - 使用 PrimitiveType 的版本