Original Post
Hi I am starting to use OBJ, and I cam across some nifty code from Stompy9999's Blog and code archive on how to load .obj files using STL vectors and Vertex Arrays (glVertexPointer). I am using the cpp files Obj_loader.h and Obj_loader.cpp as loaders. I have rarely used STL or Vectors so i need some advice on how to use the vectors in OpenGL's vertex arrays... I am trying to render the vertices using vectors using this little snippets below Snippet to load OBJ into memory Snippet used during rendering When i compile, it seems fine, but when i run the program it load the file, but it doesnt show the object.... Does anybody know what is wrong with the code above as the object has definately loaded into memory from the .obj file.. I would be greatly appreciate it if someone can help... Regards Will
// LOADING THE OBJ FILE INTO THE PROGRAM MEMORY
int init::LoadOBJ(string filename )
{
model = new OBJ_MODEL;
char some_char;
try
{
if(!model->m_Load(filename.c_str()))
throw "Error loading model";
}
catch(string error)
{
out_file << error;
return 0;
}
delete [] model;
return 0;
}
// TO RENDER THE OBJECT
glLoadIdentity();
glPushMatrix();
glTranslatef(1.0f,1.0f,80.0f);
vector<Vertex> Vertices;
glColor4f(1.0f,1.0f,1.0f,1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &Vertices[0]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, Vertices.size());
glDisableClientState( GL_VERTEX_ARRAY );
glPopMatrix();