Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualClancy

Posted 14 February 2013 - 03:59 PM

This draws a box.

 

     glBegin ( GL_LINE_STRIP );
        glVertex2i ( x0, y0 );
        glVertex2i ( x1, y0 );
        glVertex2i ( x1, y1 );
        glVertex2i ( x0, y1 );
        glVertex2i ( x0, y0 );
    glEnd ();
 

Now, to convert it to use VBO I have done

 

 

    GLint vertices[] = {x0,y0,x1,y0,x1,y1,x0,y1,x0,y0 };
    unsigned int indices[] = {0, 1, 2, 3,0};

    glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);

    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_INT, 0, NULL);
    glDrawElements(GL_LINE_STRIP, 5, GL_UNSIGNED_INT, indices);
    glDisableClientState(GL_VERTEX_ARRAY);
 

 

I must be doing something stupid, since it isn't working.  Instead of a box, it isn't drawing anything visable.

Not getting any GL errors either.

I can toggle the code above to go back to old code, and it works as it should.

 

 

 

Where did I mess up ?


#4Clancy

Posted 14 February 2013 - 03:58 PM

This draws a box.

 

     glBegin ( GL_LINE_STRIP );
        glVertex2i ( x0, y0 );
        glVertex2i ( x1, y0 );
        glVertex2i ( x1, y1 );
        glVertex2i ( x0, y1 );
        glVertex2i ( x0, y0 );
    glEnd ();
 

Now, to convert it to use VBO I have done

 

 

    GLint vertices[] = {x0,y0,x1,y0,x1,y1,x0,y1,x0,y0 };
    unsigned int indices[] = {0, 1, 2, 3,0};

    glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);

    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_INT, 0, NULL);
    glDrawElements(GL_LINE_STRIP, 5, GL_UNSIGNED_INT, indices);
    glDisableClientState(GL_VERTEX_ARRAY);
 

 

I must be doing something stupid, since it isn't working.  Instead of a box, it isn't drawing anything visable.

Not getting any GL errors either.

I can toggle the code above to go back to old code, and it works as it should.

 

 

 

Where did I mess up ?


#3Clancy

Posted 14 February 2013 - 03:56 PM

This draws a box.

 

     glBegin ( GL_LINE_STRIP );
        glVertex2i ( x0, y0 );
        glVertex2i ( x1, y0 );
        glVertex2i ( x1, y1 );
        glVertex2i ( x0, y1 );
        glVertex2i ( x0, y0 );
    glEnd ();
 

Now, to convert it to use VBO I have done

 

 

    GLint vertices[] = {x0,y0,x1,y0,x1,y1,x0,y1,x0,y0 };
    unsigned int indices[] = {0, 1, 2, 3,0};

    glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);

    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_INT, 0, NULL);
    glDrawElements(GL_LINE_STRIP, 5, GL_UNSIGNED_INT, indices);
    glDisableClientState(GL_VERTEX_ARRAY);
 

 

I must be doing something stupid, since it isn't working.  Instead of a box, it isn't drawing anything visable.

 

 

Where did I mess up ?


#2Clancy

Posted 14 February 2013 - 03:27 PM

This draws a box.

 

     glBegin ( GL_LINE_STRIP );
        glVertex2i ( x0, y0 );
        glVertex2i ( x1, y0 );
        glVertex2i ( x1, y1 );
        glVertex2i ( x0, y1 );
        glVertex2i ( x0, y0 );
    glEnd ();
 

Now, to convert it to use VBO I have done

 

 

    GLint vertices[] = {x0,y0,x1,y0,x1,y1,x0,y1,x0,y0 };
    unsigned int indices[] = {0, 1, 2, 3};

    glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);

    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_INT, 0, NULL);
    glDrawElements(GL_LINE_STRIP, 4, GL_UNSIGNED_INT, indices);
    glDisableClientState(GL_VERTEX_ARRAY);
 

 

I must be doing something stupid, since it isn't working.  Instead of a box, it is drawing a diagnol line.

 

Where did I mess up ?

 

 

 

 


#1Clancy

Posted 14 February 2013 - 03:14 PM

This draws a box.

 

     glBegin ( GL_LINE_STRIP );
        glVertex2i ( x0, y0 );
        glVertex2i ( x1, y0 );
        glVertex2i ( x1, y1 );
        glVertex2i ( x0, y1 );
        glVertex2i ( x0, y0 );
    glEnd ();
 

Now, to convert it to use VBO I have done

 

 

    GLint vertices[] = {x0,y0,x1,y0,x1,y1,x0,y1,x0,y0 };
    unsigned int indices[] = {0, 1, 2, 3};

    glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);

    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_INT, 0, NULL);
    glDrawElements(GL_LINE_STRIP, 4, GL_UNSIGNED_INT, indices);
    glDisableClientState(GL_VERTEX_ARRAY);
 

 

I must be doing something stupid, since it isn't working.  Instead of a box, it is drawing a diagnol line.

 

Where did I mess up ?

 

 

 

 


PARTNERS