GLES error: vertex attribute array is enabled with no data bound

GLES error: vertex attribute array is enabled with no data bound

OpenGl 新手,目前正在研究 Android NDK。我目前收到此错误,无法弄清楚。我觉得这是基本的东西,但我可能是错的。 java 渲染端的 appRender 每帧 运行。

错误:

E/emuglGLESv2_enc: glDrawArrays: a vertex attribute array is enabled with no data bound

app.cpp:

void appRender(long tick, int width, int height){
    const float vertices[] =
    {
         0.0f,  0.5f, 0.0f,
        -0.5f, -0.5f, 0.0f,
         0.5f, -0.5f, 0.0f
    };

    glClear(GL_COLOR_BUFFER_BIT);

    GLuint vertexBuffer;
    glGenBuffers(1, &vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    // Setup colors for each vertex
    GLfloat colors[3*4];
    for (int v = 0; v < 3; v++){
        colors[4*v+0] = 0;
        colors[4*v+1] = 1;
        colors[4*v+2] = 0;
        colors[4*v+3] = 1;
    }

    // Setup color buffer
    GLuint colorBuffer;
    glGenBuffers(1, &colorBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors, GL_STATIC_DRAW);

    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glVertexAttribPointer(
        1,
        3,
        GL_FLOAT,
        GL_FALSE,
        0,
        (void*)0
        );

    glEnableVertexAttribArray(1);
    glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
    glVertexAttribPointer(
        1,
        4,
        GL_FLOAT,
        GL_FALSE,
        0,
        (void*)0
        );


    glDrawArrays(GL_TRIANGLES, 0, 3);
    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);

    glBindTexture(GL_TEXTURE_2D, 0);
    //textRenderer.RenderTexts(0.5f);
    //boxRenderer.RenderBoxes(0.5f);
}

所以我找到了,是的,我很糟糕。

glVertexAttribPointer(1,3,...) -> glVertexAttribPointer(0,3,...)