title: OpenGL opening Mesh (.m) file with Visual Studio2010
body: <p>For some reason, it just won't load the mesh file. I can't tell if its because Im entering something wrong, or if I just dont have the file in the right folder. I have it in the same folder as the .exe right now, and I have it under my "source files" too (that could be wrong).</p>
  
  <p><strong>Mesh.cpp</strong></p>
  
  <pre><code>#include "MeshTable.h"
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  
  void MeshTable::ReadMesh_M(const char *filename) {
      points.clear();
      faces.clear();
  
      //the Vertex id in .m file begins from 1,
      //we insert an empty point to align the index
      points.push_back(Point());
  
      std::ifstream input("C:\\Users\\Zach\\Documents\\Visual Studio 2010\\Projects\\MAIN\\Release\\dog.m");
      while(input.good()) {
          std::string line;
          getline(input, line);
  
          if (line.empty()) {     
          continue;       
      }
  
      std::stringstream ss(line);
      std::string title;
      int id;
      ss &gt;&gt; title;
  
      if (title == "Vertex") {
          Point pt;
          ss &gt;&gt; id &gt;&gt; pt[0] &gt;&gt; pt[1] &gt;&gt; pt[2];
          points.push_back(pt);
      } 
      else if (title == "Face") {
          Face face;
          ss &gt;&gt; id &gt;&gt; face.pt_ids[0] &gt;&gt; face.pt_ids[1] &gt;&gt; face.pt_ids[2];
          faces.push_back(face);
      }
  
  }
  input.close();
  }
  
  void MeshTable::SaveMesh_M(const char *filename) {
  std:: ofstream output(C:\\Users\\Zach\\Documents\\Visual Studio 2010\\Projects\\MAIN\\Release\\dog_out.m);
  for (unsigned int i = 1; i &lt; points.size(); ++i) {
      const Point&amp; pt = points[i];
      output &lt;&lt; "Vertex " &lt;&lt; i &lt;&lt; " " &lt;&lt; pt[0] &lt;&lt; " " &lt;&lt; pt[1] &lt;&lt; " " &lt;&lt; pt[2] &lt;&lt; "\n";
  }
  
  for (unsigned int i = 0; i &lt; faces.size(); ++i) {
      const Face&amp; face = faces[i];
      output &lt;&lt; "Face " &lt;&lt; i + 1 &lt;&lt; " " &lt;&lt; face.pt_ids[0] &lt;&lt; " " &lt;&lt; face.pt_ids[1] &lt;&lt; " " &lt;&lt; face.pt_ids[2] &lt;&lt; "\n";
  }
  output.close();
  }
  </code></pre>
  
  <p>It builds fine, but when I try to debug it, the OpenGL window pops open for like 3 seconds and then closes and says "The program '[3188] Main.exe: Native' has exited with code -1 (0xffffffff)." Which comes from my main.cpp.</p>
  
  <pre><code>if (argc != 2) {
      std::cout &lt;&lt; "Load a .m file as a mesh table.\n";
      std::cout &lt;&lt; "Usage: " &lt;&lt; argv[0] &lt;&lt; " input_mesh.m\n";
      exit(-1);
  }
  </code></pre>
  
  <p><strong>EDIT</strong> Once I deleted this, it worked. My teacher gave me this (part) of the code so I dont really understand why that would make it not work.</p>
  
  <pre><code>if (argc != 2) {
      std::cout &lt;&lt; "Load a .m file as a mesh table.\n";
      std::cout &lt;&lt; "Usage: " &lt;&lt; argv[0] &lt;&lt; " input_mesh.m\n";
      exit(-1);
  }
  </code></pre>