drawing two objects with two vbo,vao

    GLuint VBO[2], VAO[2];

    glGenVertexArrays(2, VAO);
    glGenBuffers(2, VAO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO[0]);
    //Konfiguration bezieht sich jetzt auf VBO[0] wegen glbindvertexarray()
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
    glVertexAttribPointer(0,3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid *) 0);

    glBindBuffer(GL_ARRAY_BUFFER, VBO[1]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(secVertices), secVertices, GL_STATIC_DRAW);
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE,0, (GLvoid *) 0);

i am trying to draw two quads with two different vbos/vaos.
i am absolutely new to opengl and i am learning with a pdf tutorial.
when i start the program , only one quad is drawn
its the quad from vao[1] and vbo[1].
it has to do with glbufferdata but i dont really get it.

please tell me what to do. sorry for my english and thanks for answears

This looks like a typo. Look at which array you’re passing to glGenBuffers. Also…

glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE,0, (GLvoid *) 0);

I suspect you want 0 here for the first argument of both functions. This call enables generic vertex attribute arrays. 0 is the conventional vertex attribute used for passing the positions array.

The number you use here has to be matched with the vertex attribute index that the vertex shader is expecting the positions to come in on. And finally…


Here at the very end you probably want 0 here as well. Like the same call previously, the purpose of this is to unbind the vertex array object (VAO) that you’re currently configuring.