Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualMarkS

Posted 10 December 2012 - 02:02 PM

When I wrote my OBJ loader, I was having the same issues. What I found to be the best method of debugging the loader is to create a print function that prints the contents of the loaded OBJ to the console in OBJ format. This way you can open the OBJ file in a text editor and compare it with the console side by side. Once you see what parts of the file are not loading correctly, it becomes much easier to debug the loader.

And would suggest that you make plans to dump the OBJ format at some point and stick with binary file formats, even if that means creating your own. As you've seen, writing a loader for a human readable format SUCKS!

Also, looking at your code, this "vertexBuffer = (float*) malloc (fileSize);" needs to be "vertexBuffer = (float*) malloc (fileSize*sizeof(float));". You are allocating an array of fileSize bytes as written, not an array of fileSize floats.

To that end, skip malloc all together. Use new/delete.


vertexBuffer = new float[fileSize];

.

.

.

detete [] vertexBuffer;


#1MarkS

Posted 10 December 2012 - 01:22 PM

When I wrote my OBJ loader, I was having the same issues. What I found to be the best method of debugging the loader is to create a print function that prints the contents of the loaded OBJ to the console in OBJ format. This way you can open the OBJ file in a text editor and compare it with the console side by side. Once you see what parts of the file are not loading correctly, it becomes much easier to debug the loader.

And would suggest that you make plans to dump the OBJ format at some point and stick with binary file formats, even if that means creating your own. As you've seen, writing a loader for a human readable format SUCKS!

PARTNERS