尝试在API 8(2.2)上的OPENGL 2中实现VBO

时间:2012-01-07 10:20:17

标签: android opengl-es-2.0 vbo

我被困在如何告诉Open Gl关于VBO的布局,或者说,告诉程序哪里有东西。

//bind buffer
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vboBuffer);
//find shader attribute
int ref = GLES20.glGetAttribLocation(mProgram, "aPosition");
//set up vertex
GLES20.glVertexAttribPointer(maPositionHandle, 3,
                             GLES20.GL_FLOAT, false,
                TRIANGLE_VERTICES_DATA_STRIDE_BYTES, ???);
//enable attrib
GLES20.glEnableVertexAttribArray(maPositionHandle);

重复法线和纹理坐标。

但是,在API 8中,只有:

glVertexAttribPointer(int indx, int size, int type,
                      boolean normalized, int stride, Buffer ptr)

而不是:

glVertexAttribPointer(int indx, int size, int type,
                      boolean normalized, int stride, int offset)

所以鉴于我无法在API 8中添加偏移量,我将什么放入Buffer param?

1 个答案:

答案 0 :(得分:1)

遗憾的是,VBO不能与API 8(Android 2.2)一起使用。您需要更新到修复此错误的API 9(Android 2.3)。或者你必须坚持旧的好ByteBuffer。

希望这会有所帮助......