Rendering 3D Box

This topic contains 17 replies, has 2 voices, and was last updated by  hellboy 4 years, 5 months ago.

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #31306

    hellboy
    Member

    Hi,

    I have successfully rendered a triangle on the PandaBoard. But when I try rendering a 3D box (Indexed buffer object comes into picture), I can compile it but during running , a window shows but the box is not rendered. It suddenly turns black and prints the following line on the terminal continuously :

    PVR:(Error): Index offset 608592 is larger than index buffer size 192 [1340, /drawvarray.c]

    Can anyone tell me where did I go wrong ?

    #37445

    dgu
    Member

    Hello

    how did you do your box ?
    was it base on a list of triangle indexed or not ?
    example :

    GLushort indices[] =
    {
    4, 5, 6, 4, 6, 7,
    1, 0, 3, 1, 3, 2,
    0, 4, 7, 0, 7, 3,
    5, 1, 2, 5, 2, 6,
    0, 4, 5, 0, 5, 1,
    3, 7, 6, 3, 6, 2
    };

    glGenBuffers(1, &m_BoxIBO);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BoxIBO);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    david

    #37446

    dgu
    Member

    The great great PVRShaman can help for fast testing , it allow as well to create Open Built in Object menu and add a custom effect and a simple shader , it work very well and it s fast.

    #37447

    hellboy
    Member

    I did exactly the same. The list of triangles was indexed and consisted of 36 indices. The only difference is that I used GLuint indices[]. Please also tell the parameters of glDrawElements(). Mine is :

    glDrawElements(GL_TRIANGLES, numfaces * 3, GL_UNSIGNED_INT, indices);

    #37448

    dgu
    Member
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BoxIBO);
    glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, NULL);
    #37449

    hellboy
    Member

    Why should the last parameter be NULL ?

    #37450

    hellboy
    Member

    Well, making the last parameter NULL removed the error but the box doesn’t get rendered. There is only the background.

    #37451

    dgu
    Member

    it s an indexed triangle list !!!!!

    #37452

    dgu
    Member

    elsewhere i will use glDrawArrays
    the SDK have a lot of good material on all the spec , i like to look at it , there is so much to learn !!!

    #37453

    hellboy
    Member

    void glDrawElements( GLenum mode,
    GLsizei count,
    GLenum type,
    const GLvoid * indices);

    indices – Specifies a pointer to the location where the indices are stored.

    Why should we pass NULL to the pointer to the location i.e. indices.

    #37454

    dgu
    Member

    It s not mandatory , it depend of your choice of data structure index /not index list , strip not strip etcetc
    as we are in an index list you can select from witch indices you want to start

    #37455

    hellboy
    Member

    How do we define an indexed list data structure. I just parsed the coordIndex node of the VRML file i.e. :

    coordIndex
    [
    0, 1, 2, -1,
    2, 3, 0, -1,
    3, 2, 4, -1,
    4, 5, 3, -1,
    5, 4, 7, -1,
    7, 6, 5, -1,
    6, 7, 1, -1,
    1, 0, 6, -1,
    6, 0, 3, -1,
    3, 5, 6, -1,
    1, 7, 2, -1,
    7, 4, 2, -1,
    ]

    removed the -1s and copied the array into a GLuint indices[36].

    Any idea why the box is invisible on changing the parameter to NULL ?

    #37456

    dgu
    Member

    i didnt check your values i assume there are right 🙂 i am too lazy today…
    GLushort coordIndex[] =
    {
    0, 1, 2, 2, 3, 0,
    3, 2, 4, 4, 5, 3,
    5, 4, 7, 7, 6, 5,
    6, 7, 1, 1, 0, 6,
    6, 0, 3, 3, 5, 6,
    1, 7, 2, 7, 4, 2
    };

    glGenBuffers(1, &BoxIBO);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BoxIBO);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(coordIndex), coordIndex, GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    Rendering is :
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BoxIBO);
    glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, NULL);

    regards
    david guimard

    #37457

    hellboy
    Member

    Hey, got the box rendered. 🙂
    I don’t know for some reason sizeof(indices) was returning 4, so I tried with (numfaces*(3*sizeof(GL_UNSIGNED_SHORT)) and parameter as NULL and it worked !

    Thanks for your replies.

    #37458

    dgu
    Member

    GOOD STUFF what s your next move then ?

Viewing 15 posts - 1 through 15 (of 18 total)
You must be logged in to reply to this topic.