Sign in to follow this  

VBO segfaulting [solved]

Recommended Posts

I'm trying to use a VBO, but it keeps on segfaulting on me. Here is how I set up the VBO
    glGenBuffers(1, &m_testVBO);
    glBindBuffer(GL_ARRAY_BUFFER, m_testVBO);

    GLfloat vertexData[] = {0.0f, 1.0f,
                          0.0f, 0.0f,
                          1.0f, 1.0f,
                          1.0f, 0.0f};

    GLfloat colorData[] = {.3f, .3f, .3f, 1.f,
                           .5f, .5f, .5f, 1.f,
                           1.f, .5f, .5f, 1.f,
                           1.f, 1.f, 1.f, 1.f};

    glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData) + sizeof(colorData), 0, GL_STATIC_DRAW);
    glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertexData), vertexData);
    glBufferSubData(GL_ARRAY_BUFFER, sizeof(vertexData), sizeof(colorData), colorData);

    glColorPointer(4, GL_FLOAT, 0, (void*)(sizeof(vertexData)));
    glVertexPointer(2, GL_FLOAT, 0, (void*)(0));

    glBindBuffer(GL_ARRAY_BUFFER, 0);

and here is how I render it.
glBindBuffer(GL_ARRAY_BUFFER, m_testVBO);

  glColorPointer(4, GL_FLOAT, 0, (GLvoid*)(8 * sizeof(GLfloat)));
  glVertexPointer(2, GL_FLOAT, 0, 0);
  glDrawArrays(GL_QUADS, 0, 4);


  glBindBuffer(GL_ARRAY_BUFFER, 0);

At this point, I have no idea what I'm doing wrong. (I'm just trying to render a rectangle.) [Edited by - J2902 on September 12, 2009 6:18:10 PM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this