title: Tessellation - saving data
body: <p>I am using tessellation in order to transfer non triangled polygons to triangle polygons.
  I am trying to save the data in variable and run the tessellation code once while saving the data. The code use the saved data in order to draw it in draw function.</p>
  
  <p>I am trying the draw a star polygon, The problem is that I can see some triangles but not a star. Why when I save the data the drawing go wrong?</p>
  
  <p>Here is the initialize code:</p>
  
  <pre><code>#define callback void(CALLBACK*)()
  void Init()
  {
      GLdouble star[5][6] = /* star data, The data is 100% perfect */
  
  
      glColor3f(0.0f, 1.0f, 0.0f);
  
      GLUtesselator *pTess = gluNewTess();
  
      indexNum = 0;
      gluTessCallback(pTess, GLU_TESS_BEGIN,      (callback)glDrowMode);
      gluTessCallback(pTess, GLU_TESS_VERTEX,     (callback)saveData);
      gluTessCallback(pTess, GLU_TESS_ERROR,      (callback)tessError);
      gluTessCallback(pTess, GLU_TESS_COMBINE,    (callback) scbCombine);
  
  
      gluTessProperty(pTess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO);
      gluTessBeginPolygon(pTess, NULL); 
  
      gluTessBeginContour(pTess);
      for(int i = 0; i &lt; 5; i++)
          gluTessVertex(pTess, star[i], star[i]);
      gluTessEndContour(pTess);
  
      gluTessEndPolygon(pTess);
      gluDeleteTess(pTess);
  }
  </code></pre>
  
  <p>The saving data code and saving the drawing mode:</p>
  
  <pre><code>struct vecStruct
  {
      GLdouble *vertex, *color;
  };
  vecStruct vec[16];
  
  
  int indexNum = 0;
  void CALLBACK saveData(const GLvoid *ptr)
  {
      const GLdouble *data = (const GLdouble*)ptr;
  
      vec[indexNum].vertex = new GLdouble[3];
      vec[indexNum].color = new GLdouble[3];
      vec[indexNum].vertex[0] = data[0];
      vec[indexNum].vertex[1] = data[1];
      vec[indexNum].vertex[2] = data[2];
      vec[indexNum].color[0] = data[3];
      vec[indexNum].color[1] = data[4];
      vec[indexNum].color[2] = data[5];
  
      indexNum++;
  }
  
  
  GLenum drawMode;
  void CALLBACK glDrowMode(GLenum where)
  {
      drawMode = where;
  }
  </code></pre>
  
  <p>And last the drow function:</p>
  
  <pre><code>void vboDraw()
  {
      glBegin(drawMode);
      for (int i = 0; i &lt; indexNum; i++)
      {
          glColor3dv(vec[i].color);
          glVertex3dv(vec[i].vertex); 
      }
      glEnd();
  
  }
  </code></pre>
  
  <p>As I have said I should see star:</p>
  
  <p><img src="https://i.stack.imgur.com/TU3Z2.png" alt="enter image description here"></p>
  
  <p>But what I can see is some triangles:</p>
  
  <p><img src="https://i.stack.imgur.com/ReSjE.png" alt="enter image description here"></p>
  
  <p>What is wrong with the code?
  Why can not I save the data for doing the tessellation code only once?</p>