简体   繁体   中英

Drawing an A using a single GL_TRIANGLE_STRIP

Is this possible? (I know, it is, but I can't do it.)

void drawScene(void)
{  

   glClear(GL_COLOR_BUFFER_BIT);
   glColor3f(0.0, 0.0, 0.0);
   if (isWire) 
       glPolygonMode(GL_FRONT, GL_LINE);
   else
   glPolygonMode(GL_FRONT, GL_FILL);

   glBegin(GL_TRIANGLE_STRIP);
   glVertex3f(10,10,0);
   glVertex3f(20,10,0);

   glVertex3f(30,80,0);
   glVertex3f(40,70,0);

   glVertex3f(50,80,0);
   glVertex3f(60,10,0);

   glVertex3f(70,10,0);
   glEnd();

   glBegin(GL_TRIANGLE_STRIP);

   glEnd();

   glFlush();
}

There is my attempt, although my next idea would be to bridge the legs of the A. But I would like to do it in one single strip.

在此处输入图片说明

With help from my friend geometry :)

void drawScene(void)
{  

   glClear(GL_COLOR_BUFFER_BIT);
   glColor3f(0.0, 0.0, 0.0);
   if (isWire) 
       glPolygonMode(GL_FRONT, GL_LINE);
   else
   glPolygonMode(GL_FRONT, GL_FILL);

     // Draw a triangle strip.
   glBegin(GL_TRIANGLE_STRIP);
      glVertex3f(10.0, 10.0, 0.0);
  glVertex3f(20.0, 10.0, 0.0);
  glVertex3f(12.0, 30.0, 0.0);
  glVertex3f(22.0, 30.0, 0.0);
  glVertex3f(17.0, 80.0, 0.0);
  glVertex3f(26.0, 70.0, 0.0);
  glVertex3f(35.0, 80.0, 0.0);
  glVertex3f(31.0, 40.0, 0.0);
  glVertex3f(42.0, 35.0, 0.0);
  glVertex3f(23.0, 40.0, 0.0);
  glVertex3f(25.0, 35.0, 0.0);
  glVertex3f(21.9, 30.0,0.0); 

  glVertex3f(42.0, 35.0, 0.0);
  glVertex3f(32.0, 30.0, 0.0);
  glVertex3f(46.0, 10.0, 0.0);
  glVertex3f(36.5, 10.0, 0.0);
   glEnd();


   glFlush();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM