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

30 lines
891 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::GetIndexCount
```cpp
unsigned int GetIndexCount() const
```
获取索引数量。
**详细描述:**
返回 `m_indexCount` 成员的值。**注意**:当前实现中 `m_indexCount` 仅在构造函数中初始化为 0
`SetIndexBuffer` 不会更新此值。如需获取索引数量,需在调用 `SetIndexBuffer` 后手动维护或通过其他方式获取。
**返回:** `unsigned int` - 索引数量(当前实现中始终为 0需手动维护
**示例:**
```cpp
// 注意GetIndexCount() 总是返回 0
// 建议自行维护索引数量
unsigned int indexCount = /* 从外部获取或手动设置 */;
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0);
```
**另见:**
- [SetIndexBuffer](set-index-buffer.md) - 设置索引缓冲(不更新 m_indexCount
## 相关文档
- [OpenGLVertexArray](vertex-array.md) - 返回类总览