Code: Select all
typedef struct
{
GLfloat x;
GLfloat y;
GLfloat z;
GLfloat nx;
GLfloat ny;
GLfloat nz;
GLfloat u;
GLfloat v;
}Vert;
Vert Model = new Vert[ num faces * 3]; // each tri face has 3 verts.
Code: Select all
GLuint vboID;
glGenBuffers(1, &vboID);
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, sizeof(Model), &Model, GL_STATIC_DRAW);
Code: Select all
glVertexAttribPointer ..
glEnableVertexAttribArray ..
glDrawArrays ..
Code: Select all
# Blender v2.62 (sub 0) OBJ File: ''
# www.blender.org
mtllib cube.mtl
o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -1.000000
v 1.000000 1.000000 1.000000
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -0.000000 -0.000000 1.000000
vn -1.000000 -0.000000 -0.000000
vn 0.000000 0.000000 -1.000000
usemtl Material
s off
f 1/1/1 2/2/1 3/3/1
f 1/1/1 3/3/1 4/4/1
f 5/1/2 8/2/2 7/3/2
f 5/1/2 7/3/2 6/4/2
f 1/1/3 5/2/3 6/3/3
f 1/1/3 6/3/3 2/4/3
f 2/1/4 6/2/4 7/3/4
f 2/1/4 7/3/4 3/4/4
f 3/1/5 7/2/5 8/3/5
f 3/1/5 8/3/5 4/4/5
f 5/1/6 1/2/6 4/3/6
f 5/1/6 4/3/6 8/4/6Code: Select all
model->TriangleArray[3].Vertex[1]Code: Select all
// pass the data to OpenGL ES
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, my_array_of_vertex_data);
// draw the vertices
GLsizei count = number_of_triangles * 3;
glDrawArrays(GL_TRIANGLES, 0, count);Code: Select all
GLfloat * my_array_of_vertex_data = new GLfloat[number_of_triangles*3];Code: Select all
GLfloat *array = (GLfloat *)malloc(number_of_triangles * 3 * sizeof(GLfloat));