OpenGL如何知道它应该基于GL_ARRAY_BUFFER绘制顶点到什么位置
How does OpenGL know to what position it should draw the vertices based on the GL_ARRAY_BUFFER?
例如,我有以下代码:
//Create a vbo and bind it to the GL_ARRAY_BUFFER
glGenBuffers(1, &positionBufferObject);
glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);
//vertexPosition is an array of floats that stores the position of 3 vertices (x, y, z, w)
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, GL_STATIC_DRAW);
//Enable the vbo at index 0 of the vao (assuming I have stored it previously at index 0)
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
//Finally draw the triangle
glDrawArrays(GL_TRIANGLES, 0, 3);
我的问题是,glDrawArrays()如何知道绑定到GL_ARRAY_BUFFER的是关于位置的信息,而不是关于颜色的信息?
如果gl_Vertex
可用(即不是核心配置文件),则规范会调用该位置和顶点属性0别名。
来自gl 4.5兼容性配置文件规范(第401/1005页):
将通用顶点属性设置为零将指定一个顶点,如下所示如第10.7.2节所述。设置任何其他常规顶点属性更新属性的当前值。没有顶点属性零的当前值
相关文章:
- C++11 中不同类型的对象的 std::array 的替代方案
- constexpr begin of a std::array
- C++如果必须在编译时确定大小,std::array 有什么意义?
- OpenGL VBO Indexing ( How to compute Index Array)
- 标准::unordered_map 中的 std::array 的值初始化
- "Warning: Comma within array index expression"但逗号分隔函数参数
- 确保编译时的特定 std::array 位置
- std::array的长度有大小限制吗?
- 将 std::array 移动到另一个 std::array
- 首先按给定顺序打印所有数字,然后使用 Array 打印所有字符和其他符号
- 为什么 std::shared_ptr 被认为是"heavy"和"expensive",但 std::array "same perfprmance as plain (c-style) arrays
- 将 **float array 从 C++ Dll 传递给 python
- std::bind on statd::array 的运算符 []
- 检查输入 std::array 指针数据是否等于某个常量数组
- 我可以安全地复制矢量<array>吗?
- 解析问题 - 预期的非限定 ID - #include <array> 编译错误
- 如何读/写或遍历 std::array 中的特定元素范围?
- 通过 host() 从 af::array 检索数据会导致错误的数据
- 如何将 std::array 转换为 boost::asio::buffer
- Buffer.BlockCopy Array 2d c++ to C# 共享内存