src/third_party/angle/src/tests/gl_tests/DrawElementsTest.cpp
// Test no error is generated when using client-side arrays, indices = nullptr and count = 0
Test no error is generated when using client-side arrays, indices = nullptr and count = 0
Test no error is generated when using client - side arrays indices = nullptr and count = 0
TEST_P(DrawElementsTest, ClientSideNullptrArrayZeroCount)
{
    constexpr char kVS[] =
        "attribute vec3 a_pos;\n"
        "void main()\n"
        "{\n"
        "    gl_Position = vec4(a_pos, 1.0);\n"
        "}\n";
    ANGLE_GL_PROGRAM(program, kVS, essl1_shaders::fs::Blue());
    GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
    ASSERT_NE(-1, posLocation);
    glUseProgram(program.get());
    const auto &vertices = GetQuadVertices();
    GLBuffer vertexBuffer;
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.get());
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices[0]) * vertices.size(), vertices.data(),
                 GL_STATIC_DRAW);
    glVertexAttribPointer(posLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(posLocation);
    ASSERT_GL_NO_ERROR();
    glDrawElements(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, nullptr);
    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
    glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_BYTE, nullptr);
    ASSERT_GL_NO_ERROR();
}
TEST_P ( DrawElementsTest , ClientSideNullptrArrayZeroCount ) { constexpr char kVS [ ] = " \n " " \n " " \n " " \n " " \n " ; ANGLE_GL_PROGRAM ( program , kVS , essl1_shaders :: fs :: Blue ( ) ) ; GLint posLocation = glGetAttribLocation ( program . get ( ) , " " ) ; ASSERT_NE ( -1 , posLocation ) ; glUseProgram ( program . get ( ) ) ; const auto & vertices = GetQuadVertices ( ) ; GLBuffer vertexBuffer ; glBindBuffer ( GL_ARRAY_BUFFER , vertexBuffer . get ( ) ) ; glBufferData ( GL_ARRAY_BUFFER , sizeof ( vertices [ 0 ] ) * vertices . size ( ) , vertices . data ( ) , GL_STATIC_DRAW ) ; glVertexAttribPointer ( posLocation , 3 , GL_FLOAT , GL_FALSE , 0 , 0 ) ; glEnableVertexAttribArray ( posLocation ) ; ASSERT_GL_NO_ERROR ( ) ; glDrawElements ( GL_TRIANGLES , 1 , GL_UNSIGNED_BYTE , nullptr ) ; EXPECT_GL_ERROR ( GL_INVALID_OPERATION ) ; glDrawElements ( GL_TRIANGLES , 0 , GL_UNSIGNED_BYTE , nullptr ) ; ASSERT_GL_NO_ERROR ( ) ; }
Test no error is generated when using client-side arrays, indices = nullptr and count = 0
Test no error is generated when using client - side arrays indices = nullptr and count = 0
// "If drawElements is called with a count greater than zero, and no WebGLBuffer is bound to the // ELEMENT_ARRAY_BUFFER binding point, an INVALID_OPERATION error is generated." // count == 0 so it's fine to have no element array buffer bound.