Q:

when I implement indices into a mesh/face, why does it return an OpenGl error? 

So I have a program that generates chunk-meshes based on given vertex data.  I already have it working without indices, but upon trying to include them into my program, it returns OpenGL error 1285. 
I have the arraybuffer and vao calls on different functions, but they look like this:

void Chunk::_loadArrayBuffers()
{
    glGenBuffers(1, &_trianglesID);
    glGenBuffers(1, &_uvsID);
    glGenBuffers(1, &_normalsID);
    glGenBuffers(1, &_IndiceID);

    glBindBuffer(GL_ARRAY_BUFFER, _trianglesID);
    glBufferData(GL_ARRAY_BUFFER,
        _triangles.size() * 3 * sizeof(GLfloat),
        _triangles.data(),
        GL_STATIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, _uvsID);
    glBufferData(GL_ARRAY_BUFFER,
        _uvs.size() * 2 * sizeof(GLfloat),
        _uvs.data(),
        GL_STATIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, _normalsID);
    glBufferData(GL_ARRAY_BUFFER,
        _normals.size() * 3 * sizeof(GLfloat),
        _normals.data(),
        GL_STATIC_DRAW);

    if (_indices.size() * 3 > 0)
    {
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IndiceID);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER,
            _indices.size() * 3 * sizeof(GLfloat),
            _indices.data(),
            GL_STATIC_DRAW);
    }

}

void Chunk::_makeVAO()
{
    glGenVertexArrays(1, &_VAO);
    glBindVertexArray(_VAO);

    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _trianglesID);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

    glEnableVertexAttribArray(1);
    glBindBuffer(GL_ARRAY_BUFFER, _uvsID);
    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0);

    glEnableVertexAttribArray(2);
    glBindBuffer(GL_ARRAY_BUFFER, _normalsID);
    glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, 0);

    glBindVertexArray(0);
}

For each mesh, I store the vertex data of each triangle into multiple glm::vec3s, essentially a vector of size 3.  My rectangle/face creation function looks like this:

void Chunk::_addRectangle(glm::vec3 center, glm::vec3 height, glm::vec3 width, unsigned tex_num)
{
    if (glm::length(height) == 0 || glm::length(width) == 0)
        throw std::runtime_error("width or height should not be 0");

    glm::vec3 corner1 = center - (height / 2.0) - (width / 2.0);
    glm::vec3 corner2 = center - (height / 2.0) + (width / 2.0);
    glm::vec3 corner3 = center + (height / 2.0) + (width / 2.0);
    glm::vec3 corner4 = center + (height / 2.0) - (width / 2.0);

    glm::vec3 normal = glm::cross(height, width);

    glm::vec2 uv1;
    glm::vec2 uv2;
    glm::vec2 uv3;
    glm::vec2 uv4;

    if (fabs(normal[1]) == 1.0)
    {
        uv1 = glm::vec2(1.0 / _tex_atlas_width, 1);
        uv2 = glm::vec2(1.0 / _tex_atlas_width, 0);
        uv3 = glm::vec2(0, 0);
        uv4 = glm::vec2(0, 1);
    }
    else
    {
        uv1 = glm::vec2(1.0 / _tex_atlas_width, height[1]);
        uv2 = glm::vec2(1.0 / _tex_atlas_width, 0);
        uv3 = glm::vec2(0, 0);
        uv4 = glm::vec2(0, height[1]);
    }

    float add = (1.0 / double(_tex_atlas_width)) * tex_num;
    uv1.x += add;
    uv2.x += add;
    uv3.x += add;
    uv4.x += add;

    // triangle 1
    _triangles.push_back(corner3); 
    _triangles.push_back(corner2); 
    _triangles.push_back(corner1); 

    _normals.push_back(normal);
    _normals.push_back(normal);
    _normals.push_back(normal);

    _uvs.push_back(uv1);
    _uvs.push_back(uv2);
    _uvs.push_back(uv3);

    _indices.push_back(glm::vec3(nrOfIndices + 0, nrOfIndices + 1, nrOfIndices + 2));

    // triangle 2 
    //_triangles.push_back(corner1); 
    _triangles.push_back(corner4); 
    //_triangles.push_back(corner3); 

    _normals.push_back(normal);
    _normals.push_back(normal);
    _normals.push_back(normal);

    _uvs.push_back(uv3);
    _uvs.push_back(uv4);
    _uvs.push_back(uv1);

    _indices.push_back(glm::vec3(nrOfIndices + 2, nrOfIndices + 3, nrOfIndices + 0));

    nrOfIndices += 4;

}

everything worked perfectly until I tried to add indices.  What's wrong with it?  I double checked the order of the indices and they seem to be correct, so I'm guessing it's an error with how I'm loading the indices, but I just can't figure it out with what I could find on learnopengl and other opengl documentation.  Thanks! 

A:

The GL_ELEMENT_ARRAY_BUFFER is stated in the Vertex Array Object.  See Index buffers.  
The instruction

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IndiceID); 

associates _IndiceID to the current Vertex Array Object. 
You've to bind the Vertex Array Object, before you specify the element array buffer:
glGenVertexArrays(1, &_VAO);
glBindVertexArray(_VAO);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IndiceID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
    _indices.size() * 3 * sizeof(GLuint),
    _indices.data(),
    GL_STATIC_DRAW);

Note, also the GL_ARRAY_BUFFER is stated in the state vector of the VAO, but this happens when glVertexAttribPointer is called. 
When glVertexAttribPointer is called, then the buffer which is currently bound to the target GL_ARRAY_BUFFER is associated to the vertex attribute with the specified index.  
The difference in the behavior of GL_ELEMENT_ARRAY_BUFFER and GL_ARRAY_BUFFER is caused, because a VAO can only refer to 1 index (element) buffer, but it can refer to multiple array buffers.  Each attribute (index) can be associated to a different buffer.  

Further more the data type of the indices has to be integral.  Possible data types are (unsigned) char, short respectively int, which correspond to the OpenGL enumerator constants GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT.  See glDrawElements 
Change the index vector and use glm::ivec3 rather than glm::vec3
std::vector<glm::ivec3> _indices;

_indices.push_back(glm::ivec3(nrOfIndices + 2, nrOfIndices + 3, nrOfIndices + 0));

glDrawElements(GL_TRIANGLES, _indices.size()*3, GL_UNSIGNED_INT, nullptr);

