652 | | 2. Instead of drawing of the teapot in {{{display()}}} we will draw single vertex array object as a point cloud with |
653 | | {{{ |
654 | | #!c |
655 | | //glutSolidTeapot(0.6); |
656 | | glDrawArrays(GL_POINTS, 0, vertices); |
657 | | }}} |
658 | | 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();}}} |
659 | | {{{ |
660 | | #!c |
661 | | void init() |
662 | | { |
663 | | GLuint VAO[1]; |
664 | | GLuint Buffer[1]; |
665 | | glGenVertexArrays(1, VAO); |
666 | | glBindVertexArray(VAO[0]); |
667 | | glGenBuffers(1, Buffer); |
668 | | glBindBuffer(GL_ARRAY_BUFFER, Buffer[0]); |
669 | | glBufferData(GL_ARRAY_BUFFER, vertices*3*sizeof(GLfloat), |
670 | | vertex, GL_STATIC_DRAW); |
671 | | glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); |
672 | | glEnableVertexAttribArray(0); |
673 | | } |
674 | | }}} |
| 652 | 2. Instead of drawing of the teapot in {{{display()}}} we will draw single vertex array object as a point cloud with adding |
| 653 | {{{ |
| 654 | #!c |
| 655 | //glutSolidTeapot(0.6); |
| 656 | glVertexPointer(3, GL_FLOAT, 0, vertex); |
| 657 | glEnableClientState(GL_VERTEX_ARRAY); |
| 658 | glDrawArrays(GL_POINTS, 0, vertices); |
| 659 | glDisableClientState(GL_VERTEX_ARRAY); |
| 660 | }}} |
| 661 | that pushes 132871 vertices (1.5MB) from client memory to GPU on every redraw. Better approach would be to follow VBOs principles by generating vertex buffer in GPU as {{{temperature.c}}} example. |