title: OpenGL evaluating a plane
body: <p>I want to evaluate a plane using 4 control points which they are at four corner of the plane. so I have declared them like this :</p>
  
  <pre><code>GLfloat ctrlpoints[4][3] = {
      { -3, 0, 3 }, { 3, 0, 3 }, { 3, 0, -3 }, { -3, 0, -3 }
  };
  </code></pre>
  
  <p>Then I had used this three functions to do evaluation process :</p>
  
  <pre><code>glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 3, 4, &amp;ctrlpoints[0][0]);
  
  glMapGrid2f(5, 0.0, 1.0, 5, 0.0, 1.0);
  glEvalMesh2(GL_LINE, 0.0, 5.0, 0.0, 5.0);
  </code></pre>
  
  <p>And I have wrote loop below which draws the control points as red dots :</p>
  
  <pre><code>glPointSize(5.0f);
  glColor3f(1, 0, 0);
  
  glBegin(GL_POINTS);
  for (i = 0; i &lt; 4; i++)
      glVertex3fv(ctrlpoints[i]);
  glEnd();
  </code></pre>
  
  <p>And output is in image below :</p>
  
  <p><img src="https://i.stack.imgur.com/Zubns.jpg" alt="enter image description here"></p>
  
  <p>why this occurs , how can i fix that ?</p>
  
  <p>Full source code is listed below :</p>
  
  <pre><code>#include &lt;glut.h&gt;
  #include &lt;stdio.h&gt;
  
  GLfloat ctrlpoints[4][3] = {
      { -3, 0, 3 }, { 3, 0, 3 }, { 3, 0, -3 }, { -3, 0, -3 }
  };
  void display(void)
  {
      int i, j;
  
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glColor3f(1.0, 1.0, 1.0);
  
      //glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &amp;ctrlpoints[0][0][0]);
      glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 3, 4, &amp;ctrlpoints[0][0]);
  
      glMapGrid2f(5, 0.0, 1.0, 5, 0.0, 1.0);
      glEvalMesh2(GL_LINE, 0.0, 5.0, 0.0, 5.0);
  
      glPointSize(5.0f);
      glColor3f(1, 0, 0);
  
      glBegin(GL_POINTS);
      for (i = 0; i &lt; 4; i++)
          glVertex3fv(ctrlpoints[i]);
      glEnd();
  
      glFlush();
  }
  void reshape(int w, int h)
  {
      glViewport(0, 0, (GLsizei)w, (GLsizei)h);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      if (w &lt;= h)
          glOrtho(-6.0, 6.0, -6.0*(GLfloat)h / (GLfloat)w,
          6.0*(GLfloat)h / (GLfloat)w, -6.0, 6.0);
      else
          glOrtho(-6.0*(GLfloat)w / (GLfloat)h,
          6.0*(GLfloat)w / (GLfloat)h, -6.0, 6.0, -6.0, 6.0);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
  
      glRotatef(90.0, 1.0, 0.0, 0.0);
  
  }
  void init(void)
  {
      glClearColor(0.0, 0.0, 0.0, 0.0);
  
      glEnable(GL_MAP2_VERTEX_3);
  
      glEnable(GL_DEPTH_TEST);
      glShadeModel(GL_FLAT);
  }
  int main(int argc, char** argv)
  {
  
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
      glutInitWindowSize(500, 500);
      glutInitWindowPosition(100, 100);
      glutCreateWindow(argv[0]);
      init();
      glutDisplayFunc(display);
      glutReshapeFunc(reshape);
      //glutKeyboardFunc(keyInput);
      //glutSpecialFunc(specialKeyInput);
      glutMainLoop();
      return 0;
  }
  </code></pre>