title: How do I display/draw a .ply object in OpenGL?
body: <p>I'm trying to make OpenGL draw the figure that I'm loading with <code>OPENFILENAME</code>. What I've got right now is: I can display the comments, vertex, how many faces, etc., but I cannot draw the figure and I'm not sure how to do it. I can draw other predetermined figures, but not the ones I'm trying to open.</p>
  
  <hr>
  
  <p>This is where I'm initializing everything:</p>
  
  <pre><code>case WM_CREATE:
       hDC = GetDC(hWnd);
          hRC=wglCreateContext(hDC);
          wglMakeCurrent(hDC,hRC);
           g_hwndDlg = CreateDialog(hInst,MAKEINTRESOURCE(IDD_DIALOG1),hWnd,DialogProc);
          Figure = new DrawFigure();
          initGL();
           break;
  </code></pre>
  
  <p>This is where I find out what the element I'm opening has:</p>
  
  <pre><code>  /* go through each kind of element that we learned is in the file */
    /* and read them */
  
    for (i = 0; i &lt; nelems; i++) {
      /* get the description of the first element */
      elem_name = elist[i];
      plist = ply_get_element_description (ply, elem_name, &amp;num_elems, &amp;nprops);
      int el=sprintf(szFile,"element %s %d\n", elem_name, num_elems);
      /* print the name of the element, for debugging */
          TextOut(hDC,150,0+i*20,szFile,el);
      /* if we're on vertex elements, read them in */
      if (equal_strings ("vertex", elem_name)) {
        /* create a vertex list to hold all the vertices */
        vlist = (Vertex **) malloc (sizeof (Vertex *) * num_elems);
        /* set up for getting vertex elements */
        ply_get_property (ply, elem_name, &amp;vert_props[0]);
        ply_get_property (ply, elem_name, &amp;vert_props[1]);
        ply_get_property (ply, elem_name, &amp;vert_props[2]);
  
  
   /* grab all the vertex elements */
        for (j = 0; j &lt; num_elems; j++) {
          int move=10;
          /* grab and element from the file */
          vlist[j] = (Vertex *) malloc (sizeof (Vertex));
          ply_get_element (ply, (void *) vlist[j]);
  
  
          int vert=sprintf(szFile,"vertex: %g %g %g", vlist[j]-&gt;x, vlist[j]-&gt;y, vlist[j]-&gt;z);
          /* print out vertex x,y,z for debugging */
          TextOut(hDC,600,move+j*20,szFile,vert);
  
          Figure-&gt;Parameters(vlist[j]-&gt;x, vlist[j]-&gt;y, vlist[j]-&gt;z);
        }
      }
  </code></pre>
  
  <p>And this is where the class Figure is, where I'm suppossed to draw everything:</p>
  
  <pre><code>    Figure::Figure(){
  }
  void Figure::Parameters(float x,float y,float z)
  {
       this-&gt;x1=x;
      this-&gt;y1=y;
      this-&gt;z1=z;
  }
  void Figure::Draw()
  {
       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
      glLoadIdentity();
      gluLookAt(0.0,0.0,4.0,0.0,0.0,0.0,0.0,1.0,0.0);
  
      glBegin(GL_TRIANGLES);
  
      glNormal3f(x1,y1,z1);
  
      glVertex3f(x1,y1,z1);
      glEnd();
  }
  x1,y1,z1 are declared in Figure.h
  </code></pre>
  
  <p>I tried to explain myself the best I could; if you think it still needs more explanation please tell me and I will try to explain it in a different way</p>
  
  <p>Yeah, I forgot to explain I guess the figure I'm trying to draw...well i don't know which figure it would be because I'm using OPENFILENAME to open 1 random figure and draw it i used triangles because i thought that with triangles i could draw anything and also i tried in the class Parameters ask for the number of vertex I'm dealing with and making a "for" in the class Draw but it didn't work </p>