【发布时间】:2015-07-06 15:57:40
【问题描述】:
在我的示例中给出这个数组:
private final float[] mVerticesData =
{
-0.5f, 0.5f, 0.0f, // Position 0
0.0f, 0.0f, // TexCoord 0
-0.5f, -0.5f, 0.0f, // Position 1
0.0f, 1.0f, // TexCoord 1
0.5f, -0.5f, 0.0f, // Position 2
1.0f, 1.0f, // TexCoord 2
0.5f, 0.5f, 0.0f, // Position 3
1.0f, 0.0f // TexCoord 3
};
在绘制循环中设置属性:
//Load the vertices
mVertices.position ( 0 );
GLES30.glVertexAttribPointer ( 0, 3, GLES30.GL_FLOAT,
false,
5 * 4, mVertices );
// Load the texture coordinate
mVertices.position ( 3 );
GLES30.glVertexAttribPointer ( 1, 2, GLES30.GL_FLOAT,
false,
5 * 4,
mVertices );
顶点的加载对我来说似乎完全合乎逻辑,位置为零,这是第一个元素 在缓冲区中,三个元素组成了顶点向量。然后步幅包括五个 元素三个用于顶点向量,两个用于纹理坐标,所以我取 (5*4) 为 我认为转换为字节。
我的问题是关于纹理坐标的加载,我希望看到索引 glVertexAttributePointer 设置为 0,但设置为 1。纹理坐标是否可能是 通过OpenGL向后阅读?如果不是,为什么索引为 1?我看到它在这种配置下工作,但我不明白 1 的索引。
我在 pastebin 中的代码:http://pastebin.com/0hxDS8Kt
我在 pastebin 中的着色器:http://pastebin.com/8DkBfETn
【问题讨论】: