iphone - Correct format for loading vertex arrays from file -
i've been banging head on keyboard past couple of weeks on this. i'm trying load array of floats (glfloat) , array of unsigned shorts (glushort) text file equivalent arrays in objective-c can render contained objects. i've got arrays loaded vector objects as
vector<float> vertices; and
vector<glushort> indices; but reason can't figure out why can't these render. here code rendering above:
glvertexpointer(3, gl_float, sizeof(vertices[0])*6, &vertices[0]); glnormalpoitner(gl_float, sizeof(vertices[0])*6, &vertices[3]); gldrawelements(gl_triangles, sizeof(indices)/sizeof(indices[0]), gl_unsigned_short, indices); sample arrays below:
vertices: (vx, vy, vz, nx, ny, nz) {10, 10, 0, 0, 0, 1, -10, 10, 0, 0, 0, 1, -10, -10, 0, 0, 0, 1, 10, -10, 0, 0, 0, 1}; indices: (v1, v2, v3) {0, 1, 2, 0, 2, 3}; the text file want load these arrays rendering looks this:
4 //number of vertices ###vertices### v 10 10 0 0 0 1 v -10 10 0 0 0 1 v -10 -10 0 0 0 1 v 10 -10 0 0 0 1 ###object1### 2 //number of faces f 0 1 2 f 3 4 5 are vector objects best approach take? if not, is? , doing wrong these won't render? thanks.
you use gl_triangles specify vertices format.

see graph gl_triangles, format wrong. and, prefer use gl_triangle_strip format. needs few vertices.
Comments
Post a Comment