Skip to content Skip to sidebar Skip to footer

Incorrect Vbo For Mesh: Some Triangles Are Connected And Shouldn't [2d]

I'm generating my VBO with this code int SCREEN_WIDTH = 800; int SCREEN_HEIGHT = 480; int PIXEL_PER_VERTEX = 4; int CAVERN_TEXTURE_WIDTH = 1024; int CAVERN_TEXT

Solution 1:

I'm pretty sure that you are specifying the wrong number of primitives to your drawing code since the vertices themselves look alright to me. When you do a drawing call to openGL or any other 3D primitive drawing you do not specify the number of vertices to draw but the number of primitives. A primitive in you case is a triangle.

Since it's a triangle strip you're drawing it's always numberOfVertices - 2 primitives in your call. If it were a list of triangles it would have been numberOfVertices/3, and for a triangle fan it's numberOfVertices - 2 again.

Since you are probably specifying more triangles to be drawn than it has data to draw for, it's probably using some default (0,0,0,0) which explains that it is trying to draw two degenerate triangles in the bottom left corner that is also referencing the texture coordinate 0,0. This also makes sense since there isn't even a vertex that has the position 0,0 and the T/U 0,0 in your list, so the last vertex must be some default value.

Solution 2:

Ok, i solved it.

After trying libgdx (i don't really like it, it seams a lot of utility functions are missing, and i haven't really grasped the concept behind it, eg how it treats textures, how manage entities, etc..) and implemented a really small renderer in native language with jni and also setted up cocos-2d-x (but haven't tried it, since i first played a bit with the jni code and wrote the above mentioned renderer) i fell back to AndEngine.

I succesfully managed to implement a mesh with VBO and also a IBO, but finally i solved my problem by duplicating (adding 2 identical vertices) at the start and the end of the VBO, so that the additional triangles are degenerated and are not drawn. So, that's most a workaround, but as long as it works..

Post a Comment for "Incorrect Vbo For Mesh: Some Triangles Are Connected And Shouldn't [2d]"