Problem with VBO

Hey everybody,
I’ve got a problem with the VBO in C++ (und Mac OS x Lion). First of all thats my code:

float vertexBuffer[8] = {
        0.0F, 0.0F,
        0.0F, h,
        w, h,
        0.0F, h
    unsigned int vertexIndices[4] = {
        0, 1, 2, 3
    glGenBuffers(2, bufferId);
    glBindBuffer(GL_ARRAY_BUFFER, bufferId[0]);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferId[1]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertexBuffer), vertexBuffer, GL_STATIC_DRAW);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(vertexIndices), vertexIndices, GL_STATIC_DRAW);

And render:

glBindBuffer(GL_ARRAY_BUFFER, bufferId[0]);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferId[1]);
    glVertexPointer(2, GL_FLOAT, 8*sizeof(float), 0);
    glColor3f(1.0f, 1.0f, 1.0f);
    glDrawElements(GL_QUADS, 2, GL_UNSIGNED_INT, 0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

Now the problem is it displays nothing. No error or sth like that. Can somebody please help me? Thanks

You’ve specified a stride between vertices of 8sizeof(float) = 32 bytes. But your vertex data is tightly packed and actually has a stride of 2sizeof(float) = 8 bytes.

You’ve also drawn a QUAD with only two vertices, which is an incomplete primitive. You need four vertices per quad.

thx for the answer! But i tried it and it displays nothing… (By the way iam using glut if it helps)

ok i have the error the index array is wrong srry for the noob error :wink: vertexIndices must be 0, 2, 4, 6