Hi,
I have a problem using opengl on android to draw a simple rectangle.
This is what I did.
I drew a simple rectangle with sketchup. I exported the result using
a 3d-model collada .dae file. I copied the vertices data from
the .dae (xml) file and put in an array as X, Y, Z repeating. I then drew the triangles
using stripe mode. The result is nearly a rectangle. It is missing a triangle on
each face.
Here is the relevant portion of code and the result.
From the xml,
<float_array id=“ID8” count=“72”>22.62976164142344 29.52755905511811 0 0 0 0 0 29.52755905511811 0 22.62976164142344 0 0 22.62976164142344 0 13.77952755905512 0 0 0 22.62976164142344 0 0 0 0 13.77952755905512 0 29.52755905511811 13.77952755905512 0 0 0 0 0 13.77952755905512 0 29.52755905511811 0 0 29.52755905511811 13.77952755905512 22.62976164142344 29.52755905511811 0 0 29.52755905511811 0 22.62976164142344 29.52755905511811 13.77952755905512 22.62976164142344 29.52755905511811 0 22.62976164142344 0 13.77952755905512 22.62976164142344 0 0 22.62976164142344 29.52755905511811 13.77952755905512 22.62976164142344 0 13.77952755905512 0 29.52755905511811 13.77952755905512 0 0 13.77952755905512 22.62976164142344 29.52755905511811 13.77952755905512</float_array>
became
float vertices[] = {
22.62976164142344f, 29.52755905511811f, 0,
0, 0, 0,
0, 29.52755905511811f, 0, ...}
and then I did this in my draw routine:
public void draw(GL10 gl) {
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
// Enable color tracking
gl.glEnable(GL10.GL_COLOR_MATERIAL);
for (int i=0; i<108/4; i=i+4) {
myDrawColor(gl,i);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,i,4);//mode, first, count
}
}
the result is shown here
http://imgur.com/a/o3HTP
Please advise
John