glDrawElements BUG !! or NOT ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

glDrawElements BUG !! or NOT ?

Itun
When I use buffer offset in glDrawElements there are bugs: some new triangles appear in the screen.
A snippet of code with usage of Buffer offset .
                gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, VBOs.get(Meshes.size() + i));
                long offset = 0;
                for (int j = 0; j < 2; j++) {
                    List<Face> FaceAssignedMaterial = Meshes.get(i).MaterialMaps.get(j).FaceAssignedMaterial;
                    gl.glDrawElements(GL2.GL_TRIANGLES, FaceAssignedMaterial.size() * 3, GL2.GL_UNSIGNED_INT, offset);
                    offset += FaceAssignedMaterial.size() * 3;
                }
                gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);

                gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);

But when I replace the snippet above by this:
                gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, VBOs.get(Meshes.size() + i));
                long offset = 0;
                for (int j = 0; j < 2; j++) {
                    List<Face> FaceAssignedMaterial = Meshes.get(i).MaterialMaps.get(j).FaceAssignedMaterial;
                    offset += FaceAssignedMaterial.size() * 3;
                }
gl.glDrawElements(GL2.GL_TRIANGLES, Meshes.get(i).Faces.size() * 3, GL2.GL_UNSIGNED_INT, (long) (0));
                gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);

                gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);

I have watched the length of rendering elements in the both cases in Debuge mode, but the lengths are equal. I have wtched all I can, I have done all tests, this is something unbelievable.

Was somebody confronted by such problems?