Jump to content
  • Advertisement
Sign in to follow this  

VBO segfaulting [solved]

This topic is 3380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
The code looks correct to me, so just make sure there are no GL errors, you have existing context while creating the VBO and m_testVBO is not zero.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!