Files
XCEngine/docs/api/rhi/opengl/vertex-array/set-index-buffer.md
2026-03-20 02:35:45 +08:00

31 lines
929 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# OpenGLVertexArray::SetIndexBuffer
```cpp
void SetIndexBuffer(unsigned int buffer, unsigned int type)
```
设置索引缓冲区。
**详细描述:**
将索引缓冲区绑定到此 VAO。绑定后绘制调用 `glDrawElements` 将使用此索引缓冲。
注意:当前实现中 `type` 参数仅存储,不影响实际 OpenGL 调用;`m_indexCount` 也不会被更新,
需通过其他方式跟踪索引数量。
**参数:**
- `buffer` - OpenGL 缓冲区对象 IDELEMENT_ARRAY_BUFFER
- `type` - 索引数据类型(`GL_UNSIGNED_BYTE``GL_UNSIGNED_SHORT``GL_UNSIGNED_INT`),当前未使用
**示例:**
```cpp
vao.SetIndexBuffer(ibo, GL_UNSIGNED_INT);
```
**注意:**
- `m_indexCount` 在调用此方法后不会自动更新,需手动维护索引数量
- 索引缓冲区的实际类型信息由 OpenGL 绑定时确定
## 相关文档
- [OpenGLVertexArray](vertex-array.md) - 返回类总览