Results 1 to 2 of 2

Thread: VBOs

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2009


    Is there anything wrong in the way I try to draw VBOs/IBOs? I only manage to get random lines on the screen that appear and disappear every other frame.

    Here is the code to create them:
    // VBO
    glGenBuffers(1, &VBOID);
    glBindBuffer(GL_ARRAY_BUFFER, VBOID);
    glBufferData(GL_ARRAY_BUFFER, VBOSize*sizeof(float), NULL, GL_STATIC_DRAW);
    glBufferSubData(GL_ARRAY_BUFFER, 0, VBOSize*sizeof(GLushort), VBO);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    glGenBuffers(1, &IBOID);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, IBOSize*sizeof(GLuint), NULL, GL_STATIC_DRAW);
    glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, IBOSize*sizeof(GLushort), IBO);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    // end VBO

    And here the way I draw them:

    // Draw VBO
    glEnableClientState(GL_VERTEX_ARRAY); // enable array states
    glBindBuffer(GL_ARRAY_BUFFER, VBOID); // binding the VBO and assign NULL to the vertex pointer
    glVertexPointer(3, GL_FLOAT, 0, NULL);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOID); // binding the VBO and assign NULL to the vertex pointer
    glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL); // draw elements in the IBO

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // debind IBO
    glBindBuffer(GL_ARRAY_BUFFER, 0); // debind VBO
    glDisableClientState(GL_VERTEX_ARRAY); // disable array states

    Here is the complete source:

  2. #2
    Senior Member Frequent Contributor plasmonster's Avatar
    Join Date
    Mar 2004

    Re: VBOs

    When in doubt, ferret it out:

    Probably best to start with a tried and true recipe where possible, then season to taste.

    Hope it helps.

Similar Threads

  1. Some Help With VBOs
    By Fezziwig in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-08-2013, 06:07 AM
  2. Use of VBOs
    By GarrickW in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-22-2011, 12:42 AM
  3. C++/CLI and VBOs
    By sunburntfish in forum OpenGL: Windows
    Replies: 5
    Last Post: 09-29-2011, 12:49 PM
  4. Two VBOs at once?
    By strattonbrazil in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 11-01-2010, 07:25 AM
  5. Using VBOs
    By Cinderella in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-29-2010, 04:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean