Im working with a parser that processes Wavefront OBJ 3D 3D objects, and I'm not quite sure that im is loading correctly in OpenGL.
So basically what I do is that I read my Wavefront OBJ files and analyze all the data.
Typically, in OpenGL ES 1.1, I perform the following operations when loading data:
glBegin(GL_TRIANGLES);
glNormal3f(normals[faces[i].normal[0]].v[0], normals[faces[i].normal[0]].v[1], normals[faces[i].normal[0]].v[2]);
glVertex3f(vertices[faces[i].vertex[0]].v[0], vertices[faces[i].vertex[0]].v[1], vertices[faces[i].vertex[0]].v[2]);
glNormal3f(normals[faces[i].normal[1]].v[0], normals[faces[i].normal[1]].v[1], normals[faces[i].normal[1]].v[2]);
glVertex3f(vertices[faces[i].vertex[1]].v[0], vertices[faces[i].vertex[1]].v[1], vertices[faces[i].vertex[1]].v[2]);
glNormal3f(normals[faces[i].normal[2]].v[0], normals[faces[i].normal[2]].v[1], normals[faces[i].normal[2]].v[2]);
glVertex3f(vertices[faces[i].vertex[2]].v[0], vertices[faces[i].vertex[2]].v[1], vertices[faces[i].vertex[2]].v[2]);
glEnd();
As for OpenGL ES 2.0, I tried following the tops with no luck:
glBufferData(GL_ARRAY_BUFFER, obj.vertices.size()*sizeof(float), &(obj.vertices[0].v), GL_STATIC_DRAW);
My data structure:
struct vertex {
std::vector<float> v;
}
A vector vis created for each end end, s {x,y,z}.
class waveObj {
public:
std::vector<vertex> vertices;
std::vector<vertex> texcoords;
std::vector<vertex> normals;
std::vector<vertex> parameters;
std::vector<face> faces;
}
struct face {
std::vector<int> vertex;
std::vector<int> texture;
std::vector<int> normal;
};
How can I load my data, as it was with OpenGL ES 1.1 in 2.0?
Is it also possible to load a vector ( v) rather than line items ( float x,y,z)?