title: Drawing letters using triangles in OpenGL?
body: <p>I'm required to draw my name using triangles. I understand how to handle shaders. I am just confused on how to actual draw the objects and connect them to make a letter.</p>
  
  <p>I've been given some code to work with:</p>
  
  <pre><code>#include "Angel.h"
  
  const int NumPoints = 50000;
  
  
  /*This function initializes an array of 3d vectors 
     and sends it to the graphics card along with shaders
     properly connected to them.*/
  
  void
  init( void )
  {
      vec3 points[NumPoints];
  
      // Specifiy the vertices for a triangle
      vec3 vertices[] = {
          vec3( -1.0, -1.0, 0.0 ),
          vec3(  0.0,  1.0, 0.0 ),
          vec3(  1.0, -1.0, 0.0 )
      };
  
      // Select an arbitrary initial point inside of the triangle
      points[0] = vec3( 0.0, 1.0, 0.0 );
  
      // compute and store NumPoints - 1 new points
      for ( int i = 1; i &lt; NumPoints; ++i ) {
          int j = rand() % 3;   // pick a vertex from the triangle at random
  
          // Compute the point halfway between the selected vertex
          //   and the previous point
          points[i] = ( points[i - 1] + vertices[j] ) / 2.0;
      }
  
      // Create a vertex array object
      GLuint vao;  //just an integer recognized by graphics card
      glGenVertexArrays( 1, &amp;vao ); //generate 1 buffer
      glBindVertexArray( vao ); //become array buffer
  
      // Create and initialize a buffer object //sends it to graphics card
      GLuint buffer;
      glGenBuffers( 1, &amp;buffer );
      glBindBuffer( GL_ARRAY_BUFFER, buffer );
      glBufferData( GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW ); //size of array glstatic draw means this point isnt gonna change its static
  
     // Load shaders and use the resulting shader program
  
      GLuint program = InitShader("simpleShader - Copy.vert", "simpleShader - Copy.frag");
      // make these shaders the current shaders
      glUseProgram( program );
  
      // Initialize the vertex position attribute from the vertex shader
      GLuint loc = glGetAttribLocation( program, "vPosition" ); //find the location in the code
      glEnableVertexAttribArray( loc );
      glVertexAttribPointer( loc, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) );
  
      glClearColor( 0.5, 0.5, 0.5, 1.0 ); // gray background
  }
  
  //----------------------------------------------------------------------------
  /* This function handles the display and it is automatically called by GLUT
     once it is declared as the display function. The application should not
     call it directly.
  */
  
  void
  display( void )
  {
      glClear( GL_COLOR_BUFFER_BIT );             // clear the window
      glDrawArrays( GL_POINTS, 0, NumPoints );    // draw the points
      glFlush();                                  // flush the buffer
  }
  
  //----------------------------------------------------------------------------
  /* This function handles the keyboard and it is called by GLUT once it is 
     declared as the keyboard function. The application should not call it
     directly.
  */
  
  void
  keyboard( unsigned char key, int x, int y )
  {
      switch ( key ) {
      case 033:                   // escape key
          exit( EXIT_SUCCESS );   // terminates the program
          break;
      }
  }
  
  //----------------------------------------------------------------------------
  /* This is the main function that calls all the functions to initialize
     and setup the OpenGL environment through GLUT and GLEW.
  */
  
  int
  main( int argc, char **argv )
  {
      // Initialize GLUT
      glutInit( &amp;argc, argv );
      // Initialize the display mode to a buffer with Red, Green, Blue and Alpha channels
      glutInitDisplayMode( GLUT_RGBA );
      // Set the window size
      glutInitWindowSize( 512, 512 );
      // Here you set the OpenGL version
      glutInitContextVersion( 3, 2 );
      //Use only one of the next two lines
      //glutInitContextProfile( GLUT_CORE_PROFILE );
      glutInitContextProfile( GLUT_COMPATIBILITY_PROFILE );
      glutCreateWindow( "Simple GLSL example" );
  
      // Uncomment if you are using GLEW
      glewInit(); 
  
      // initialize the array and send it to the graphics card
      init();
  
      // provide the function that handles the display
      glutDisplayFunc( display );
      // provide the functions that handles the keyboard
      glutKeyboardFunc( keyboard );
      glutMainLoop();
      return 0;
  }
  </code></pre>