Vertices are created by an .obj file. (loading/OBJFile.java
)
I draw a cube perfectly fine with glDrawArrays
. (VertexModel.java
)
created like this:
new VertexModel(square.getIndexedVertexBuffer());
However, when I try to do the same with glDrawElements
i get a distorted cube.. (IndexedVertexModel.java
)
The IndexedVertexModel is created like this:
new IndexedVertexModel(square.getVertexBuffer(), square.getVertexIndecies());
The result can be seen here.
I've tried to figure out what's wrong, but i really have no idea what causes it to behave this way.
The OBJ file I'm using looks like this:
v -1.00000000000000 -1.00000000000000 -1.00000000000000
v -1.00000000000000 1.00000000000000 -1.00000000000000
v 1.00000000000000 -1.00000000000000 -1.00000000000000
v 1.00000000000000 1.00000000000000 -1.00000000000000
v 1.00000000000000 -1.00000000000000 1.00000000000000
v 1.00000000000000 1.00000000000000 1.00000000000000
v -1.00000000000000 -1.00000000000000 1.00000000000000
v -1.00000000000000 1.00000000000000 1.00000000000000
f 1/4/1 2/3/1 4/2/1
f 3/4/3 4/3/3 6/2/3
f 5/4/4 6/3/5 8/2/4
f 7/4/6 8/3/6 2/2/6
f 2/4/7 8/3/7 6/2/7
f 7/4/8 1/3/8 3/2/8
f 1/4/1 4/4/1 3/3/1
f 3/4/3 6/4/3 5/3/3
f 5/4/4 8/4/4 7/3/4
f 7/4/6 2/4/6 1/3/6
f 2/4/7 6/4/7 4/3/7
f 7/4/8 3/4/8 5/3/8