Start a new topic

Cannot load 3d object from obj format

Cannot load 3d object from obj format


I am trying to load a 3d object from an obj file. I use tiny obj ( for obj file parsing, I only added the c++ header and call its methods. The data seems to be fine, but for some reason I don't get anything loaded inside opengl. I was able to load the cube that I have inside the source file but no success with a parsed obj file. I atached a link to the project.

Any help would be apreciated.



Having a quick look at your renderer I found some flaws regarding the data types and the buffers you pass to OpenGL:


    glBufferData(GL_ARRAY_BUFFER, sizeof(float) * shapes.mesh.positions.size(), (, GL_STATIC_DRAW);


    glBufferData(GL_ARRAY_BUFFER, sizeof(unsigned int) * shapes.mesh.positions.size(), (, GL_STATIC_DRAW);



    glDrawElements(GL_TRIANGLES, (int)shapes.mesh.positions.size() / 3, GL_UNSIGNED_BYTE, 0);



    glDrawElements(GL_TRIANGLES, (int)shapes.mesh.positions.size() / 3, GL_UNSIGNED_INT, 0);


Since you are using an external renderer, the OpenGL rendering is basically up to you.
For further questions on rendering I would recommend an OpenGL forum or  

Thank you very much! :)

I didn't know exactly if it was a wrong use of opengl or something else. 
Login or Signup to post a comment