• Advertisement
Sign in to follow this  

indice problem

This topic is 3362 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 doing a simple plane using vbo's to make sure I understand vbo's but I've run into a problem. It's just to be clear of vbo's for myself. I'm trying to do a simple plane that is divided n times. I store the vertices into a stl vector. I then store the indices into a stl vector that I generate through a for loop. It works but for some reason when I have too many indices the plane screws up and the plane will not look right.

struct Vertex
    void setXYZ(float x_ = 0.0f, float y_ = 0.0f, float z_ = 0.0f){v[0]=x_; v[1]=y_; v[2]=z_;}
    float v[3];

vector<Vertex> vList; //Array Of Vertices
vector<unsigned short> iList; //Array Of Indices

void drawPlaneInit()
    //Push 48 vertices into vList and set position.
    //simple 2d like plane
    Vertex vert;
    for(int i=0; i<6; i++)
        for(int j=0; j<8; j++)
            vert.setXYZ(j, i, 0.0f);

    //create the indices needed to form the triangles

    //Problem: Everything looks okay until I set the loop to stop before 25.    
    //The plane would look like it's broken in parts unless it less than 25. I've 
    //printed iList to the console to confirm that the indices should be correct 
    //(which they are).

    unsigned short it=0;
    for(unsigned int i=0; i<24; i++)
        if(it == 7)
        {   it = 0;
            //1 square is triangle 1 and 2
            //Triangle 1

            //Triangle 2


    glGenBuffersARB(1, &vBuf);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vBuf);

    glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(Vertex)*vList.size(), &(*vList.begin()), GL_STATIC_DRAW_ARB);
    glVertexPointer(3, GL_FLOAT, 0, 0);

    glGenBuffersARB(1, &eBuf);

    glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(unsigned short)*iList.size(), &(*iList.begin()) , GL_STATIC_DRAW_ARB);


//Then Draw blah blah...

Everything is arb since unfortunately at the moment I'm relying on an intel gpu that only supports ogl 1.4 somewhat 1.5 for now. example of i<24 when creating the indices for iList your_link_text example of i<25 or higher when creating the indices for iList. your_link_text hopefully this is clear. [Edited by - Asem on January 7, 2009 12:03:35 AM]

Share this post

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

  • Advertisement