Why does this error happen?

#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/glfw3.h>

GLuint VBO[2], VAO[2];

GLfloat vertices[] =
{
        -0.9f, -0.5f, 0.0f,
        -0.0f, -0.5f, 0.0f,
        -0.45f, 0.5f, 0.0f
};

GLfloat vertices2[] =
{
        0.0f, -0.5f, 0.0f,
        0.9f, -0.5f, 0.0f,
        0.45f, 0.5f, 0.0f
};

void init(GLuint &vbo, GLuint &vao, GLfloat *v)
{
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);
    glGenBuffers(1, &vbo);
    glBindBuffer(GL_ARRAY_BUFFER, vbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof(v), v, GL_STATIC_DRAW);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), 0);
    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
}

static void render()
{
    glClearColor(0, 0, 0.2, 0);
    glClear(GL_COLOR_BUFFER_BIT);
    glBindVertexArray(VAO[0]);
    glDrawArrays(GL_TRIANGLES, 0, 6);
    glBindVertexArray(VAO[1]);
    glDrawArrays(GL_TRIANGLES, 0, 6);
}

int main()
{
    glfwInit();
    GLFWwindow *window = glfwCreateWindow(640, 480, "VAO", nullptr, nullptr);
    glfwMakeContextCurrent(window);
    glewInit();
    init(VBO[0], VAO[0], vertices);    init(VBO[1], VAO[1], vertices2);

    while (!glfwWindowShouldClose(window))
    {
        render();

        glfwSwapBuffers(window);
        glfwPollEvents();
    }
    glfwDestroyWindow(window);
    glfwTerminate();
    return 0;
}

The triangle isn’t drawing for me, I just see the clear color.

Hi,

Don’t you need at least need a vertex and a pixel shader? You don’t setup any state at all.
Have a look here: LearnOpenGL - Hello Triangle
This site contains some good tutorials on getting things going with OpenGL.

Regards,
pettersson