|   | 591 | [[Image(point-cloud.png,right)]] | 
                  
                          |   | 592 | === Exercises #3 === | 
                  
                          |   | 593 |  1.Insert {{{teapot.c}}} interactivity example into {{{wavefront.c}}} above and save it as {{{motorbike.c}}}. | 
                  
                          |   | 594 |    Verify that there is no compile problems ant that the {{{main()}}} contains {{{read_wavefront("motorBike.obj");}}}.  | 
                  
                          |   | 595 |    Disable lengthy saving in {{{main()}}}. | 
                  
                          |   | 596 |  2. Instead of drawing of the teapot in {{{display()}}} we will draw single vertex array object as a point cloud with  | 
                  
                          |   | 597 |   {{{ | 
                  
                          |   | 598 |   #!c | 
                  
                          |   | 599 |    glDrawArrays(GL_POINTS, 0, vertices); | 
                  
                          |   | 600 |   }}} | 
                  
                          |   | 601 |   To be able to draw this, we need to prepare Vertex Array Object and buffer with {{{init();}}} that is called from {{{main()}} just before {{{glutMainLoop();}}} | 
                  
                          |   | 602 |   {{{ | 
                  
                          |   | 603 |   #!c | 
                  
                          |   | 604 | void init() | 
                  
                          |   | 605 | { | 
                  
                          |   | 606 |   GLuint VAO[1]; | 
                  
                          |   | 607 |   GLuint Buffer[1]; | 
                  
                          |   | 608 |   glGenVertexArrays(1, VAO); | 
                  
                          |   | 609 |   glBindVertexArray(VAO[0]); | 
                  
                          |   | 610 |   glGenBuffers(1, Buffer); | 
                  
                          |   | 611 |   glBindBuffer(GL_ARRAY_BUFFER, Buffer[0]); | 
                  
                          |   | 612 |   glBufferData(GL_ARRAY_BUFFER, vertices*3*sizeof(GLfloat), | 
                  
                          |   | 613 |                vertex, GL_STATIC_DRAW); | 
                  
                          |   | 614 |   glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); | 
                  
                          |   | 615 |   glEnableVertexAttribArray(0); | 
                  
                          |   | 616 | } | 
                  
                          |   | 617 | }}} | 
                  
                          |   | 618 |   |