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 ?
Hello
how did you do your box ?
was it base on a list of triangle indexed or not ?
example :
GLushort indices[] =<br />
{<br />
4, 5, 6, 4, 6, 7,<br />
1, 0, 3, 1, 3, 2,<br />
0, 4, 7, 0, 7, 3,<br />
5, 1, 2, 5, 2, 6,<br />
0, 4, 5, 0, 5, 1,<br />
3, 7, 6, 3, 6, 2<br />
};<br />
<br />
glGenBuffers(1, &m_BoxIBO);<br />
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BoxIBO);<br />
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);<br />
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
```<br />
<br />
david<br />
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.
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);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BoxIBO);<br />
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, NULL);
Why should the last parameter be NULL ?
Well, making the last parameter NULL removed the error but the box doesn’t get rendered. There is only the background.
it s an indexed triangle list !!!
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 !!!
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.
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
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 ?
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
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.
GOOD STUFF what s your next move then ?
Now I’ll proceed to provide navigation features in the scene.
ok good luck
Hey, I think I got it wrong. When I rotated the camera to look the box from a different angle, I saw that it’s actually rendered two dimensionally. Do you know what the problem may be ?