Results 1 to 2 of 2

Thread: IBO's and glDrawElements

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011

    IBO's and glDrawElements

    So what I am attempting to do is create multiple pieces of geometry and concate them together into an IBO I can then iterate over displaying each piece of geometry via glDrawElements. I know that I have created & uploaded the VBO correctly, and have the desired index list made. I can see this by replacing the glDrawElements by a glDrawArrays and I get the appropriate geometry on the screen. Which indicates to me that the problem is either how I am uploading the IBO to gl or in the glDrawElements command. I've been over this multiple times and can't seam to pinpoint the problem, is there something obvious going on that I am simply not seeing? Code snippet below:

    Code :
    void SVIS_displayVectorData(SVIS_VECTORDATA *data)
      int i;
      // First we validate the data, then ensure that it's uploaded, then, finaly,
      // display it.
      if (data && data->vectorLoadComplete) {
        if (!data->vboCreateComplete) {
          glGenBuffers(1, &data->vbo);
          glGenBuffers(1, &data->ibo);
          glBindBuffer(GL_ARRAY_BUFFER, data->vbo);
          glBufferData(GL_ARRAY_BUFFER, sizeof(SVN_VEC3) * data->maxVerticies, 
                       data->verts, GL_DYNAMIC_DRAW);
          data->vboCreateComplete = TRUE;
        } else {
          if (data->zoomLvl != G_mapZoom) {
            //NOTE: data->indicies are propogated at this point, TODO: Repopulate based on zoom level.
            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data->ibo);
            glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * data->maxVerticies, // 1:1 ratio of verts to indicies is max case.
                         data->indicies, GL_DYNAMIC_DRAW);
            data->zoomLvl = G_mapZoom;
          // At this point, we do the actual drawing.
          glEnableClientState(GL_VERTEX_ARRAY);     // Enable vertex points
          glEnable(GL_POLYGON_SMOOTH);              // Don't know if this is neccisary
          glDepthFunc(GL_ALWAYS);                   // Don't let terrain be drawn on top
          // NOTE: Don't set color or line width here. These should be done by
          // the calling procedure.
          glBindBuffer(GL_ARRAY_BUFFER, data->vbo);
          glVertexPointer(3, GL_FLOAT, sizeof(SVN_VEC3), 0);
          glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data->ibo);
          for (i = 0; i < data->numElements; i++) {
            SVIS_VECTOR_ELEMENT *ptr = &data->elements[i];
            glDrawElements(GL_LINE_STRIP, ptr->indicyCount, GL_UNSIGNED_INT, 
                           ptr->startIndicyIndex * sizeof(unsigned int));
            //glDrawArrays(GL_LINE_STRIP, ptr->startIndicyIndex, ptr->indicyCount); // NOTE: replacing glDrawElements with this works.
          glDepthFunc(GL_LESS);                     // Reset to default
          glDisable(GL_POLYGON_SMOOTH);             // See comment for Enable
          glDisableClientState(GL_VERTEX_ARRAY);    // Clean up the gl state.

  2. #2
    Junior Member Newbie
    Join Date
    Mar 2011
    Nevermind, I found the problem. The initial state of the system had data->zoomLvl == G_mapZoom causing the IBO not to be allocated/filled.

Similar Threads

  1. about glDrawElements
    By freesui1984 in forum OpenGL ES
    Replies: 3
    Last Post: 10-10-2008, 04:17 AM
  2. Getting glDrawElements
    By Cribs in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-24-2007, 09:46 PM
  3. glDrawElements
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-28-2005, 04:39 AM
  4. Once & Again: glDrawElements
    By t33mu in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 06-02-2001, 09:16 AM
  5. glDrawElements()
    By eckiller in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 05-04-2000, 11:37 PM

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