• Advertisement

Archived

This topic is now archived and is closed to further replies.

Visual C Question

This topic is 6454 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

WARNING! This is going to be a large post! I have a question that deals purely with MSVC. No OpenGL knowledge needed. I am trying to set up a OBJ loader in my little engine. However, when I start loading the variables into memory I get lots of nasty errors! Here is a quick section of the code... typedef struct { float vert[3]; } vert3d; typedef struct { // other variables in here vert3d *vertex; } mesh; class Object { public: Load(char *filename); Draw(); private: mesh *Mesh; }; Object::Load(char *filename) { // Open file, count verticies, etc. Mesh = (mesh*) malloc(sizeof (mesh)); Mesh->vertex = (vert3d*) malloc(sizeof(vert3d) * numberofverts); while (!feof (File)) { fscanf (File, "%s", line); if (line[0] == ''v'' && line[1] == ''\0'') { fscanf (File, "%f %f %f", // <--This is where I &Mesh->vertex[verts].vert[0], // run into problems &Mesh->vertex[verts].vert[1], &Mesh->vertex[verts].vert[2]); verts++; } } } Did you catch all that? If you would like too look at the full source just E-mail me. Anyways, If anyone understood that, could you please tell me what I did wrong!!! ----------------------------- Blue*Omega (Insert Witty Quote Here)

Share this post


Link to post
Share on other sites
Advertisement
What kind of errors do you get? If its the standard memory error I would recommend to recheck all the memory accesses. One thing that sounds strange is that you use "&Mesh->", but Mesh is already a pointer, so put away the "&"!
What I don''t understand is why you are using a pointer to a mesh in your class, why not simply a mesh?
btw did you store floats in the file? Which format do you use? And why is there a "v\0" in every line you check for?

hope any of these helps!
tell me about it!

pi~

Share this post


Link to post
Share on other sites

  • Advertisement